diff options
| author | Augustin Cavalier <waddlesplash@gmail.com> | 2014-10-27 13:11:55 -0400 |
|---|---|---|
| committer | Augustin Cavalier <waddlesplash@gmail.com> | 2014-10-28 14:39:20 -0400 |
| commit | 5b4b74de6a930e429b83fc065bf421f1076a6fe0 (patch) | |
| tree | 56d8cadd4d4086603352ba4e4b2a019b01365ace /Source | |
| parent | 32c6848c79a65e91f81e091b7b86560b2d9d405e (diff) | |
Fix image loading on Retina and other HiDPI displays.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/DolphinQt/Main.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Utils/Resources.cpp | 47 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Utils/Resources.h | 2 |
3 files changed, 35 insertions, 15 deletions
diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 9bcea4de27..93d853ad62 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -39,6 +39,7 @@ static QString LowestSupportedOsVersion() int main(int argc, char* argv[]) { QApplication app(argc, argv); + app.setAttribute(Qt::AA_UseHighDpiPixmaps); // TODO: Add command line options UICommon::CreateDirectories(); diff --git a/Source/Core/DolphinQt/Utils/Resources.cpp b/Source/Core/DolphinQt/Utils/Resources.cpp index 08c9e37ed2..0056f4f972 100644 --- a/Source/Core/DolphinQt/Utils/Resources.cpp +++ b/Source/Core/DolphinQt/Utils/Resources.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include <QApplication> +#include <QFile> + #include "Common/FileUtil.h" #include "Core/ConfigManager.h" @@ -47,26 +50,40 @@ void Resources::Init() UpdatePixmaps(); } +// Wrapper for GetImageFilename() so you don't have to to call it directly +#define GIFN(file) GetImageFilename(SL(file), dir) + void Resources::UpdatePixmaps() { QString dir = QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name)); - m_pixmaps[TOOLBAR_OPEN].load(dir + SL("open.png")); - m_pixmaps[TOOLBAR_REFRESH].load(dir + SL("refresh.png")); - m_pixmaps[TOOLBAR_BROWSE].load(dir + SL("browse.png")); - m_pixmaps[TOOLBAR_PLAY].load(dir + SL("play.png")); - m_pixmaps[TOOLBAR_STOP].load(dir + SL("stop.png")); - m_pixmaps[TOOLBAR_PAUSE].load(dir + SL("pause.png")); - m_pixmaps[TOOLBAR_FULLSCREEN].load(dir + SL("fullscreen.png")); - m_pixmaps[TOOLBAR_SCREENSHOT].load(dir + SL("screenshot.png")); - m_pixmaps[TOOLBAR_CONFIGURE].load(dir + SL("config.png")); - m_pixmaps[TOOLBAR_PLUGIN_GFX].load(dir + SL("graphics.png")); - m_pixmaps[TOOLBAR_PLUGIN_DSP].load(dir + SL("dsp.png")); - m_pixmaps[TOOLBAR_PLUGIN_GCPAD].load(dir + SL("gcpad.png")); - m_pixmaps[TOOLBAR_PLUGIN_WIIMOTE].load(dir + SL("wiimote.png")); - m_pixmaps[TOOLBAR_HELP].load(dir + SL("nobanner.png")); // TODO + m_pixmaps[TOOLBAR_OPEN].load(GIFN("open")); + m_pixmaps[TOOLBAR_REFRESH].load(GIFN("refresh")); + m_pixmaps[TOOLBAR_BROWSE].load(GIFN("browse")); + m_pixmaps[TOOLBAR_PLAY].load(GIFN("play")); + m_pixmaps[TOOLBAR_STOP].load(GIFN("stop")); + m_pixmaps[TOOLBAR_PAUSE].load(GIFN("pause")); + m_pixmaps[TOOLBAR_FULLSCREEN].load(GIFN("fullscreen")); + m_pixmaps[TOOLBAR_SCREENSHOT].load(GIFN("screenshot")); + m_pixmaps[TOOLBAR_CONFIGURE].load(GIFN("config")); + m_pixmaps[TOOLBAR_PLUGIN_GFX].load(GIFN("graphics")); + m_pixmaps[TOOLBAR_PLUGIN_DSP].load(GIFN("dsp")); + m_pixmaps[TOOLBAR_PLUGIN_GCPAD].load(GIFN("gcpad")); + m_pixmaps[TOOLBAR_PLUGIN_WIIMOTE].load(GIFN("wiimote")); + m_pixmaps[TOOLBAR_HELP].load(GIFN("nobanner")); // TODO // TODO: toolbar[MEMCARD]; // TODO: toolbar[HOTKEYS]; - m_pixmaps[BANNER_MISSING].load(dir + SL("nobanner.png")); + m_pixmaps[BANNER_MISSING].load(GIFN("nobanner")); +} + +QString Resources::GetImageFilename(QString name, QString dir) +{ + if (qApp->devicePixelRatio() >= 2) + { + QString fileName = name.prepend(dir).append(SL("@2x.png")); + if (QFile::exists(fileName)) + return fileName; + } + return name.prepend(dir).append(SL(".png")); } QPixmap& Resources::GetRegionPixmap(DiscIO::IVolume::ECountry region) diff --git a/Source/Core/DolphinQt/Utils/Resources.h b/Source/Core/DolphinQt/Utils/Resources.h index df9def2697..2820d9d6cb 100644 --- a/Source/Core/DolphinQt/Utils/Resources.h +++ b/Source/Core/DolphinQt/Utils/Resources.h @@ -50,4 +50,6 @@ private: static QVector<QPixmap> m_regions; static QVector<QPixmap> m_ratings; static QVector<QPixmap> m_pixmaps; + + static QString GetImageFilename(QString name, QString dir); }; |
