diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2019-11-28 13:57:51 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2019-12-04 21:58:54 +0300 |
commit | 8d9cb09335b72df421121f2fcdd5ee4d37bf65d5 (patch) | |
tree | cc2557025ae1457adffe72991d4daefd01bbfb56 | |
parent | 93ac380492fd6f7a00e2ce8d2e9df9b94554b83e (diff) |
Application: Allow to quit running instances by commandline
-rw-r--r-- | docs/modules/ROOT/pages/advanced_usage/options.adoc | 2 | ||||
-rw-r--r-- | src/gui/application.cpp | 12 | ||||
-rw-r--r-- | src/gui/application.h | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/docs/modules/ROOT/pages/advanced_usage/options.adoc b/docs/modules/ROOT/pages/advanced_usage/options.adoc index 663fef3fa..a449e2434 100644 --- a/docs/modules/ROOT/pages/advanced_usage/options.adoc +++ b/docs/modules/ROOT/pages/advanced_usage/options.adoc @@ -12,6 +12,8 @@ The other options are: | Option | Description | `-s` + `--showsettings` | Open the settings dialog while starting. +|`-q` + +`--quit` | Quit the running instance. | `--logwindow` | Opens a window displaying log output. | `--logfile <filename>` | Write log output to the file specified. To write to stdout, specify `-` as the filename. | `--logdir <name>` | Writes each synchronization log output in a new file in the specified directory. diff --git a/src/gui/application.cpp b/src/gui/application.cpp index ff373a0fc..d4ec53555 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -69,6 +69,7 @@ namespace { "Options:\n" " -h --help : show this help screen.\n" " -s --showsettings : show the settings dialog while starting.\n" + " -q --quit : quit the running instance\n" " --logwindow : open a window to show log output.\n" " --logfile <filename> : write log output to file <filename>.\n" " --logfile - : write log output to stdout.\n" @@ -235,6 +236,11 @@ Application::Application(int &argc, char **argv) if (_helpOnly || _versionOnly) return; + if (_quitInstance) { + QTimer::singleShot(0, qApp, &QApplication::quit); + return; + } + if (isRunning()) return; @@ -527,6 +533,10 @@ void Application::slotParseMessage(const QString &msg, QObject *) if (_showSettings) { _gui->slotShowSettings(); } + if (_quitInstance) { + qApp->quit(); + } + } else if (msg.startsWith(QLatin1String("MSG_SHOWSETTINGS"))) { qCInfo(lcApplication) << "Running for" << _startedAt.elapsed() / 1000.0 << "sec"; if (_startedAt.elapsed() < 10 * 1000) { @@ -553,6 +563,8 @@ void Application::parseOptions(const QStringList &options) break; } else if (option == QLatin1String("--showsettings") || option == QLatin1String("-s")) { _showSettings = true; + } else if (option == QLatin1String("--quit") || option == QLatin1String("-q")) { + _quitInstance = true; } else if (option == QLatin1String("--logwindow") || option == QLatin1String("-l")) { _showLogWindow = true; } else if (option == QLatin1String("--logfile")) { diff --git a/src/gui/application.h b/src/gui/application.h index 97c829fd5..9dc1a92d0 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -123,6 +123,7 @@ private: // options from command line: bool _showLogWindow; bool _showSettings = false; + bool _quitInstance = false; QString _logFile; QString _logDir; std::chrono::hours _logExpire; |