citra-emu
/
citra
Archived
1
0
Fork 0

yuzu/main: Specify string conversions explicitly

This commit is contained in:
FearlessTobi 2019-11-20 22:34:39 +01:00
parent 5f20bf0e10
commit 4b7a45ccc7
3 changed files with 140 additions and 113 deletions

View File

@ -235,12 +235,15 @@ void Config::ReadControlValues() {
} }
void Config::ReadUtilityValues() { void Config::ReadUtilityValues() {
qt_config->beginGroup("Utility"); qt_config->beginGroup(QStringLiteral("Utility"));
Settings::values.dump_textures = ReadSetting("dump_textures", false).toBool(); Settings::values.dump_textures = ReadSetting(QStringLiteral("dump_textures"), false).toBool();
Settings::values.custom_textures = ReadSetting("custom_textures", false).toBool(); Settings::values.custom_textures =
Settings::values.preload_textures = ReadSetting("preload_textures", false).toBool(); ReadSetting(QStringLiteral("custom_textures"), false).toBool();
Settings::values.use_disk_shader_cache = ReadSetting("use_disk_shader_cache", true).toBool(); Settings::values.preload_textures =
ReadSetting(QStringLiteral("preload_textures"), false).toBool();
Settings::values.use_disk_shader_cache =
ReadSetting(QStringLiteral("use_disk_shader_cache"), true).toBool();
qt_config->endGroup(); qt_config->endGroup();
} }
@ -711,12 +714,13 @@ void Config::SaveControlValues() {
} }
void Config::SaveUtilityValues() { void Config::SaveUtilityValues() {
qt_config->beginGroup("Utility"); qt_config->beginGroup(QStringLiteral("Utility"));
WriteSetting("dump_textures", Settings::values.dump_textures, false); WriteSetting(QStringLiteral("dump_textures"), Settings::values.dump_textures, false);
WriteSetting("custom_textures", Settings::values.custom_textures, false); WriteSetting(QStringLiteral("custom_textures"), Settings::values.custom_textures, false);
WriteSetting("preload_textures", Settings::values.preload_textures, false); WriteSetting(QStringLiteral("preload_textures"), Settings::values.preload_textures, false);
WriteSetting("use_disk_shader_cache", Settings::values.use_disk_shader_cache, true); WriteSetting(QStringLiteral("use_disk_shader_cache"), Settings::values.use_disk_shader_cache,
true);
qt_config->endGroup(); qt_config->endGroup();
} }

View File

