File indexing completed on 2024-04-28 09:40:58
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2010-2021 Harald Sitter <sitter@kde.org> 0003 0004 #include <QApplication> 0005 #include <QQmlApplicationEngine> 0006 #include <QCommandLineParser> 0007 #include <QUrl> 0008 #include <QQmlContext> 0009 #include <QIcon> 0010 0011 #include <KAboutData> 0012 #include <KLocalizedString> 0013 #include <KDeclarative/KDeclarative> 0014 #include <KLocalizedContext> 0015 0016 #include "Debug.h" 0017 #include "Logger.h" 0018 #include "Installer.h" 0019 #include "BuildConfig.h" 0020 #include "DebugRepoEnabler.h" 0021 0022 int main(int argc, char *argv[]) 0023 { 0024 Logger::instance()->install(); 0025 0026 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0027 QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 0028 0029 // Desktop style requires QApplication not QGuiApplication. 0030 QApplication app(argc, argv); 0031 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("tools-report-bug"))); 0032 app.setDesktopFileName(QStringLiteral("org.kde.drkonqi-pk-debug-installer")); 0033 0034 KAboutData aboutData(QStringLiteral("drkonqi-pk-debug-installer"), 0035 i18nc("@title", "Debug Symbols Helper"), 0036 QString::fromLatin1(VERSION), 0037 i18n("A debug package installer using PackageKit"), 0038 KAboutLicense::LicenseKey::GPL, 0039 i18n("(C) 2010-2020 Harald Sitter")); 0040 0041 aboutData.addAuthor(i18n("Harald Sitter"), 0042 QStringLiteral(), 0043 QStringLiteral("sitter@kde.org")); 0044 0045 QCommandLineParser parser; 0046 parser.addPositionalArgument(QStringLiteral("FILES"), 0047 i18nc("command line description", "Files to find debug packages for")); 0048 aboutData.setupCommandLine(&parser); 0049 parser.process(app); 0050 aboutData.processCommandLine(&parser); 0051 0052 auto files = parser.positionalArguments(); 0053 if (files.isEmpty()) { 0054 return 0; 0055 } 0056 qCDebug(INSTALLER) << "files:" << files; 0057 0058 PackageKit::Daemon::setHints(PackageKit::Daemon::hints() + QStringList{QStringLiteral("interactive=true")}); 0059 0060 DebugRepoEnabler repoEnabler; 0061 qmlRegisterSingletonInstance("org.kde.drkonqi.debug.installer.pk", 1, 0, "DebugRepoEnabler", &repoEnabler); 0062 Installer installer(files); 0063 qmlRegisterSingletonInstance("org.kde.drkonqi.debug.installer.pk", 1, 0, "Installer", &installer); 0064 qmlRegisterSingletonInstance("org.kde.drkonqi.debug.installer.pk", 1, 0, "Logger", Logger::instance()); 0065 0066 KLocalizedContext i18nContext; 0067 i18nContext.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN)); 0068 0069 QQmlApplicationEngine engine; 0070 engine.rootContext()->setContextObject(&i18nContext); 0071 0072 KDeclarative::KDeclarative::setupEngine(&engine); 0073 0074 const QUrl url(QStringLiteral("qrc:/main.qml")); 0075 QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 0076 &app, [url](QObject *obj, const QUrl &objUrl) { 0077 if (!obj && url == objUrl) { 0078 QCoreApplication::exit(-1); 0079 } 0080 }, Qt::QueuedConnection); 0081 engine.load(url); 0082 0083 return app.exec(); 0084 }