File indexing completed on 2025-01-05 05:09:31
0001 /* 0002 SPDX-FileCopyrightText: 2015 Jan Grulich <jgrulich@redhat.com> 0003 SPDX-FileCopyrightText: 2023 Mike Noe <noeerover@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "ProcessRunner.h" 0009 #include <KIO/CommandLauncherJob> 0010 0011 using namespace Qt::StringLiterals; 0012 0013 ProcessRunner::ProcessRunner(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void ProcessRunner::configurePrinter(const QString &printerName) 0019 { 0020 exec(u"configure-printer"_s, {printerName}, u"org.kde.ConfigurePrinter"_s); 0021 } 0022 0023 void ProcessRunner::openPrintQueue(const QString &printerName) 0024 { 0025 exec(u"kde-print-queue"_s, {printerName}, u"org.kde.PrintQueue"_s); 0026 } 0027 0028 void ProcessRunner::addPrinter() 0029 { 0030 exec(u"kde-add-printer"_s, {u"--add-printer"_s}, u"org.kde.kde-add-printer"_s); 0031 } 0032 0033 void ProcessRunner::addPrinterFromDevice(const QString &device) 0034 { 0035 exec(u"kde-add-printer"_s, {u"--new-printer-from-device"_s, device}, u"org.kde.kde-add-printer"_s); 0036 } 0037 0038 void ProcessRunner::addClass() 0039 { 0040 exec(u"kde-add-printer"_s, {u"--add-class"_s}, u"org.kde.kde-add-printer"_s); 0041 } 0042 0043 void ProcessRunner::changePrinterPPD(const QString &printerName) 0044 { 0045 exec(u"kde-add-printer"_s, {u"--change-ppd"_s, printerName}, u"org.kde.kde-add-printer"_s); 0046 } 0047 0048 void ProcessRunner::exec(const QString &cmd, const QStringList &args, const QString &desktopFile) 0049 { 0050 auto job = new KIO::CommandLauncherJob(cmd, args); 0051 if (!desktopFile.isEmpty()) { 0052 job->setDesktopName(desktopFile); 0053 } 0054 job->start(); 0055 } 0056 0057 #include "moc_ProcessRunner.cpp"