Skip to content

Commit

Permalink
Linux: Don't show settings dialog always when launched twice
Browse files Browse the repository at this point in the history
For #3273 #3771 #3485
See also d503221
  • Loading branch information
guruz committed Sep 28, 2015
1 parent 2c9d418 commit 641dece
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Application::Application(int &argc, char **argv) :
_userTriggeredConnect(false),
_debugMode(false)
{
_startedAt.start();

// TODO: Can't set this without breaking current config pathes
// setOrganizationName(QLatin1String(APPLICATION_VENDOR));
setOrganizationDomain(QLatin1String(APPLICATION_REV_DOMAIN));
Expand Down Expand Up @@ -301,6 +303,12 @@ void Application::slotParseMessage(const QString &msg, QObject*)
parseOptions(options);
setupLogging();
} else if (msg.startsWith(QLatin1String("MSG_SHOWSETTINGS"))) {
qDebug() << "Running for" << _startedAt.elapsed()/1000.0 << "sec";
if (isSessionRestored() && _startedAt.elapsed() < 10*1000) {
// This call is mirrored with the one in int main()
qWarning() << "Ignoring MSG_SHOWSETTINGS, possibly double-invocation of client via session restore and auto start";
return;
}
showSettingsDialog();
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QPointer>
#include <QQueue>
#include <QTimer>
#include <QElapsedTimer>

#include "qtsingleapplication.h"

Expand Down Expand Up @@ -97,6 +98,8 @@ protected slots:
bool _helpOnly;
bool _versionOnly;

QElapsedTimer _startedAt;

// options from command line:
bool _showLogWindow;
QString _logFile;
Expand Down
4 changes: 3 additions & 1 deletion src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int main(int argc, char **argv)
if(app.isRunning()) {
qDebug() << Q_FUNC_INFO << "Already running, exiting...";
if (app.isSessionRestored()) {
// This call is mirrored with the one in Application::slotParseMessage
qDebug() << "Session was restored, don't notify app!";
return -1;
}
Expand All @@ -99,8 +100,9 @@ int main(int argc, char **argv)
if(!app.sendMessage(QLatin1String("MSG_PARSEOPTIONS:") + msg))
return -1;
}
if(!app.sendMessage(QLatin1String("MSG_SHOWSETTINGS")))
if(!app.sendMessage(QLatin1String("MSG_SHOWSETTINGS"))) {
return -1;
}
return 0;
} else {
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
Expand Down

0 comments on commit 641dece

Please sign in to comment.