'Select' the log when opening the folder if SeparateLogFiles (#2560)

* Select when opening log folder when getSeparateLogFilesEnabled

* TR

* +
This commit is contained in:
DanielSvoboda 2025-02-28 12:33:52 -03:00 committed by GitHub
parent 6331eb1d8a
commit 75db253370
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 52 additions and 4 deletions

View file

@ -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) {

View file

@ -855,6 +855,10 @@
<source>This game has no update folder to open!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No log file found for this game!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Failed to convert icon.</source>
<translation type="unfinished"></translation>