intialstart: Correctly init command line parser

Link the QCommandLine parse to the KAboutData to show the license and authorship
info.
This commit is contained in:
Carl Schwan 2024-01-17 16:40:37 +01:00 committed by Devin Lin
parent d161292426
commit fc6b83d50f

View file

@ -15,12 +15,10 @@
#include "version.h"
#include "wizard.h"
QCommandLineParser *createParser()
std::unique_ptr<QCommandLineParser> createParser()
{
QCommandLineParser *parser = new QCommandLineParser;
auto parser = std::make_unique<QCommandLineParser>();
parser->addOption(QCommandLineOption(QStringLiteral("test-wizard"), i18n("Opens the initial start wizard without modifying configuration")));
parser->addVersionOption();
parser->addHelpOption();
return parser;
}
@ -28,20 +26,6 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// parse command
QScopedPointer<QCommandLineParser> parser{createParser()};
parser->process(app);
bool testWizard = parser->isSet(QStringLiteral("test-wizard"));
if (!testWizard) {
// if the wizard has already been run, or we aren't in plasma mobile
if (!Settings::self()->shouldStartWizard()) {
qDebug() << "Wizard will not be started since either it has already been run, or the current session is not Plasma Mobile.";
return 0;
}
}
// start wizard
KLocalizedString::setApplicationDomain("plasma_org.kde.plasma.mobileinitialstart");
KAboutData aboutData(QStringLiteral("plasma-mobile-initial-start"),
@ -53,6 +37,21 @@ int main(int argc, char *argv[])
aboutData.addAuthor(i18n("Devin Lin"), QString(), QStringLiteral("devin@kde.org"));
KAboutData::setApplicationData(aboutData);
// parse command
auto parser = createParser();
aboutData.setupCommandLine(parser.get());
parser->process(app);
aboutData.processCommandLine(parser.get());
const bool testWizard = parser->isSet(QStringLiteral("test-wizard"));
if (!testWizard) {
// if the wizard has already been run, or we aren't in plasma mobile
if (!Settings::self()->shouldStartWizard()) {
qDebug() << "Wizard will not be started since either it has already been run, or the current session is not Plasma Mobile.";
return 0;
}
}
QQmlApplicationEngine engine;
engine.rootContext()->setContextObject(new KLocalizedContext{&engine});