Show the settings also when no arguments are passed

sendMessage would only be called if there were options to
be sent to the running application.
Fix the issue by having explicitly named messages and always
send the show settings message.

Issue #2374
This commit is contained in:
Jocelyn Turcotte 2015-02-19 16:54:34 +01:00
parent 2ddaf5a06a
commit 03e23da6a3
3 changed files with 17 additions and 14 deletions

View file

@ -111,7 +111,7 @@ Application::Application(int &argc, char **argv) :
_folderManager.reset(new FolderMan);
connect( this, SIGNAL(messageReceived(QString, QObject*)), SLOT(slotParseOptions(QString, QObject*)));
connect(this, SIGNAL(messageReceived(QString, QObject*)), SLOT(slotParseMessage(QString, QObject*)));
// Create the account info manager to ensure it's listening to the
// account manager.
@ -343,15 +343,16 @@ void Application::slotUseMonoIconsChanged(bool)
_gui->slotComputeOverallSyncStatus();
}
void Application::slotParseOptions(const QString &opts, QObject*)
void Application::slotParseMessage(const QString &msg, QObject*)
{
QStringList options = opts.split(QLatin1Char('|'));
parseOptions(options);
setupLogging();
//This function is calld happens when someone tries to run another instance of ownCloud
// show the settings dialog
showSettingsDialog();
if (msg.startsWith(QLatin1String("MSG_PARSEOPTIONS:"))) {
const int lengthOfMsgPrefix = 17;
QStringList options = msg.mid(lengthOfMsgPrefix).split(QLatin1Char('|'));
parseOptions(options);
setupLogging();
} else if (msg.startsWith(QLatin1String("MSG_SHOWSETTINGS"))) {
showSettingsDialog();
}
}
void Application::parseOptions(const QStringList &options)

View file

@ -73,7 +73,7 @@ signals:
void folderStateChanged(Folder*);
protected slots:
void slotParseOptions( const QString&, QObject* );
void slotParseMessage(const QString&, QObject*);
void slotCheckConnection();
void slotUpdateConnectionErrors(int accountState);
void slotStartUpdateDetector();

View file

@ -96,14 +96,16 @@ int main(int argc, char **argv)
}
// if the application is already running, notify it.
if( app.isRunning() ) {
if(app.isRunning()) {
qDebug() << Q_FUNC_INFO << "Already running, exiting...";
QStringList args = app.arguments();
if ( args.size() > 1 && ! app.giveHelp() ) {
QString msg = args.join( QLatin1String("|") );
if( ! app.sendMessage( msg ) )
if (args.size() > 1) {
QString msg = args.join(QLatin1String("|"));
if(!app.sendMessage(QLatin1String("MSG_PARSEOPTIONS:") + msg))
return -1;
}
if(!app.sendMessage(QLatin1String("MSG_SHOWSETTINGS")))
return -1;
return 0;
} else {
if (!QSystemTrayIcon::isSystemTrayAvailable()) {