Warning, file /utilities/kdialog/src/kdialog_progress_helper.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // SPDX-FileCopyrightText: 2017 David Faure <faure@kde.org> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 #include <KDBusService> 0005 #include <QApplication> 0006 #include <QCommandLineOption> 0007 #include <QCommandLineParser> 0008 #include <KLocalizedString> 0009 #include "progressdialog.h" 0010 #include "utils.h" 0011 0012 #include <unistd.h> 0013 #include <sys/stat.h> 0014 #include <fcntl.h> 0015 0016 int main(int argc, char **argv) 0017 { 0018 QStringList rawArgs; 0019 rawArgs.reserve(argc); 0020 for (int i = 0; i < argc; ++i) { 0021 rawArgs << QString::fromLocal8Bit(argv[i]); 0022 } 0023 0024 // This code was given by Thiago as a solution for the issue that 0025 // otherwise bash waits for a SIGPIPE from kdialog that never comes in. 0026 int fd = open("/dev/null", O_RDWR); 0027 dup2(fd, STDIN_FILENO); 0028 dup2(fd, STDOUT_FILENO); 0029 dup2(fd, STDERR_FILENO); 0030 close(fd); 0031 0032 QApplication app(argc, argv); 0033 app.setApplicationName(QStringLiteral("kdialog")); 0034 app.setOrganizationDomain(QStringLiteral("kde.org")); 0035 KLocalizedString::setApplicationDomain(QByteArrayLiteral("kdialog")); 0036 0037 KDBusService dbusService(KDBusService::Multiple); 0038 0039 QCommandLineParser parser; 0040 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("progressbar"), i18n("Progress bar dialog, returns a D-Bus reference for communication"), QStringLiteral("text"))); 0041 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("title"), i18n("Dialog title"), QStringLiteral("text"))); 0042 parser.addPositionalArgument(QStringLiteral("[arg]"), i18n("Arguments - depending on main option")); 0043 parser.process(rawArgs); 0044 0045 const QStringList args = parser.positionalArguments(); 0046 0047 const QString text = Utils::parseString(parser.value(QStringLiteral("progressbar"))); 0048 const QString title = parser.value(QStringLiteral("title")); 0049 0050 int totalsteps = 100; 0051 if (args.count() == 1) { 0052 totalsteps = args.at(0).toInt(); 0053 } 0054 0055 ProgressDialog dlg(nullptr, title, text, totalsteps); 0056 return dlg.exec() ? 0 : 1; 0057 }