Qt: Fix low-resolution icon
This commit is contained in:
parent
5c83e18fbd
commit
4f63d7f204
|
@ -805,7 +805,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
|
||||||
install(FILES Data/dolphin-emu.svg
|
install(FILES Data/dolphin-emu.svg
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps)
|
||||||
install(FILES Data/dolphin-emu.png
|
install(FILES Data/dolphin-emu.png
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/256x256/apps)
|
||||||
install(FILES Data/dolphin-emu.desktop
|
install(FILES Data/dolphin-emu.desktop
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||||
# Install manpages
|
# Install manpages
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 9.8 KiB |
|
@ -102,6 +102,7 @@ set(SRCS
|
||||||
QtUtils/ImageConverter.cpp
|
QtUtils/ImageConverter.cpp
|
||||||
QtUtils/ListTabWidget.cpp
|
QtUtils/ListTabWidget.cpp
|
||||||
QtUtils/WindowActivationEventFilter.cpp
|
QtUtils/WindowActivationEventFilter.cpp
|
||||||
|
QtUtils/WinIconHelper.cpp
|
||||||
QtUtils/WrapInScrollArea.cpp
|
QtUtils/WrapInScrollArea.cpp
|
||||||
QtUtils/AspectRatioWidget.cpp
|
QtUtils/AspectRatioWidget.cpp
|
||||||
Settings/AdvancedPane.cpp
|
Settings/AdvancedPane.cpp
|
||||||
|
|
|
@ -248,6 +248,7 @@
|
||||||
<ClCompile Include="Debugger\CodeViewWidget.cpp" />
|
<ClCompile Include="Debugger\CodeViewWidget.cpp" />
|
||||||
<ClCompile Include="Debugger\CodeWidget.cpp" />
|
<ClCompile Include="Debugger\CodeWidget.cpp" />
|
||||||
<ClCompile Include="FIFOPlayerWindow.cpp" />
|
<ClCompile Include="FIFOPlayerWindow.cpp" />
|
||||||
|
<ClCompile Include="QtUtils\WinIconHelper.cpp" />
|
||||||
<ClCompile Include="TAS\GCTASInputWindow.cpp" />
|
<ClCompile Include="TAS\GCTASInputWindow.cpp" />
|
||||||
<ClCompile Include="TAS\WiiTASInputWindow.cpp" />
|
<ClCompile Include="TAS\WiiTASInputWindow.cpp" />
|
||||||
<ClCompile Include="TAS\StickWidget.cpp" />
|
<ClCompile Include="TAS\StickWidget.cpp" />
|
||||||
|
@ -310,6 +311,7 @@
|
||||||
<ClInclude Include="Config\Mapping\HotkeyGraphics.h" />
|
<ClInclude Include="Config\Mapping\HotkeyGraphics.h" />
|
||||||
<ClInclude Include="Config\Mapping\HotkeyStates.h" />
|
<ClInclude Include="Config\Mapping\HotkeyStates.h" />
|
||||||
<ClInclude Include="Config\Mapping\HotkeyTAS.h" />
|
<ClInclude Include="Config\Mapping\HotkeyTAS.h" />
|
||||||
|
<ClInclude Include="QtUtils\WinIconHelper.h" />
|
||||||
<ClInclude Include="TAS\Shared.h" />
|
<ClInclude Include="TAS\Shared.h" />
|
||||||
<ClInclude Include="Config\Mapping\HotkeyWii.h" />
|
<ClInclude Include="Config\Mapping\HotkeyWii.h" />
|
||||||
<ClInclude Include="Config\Mapping\MappingBool.h" />
|
<ClInclude Include="Config\Mapping\MappingBool.h" />
|
||||||
|
@ -414,4 +416,4 @@
|
||||||
<Message Text="Copy: @(BinaryFiles) -> $(BinaryOutputDir)" Importance="High" />
|
<Message Text="Copy: @(BinaryFiles) -> $(BinaryOutputDir)" Importance="High" />
|
||||||
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(BinaryOutputDir)" />
|
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(BinaryOutputDir)" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
|
@ -85,7 +85,7 @@
|
||||||
MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainWindow(nullptr)
|
MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainWindow(nullptr)
|
||||||
{
|
{
|
||||||
setWindowTitle(QString::fromStdString(Common::scm_rev_str));
|
setWindowTitle(QString::fromStdString(Common::scm_rev_str));
|
||||||
setWindowIcon(QIcon(Resources::GetMisc(Resources::LOGO_SMALL)));
|
setWindowIcon(Resources::GetAppIcon());
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
// Copyright 2018 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "DolphinQt2/QtUtils/WinIconHelper.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
// The following code is adapted from qpixmap_win.cpp (c) The Qt Company Ltd. (https://qt.io)
|
||||||
|
// Licensed under the GNU GPL v3
|
||||||
|
static inline BITMAPINFO GetBMI(int width, int height, bool topToBottom)
|
||||||
|
{
|
||||||
|
BITMAPINFO bmi = {};
|
||||||
|
auto& bih = bmi.bmiHeader;
|
||||||
|
|
||||||
|
bih.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
bih.biWidth = width;
|
||||||
|
bih.biHeight = topToBottom ? -height : height;
|
||||||
|
bih.biPlanes = 1;
|
||||||
|
bih.biBitCount = 32;
|
||||||
|
bih.biCompression = BI_RGB;
|
||||||
|
bih.biSizeImage = width * height * 4;
|
||||||
|
|
||||||
|
return bmi;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QPixmap PixmapFromHICON(HICON icon)
|
||||||
|
{
|
||||||
|
HDC screenDevice = GetDC(0);
|
||||||
|
HDC hdc = CreateCompatibleDC(screenDevice);
|
||||||
|
ReleaseDC(0, screenDevice);
|
||||||
|
ICONINFO iconinfo;
|
||||||
|
const bool result = GetIconInfo(icon, &iconinfo); // x and y Hotspot describes the icon center
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
qErrnoWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
|
||||||
|
DeleteDC(hdc);
|
||||||
|
return QPixmap();
|
||||||
|
}
|
||||||
|
const int w = iconinfo.xHotspot * 2;
|
||||||
|
const int h = iconinfo.yHotspot * 2;
|
||||||
|
BITMAPINFO bitmapInfo = GetBMI(w, h, false);
|
||||||
|
DWORD* bits;
|
||||||
|
HBITMAP winBitmap = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, (VOID**)&bits, NULL, 0);
|
||||||
|
HGDIOBJ oldhdc = reinterpret_cast<HBITMAP>(SelectObject(hdc, winBitmap));
|
||||||
|
DrawIconEx(hdc, 0, 0, icon, iconinfo.xHotspot * 2, iconinfo.yHotspot * 2, 0, 0, DI_NORMAL);
|
||||||
|
|
||||||
|
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
|
||||||
|
if (image.isNull())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
BITMAPINFO bmi = GetBMI(w, h, true);
|
||||||
|
|
||||||
|
QScopedArrayPointer<uchar> data(new uchar[bmi.bmiHeader.biSizeImage]);
|
||||||
|
if (!GetDIBits(hdc, winBitmap, 0, h, data.data(), &bmi, DIB_RGB_COLORS))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
for (int y = 0; y < image.height(); ++y)
|
||||||
|
{
|
||||||
|
void* dest = static_cast<void*>(image.scanLine(y));
|
||||||
|
const void* src = data.data() + y * image.bytesPerLine();
|
||||||
|
memcpy(dest, src, image.bytesPerLine());
|
||||||
|
}
|
||||||
|
|
||||||
|
// dispose resources created by iconinfo call
|
||||||
|
DeleteObject(iconinfo.hbmMask);
|
||||||
|
DeleteObject(iconinfo.hbmColor);
|
||||||
|
SelectObject(hdc, oldhdc); // restore state
|
||||||
|
DeleteObject(winBitmap);
|
||||||
|
DeleteDC(hdc);
|
||||||
|
return QPixmap::fromImage(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon WinIconHelper::GetNativeIcon()
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
for (int size : {16, 32, 48, 256})
|
||||||
|
{
|
||||||
|
HANDLE h = LoadImageW(GetModuleHandleW(nullptr), L"\"DOLPHIN\"", IMAGE_ICON, size, size,
|
||||||
|
LR_CREATEDIBSECTION);
|
||||||
|
|
||||||
|
if (h && h != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
auto* icon_handle = static_cast<HICON>(h);
|
||||||
|
icon.addPixmap(PixmapFromHICON(icon_handle));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2018 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
namespace WinIconHelper
|
||||||
|
{
|
||||||
|
QIcon GetNativeIcon();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -14,6 +14,10 @@
|
||||||
#include "DolphinQt2/Resources.h"
|
#include "DolphinQt2/Resources.h"
|
||||||
#include "DolphinQt2/Settings.h"
|
#include "DolphinQt2/Settings.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "DolphinQt2/QtUtils/WinIconHelper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
QList<QPixmap> Resources::m_platforms;
|
QList<QPixmap> Resources::m_platforms;
|
||||||
QList<QPixmap> Resources::m_countries;
|
QList<QPixmap> Resources::m_countries;
|
||||||
QList<QPixmap> Resources::m_ratings;
|
QList<QPixmap> Resources::m_ratings;
|
||||||
|
@ -128,3 +132,17 @@ QPixmap Resources::GetMisc(int id)
|
||||||
{
|
{
|
||||||
return m_misc[id];
|
return m_misc[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon Resources::GetAppIcon()
|
||||||
|
{
|
||||||
|
QIcon icon;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
icon = WinIconHelper::GetNativeIcon();
|
||||||
|
#else
|
||||||
|
icon.addPixmap(GetScaledPixmap("dolphin_logo"));
|
||||||
|
icon.addPixmap(GetScaledPixmap("Dolphin"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
|
|
||||||
static QIcon GetScaledIcon(const std::string& name);
|
static QIcon GetScaledIcon(const std::string& name);
|
||||||
static QIcon GetScaledThemeIcon(const std::string& name);
|
static QIcon GetScaledThemeIcon(const std::string& name);
|
||||||
|
static QIcon GetAppIcon();
|
||||||
|
|
||||||
static QPixmap GetScaledPixmap(const std::string& name);
|
static QPixmap GetScaledPixmap(const std::string& name);
|
||||||
static QPixmap GetScaledThemePixmap(const std::string& name);
|
static QPixmap GetScaledThemePixmap(const std::string& name);
|
||||||
|
|
Loading…
Reference in New Issue