From kde-commits Sat Oct 29 17:23:35 2016 From: Peter Simonsson Date: Sat, 29 Oct 2016 17:23:35 +0000 To: kde-commits Subject: [konversation] src: Reenable --restart option Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147776182518176 Git commit 285beecc4a0e3f98160e20b6a1e5eee272d5cfb5 by Peter Simonsson. Committed on 29/10/2016 at 17:23. Pushed by psn into branch 'master'. Reenable --restart option BUG: 341404 M +15 -20 src/application.cpp M +1 -0 src/application.h M +1 -1 src/main.cpp http://commits.kde.org/konversation/285beecc4a0e3f98160e20b6a1e5eee272d5cfb5 diff --git a/src/application.cpp b/src/application.cpp index afe1339..0d27314 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -107,30 +107,23 @@ Application::~Application() = void Application::implementRestart() { -#if 0 // FIXME KF5 Port: --restart - QStringList argumentList; - - KCmdLineArgs* args =3D KCmdLineArgs::parsedArgs(); - - argumentList =3D args->allArguments(); - // Pop off the executable name. May not be the first argument in argv // everywhere, so verify first. - if (QFileInfo(argumentList.first()) =3D=3D QFileInfo(QCoreApplication:= :applicationFilePath())) - argumentList.removeFirst(); + if (QFileInfo(m_restartArguments.first()) =3D=3D QFileInfo(QCoreApplic= ation::applicationFilePath())) + m_restartArguments.removeFirst(); = // Don't round-trip --restart. - argumentList.removeAll(QStringLiteral("--restart")); + m_restartArguments.removeAll(QStringLiteral("--restart")); = // Avoid accumulating multiple --startupdelay arguments across multiple // uses of restart(). - if (argumentList.contains(QStringLiteral("--startupdelay"))) + if (m_restartArguments.contains(QStringLiteral("--startupdelay"))) { - int index =3D argumentList.lastIndexOf(QStringLiteral("--startupde= lay")); + int index =3D m_restartArguments.lastIndexOf(QStringLiteral("--sta= rtupdelay")); = - if (index < argumentList.count() - 1 && !argumentList.at(index + 1= ).startsWith(QLatin1Char('-'))) + if (index < m_restartArguments.count() - 1 && !m_restartArguments.= at(index + 1).startsWith(QLatin1Char('-'))) { - QString delayArgument =3D argumentList.at(index + 1); + QString delayArgument =3D m_restartArguments.at(index + 1); = bool ok; = @@ -138,14 +131,13 @@ void Application::implementRestart() = // If the argument is invalid or too low, raise to at least 20= 00 msecs. if (!ok || delay < 2000) - argumentList.replace(index + 1, QStringLiteral("2000")); + m_restartArguments.replace(index + 1, QStringLiteral("2000= ")); } } else - argumentList << QStringLiteral("--startupdelay") << QStringLiteral= ("2000"); + m_restartArguments << QStringLiteral("--startupdelay") << QStringL= iteral("2000"); = - KProcess::startDetached(QCoreApplication::applicationFilePath(), argum= entList); -#endif + KProcess::startDetached(QCoreApplication::applicationFilePath(), m_res= tartArguments); } = void Application::newInstance(QCommandLineParser *args) @@ -281,14 +273,12 @@ void Application::newInstance(QCommandLineParser *arg= s) = connect(this, &Application::appearanceChanged, this, &Application:= :updateProxySettings); } -#if 0 //FIXME KF5 Port: --restart else if (args->isSet(QStringLiteral("restart"))) { restart(); = return; } -#endif = if (!url.isEmpty()) getConnectionManager()->connectTo(Konversation::SilentlyReuseConne= ction, url); @@ -1397,6 +1387,11 @@ void Application::handleActivate(const QStringList& = arguments) { m_commandLineParser->parse(arguments); = + if(m_commandLineParser->isSet(QStringLiteral("restart"))) + { + m_restartArguments =3D arguments; + } + newInstance(m_commandLineParser); = KStartupInfo::setNewStartupId(mainWindow, KStartupInfo::startupId()); diff --git a/src/application.h b/src/application.h index e87f98d..6b7bcb1 100644 --- a/src/application.h +++ b/src/application.h @@ -199,6 +199,7 @@ class Application : public QApplication QNetworkConfigurationManager* m_networkConfigurationManager; = QCommandLineParser *m_commandLineParser; + QStringList m_restartArguments; }; = #endif diff --git a/src/main.cpp b/src/main.cpp index 23ef640..58320d4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -121,7 +121,7 @@ int main(int argc, char* argv[]) cmdLineParser.addOption(QCommandLineOption(QStringLiteral("ssl"), i18n= ("Use SSL for connection"))); cmdLineParser.addOption(QCommandLineOption(QStringLiteral("noautoconne= ct"), i18n("Disable auto-connecting to any IRC networks"))); cmdLineParser.addOption(QCommandLineOption(QStringLiteral("startupdela= y"), i18n("Delay D-Bus activity and UI creation by the specified amount of = milliseconds"), i18n("msec"), "2000")); - // cmdLineParser.addOption(QCommandLineOption(QStringLiteral("restart"= ), i18n("Quits and restarts Konversation (if running, otherwise has no effe= ct)"))); FIXME KF5 Port: --restart + cmdLineParser.addOption(QCommandLineOption(QStringLiteral("restart"), = i18n("Quits and restarts Konversation (if running, otherwise has no effect)= "))); #ifndef QT_NO_DEBUG cmdLineParser.addOption(QCommandLineOption(QStringLiteral("nui"), i18n= ("Sets KUniqueApplication::NonUniqueInstance (debug only, use with caution)= "))); #endif