[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [konversation] src: Reenable --restart option
From:       Peter Simonsson <peter.simonsson () gmail ! com>
Date:       2016-10-29 17:23:35
Message-ID: E1c0XLz-00076v-Pb () code ! kde ! org
[Download RAW message or body]

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 = KCmdLineArgs::parsedArgs();
-
-    argumentList = args->allArguments();
-
     // Pop off the executable name. May not be the first argument in argv
     // everywhere, so verify first.
-    if (QFileInfo(argumentList.first()) == \
                QFileInfo(QCoreApplication::applicationFilePath()))
-        argumentList.removeFirst();
+    if (QFileInfo(m_restartArguments.first()) == \
QFileInfo(QCoreApplication::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 = argumentList.lastIndexOf(QStringLiteral("--startupdelay"));
+        int index = \
m_restartArguments.lastIndexOf(QStringLiteral("--startupdelay"));  
-        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 = argumentList.at(index + 1);
+            QString delayArgument = 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 2000 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") << \
QStringLiteral("2000");  
-    KProcess::startDetached(QCoreApplication::applicationFilePath(), argumentList);
-#endif
+    KProcess::startDetached(QCoreApplication::applicationFilePath(), \
m_restartArguments);  }
 
 void Application::newInstance(QCommandLineParser *args)
@@ -281,14 +273,12 @@ void Application::newInstance(QCommandLineParser *args)
 
         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::SilentlyReuseConnection, \
url); @@ -1397,6 +1387,11 @@ void Application::handleActivate(const QStringList& \
arguments)  {
     m_commandLineParser->parse(arguments);
 
+    if(m_commandLineParser->isSet(QStringLiteral("restart")))
+    {
+        m_restartArguments = 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("noautoconnect"), \
i18n("Disable auto-connecting to any IRC networks")));  \
cmdLineParser.addOption(QCommandLineOption(QStringLiteral("startupdelay"), \
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 effect)"))); \
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic