Merge pull request #778 from jpnurmi/background

Add a command line option to launch the client in the background
This commit is contained in:
Camila Ayres 2018-12-06 09:53:19 +01:00 committed by GitHub
commit 840904d527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View file

@ -72,7 +72,8 @@ namespace {
" (to be used with --logdir)\n"
" --logflush : flush the log file after every write.\n"
" --logdebug : also output debug-level messages in the log.\n"
" --confdir <dirname> : Use the given configuration folder.\n";
" --confdir <dirname> : Use the given configuration folder.\n"
" --background : launch the application in the background.\n";
QString applicationTrPath()
{
@ -106,6 +107,7 @@ Application::Application(int &argc, char **argv)
, _logDebug(false)
, _userTriggeredConnect(false)
, _debugMode(false)
, _backgroundMode(false)
{
_startedAt.start();
@ -467,6 +469,8 @@ void Application::parseOptions(const QStringList &options)
} else if (option == QLatin1String("--debug")) {
_logDebug = true;
_debugMode = true;
} else if (option == QLatin1String("--background")) {
_backgroundMode = true;
} else if (option == QLatin1String("--version")) {
_versionOnly = true;
} else {
@ -540,6 +544,11 @@ bool Application::debugMode()
return _debugMode;
}
bool Application::backgroundMode() const
{
return _backgroundMode;
}
void Application::setHelp()
{
_helpOnly = true;

View file

@ -63,6 +63,7 @@ public:
void showHelp();
void showHint(std::string errorHint);
bool debugMode();
bool backgroundMode() const;
bool versionOnly(); // only display the version?
void showVersion();
@ -112,6 +113,7 @@ private:
bool _logDebug;
bool _userTriggeredConnect;
bool _debugMode;
bool _backgroundMode;
ClientProxy _proxy;

View file

@ -126,7 +126,7 @@ int main(int argc, char **argv)
if (!app.sendMessage(QLatin1String("MSG_PARSEOPTIONS:") + msg))
return -1;
}
if (!app.sendMessage(QLatin1String("MSG_SHOWSETTINGS"))) {
if (!app.backgroundMode() && !app.sendMessage(QLatin1String("MSG_SHOWSETTINGS"))) {
return -1;
}
return 0;
@ -158,7 +158,7 @@ int main(int argc, char **argv)
warnSystray();
}
}
if (!QSystemTrayIcon::isSystemTrayAvailable() && desktopSession != "ubuntu") {
if (!app.backgroundMode() && !QSystemTrayIcon::isSystemTrayAvailable() && desktopSession != "ubuntu") {
app.showSettingsDialog();
}
}