From 4acd90d570be16c8e5bd8737238a681c43aa8358 Mon Sep 17 00:00:00 2001 From: waddlesplash Date: Wed, 25 Nov 2015 23:05:43 -0500 Subject: [PATCH] DolphinQt: Get rid of unneeded abbreviation macros. --- Source/Core/DolphinQt/AboutDialog.cpp | 14 ++-- Source/Core/DolphinQt/GameList/GameFile.cpp | 21 +++-- Source/Core/DolphinQt/Main.cpp | 7 +- Source/Core/DolphinQt/MainWindow.cpp | 9 +-- Source/Core/DolphinQt/SystemInfo.cpp | 62 +++++++------- Source/Core/DolphinQt/Utils/Resources.cpp | 90 ++++++++++----------- Source/Core/DolphinQt/Utils/Resources.h | 2 +- Source/Core/DolphinQt/Utils/Utils.cpp | 13 ++- Source/Core/DolphinQt/Utils/Utils.h | 7 -- 9 files changed, 110 insertions(+), 115 deletions(-) diff --git a/Source/Core/DolphinQt/AboutDialog.cpp b/Source/Core/DolphinQt/AboutDialog.cpp index 560a4815cc..3ef7f91b48 100644 --- a/Source/Core/DolphinQt/AboutDialog.cpp +++ b/Source/Core/DolphinQt/AboutDialog.cpp @@ -12,7 +12,6 @@ #include "DolphinQt/AboutDialog.h" #include "DolphinQt/Utils/Resources.h" -#include "DolphinQt/Utils/Utils.h" DAboutDialog::DAboutDialog(QWidget* parent_widget) : QDialog(parent_widget) @@ -23,13 +22,14 @@ DAboutDialog::DAboutDialog(QWidget* parent_widget) m_ui = std::make_unique(); m_ui->setupUi(this); - m_ui->lblGitRev->setText(SC(scm_desc_str)); - m_ui->lblGitInfo->setText(m_ui->lblGitInfo->text().arg(SC(scm_branch_str), SC(scm_rev_git_str))); - m_ui->lblFinePrint->setText(m_ui->lblFinePrint->text().arg(SL("2015"))); + m_ui->lblGitRev->setText(QString::fromUtf8(scm_desc_str)); + m_ui->lblGitInfo->setText(m_ui->lblGitInfo->text().arg(QString::fromUtf8(scm_branch_str), + QString::fromUtf8(scm_rev_git_str))); + m_ui->lblFinePrint->setText(m_ui->lblFinePrint->text().arg(QStringLiteral("2015"))); m_ui->lblLicenseAuthorsSupport->setText(m_ui->lblLicenseAuthorsSupport->text() - .arg(SL("https://github.com/dolphin-emu/dolphin/blob/master/license.txt")) - .arg(SL("https://github.com/dolphin-emu/dolphin/graphs/contributors")) - .arg(SL("https://forums.dolphin-emu.org/"))); + .arg(QStringLiteral("https://github.com/dolphin-emu/dolphin/blob/master/license.txt")) + .arg(QStringLiteral("https://github.com/dolphin-emu/dolphin/graphs/contributors")) + .arg(QStringLiteral("https://forums.dolphin-emu.org/"))); m_ui->lblLogo->setPixmap(Resources::GetPixmap(Resources::DOLPHIN_LOGO_LARGE)); } diff --git a/Source/Core/DolphinQt/GameList/GameFile.cpp b/Source/Core/DolphinQt/GameList/GameFile.cpp index 845487b68e..4cc6b9a328 100644 --- a/Source/Core/DolphinQt/GameList/GameFile.cpp +++ b/Source/Core/DolphinQt/GameList/GameFile.cpp @@ -23,7 +23,6 @@ #include "DiscIO/VolumeCreator.h" #include "DolphinQt/GameList/GameFile.h" -#include "DolphinQt/Utils/Utils.h" static const u32 CACHE_REVISION = 0x00D; // Last changed in PR 3097 static const u32 DATASTREAM_REVISION = 15; // Introduced in Qt 5.2 @@ -66,7 +65,7 @@ static QString GetLanguageString(DiscIO::IVolume::ELanguage language, QMapactionWebsite, &QAction::triggered, this, []() { - QDesktopServices::openUrl(QUrl(SL("https://dolphin-emu.org/"))); + QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/"))); }); connect(m_ui->actionOnlineDocs, &QAction::triggered, this, []() { - QDesktopServices::openUrl(QUrl(SL("https://dolphin-emu.org/docs/guides/"))); + QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/docs/guides/"))); }); connect(m_ui->actionGitHub, &QAction::triggered, this, []() { - QDesktopServices::openUrl(QUrl(SL("https://github.com/dolphin-emu/dolphin"))); + QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/dolphin-emu/dolphin"))); }); connect(m_ui->actionSystemInfo, &QAction::triggered, this, [&]() { DSystemInfo* dlg = new DSystemInfo(this); @@ -209,7 +208,7 @@ QString DMainWindow::ShowFileDialog() { return QFileDialog::getOpenFileName(this, tr("Open File"), QString(), tr("All supported ROMs (%1);;All files (*)") - .arg(SL("*.gcm *.iso *.ciso *.gcz *.wbfs *.elf *.dol *.dff *.tmd *.wad"))); + .arg(QStringLiteral("*.gcm *.iso *.ciso *.gcz *.wbfs *.elf *.dol *.dff *.tmd *.wad"))); } QString DMainWindow::ShowFolderDialog() diff --git a/Source/Core/DolphinQt/SystemInfo.cpp b/Source/Core/DolphinQt/SystemInfo.cpp index 5c16b9ba80..dd53c46ad4 100644 --- a/Source/Core/DolphinQt/SystemInfo.cpp +++ b/Source/Core/DolphinQt/SystemInfo.cpp @@ -13,7 +13,6 @@ #include "Common/CPUDetect.h" #include "DolphinQt/SystemInfo.h" -#include "DolphinQt/Utils/Utils.h" DSystemInfo::DSystemInfo(QWidget* parent_widget) : QDialog(parent_widget) @@ -44,17 +43,20 @@ void DSystemInfo::UpdateSystemInfo() { QString sysinfo; - sysinfo += SL("System\n===========================\n"); - sysinfo += SL("OS: %1\n").arg(GetOS()); - sysinfo += SL("CPU: %1, %2 logical processors\n").arg(QString::fromStdString(cpu_info.Summarize())) + sysinfo += QStringLiteral("System\n===========================\n"); + sysinfo += QStringLiteral("OS: %1\n").arg(GetOS()); + sysinfo += QStringLiteral("CPU: %1, %2 logical processors\n") + .arg(QString::fromStdString(cpu_info.Summarize())) .arg(QThread::idealThreadCount()); - sysinfo += SL("\nDolphin\n===========================\n"); - sysinfo += SL("SCM: branch %1, rev %2\n").arg(SC(scm_branch_str)).arg(SC(scm_rev_git_str)); + sysinfo += QStringLiteral("\nDolphin\n===========================\n"); + sysinfo += QStringLiteral("SCM: branch %1, rev %2\n") + .arg(QString::fromUtf8(scm_branch_str)) + .arg(QString::fromUtf8(scm_rev_git_str)); - sysinfo += SL("\nGUI\n===========================\n"); - sysinfo += SL("Compiled for Qt: %1\n").arg(SL(QT_VERSION_STR)); - sysinfo += SL("Running on Qt: %1").arg(SC(qVersion())); + sysinfo += QStringLiteral("\nGUI\n===========================\n"); + sysinfo += QStringLiteral("Compiled for Qt: %1\n").arg(QStringLiteral(QT_VERSION_STR)); + sysinfo += QStringLiteral("Running on Qt: %1").arg(QString::fromUtf8(qVersion())); m_ui->txtSysInfo->setPlainText(sysinfo); } @@ -64,43 +66,43 @@ QString DSystemInfo::GetOS() const QString ret; /* DON'T REORDER WITHOUT READING Qt DOCS! */ #if defined(Q_OS_WIN) - ret += SL("Windows "); + ret += QStringLiteral("Windows "); switch (QSysInfo::WindowsVersion) { - case QSysInfo::WV_VISTA: ret += SL("Vista"); break; - case QSysInfo::WV_WINDOWS7: ret += SL("7"); break; - case QSysInfo::WV_WINDOWS8: ret += SL("8"); break; - case QSysInfo::WV_WINDOWS8_1: ret += SL("8.1"); break; - case QSysInfo::WV_WINDOWS10: ret += SL("10"); break; - default: ret += SL("(unknown)"); break; + case QSysInfo::WV_VISTA: ret += QStringLiteral("Vista"); break; + case QSysInfo::WV_WINDOWS7: ret += QStringLiteral("7"); break; + case QSysInfo::WV_WINDOWS8: ret += QStringLiteral("8"); break; + case QSysInfo::WV_WINDOWS8_1: ret += QStringLiteral("8.1"); break; + case QSysInfo::WV_WINDOWS10: ret += QStringLiteral("10"); break; + default: ret += QStringLiteral("(unknown)"); break; } #elif defined(Q_OS_MAC) - ret += SL("Mac OS X "); + ret += QStringLiteral("Mac OS X "); switch (QSysInfo::MacintoshVersion) { - case QSysInfo::MV_10_9: ret += SL("10.9"); break; - case QSysInfo::MV_10_10: ret += SL("10.10"); break; - case QSysInfo::MV_10_11: ret += SL("10.11"); break; - default: ret += SL("(unknown)"); break; + case QSysInfo::MV_10_9: ret += QStringLiteral("10.9"); break; + case QSysInfo::MV_10_10: ret += QStringLiteral("10.10"); break; + case QSysInfo::MV_10_11: ret += QStringLiteral("10.11"); break; + default: ret += QStringLiteral("(unknown)"); break; } #elif defined(Q_OS_LINUX) - ret += SL("Linux"); + ret += QStringLiteral("Linux"); #elif defined(Q_OS_FREEBSD) - ret += SL("FreeBSD"); + ret += QStringLiteral("FreeBSD"); #elif defined(Q_OS_OPENBSD) - ret += SL("OpenBSD"); + ret += QStringLiteral("OpenBSD"); #elif defined(Q_OS_NETBSD) - ret += SL("NetBSD"); + ret += QStringLiteral("NetBSD"); #elif defined(Q_OS_BSD4) - ret += SL("Other BSD"); + ret += QStringLiteral("Other BSD"); #elif defined(Q_OS_UNIX) - ret += SL("Unix"); + ret += QStringLiteral("Unix"); #else - ret += SL("Unknown"); + ret += QStringLiteral("Unknown"); #endif #if defined(Q_WS_X11) || defined(Q_OS_X11) - ret += SL(" X11"); + ret += QStringLiteral(" X11"); #elif defined(Q_WS_WAYLAND) - ret += SL(" Wayland"); + ret += QStringLiteral(" Wayland"); #endif return ret; diff --git a/Source/Core/DolphinQt/Utils/Resources.cpp b/Source/Core/DolphinQt/Utils/Resources.cpp index d6f4aa4961..dc3c44e559 100644 --- a/Source/Core/DolphinQt/Utils/Resources.cpp +++ b/Source/Core/DolphinQt/Utils/Resources.cpp @@ -9,88 +9,84 @@ #include "Core/ConfigManager.h" #include "DolphinQt/Utils/Resources.h" -#include "DolphinQt/Utils/Utils.h" QVector Resources::m_platforms; QVector Resources::m_regions; QVector Resources::m_ratings; QVector Resources::m_pixmaps; -// Wrapper for GetImageFilename() so you don't have to to call it directly -#define GIFN(file) GetImageFilename(SL(file), dir) - void Resources::Init() { QString dir = QString::fromStdString(File::GetSysDirectory() + "Resources/"); m_regions.resize(DiscIO::IVolume::NUMBER_OF_COUNTRIES); - m_regions[DiscIO::IVolume::COUNTRY_JAPAN].load(GIFN("Flag_Japan")); - m_regions[DiscIO::IVolume::COUNTRY_EUROPE].load(GIFN("Flag_Europe")); - m_regions[DiscIO::IVolume::COUNTRY_USA].load(GIFN("Flag_USA")); + m_regions[DiscIO::IVolume::COUNTRY_JAPAN].load(GetImageFilename("Flag_Japan", dir)); + m_regions[DiscIO::IVolume::COUNTRY_EUROPE].load(GetImageFilename("Flag_Europe", dir)); + m_regions[DiscIO::IVolume::COUNTRY_USA].load(GetImageFilename("Flag_USA", dir)); - m_regions[DiscIO::IVolume::COUNTRY_AUSTRALIA].load(GIFN("Flag_Australia")); - m_regions[DiscIO::IVolume::COUNTRY_FRANCE].load(GIFN("Flag_France")); - m_regions[DiscIO::IVolume::COUNTRY_GERMANY].load(GIFN("Flag_Germany")); - m_regions[DiscIO::IVolume::COUNTRY_ITALY].load(GIFN("Flag_Italy")); - m_regions[DiscIO::IVolume::COUNTRY_KOREA].load(GIFN("Flag_Korea")); - m_regions[DiscIO::IVolume::COUNTRY_NETHERLANDS].load(GIFN("Flag_Netherlands")); - m_regions[DiscIO::IVolume::COUNTRY_RUSSIA].load(GIFN("Flag_Russia")); - m_regions[DiscIO::IVolume::COUNTRY_SPAIN].load(GIFN("Flag_Spain")); - m_regions[DiscIO::IVolume::COUNTRY_TAIWAN].load(GIFN("Flag_Taiwan")); - m_regions[DiscIO::IVolume::COUNTRY_WORLD].load(GIFN("Flag_International")); - m_regions[DiscIO::IVolume::COUNTRY_UNKNOWN].load(GIFN("Flag_Unknown")); + m_regions[DiscIO::IVolume::COUNTRY_AUSTRALIA].load(GetImageFilename("Flag_Australia", dir)); + m_regions[DiscIO::IVolume::COUNTRY_FRANCE].load(GetImageFilename("Flag_France", dir)); + m_regions[DiscIO::IVolume::COUNTRY_GERMANY].load(GetImageFilename("Flag_Germany", dir)); + m_regions[DiscIO::IVolume::COUNTRY_ITALY].load(GetImageFilename("Flag_Italy", dir)); + m_regions[DiscIO::IVolume::COUNTRY_KOREA].load(GetImageFilename("Flag_Korea", dir)); + m_regions[DiscIO::IVolume::COUNTRY_NETHERLANDS].load(GetImageFilename("Flag_Netherlands", dir)); + m_regions[DiscIO::IVolume::COUNTRY_RUSSIA].load(GetImageFilename("Flag_Russia", dir)); + m_regions[DiscIO::IVolume::COUNTRY_SPAIN].load(GetImageFilename("Flag_Spain", dir)); + m_regions[DiscIO::IVolume::COUNTRY_TAIWAN].load(GetImageFilename("Flag_Taiwan", dir)); + m_regions[DiscIO::IVolume::COUNTRY_WORLD].load(GetImageFilename("Flag_International", dir)); + m_regions[DiscIO::IVolume::COUNTRY_UNKNOWN].load(GetImageFilename("Flag_Unknown", dir)); m_platforms.resize(4); - m_platforms[0].load(GIFN("Platform_Gamecube")); - m_platforms[1].load(GIFN("Platform_Wii")); - m_platforms[2].load(GIFN("Platform_Wad")); + m_platforms[0].load(GetImageFilename("Platform_Gamecube", dir)); + m_platforms[1].load(GetImageFilename("Platform_Wii", dir)); + m_platforms[2].load(GetImageFilename("Platform_Wad", dir)); m_ratings.resize(6); - m_ratings[0].load(GIFN("rating0")); - m_ratings[1].load(GIFN("rating1")); - m_ratings[2].load(GIFN("rating2")); - m_ratings[3].load(GIFN("rating3")); - m_ratings[4].load(GIFN("rating4")); - m_ratings[5].load(GIFN("rating5")); + m_ratings[0].load(GetImageFilename("rating0", dir)); + m_ratings[1].load(GetImageFilename("rating1", dir)); + m_ratings[2].load(GetImageFilename("rating2", dir)); + m_ratings[3].load(GetImageFilename("rating3", dir)); + m_ratings[4].load(GetImageFilename("rating4", dir)); + m_ratings[5].load(GetImageFilename("rating5", dir)); m_pixmaps.resize(NUM_ICONS); - m_pixmaps[DOLPHIN_LOGO].load(GIFN("Dolphin")); - m_pixmaps[DOLPHIN_LOGO_LARGE].load(GIFN("dolphin_logo")); + m_pixmaps[DOLPHIN_LOGO].load(GetImageFilename("Dolphin", dir)); + m_pixmaps[DOLPHIN_LOGO_LARGE].load(GetImageFilename("dolphin_logo", dir)); UpdatePixmaps(); } void Resources::UpdatePixmaps() { QString dir = QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().theme_name)); - 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_GRAPHICS].load(GIFN("graphics")); - m_pixmaps[TOOLBAR_CONTROLLERS].load(GIFN("classic")); - m_pixmaps[TOOLBAR_HELP].load(GIFN("nobanner")); // TODO + m_pixmaps[TOOLBAR_OPEN].load(GetImageFilename("open", dir)); + m_pixmaps[TOOLBAR_REFRESH].load(GetImageFilename("refresh", dir)); + m_pixmaps[TOOLBAR_BROWSE].load(GetImageFilename("browse", dir)); + m_pixmaps[TOOLBAR_PLAY].load(GetImageFilename("play", dir)); + m_pixmaps[TOOLBAR_STOP].load(GetImageFilename("stop", dir)); + m_pixmaps[TOOLBAR_PAUSE].load(GetImageFilename("pause", dir)); + m_pixmaps[TOOLBAR_FULLSCREEN].load(GetImageFilename("fullscreen", dir)); + m_pixmaps[TOOLBAR_SCREENSHOT].load(GetImageFilename("screenshot", dir)); + m_pixmaps[TOOLBAR_CONFIGURE].load(GetImageFilename("config", dir)); + m_pixmaps[TOOLBAR_GRAPHICS].load(GetImageFilename("graphics", dir)); + m_pixmaps[TOOLBAR_CONTROLLERS].load(GetImageFilename("classic", dir)); + m_pixmaps[TOOLBAR_HELP].load(GetImageFilename("nobanner", dir)); // TODO // TODO: toolbar[MEMCARD]; // TODO: toolbar[HOTKEYS]; - m_pixmaps[BANNER_MISSING].load(GIFN("nobanner")); + m_pixmaps[BANNER_MISSING].load(GetImageFilename("nobanner", dir)); // TODO: Make this consistent with the other files - m_platforms[3].load(GIFN("fileplatform")); + m_platforms[3].load(GetImageFilename("fileplatform", dir)); } -QString Resources::GetImageFilename(QString name, QString dir) +QString Resources::GetImageFilename(const char* name, QString dir) { + QString fileName = QString::fromUtf8(name); if (qApp->devicePixelRatio() >= 2) { - QString fileName = name; - fileName.prepend(dir).append(SL("@2x.png")); + fileName.prepend(dir).append(QStringLiteral("@2x.png")); if (QFile::exists(fileName)) return fileName; } - return name.prepend(dir).append(SL(".png")); + return fileName.prepend(dir).append(QStringLiteral(".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 c95dbe6b25..40a74455a2 100644 --- a/Source/Core/DolphinQt/Utils/Resources.h +++ b/Source/Core/DolphinQt/Utils/Resources.h @@ -50,5 +50,5 @@ private: static QVector m_ratings; static QVector m_pixmaps; - static QString GetImageFilename(QString name, QString dir); + static QString GetImageFilename(const char* name, QString dir); }; diff --git a/Source/Core/DolphinQt/Utils/Utils.cpp b/Source/Core/DolphinQt/Utils/Utils.cpp index ca758c5dcd..b4497e4d6f 100644 --- a/Source/Core/DolphinQt/Utils/Utils.cpp +++ b/Source/Core/DolphinQt/Utils/Utils.cpp @@ -8,14 +8,21 @@ QString NiceSizeFormat(s64 size) { - QStringList list = { SL("KB"), SL("MB"), SL("GB"), SL("TB"), SL("PB"), SL("EB") }; + QStringList list = { + QStringLiteral("KB"), + QStringLiteral("MB"), + QStringLiteral("GB"), + QStringLiteral("TB"), + QStringLiteral("PB"), + QStringLiteral("EB") + }; QStringListIterator i(list); - QString unit = SL("b"); + QString unit = QStringLiteral("b"); double num = size; while (num >= 1024.0 && i.hasNext()) { unit = i.next(); num /= 1024.0; } - return SL("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit); + return QStringLiteral("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit); } diff --git a/Source/Core/DolphinQt/Utils/Utils.h b/Source/Core/DolphinQt/Utils/Utils.h index 0d9a52a59a..4ef7823525 100644 --- a/Source/Core/DolphinQt/Utils/Utils.h +++ b/Source/Core/DolphinQt/Utils/Utils.h @@ -8,11 +8,4 @@ #include "Common/CommonTypes.h" -// Use this to encapsulate ASCII string literals -#define SL(str) QStringLiteral(str) - -// Use this to encapsulate string constants and functions that -// return "char*"s -#define SC(str) QString::fromLatin1(str) - QString NiceSizeFormat(s64 size);