mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-12-26 19:54:28 +01:00
Merge pull request #13121 from german77/clean-shortcut
yuzu: Fix shortcut error message
This commit is contained in:
commit
9dc624f5dc
@ -3010,9 +3010,6 @@ bool GMainWindow::MakeShortcutIcoPath(const u64 program_id, const std::string_vi
|
|||||||
|
|
||||||
void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path,
|
void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& game_path,
|
||||||
GameListShortcutTarget target) {
|
GameListShortcutTarget target) {
|
||||||
std::string game_title;
|
|
||||||
QString qt_game_title;
|
|
||||||
std::filesystem::path out_icon_path;
|
|
||||||
// Get path to yuzu executable
|
// Get path to yuzu executable
|
||||||
const QStringList args = QApplication::arguments();
|
const QStringList args = QApplication::arguments();
|
||||||
std::filesystem::path yuzu_command = args[0].toStdString();
|
std::filesystem::path yuzu_command = args[0].toStdString();
|
||||||
@ -3029,15 +3026,22 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
|||||||
shortcut_path =
|
shortcut_path =
|
||||||
QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString();
|
QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString();
|
||||||
}
|
}
|
||||||
// Icon path and title
|
|
||||||
if (std::filesystem::exists(shortcut_path)) {
|
if (!std::filesystem::exists(shortcut_path)) {
|
||||||
|
GMainWindow::CreateShortcutMessagesGUI(
|
||||||
|
this, GMainWindow::CREATE_SHORTCUT_MSGBOX_ERROR,
|
||||||
|
QString::fromStdString(shortcut_path.generic_string()));
|
||||||
|
LOG_ERROR(Frontend, "Invalid shortcut target {}", shortcut_path.generic_string());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get title from game file
|
// Get title from game file
|
||||||
const FileSys::PatchManager pm{program_id, system->GetFileSystemController(),
|
const FileSys::PatchManager pm{program_id, system->GetFileSystemController(),
|
||||||
system->GetContentProvider()};
|
system->GetContentProvider()};
|
||||||
const auto control = pm.GetControlMetadata();
|
const auto control = pm.GetControlMetadata();
|
||||||
const auto loader =
|
const auto loader =
|
||||||
Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read));
|
Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read));
|
||||||
game_title = fmt::format("{:016X}", program_id);
|
std::string game_title = fmt::format("{:016X}", program_id);
|
||||||
if (control.first != nullptr) {
|
if (control.first != nullptr) {
|
||||||
game_title = control.first->GetApplicationName();
|
game_title = control.first->GetApplicationName();
|
||||||
} else {
|
} else {
|
||||||
@ -3050,7 +3054,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
|||||||
game_title.erase(it.base() - 1);
|
game_title.erase(it.base() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qt_game_title = QString::fromStdString(game_title);
|
const QString qt_game_title = QString::fromStdString(game_title);
|
||||||
// Get icon from game file
|
// Get icon from game file
|
||||||
std::vector<u8> icon_image_file{};
|
std::vector<u8> icon_image_file{};
|
||||||
if (control.second != nullptr) {
|
if (control.second != nullptr) {
|
||||||
@ -3060,17 +3064,13 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
|||||||
}
|
}
|
||||||
QImage icon_data =
|
QImage icon_data =
|
||||||
QImage::fromData(icon_image_file.data(), static_cast<int>(icon_image_file.size()));
|
QImage::fromData(icon_image_file.data(), static_cast<int>(icon_image_file.size()));
|
||||||
|
std::filesystem::path out_icon_path;
|
||||||
if (GMainWindow::MakeShortcutIcoPath(program_id, game_title, out_icon_path)) {
|
if (GMainWindow::MakeShortcutIcoPath(program_id, game_title, out_icon_path)) {
|
||||||
if (!SaveIconToFile(out_icon_path, icon_data)) {
|
if (!SaveIconToFile(out_icon_path, icon_data)) {
|
||||||
LOG_ERROR(Frontend, "Could not write icon to file");
|
LOG_ERROR(Frontend, "Could not write icon to file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
GMainWindow::CreateShortcutMessagesGUI(this, GMainWindow::CREATE_SHORTCUT_MSGBOX_ERROR,
|
|
||||||
qt_game_title);
|
|
||||||
LOG_ERROR(Frontend, "Invalid shortcut target");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
// Special case for AppImages
|
// Special case for AppImages
|
||||||
// Warn once if we are making a shortcut to a volatile AppImage
|
// Warn once if we are making a shortcut to a volatile AppImage
|
||||||
|
Loading…
Reference in New Issue
Block a user