@ -277,7 +277,7 @@ void GMainWindow::InitializeWidgets() {
statusBar()->setVisible(true); statusBar()->setVisible(true);
// Removes an ugly inner border from the status bar widgets under Linux // Removes an ugly inner border from the status bar widgets under Linux
setStyleSheet("QStatusBar::item{border: none;}"); setStyleSheet(QStringLiteral("QStatusBar::item{border: none;}"));
QActionGroup* actionGroup_ScreenLayouts = new QActionGroup(this); QActionGroup* actionGroup_ScreenLayouts = new QActionGroup(this);
actionGroup_ScreenLayouts->addAction(ui.action_Screen_Layout_Default); actionGroup_ScreenLayouts->addAction(ui.action_Screen_Layout_Default);
@ -385,100 +385,111 @@ void GMainWindow::InitializeRecentFileMenuActions() {
void GMainWindow::InitializeHotkeys() { void GMainWindow::InitializeHotkeys() {
hotkey_registry.LoadHotkeys(); hotkey_registry.LoadHotkeys();
const QString main_window = QStringLiteral("Main Window");
const QString load_file = QStringLiteral("Load File");
const QString exit_citra = QStringLiteral("Exit Citra");
const QString stop_emulation = QStringLiteral("Stop Emulation");
const QString toggle_filter_bar = QStringLiteral("Toggle Filter Bar");
const QString toggle_status_bar = QStringLiteral("Toggle Status Bar");
const QString fullscreen = QStringLiteral("Fullscreen");
ui.action_Show_Filter_Bar->setShortcut( ui.action_Show_Filter_Bar->setShortcut(
hotkey_registry.GetKeySequence("Main Window", "Toggle Filter Bar")); hotkey_registry.GetKeySequence(main_window, toggle_filter_bar));
ui.action_Show_Filter_Bar->setShortcutContext( ui.action_Show_Filter_Bar->setShortcutContext(
hotkey_registry.GetShortcutContext("Main Window", "Toggle Filter Bar")); hotkey_registry.GetShortcutContext(main_window, toggle_filter_bar));
ui.action_Show_Status_Bar->setShortcut( ui.action_Show_Status_Bar->setShortcut(
hotkey_registry.GetKeySequence("Main Window", "Toggle Status Bar")); hotkey_registry.GetKeySequence(main_window, toggle_status_bar));
ui.action_Show_Status_Bar->setShortcutContext( ui.action_Show_Status_Bar->setShortcutContext(
hotkey_registry.GetShortcutContext("Main Window", "Toggle Status Bar")); hotkey_registry.GetShortcutContext(main_window, toggle_status_bar));
connect(hotkey_registry.GetHotkey("Main Window", "Load File", this), &QShortcut::activated, connect(hotkey_registry.GetHotkey(main_window, load_file, this), &QShortcut::activated,
ui.action_Load_File, &QAction::trigger); ui.action_Load_File, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Stop Emulation", this), &QShortcut::activated, connect(hotkey_registry.GetHotkey(main_window, stop_emulation, this), &QShortcut::activated,
ui.action_Stop, &QAction::trigger); ui.action_Stop, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Exit Citra", this), &QShortcut::activated, connect(hotkey_registry.GetHotkey(main_window, exit_citra, this), &QShortcut::activated,
ui.action_Exit, &QAction::trigger); ui.action_Exit, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Continue/Pause Emulation", this), connect(
&QShortcut::activated, this, [&] { hotkey_registry.GetHotkey(main_window, QStringLiteral("Continue/Pause Emulation"), this),
if (emulation_running) { &QShortcut::activated, this, [&] {
if (emu_thread->IsRunning()) { if (emulation_running) {
OnPauseGame(); if (emu_thread->IsRunning()) {
} else { OnPauseGame();
OnStartGame(); } else {
} OnStartGame();
} }
}); }
connect(hotkey_registry.GetHotkey("Main Window", "Restart Emulation", this), });
connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Restart Emulation"), this),
&QShortcut::activated, this, [this] { &QShortcut::activated, this, [this] {
if (!Core::System::GetInstance().IsPoweredOn()) if (!Core::System::GetInstance().IsPoweredOn())
return; return;
BootGame(QString(game_path)); BootGame(QString(game_path));
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Swap Screens", render_window), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Swap Screens"), render_window),
&QShortcut::activated, ui.action_Screen_Layout_Swap_Screens, &QAction::trigger); &QShortcut::activated, ui.action_Screen_Layout_Swap_Screens, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Rotate Screens Upright", render_window), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Rotate Screens Upright"),
render_window),
&QShortcut::activated, ui.action_Screen_Layout_Upright_Screens, &QAction::trigger); &QShortcut::activated, ui.action_Screen_Layout_Upright_Screens, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Toggle Screen Layout", render_window), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Screen Layout"),
render_window),
&QShortcut::activated, this, &GMainWindow::ToggleScreenLayout); &QShortcut::activated, this, &GMainWindow::ToggleScreenLayout);
connect(hotkey_registry.GetHotkey("Main Window", "Fullscreen", render_window), connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
&QShortcut::activated, ui.action_Fullscreen, &QAction::trigger); &QShortcut::activated, ui.action_Fullscreen, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Fullscreen", render_window), connect(hotkey_registry.GetHotkey(main_window, fullscreen, render_window),
&QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger); &QShortcut::activatedAmbiguously, ui.action_Fullscreen, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Exit Fullscreen", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Exit Fullscreen"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (emulation_running) { if (emulation_running) {
ui.action_Fullscreen->setChecked(false); ui.action_Fullscreen->setChecked(false);
ToggleFullscreen(); ToggleFullscreen();
} }
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Toggle Speed Limit", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Speed Limit"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
Settings::values.use_frame_limit = !Settings::values.use_frame_limit; Settings::values.use_frame_limit = !Settings::values.use_frame_limit;
UpdateStatusBar(); UpdateStatusBar();
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Toggle Texture Dumping", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Texture Dumping"), this),
&QShortcut::activated, this, &QShortcut::activated, this,
[&] { Settings::values.dump_textures = !Settings::values.dump_textures; }); [&] { Settings::values.dump_textures = !Settings::values.dump_textures; });
// We use "static" here in order to avoid capturing by lambda due to a MSVC bug, which makes // We use "static" here in order to avoid capturing by lambda due to a MSVC bug, which makes
// the variable hold a garbage value after this function exits // the variable hold a garbage value after this function exits
static constexpr u16 SPEED_LIMIT_STEP = 5; static constexpr u16 SPEED_LIMIT_STEP = 5;
connect(hotkey_registry.GetHotkey("Main Window", "Increase Speed Limit", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Increase Speed Limit"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (Settings::values.frame_limit < 9999 - SPEED_LIMIT_STEP) { if (Settings::values.frame_limit < 9999 - SPEED_LIMIT_STEP) {
Settings::values.frame_limit += SPEED_LIMIT_STEP; Settings::values.frame_limit += SPEED_LIMIT_STEP;
UpdateStatusBar(); UpdateStatusBar();
} }
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Decrease Speed Limit", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Decrease Speed Limit"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (Settings::values.frame_limit > SPEED_LIMIT_STEP) { if (Settings::values.frame_limit > SPEED_LIMIT_STEP) {
Settings::values.frame_limit -= SPEED_LIMIT_STEP; Settings::values.frame_limit -= SPEED_LIMIT_STEP;
UpdateStatusBar(); UpdateStatusBar();
} }
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Toggle Frame Advancing", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Toggle Frame Advancing"), this),
&QShortcut::activated, ui.action_Enable_Frame_Advancing, &QAction::trigger); &QShortcut::activated, ui.action_Enable_Frame_Advancing, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Advance Frame", this), &QShortcut::activated, connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Advance Frame"), this),
ui.action_Advance_Frame, &QAction::trigger); &QShortcut::activated, ui.action_Advance_Frame, &QAction::trigger);
connect(hotkey_registry.GetHotkey("Main Window", "Load Amiibo", this), &QShortcut::activated, connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Load Amiibo"), this),
this, [&] { &QShortcut::activated, this, [&] {
if (ui.action_Load_Amiibo->isEnabled()) { if (ui.action_Load_Amiibo->isEnabled()) {
OnLoadAmiibo(); OnLoadAmiibo();
} }
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Remove Amiibo", this), &QShortcut::activated, connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Remove Amiibo"), this),
this, [&] { &QShortcut::activated, this, [&] {
if (ui.action_Remove_Amiibo->isEnabled()) { if (ui.action_Remove_Amiibo->isEnabled()) {
OnRemoveAmiibo(); OnRemoveAmiibo();
} }
}); });
connect(hotkey_registry.GetHotkey("Main Window", "Capture Screenshot", this), connect(hotkey_registry.GetHotkey(main_window, QStringLiteral("Capture Screenshot"), this),
&QShortcut::activated, this, [&] { &QShortcut::activated, this, [&] {
if (emu_thread->IsRunning()) { if (emu_thread->IsRunning()) {
OnCaptureScreenshot(); OnCaptureScreenshot();
@ -617,9 +628,13 @@ void GMainWindow::ConnectMenuEvents() {
&MultiplayerState::OnOpenNetworkRoom); &MultiplayerState::OnOpenNetworkRoom);
ui.action_Fullscreen->setShortcut( ui.action_Fullscreen->setShortcut(
hotkey_registry.GetHotkey("Main Window", "Fullscreen", this)->key()); hotkey_registry
.GetHotkey(QStringLiteral("Main Window"), QStringLiteral("Fullscreen"), this)
->key());
ui.action_Screen_Layout_Swap_Screens->setShortcut( ui.action_Screen_Layout_Swap_Screens->setShortcut(
hotkey_registry.GetHotkey("Main Window", "Swap Screens", this)->key()); hotkey_registry
.GetHotkey(QStringLiteral("Main Window"), QStringLiteral("Swap Screens"), this)
->key());
ui.action_Screen_Layout_Swap_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut); ui.action_Screen_Layout_Swap_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut);
ui.action_Screen_Layout_Upright_Screens->setShortcut( ui.action_Screen_Layout_Upright_Screens->setShortcut(
hotkey_registry.GetHotkey("Main Window", "Rotate Screens Upright", this)->key()); hotkey_registry.GetHotkey("Main Window", "Rotate Screens Upright", this)->key());
@ -674,8 +689,9 @@ void GMainWindow::ConnectMenuEvents() {
// Help // Help
connect(ui.action_Open_Citra_Folder, &QAction::triggered, this, connect(ui.action_Open_Citra_Folder, &QAction::triggered, this,
&GMainWindow::OnOpenCitraFolder); &GMainWindow::OnOpenCitraFolder);
connect(ui.action_FAQ, &QAction::triggered, connect(ui.action_FAQ, &QAction::triggered, []() {
[]() { QDesktopServices::openUrl(QUrl("https://citra-emu.org/wiki/faq/")); }); QDesktopServices::openUrl(QUrl(QStringLiteral("https://citra-emu.org/wiki/faq/")));
});
connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnMenuAboutCitra); connect(ui.action_About, &QAction::triggered, this, &GMainWindow::OnMenuAboutCitra);
connect(ui.action_Check_For_Updates, &QAction::triggered, this, connect(ui.action_Check_For_Updates, &QAction::triggered, this,
&GMainWindow::OnCheckForUpdates); &GMainWindow::OnCheckForUpdates);
@ -890,7 +906,7 @@ bool GMainWindow::LoadROM(const QString& filename) {
} }
void GMainWindow::BootGame(const QString& filename) { void GMainWindow::BootGame(const QString& filename) {
if (filename.endsWith(".cia")) { if (filename.endsWith(QStringLiteral(".cia"))) {
const auto answer = QMessageBox::question( const auto answer = QMessageBox::question(
this, tr("CIA must be installed before usage"), this, tr("CIA must be installed before usage"),
tr("Before using this CIA, you must install it. Do you want to install it now?"), tr("Before using this CIA, you must install it. Do you want to install it now?"),
@ -1067,7 +1083,7 @@ void GMainWindow::UpdateRecentFiles() {
std::min(UISettings::values.recent_files.size(), max_recent_files_item); std::min(UISettings::values.recent_files.size(), max_recent_files_item);
for (int i = 0; i < num_recent_files; i++) { for (int i = 0; i < num_recent_files; i++) {
const QString text = QString("&%1. %2").arg(i + 1).arg( const QString text = QStringLiteral("&%1. %2").arg(i + 1).arg(
QFileInfo(UISettings::values.recent_files[i]).fileName()); QFileInfo(UISettings::values.recent_files[i]).fileName());
actions_recent_files[i]->setText(text); actions_recent_files[i]->setText(text);
actions_recent_files[i]->setData(UISettings::values.recent_files[i]); actions_recent_files[i]->setData(UISettings::values.recent_files[i]);
@ -1158,12 +1174,12 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,
void GMainWindow::OnGameListOpenDirectory(const QString& directory) { void GMainWindow::OnGameListOpenDirectory(const QString& directory) {
QString path; QString path;
if (directory == "INSTALLED") { if (directory == QStringLiteral("INSTALLED")) {
path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) +
"Nintendo " "Nintendo "
"3DS/00000000000000000000000000000000/" "3DS/00000000000000000000000000000000/"
"00000000000000000000000000000000/title/00040000"); "00000000000000000000000000000000/title/00040000");
} else if (directory == "SYSTEM") { } else if (directory == QStringLiteral("SYSTEM")) {
path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) +
"00000000000000000000000000000000/title/00040010"); "00000000000000000000000000000000/title/00040010");
} else { } else {
@ -1197,8 +1213,8 @@ void GMainWindow::OnGameListShowList(bool show) {
}; };
void GMainWindow::OnMenuLoadFile() { void GMainWindow::OnMenuLoadFile() {
const QString extensions = const QString extensions = QStringLiteral("*.").append(
QString("*.").append(GameList::supported_file_extensions.join(" *.")); GameList::supported_file_extensions.join(QStringLiteral(" *.")));
const QString file_filter = tr("3DS Executable (%1);;All Files (*.*)", const QString file_filter = tr("3DS Executable (%1);;All Files (*.*)",
"%1 is an identifier for the 3DS executable file extensions.") "%1 is an identifier for the 3DS executable file extensions.")
.arg(extensions); .arg(extensions);
@ -1507,9 +1523,9 @@ void GMainWindow::OnConfigure() {
} }
void GMainWindow::OnLoadAmiibo() { void GMainWindow::OnLoadAmiibo() {
const QString extensions{"*.bin"}; const QString extensions{QStringLiteral("*.bin")};
const QString file_filter = tr("Amiibo File (%1);; All Files (*.*)").arg(extensions); const QString file_filter = tr("Amiibo File (%1);; All Files (*.*)").arg(extensions);
const QString filename = QFileDialog::getOpenFileName(this, tr("Load Amiibo"), "", file_filter); const QString filename = QFileDialog::getOpenFileName(this, tr("Load Amiibo"), {}, file_filter);
if (filename.isEmpty()) { if (filename.isEmpty()) {
return; return;
@ -1728,7 +1744,7 @@ void GMainWindow::OnCaptureScreenshot() {
QFileDialog png_dialog(this, tr("Capture Screenshot"), UISettings::values.screenshot_path, QFileDialog png_dialog(this, tr("Capture Screenshot"), UISettings::values.screenshot_path,
tr("PNG Image (*.png)")); tr("PNG Image (*.png)"));
png_dialog.setAcceptMode(QFileDialog::AcceptSave); png_dialog.setAcceptMode(QFileDialog::AcceptSave);
png_dialog.setDefaultSuffix("png"); png_dialog.setDefaultSuffix(QStringLiteral("png"));
if (png_dialog.exec()) { if (png_dialog.exec()) {
const QString path = png_dialog.selectedFiles().first(); const QString path = png_dialog.selectedFiles().first();
if (!path.isEmpty()) { if (!path.isEmpty()) {
@ -1821,11 +1837,11 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
if (!details.empty()) { if (!details.empty()) {
message = common_message.arg(QString::fromStdString(details)); message = common_message.arg(QString::fromStdString(details));
} else { } else {
message = common_message.arg("A system archive"); message = common_message.arg(tr("A system archive"));
} }
title = tr("System Archive Not Found"); title = tr("System Archive Not Found");
status_message = "System Archive Missing"; status_message = tr("System Archive Missing");
} else { } else {
title = tr("Fatal Error"); title = tr("Fatal Error");
message = message =
@ -1833,7 +1849,7 @@ void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string det
"<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>Check " "<a href='https://community.citra-emu.org/t/how-to-upload-the-log-file/296'>Check "
"the log</a> for details." "the log</a> for details."
"<br/>Continuing emulation may result in crashes and bugs."); "<br/>Continuing emulation may result in crashes and bugs.");
status_message = "Fatal Error encountered"; status_message = tr("Fatal Error encountered");
} }
QMessageBox message_box; QMessageBox message_box;
@ -1941,7 +1957,7 @@ bool GMainWindow::DropAction(QDropEvent* event) {
const QMimeData* mime_data = event->mimeData(); const QMimeData* mime_data = event->mimeData();
const QString& filename = mime_data->urls().at(0).toLocalFile(); const QString& filename = mime_data->urls().at(0).toLocalFile();
if (emulation_running && QFileInfo(filename).suffix() == "bin") { if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) {
// Amiibo // Amiibo
LoadAmiibo(filename); LoadAmiibo(filename);
} else { } else {
@ -1981,32 +1997,38 @@ void GMainWindow::filterBarSetChecked(bool state) {
} }
void GMainWindow::UpdateUITheme() { void GMainWindow::UpdateUITheme() {
const QString default_icons = QStringLiteral(":/icons/default");
const QString& current_theme = UISettings::values.theme;
const bool is_default_theme = current_theme == QString::fromUtf8(UISettings::themes[0].second);
QStringList theme_paths(default_theme_paths); QStringList theme_paths(default_theme_paths);
if (UISettings::values.theme != UISettings::themes[0].second &&
!UISettings::values.theme.isEmpty()) { if (is_default_theme || current_theme.isEmpty()) {
const QString theme_uri(":" + UISettings::values.theme + "/style.qss"); qApp->setStyleSheet({});
setStyleSheet({});
theme_paths.append(default_icons);
QIcon::setThemeName(default_icons);
} else {
const QString theme_uri(QLatin1Char{':'} + current_theme + QStringLiteral("/style.qss"));
QFile f(theme_uri); QFile f(theme_uri);
if (f.open(QFile::ReadOnly | QFile::Text)) { if (f.open(QFile::ReadOnly | QFile::Text)) {
QTextStream ts(&f); QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll()); qApp->setStyleSheet(ts.readAll());
GMainWindow::setStyleSheet(ts.readAll()); setStyleSheet(ts.readAll());
} else { } else {
LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found"); LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
} }
theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme});
QIcon::setThemeName(":/icons/" + UISettings::values.theme); const QString theme_name = QStringLiteral(":/icons/") + current_theme;
} else { theme_paths.append({default_icons, theme_name});
qApp->setStyleSheet(""); QIcon::setThemeName(theme_name);
GMainWindow::setStyleSheet("");
theme_paths.append(QStringList{":/icons/default"});
QIcon::setThemeName(":/icons/default");
} }
QIcon::setThemeSearchPaths(theme_paths); QIcon::setThemeSearchPaths(theme_paths);
} }
void GMainWindow::LoadTranslation() { void GMainWindow::LoadTranslation() {
// If the selected language is English, no need to install any translation // If the selected language is English, no need to install any translation
if (UISettings::values.language == "en") { if (UISettings::values.language == QStringLiteral("en")) {
return; return;
} }
@ -2014,21 +2036,21 @@ void GMainWindow::LoadTranslation() {
if (UISettings::values.language.isEmpty()) { if (UISettings::values.language.isEmpty()) {
// If the selected language is empty, use system locale // If the selected language is empty, use system locale
loaded = translator.load(QLocale(), "", "", ":/languages/"); loaded = translator.load(QLocale(), {}, {}, QStringLiteral(":/languages/"));
} else { } else {
// Otherwise load from the specified file // Otherwise load from the specified file
loaded = translator.load(UISettings::values.language, ":/languages/"); loaded = translator.load(UISettings::values.language, QStringLiteral(":/languages/"));
} }
if (loaded) { if (loaded) {
qApp->installTranslator(&translator); qApp->installTranslator(&translator);
} else { } else {
UISettings::values.language = "en"; UISettings::values.language = QStringLiteral("en");
} }
} }
void GMainWindow::OnLanguageChanged(const QString& locale) { void GMainWindow::OnLanguageChanged(const QString& locale) {
if (UISettings::values.language != "en") { if (UISettings::values.language != QStringLiteral("en")) {
qApp->removeTranslator(&translator); qApp->removeTranslator(&translator);
} }
@ -2110,8 +2132,8 @@ int main(int argc, char* argv[]) {
SCOPE_EXIT({ MicroProfileShutdown(); }); SCOPE_EXIT({ MicroProfileShutdown(); });
// Init settings params // Init settings params
QCoreApplication::setOrganizationName("Citra team"); QCoreApplication::setOrganizationName(QStringLiteral("Citra team"));
QCoreApplication::setApplicationName("Citra"); QCoreApplication::setApplicationName(QStringLiteral("Citra"));
QSurfaceFormat format; QSurfaceFormat format;
format.setVersion(3, 3); format.setVersion(3, 3);

View File

@ -128,25 +128,25 @@ static QString StringToInputMask(const QString& input) {
QString mask = input; QString mask = input;
// ... replace any special characters by their escaped counterparts ... // ... replace any special characters by their escaped counterparts ...
mask.replace("\\", "\\\\"); mask.replace(QStringLiteral("\\"), QStringLiteral("\\\\"));
mask.replace("A", "\\A"); mask.replace(QLatin1Char{'A'}, QStringLiteral("\\A"));
mask.replace("a", "\\a"); mask.replace(QLatin1Char{'a'}, QStringLiteral("\\a"));
mask.replace("N", "\\N"); mask.replace(QLatin1Char{'N'}, QStringLiteral("\\N"));
mask.replace("n", "\\n"); mask.replace(QLatin1Char{'n'}, QStringLiteral("\\n"));
mask.replace("X", "\\X"); mask.replace(QLatin1Char{'X'}, QStringLiteral("\\X"));
mask.replace("x", "\\x"); mask.replace(QLatin1Char{'x'}, QStringLiteral("\\x"));
mask.replace("9", "\\9"); mask.replace(QLatin1Char{'9'}, QStringLiteral("\\9"));
mask.replace("0", "\\0"); mask.replace(QLatin1Char{'0'}, QStringLiteral("\\0"));
mask.replace("D", "\\D"); mask.replace(QLatin1Char{'D'}, QStringLiteral("\\D"));
mask.replace("d", "\\d"); mask.replace(QLatin1Char{'d'}, QStringLiteral("\\d"));
mask.replace("#", "\\#"); mask.replace(QLatin1Char{'#'}, QStringLiteral("\\#"));
mask.replace("H", "\\H"); mask.replace(QLatin1Char{'H'}, QStringLiteral("\\H"));
mask.replace("h", "\\h"); mask.replace(QLatin1Char{'h'}, QStringLiteral("\\h"));
mask.replace("B", "\\B"); mask.replace(QLatin1Char{'B'}, QStringLiteral("\\B"));
mask.replace("b", "\\b"); mask.replace(QLatin1Char{'b'}, QStringLiteral("\\b"));
mask.replace(">", "\\>"); mask.replace(QLatin1Char{'>'}, QStringLiteral("\\>"));
mask.replace("<", "\\<"); mask.replace(QLatin1Char{'<'}, QStringLiteral("\\<"));
mask.replace("!", "\\!"); mask.replace(QLatin1Char{'!'}, QStringLiteral("\\!"));
return mask; return mask;
} }
@ -160,19 +160,19 @@ void CSpinBox::UpdateText() {
// For base 10 and negative range, demand a single sign character // For base 10 and negative range, demand a single sign character
if (HasSign()) if (HasSign())
mask += "X"; // identified as "-" or "+" in the validator mask.append(QLatin1Char{'X'}); // identified as "-" or "+" in the validator
// Uppercase digits greater than 9. // Uppercase digits greater than 9.
mask += ">"; mask.append(QLatin1Char{'>'});
// Match num_digits digits // Match num_digits digits
// Digits irrelevant to the chosen number base are filtered in the validator // Digits irrelevant to the chosen number base are filtered in the validator
mask += QString("H").repeated(std::max(num_digits, 1)); mask.append(QStringLiteral("H").repeated(std::max(num_digits, 1)));
// Switch off case conversion // Switch off case conversion
mask += "!"; mask.append(QLatin1Char{'!'});
mask += StringToInputMask(suffix); mask.append(StringToInputMask(suffix));
} }
lineEdit()->setInputMask(mask); lineEdit()->setInputMask(mask);
@ -185,8 +185,9 @@ void CSpinBox::UpdateText() {
} }
QString CSpinBox::TextFromValue() { QString CSpinBox::TextFromValue() {
return prefix + QString(HasSign() ? ((value < 0) ? "-" : "+") : "") + return prefix +
QString("%1").arg(std::abs(value), num_digits, base, QLatin1Char('0')).toUpper() + (HasSign() ? ((value < 0) ? QStringLiteral("-") : QStringLiteral("+")) : QString{}) +
QStringLiteral("%1").arg(std::abs(value), num_digits, base, QLatin1Char('0')).toUpper() +
suffix; suffix;
} }
@ -224,20 +225,20 @@ QValidator::State CSpinBox::validate(QString& input, int& pos) const {
// Demand sign character for negative ranges // Demand sign character for negative ranges
if (HasSign()) if (HasSign())
regexp += "[+\\-]"; regexp.append(QStringLiteral("[+\\-]"));
// Match digits corresponding to the chosen number base. // Match digits corresponding to the chosen number base.
regexp += QString("[0-%1").arg(std::min(base, 9)); regexp.append(QStringLiteral("[0-%1").arg(std::min(base, 9)));
if (base == 16) { if (base == 16) {
regexp += "a-fA-F"; regexp.append(QStringLiteral("a-fA-F"));
} }
regexp += "]"; regexp.append(QLatin1Char(']'));
// Specify number of digits // Specify number of digits
if (num_digits > 0) { if (num_digits > 0) {
regexp += QString("{%1}").arg(num_digits); regexp.append(QStringLiteral("{%1}").arg(num_digits));
} else { } else {
regexp += "+"; regexp.append(QLatin1Char{'+'});
} }
// Match string // Match string