Commit f546973b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Add --replace option in krunner

Summary:
Useful for developing it.
Inspired in the plasmashell --replace option.

Test Plan: Replaced krunner

Reviewers: davidedmundson

Reviewed By: davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D20256
parent 4516ab53
......@@ -25,6 +25,8 @@
#include <QDebug>
#include <QQuickWindow>
#include <QSessionManager>
#include <QDBusMessage>
#include <QDBusConnection>
#include <KAuthorized>
#include <KAboutData>
......@@ -37,8 +39,6 @@
#include "view.h"
static QCommandLineParser parser;
int main(int argc, char **argv)
{
qunsetenv("QT_DEVICE_PIXEL_RATIO");
......@@ -68,10 +68,22 @@ int main(int argc, char **argv)
KAboutData::setApplicationData(aboutData);
app.setQuitOnLastWindowClosed(false);
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
{
QCommandLineParser parser;
QCommandLineOption replaceOption({QStringLiteral("replace")}, i18n("Replace an existing instance"));
parser.addOption(replaceOption);
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
if (parser.isSet(replaceOption)) {
auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.krunner"),
QStringLiteral("/MainApplication"),
QStringLiteral("org.qtproject.Qt.QCoreApplication"),
QStringLiteral("quit"));
QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits
}
}
if (!KAuthorized::authorize(QStringLiteral("run_command"))) {
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment