1 /*
2 SPDX-FileCopyrightText: 2013-2021 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "sieveeditor-version.h"
8 #include "sieveeditormainwindow.h"
9 #include <KAboutData>
10 #include <KCrash>
11 #include <KDBusService>
12 #include <KLocalizedString>
13 #include <kcoreaddons_version.h>
14 #if KCOREADDONS_VERSION < QT_VERSION_CHECK(6, 0, 0)
15 #include <Kdelibs4ConfigMigrator>
16 #endif
17 #include <QApplication>
18 #include <QCommandLineParser>
19 #include <QTextStream>
20 #ifdef WITH_KUSERFEEDBACK
21 #include "userfeedback/userfeedbackmanager.h"
22 #include <KUserFeedback/FeedbackConfigWidget>
23 #include <KUserFeedback/Provider>
24 #endif
25
main(int argc,char ** argv)26 int main(int argc, char **argv)
27 {
28 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
29 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
30 QApplication app(argc, argv);
31 app.setDesktopFileName(QStringLiteral("org.kde.sieveeditor"));
32 KCrash::initialize();
33
34 #if KCOREADDONS_VERSION < QT_VERSION_CHECK(6, 0, 0)
35 Kdelibs4ConfigMigrator migrate(QStringLiteral("sieveeditor"));
36 migrate.setConfigFiles(QStringList() << QStringLiteral("sieveeditorrc") << QStringLiteral("sievetemplaterc"));
37 migrate.setUiFiles(QStringList() << QStringLiteral("sieveeditorui.rc"));
38 migrate.migrate();
39 #endif
40 KLocalizedString::setApplicationDomain("sieveeditor");
41
42 KAboutData aboutData(QStringLiteral("sieveeditor"),
43 i18n("KSieve Editor"),
44 QStringLiteral(SIEVEEDITOR_VERSION),
45 i18n("Sieve Editor"),
46 KAboutLicense::GPL_V2,
47 i18n("Copyright © 2013-2021 sieveeditor authors"));
48 aboutData.addAuthor(i18n("Laurent Montel"), i18n("Maintainer"), QStringLiteral("montel@kde.org"));
49
50 QApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail")));
51 KAboutData::setApplicationData(aboutData);
52
53 QCommandLineParser parser;
54 aboutData.setupCommandLine(&parser);
55 #ifdef WITH_KUSERFEEDBACK
56 parser.addOption(QCommandLineOption(QStringLiteral("feedback"), i18n("Lists the available options for user feedback")));
57 #endif
58 parser.process(app);
59 aboutData.processCommandLine(&parser);
60
61 #ifdef WITH_KUSERFEEDBACK
62 if (parser.isSet(QStringLiteral("feedback"))) {
63 QTextStream(stdout) << UserFeedBackManager::self()->userFeedbackProvider()->describeDataSources() << '\n';
64 return 0;
65 }
66 #endif
67
68 KDBusService service(KDBusService::Unique);
69
70 auto mw = new SieveEditorMainWindow();
71 mw->show();
72 const int val = app.exec();
73 return val;
74 }
75