File indexing completed on 2022-11-23 12:38:57

0001 /*
0002     SPDX-FileCopyrightText: 2010-2018 Daniel Nicoletti <dantti12@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "PrintQueue.h"
0008 
0009 #include <config.h>
0010 
0011 #include <QCommandLineParser>
0012 #include <QCommandLineOption>
0013 
0014 #include <KLocalizedString>
0015 #include <KAboutData>
0016 #include <KDBusService>
0017 
0018 int main(int argc, char **argv)
0019 {
0020     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
0021     PrintQueue app(argc, argv);
0022     app.setOrganizationDomain(QLatin1String("org.kde"));
0023 
0024     KAboutData about(QLatin1String("PrintQueue"),
0025                      i18n("Print Queue"),
0026                      QLatin1String(PM_VERSION),
0027                      i18n("Print Queue"),
0028                      KAboutLicense::GPL,
0029                      i18n("(C) 2010-2018 Daniel Nicoletti"));
0030 
0031     about.addAuthor(QStringLiteral("Daniel Nicoletti"), QString(), QLatin1String("dantti12@gmail.com"));
0032     about.addAuthor(QStringLiteral("Lukáš Tinkl"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("ltinkl@redhat.com"));
0033 
0034     KAboutData::setApplicationData(about);
0035     KDBusService service(KDBusService::Unique);
0036 
0037     QCommandLineParser parser;
0038     about.setupCommandLine(&parser);
0039     parser.addPositionalArgument(QLatin1String("queue"), i18n("Show printer queue(s)"));
0040     parser.process(app);
0041     about.processCommandLine(&parser);
0042 
0043     QObject::connect(&service, &KDBusService::activateRequested, &app, [&app](const QStringList &arguments) {
0044         if (!arguments.isEmpty()) {
0045             app.showQueues(arguments.mid(1)); // strip off executable name
0046         }
0047     });
0048 
0049     app.showQueues(parser.positionalArguments());
0050 
0051     return app.exec();
0052 }