From 6b41eb69ebec9ca64aaf53129bc3f5ec2f76b403 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 7 May 2020 16:49:50 +0100 Subject: [PATCH] Lock-file dialog: allow quit-ing, make translated Add translation macros for the text of the lock-file warning dialog, and update the default text after some discussion on the devel list. Also allow quiting the app, as an alternative option. --- src/GUI/QtLauncher.cxx | 29 +++++++++++++++++++++++------ src/GUI/QtLauncher.hxx | 3 ++- src/Main/main.cxx | 2 ++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index 068553cce..46409b7c6 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -500,23 +500,40 @@ bool runInAppLauncherDialog() return true; } +static const char* static_lockFileDialog_Title = + QT_TRANSLATE_NOOP("LockFileDialog", "Multiple copies of FlightGear running"); +static const char* static_lockFileDialog_Text = + QT_TRANSLATE_NOOP("LockFileDialog", + "FlightGear has detected another copy is already running. " + "This copy will run in read-only mode, so downloads will not be possible, " + "and settings will not be saved."); +static const char* static_lockFileDialog_Info = + QT_TRANSLATE_NOOP("LockFileDialog", + "If you are sure another copy is not running on this computer, " + "you can choose to reset the lock file, and run this copy as normal. " + "Alternatively, you can close this copy of the software."); + LockFileDialogResult showLockFileDialog() { + QString title = qApp->translate("LockFileDialog", static_lockFileDialog_Title); + QString text = qApp->translate("LockFileDialog", static_lockFileDialog_Text); + QString infoText = qApp->translate("LockFileDialog", static_lockFileDialog_Info); + QMessageBox mb; mb.setIconPixmap(QPixmap(":/app-icon-large")); - mb.setWindowTitle("Multiple copies of Flightgear running"); - mb.setText("Flightgear has detected another copy is already running. " - "This copy will run in read-only mode, so downloads will not be possible, " - "and settings will not be saved."); - mb.setInformativeText("If you are sure another copy is not running on this computer, " - "you can choose to reset the lock file to prevent seeing this message again."); + mb.setWindowTitle(title); + mb.setText(text); + mb.setInformativeText(infoText); mb.addButton(QMessageBox::Ok); mb.setDefaultButton(QMessageBox::Ok); mb.addButton(QMessageBox::Reset); + mb.addButton(QMessageBox::Close); int r = mb.exec(); if (r == QMessageBox::Reset) return LockFileReset; + if (r == QMessageBox::Close) + return LockFileQuit; return LockFileContinue; } diff --git a/src/GUI/QtLauncher.hxx b/src/GUI/QtLauncher.hxx index 183d51dc6..8f0edd076 100644 --- a/src/GUI/QtLauncher.hxx +++ b/src/GUI/QtLauncher.hxx @@ -46,7 +46,8 @@ namespace flightgear enum LockFileDialogResult { LockFileContinue, - LockFileReset + LockFileReset, + LockFileQuit }; LockFileDialogResult showLockFileDialog(); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 0ddadbdc8..ad437dcc3 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -554,6 +554,8 @@ int fgMainInit( int argc, char **argv ) SG_LOG( SG_GENERAL, SG_ALERT, "Deleting lock file at user request"); fgDeleteLockFile(); fgSetBool("/sim/fghome-readonly", false); + } else if (r == flightgear::LockFileQuit) { + return EXIT_SUCCESS; } } #endif