File indexing completed on 2024-05-12 09:32:20
0001 /* 0002 SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org> 0003 SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #include <QCommandLineParser> 0009 #include <QCoreApplication> 0010 0011 #include "daemon.h" 0012 0013 int main(int argc, char **argv) 0014 { 0015 QCoreApplication app(argc, argv); 0016 app.setQuitLockEnabled(false) ; 0017 app.setOrganizationDomain(QStringLiteral("kde.org")); 0018 0019 QCommandLineParser parser; 0020 parser.addOption(QCommandLineOption(QStringLiteral("replace"), QStringLiteral("Replace the running instance"))); 0021 parser.addOption({QStringLiteral("remain"), QStringLiteral("Do not quit when last client has disconnected")}); 0022 parser.addHelpOption(); 0023 parser.process(app); 0024 0025 Daemon d; 0026 if (!d.init(parser.isSet(QStringLiteral("replace")) ? Daemon::ReplaceIfRunning::Replace : Daemon::ReplaceIfRunning::DoNotReplace)) { 0027 return 1; 0028 } 0029 0030 d.setQuitOnLastClientDisconnect(!parser.isSet(QStringLiteral("remain"))); 0031 return app.exec(); 0032 }