From ba4e1adda1c28166dbcdbd7b30b465c708aeb8df Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 3 Apr 2019 23:53:29 -0400 Subject: [PATCH 1/5] yuzu/main: Use static variant of QFile's exists() There's no need to construct a QFile instance just to check for its existence. --- src/yuzu/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 9efe626d06..f45a74c6d8 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1096,7 +1096,7 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { tranferable_shader_cache_folder_path + DIR_SEP + QString::fromStdString(fmt::format("{:016X}", program_id)) + ".bin"; - if (!QFile(transferable_shader_cache_file_path).exists()) { + if (!QFile::exists(transferable_shader_cache_file_path)) { QMessageBox::warning(this, tr("Error Opening %1 File").arg(QString::fromStdString(open_target)), tr("File does not exist!")); From 872d480c6063d77c4e3f29b9a6a357fa8b874fb6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 3 Apr 2019 23:55:55 -0400 Subject: [PATCH 2/5] yuzu/main: Make open_target a QString Simplifies the amount of string conversions necessary. We also don't need to log out what occurs here. --- src/yuzu/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f45a74c6d8..6f1d10e17c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1087,7 +1087,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { ASSERT(program_id != 0); - constexpr char open_target[] = "Transferable Shader Cache"; + const QString open_target = QStringLiteral("Transferable Shader Cache"); const QString tranferable_shader_cache_folder_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)) + "opengl" + DIR_SEP + "transferable"; @@ -1097,12 +1097,10 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { QString::fromStdString(fmt::format("{:016X}", program_id)) + ".bin"; if (!QFile::exists(transferable_shader_cache_file_path)) { - QMessageBox::warning(this, - tr("Error Opening %1 File").arg(QString::fromStdString(open_target)), + QMessageBox::warning(this, tr("Error Opening %1 File").arg(open_target), tr("File does not exist!")); return; } - LOG_INFO(Frontend, "Opening {} path for program_id={:016x}", open_target, program_id); // Windows supports opening a folder with selecting a specified file in explorer. On every other // OS we just open the transferable shader cache folder without preselecting the transferable From 3f8c9b25d8bf0423bc0e390a2302cb7893cac11e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 3 Apr 2019 23:58:56 -0400 Subject: [PATCH 3/5] yuzu/main: Remove unnecessary string concatenation in OnTransferableShaderCacheOpenFile() We can just make the trailing portion of the string part of the formatting, getting rid of the need to make another temporary string. --- src/yuzu/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 6f1d10e17c..cff5d9df8d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1094,7 +1094,7 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { const QString transferable_shader_cache_file_path = tranferable_shader_cache_folder_path + DIR_SEP + - QString::fromStdString(fmt::format("{:016X}", program_id)) + ".bin"; + QString::fromStdString(fmt::format("{:016X}.bin", program_id)); if (!QFile::exists(transferable_shader_cache_file_path)) { QMessageBox::warning(this, tr("Error Opening %1 File").arg(open_target), From 5ba5f82082a1406b81f9a2a40a99bdd3d0cc6314 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 4 Apr 2019 00:06:32 -0400 Subject: [PATCH 4/5] yuzu/main: Tidy up the error dialog string in OnTransferableShaderCacheOpenFile() Rather than scream that the file doesn't exist, we can clearly state what specifically doesn't exist, to avoid ambiguity, and make it easier to understand for non-primary English speakers/readers. --- src/yuzu/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index cff5d9df8d..980aed496c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1087,7 +1087,6 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { ASSERT(program_id != 0); - const QString open_target = QStringLiteral("Transferable Shader Cache"); const QString tranferable_shader_cache_folder_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)) + "opengl" + DIR_SEP + "transferable"; @@ -1097,8 +1096,8 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { QString::fromStdString(fmt::format("{:016X}.bin", program_id)); if (!QFile::exists(transferable_shader_cache_file_path)) { - QMessageBox::warning(this, tr("Error Opening %1 File").arg(open_target), - tr("File does not exist!")); + QMessageBox::warning(this, tr("Error Opening Transferable Shader Cache"), + tr("A shader cache for this title does not exist.")); return; } From e5bb07a973708b69d2e3d465ced87136b817d0a1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 4 Apr 2019 00:12:52 -0400 Subject: [PATCH 5/5] yuzu/main: Use QStringLiteral where applicable within OnTransferableShaderCacheOpenFile() Allows these strings to have no allocation cost when used at runtime. --- src/yuzu/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 980aed496c..86795eb67c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1105,10 +1105,10 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { // OS we just open the transferable shader cache folder without preselecting the transferable // shader cache file for the selected game. #if defined(Q_OS_WIN) - const QString explorer = "explorer"; + const QString explorer = QStringLiteral("explorer"); QStringList param; if (!QFileInfo(transferable_shader_cache_file_path).isDir()) { - param << QLatin1String("/select,"); + param << QStringLiteral("/select,"); } param << QDir::toNativeSeparators(transferable_shader_cache_file_path); QProcess::startDetached(explorer, param);