Skip to content

Commit

Permalink
Merge pull request #1403 from waddlesplash/dolphin-qt
Browse files Browse the repository at this point in the history
DolphinQt: Fix toolbar image loading on Retina displays
  • Loading branch information
comex committed Oct 28, 2014
2 parents 64b0958 + 5b4b74d commit 31c679a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
3 changes: 2 additions & 1 deletion Source/Core/DolphinQt/AboutDialog.h
Expand Up @@ -8,7 +8,8 @@
#include <QDialog>

// Predefinitions
namespace Ui {
namespace Ui
{
class DAboutDialog;
}

Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinQt/Main.cpp
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DolphinQt/MainWindow.h
Expand Up @@ -8,7 +8,8 @@
#include <QMainWindow>

// Predefinitions
namespace Ui {
namespace Ui
{
class DMainWindow;
}

Expand Down
47 changes: 32 additions & 15 deletions Source/Core/DolphinQt/Utils/Resources.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinQt/Utils/Resources.h
Expand Up @@ -50,4 +50,6 @@ class Resources
static QVector<QPixmap> m_regions;
static QVector<QPixmap> m_ratings;
static QVector<QPixmap> m_pixmaps;

static QString GetImageFilename(QString name, QString dir);
};

0 comments on commit 31c679a

Please sign in to comment.