From 75db2533705b686dab34273c19571d948c4e4560 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Fri, 28 Feb 2025 12:33:52 -0300 Subject: [PATCH] 'Select' the log when opening the folder if SeparateLogFiles (#2560) * Select when opening log folder when getSeparateLogFilesEnabled * TR * + --- src/qt_gui/gui_context_menus.h | 52 +++++++++++++++++++++++++++++--- src/qt_gui/translations/en_US.ts | 4 +++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/qt_gui/gui_context_menus.h b/src/qt_gui/gui_context_menus.h index 385b5fda9..8a6e07847 100644 --- a/src/qt_gui/gui_context_menus.h +++ b/src/qt_gui/gui_context_menus.h @@ -157,10 +157,54 @@ public: } if (selected == openLogFolder) { - QString userPath; - Common::FS::PathToQString(userPath, - Common::FS::GetUserPath(Common::FS::PathType::UserDir)); - QDesktopServices::openUrl(QUrl::fromLocalFile(userPath + "/log")); + QString logPath; + Common::FS::PathToQString(logPath, + Common::FS::GetUserPath(Common::FS::PathType::LogDir)); + if (!Config::getSeparateLogFilesEnabled()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(logPath)); + } else { + QString fileName = QString::fromStdString(m_games[itemID].serial) + ".log"; + QString filePath = logPath + "/" + fileName; + QStringList arguments; + if (QFile::exists(filePath)) { +#ifdef Q_OS_WIN + arguments << "/select," << filePath.replace("/", "\\"); + QProcess::startDetached("explorer", arguments); + +#elif defined(Q_OS_MAC) + arguments << "-R" << filePath; + QProcess::startDetached("open", arguments); + +#elif defined(Q_OS_LINUX) + QStringList arguments; + arguments << "--select" << filePath; + if (!QProcess::startDetached("nautilus", arguments)) { + // Failed to open Nautilus to select file + arguments.clear(); + arguments << logPath; + if (!QProcess::startDetached("xdg-open", arguments)) { + // Failed to open directory on Linux + } + } +#else + QDesktopServices::openUrl(QUrl::fromLocalFile(logPath)); +#endif + } else { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Information); + msgBox.setText(tr("No log file found for this game!")); + + QPushButton* okButton = msgBox.addButton(QMessageBox::Ok); + QPushButton* openFolderButton = + msgBox.addButton(tr("Open Log Folder"), QMessageBox::ActionRole); + + msgBox.exec(); + + if (msgBox.clickedButton() == openFolderButton) { + QDesktopServices::openUrl(QUrl::fromLocalFile(logPath)); + } + } + } } if (selected == &openSfoViewer) { diff --git a/src/qt_gui/translations/en_US.ts b/src/qt_gui/translations/en_US.ts index ea777a73a..92fb59a02 100644 --- a/src/qt_gui/translations/en_US.ts +++ b/src/qt_gui/translations/en_US.ts @@ -855,6 +855,10 @@ This game has no update folder to open! + + No log file found for this game! + + Failed to convert icon.