add --replace option to kdeconnectd
This commit is contained in:
parent
a28059315e
commit
e4d81ff97b
1 changed files with 20 additions and 0 deletions
|
@ -21,6 +21,11 @@
|
|||
#include <QApplication>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QTimer>
|
||||
#include <QLoggingCategory>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusConnection>
|
||||
|
||||
#include <KDBusService>
|
||||
#include <KNotification>
|
||||
|
@ -91,6 +96,21 @@ int main(int argc, char* argv[])
|
|||
app.setOrganizationDomain(QStringLiteral("kde.org"));
|
||||
app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
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.kdeconnectd"),
|
||||
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
|
||||
}
|
||||
|
||||
KDBusService dbusService(KDBusService::Unique);
|
||||
|
||||
Daemon* daemon = new DesktopDaemon;
|
||||
|
|
Loading…
Reference in a new issue