Changeset View
Changeset View
Standalone View
Standalone View
app/main.cpp
Show All 20 Lines | |||||
21 | * Boston, MA 02110-1301, USA. | 21 | * Boston, MA 02110-1301, USA. | ||
22 | */ | 22 | */ | ||
23 | 23 | | |||
24 | #include <QCommandLineParser> | 24 | #include <QCommandLineParser> | ||
25 | #include <KAboutData> | 25 | #include <KAboutData> | ||
26 | #include <KCrash> | 26 | #include <KCrash> | ||
27 | 27 | | |||
28 | #include <kworkspace.h> | 28 | #include <kworkspace.h> | ||
29 | #include <kdbusservice.h> | ||||
29 | #include <KQuickAddons/QtQuickSettings> | 30 | #include <KQuickAddons/QtQuickSettings> | ||
30 | 31 | | |||
31 | #include "SystemSettingsApp.h" | 32 | #include "SystemSettingsApp.h" | ||
32 | #include "SettingsBase.h" | 33 | #include "SettingsBase.h" | ||
33 | 34 | | |||
34 | int main( int argc, char *argv[] ) | 35 | int main( int argc, char *argv[] ) | ||
35 | { | 36 | { | ||
37 | // Make sure the binary name is either kinfocenter or systemsettings, | ||||
38 | // Anything else will just be considered as "systemsettings" | ||||
39 | QString binaryName = QString::fromUtf8(argv[0]); | ||||
40 | BaseMode::ApplicationMode mode = BaseMode::InfoCenter; | ||||
41 | if (binaryName != QStringLiteral("kinfocenter")) { | ||||
42 | binaryName = QStringLiteral("systemsettings"); | ||||
43 | mode = BaseMode::SystemSettings; | ||||
44 | } | ||||
45 | | ||||
36 | //exec is systemsettings5, but we need the QPT to use the right config from the qApp constructor | 46 | //exec is systemsettings5, but we need the QPT to use the right config from the qApp constructor | ||
37 | //which is before KAboutData::setApplicationData | 47 | //which is before KAboutData::setApplicationData | ||
38 | QCoreApplication::setApplicationName(QStringLiteral("systemsettings")); | 48 | QCoreApplication::setApplicationName(binaryName); | ||
39 | 49 | | |||
40 | KWorkSpace::detectPlatform(argc, argv); | 50 | KWorkSpace::detectPlatform(argc, argv); | ||
41 | SystemSettingsApp application(argc, argv); | 51 | SystemSettingsApp application(argc, argv); | ||
42 | KQuickAddons::QtQuickSettings::init(); | 52 | KQuickAddons::QtQuickSettings::init(); | ||
43 | KCrash::initialize(); | 53 | KCrash::initialize(); | ||
44 | 54 | | |||
45 | KLocalizedString::setApplicationDomain("systemsettings"); | 55 | KLocalizedString::setApplicationDomain(binaryName.toUtf8().constData()); | ||
46 | 56 | | |||
57 | KAboutData aboutData; | ||||
58 | | ||||
59 | if (mode == BaseMode::InfoCenter) { | ||||
47 | // About data | 60 | // About data | ||
48 | KAboutData aboutData(QStringLiteral("systemsettings"), i18n("System Settings"), QLatin1String(PROJECT_VERSION), i18n("Central configuration center by KDE."), KAboutLicense::GPL, i18n("(c) 2009, Ben Cooksley")); | 61 | aboutData = KAboutData(QStringLiteral("kinfocenter"), i18n("Info Center"), QLatin1String(PROJECT_VERSION), i18n("Centralized and convenient overview of system information."), KAboutLicense::GPL, i18n("(c) 2009, Ben Cooksley")); | ||
49 | aboutData.addAuthor(i18n("Ben Cooksley"), i18n("Maintainer"), QStringLiteral("bcooksley@kde.org")); | 62 | aboutData.addAuthor(i18n("Ben Cooksley"), i18n("Maintainer"), QStringLiteral("bcooksley@kde.org")); | ||
50 | aboutData.addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); | 63 | aboutData.addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); | ||
51 | aboutData.addAuthor(i18n("Will Stephenson"), i18n("Internal module representation, internal module model"), QStringLiteral("wstephenson@kde.org")); | 64 | aboutData.addAuthor(i18n("Will Stephenson"), i18n("Internal module representation, internal module model"), QStringLiteral("wstephenson@kde.org")); | ||
52 | 65 | | |||
53 | if (qEnvironmentVariableIsSet("KDE_FULL_SESSION")) { | | |||
54 | aboutData.setDesktopFileName(QStringLiteral("systemsettings")); | | |||
55 | } else { | 66 | } else { | ||
56 | aboutData.setDesktopFileName(QStringLiteral("kdesystemsettings")); | 67 | aboutData = KAboutData(QStringLiteral("systemsettings"), i18n("System Settings"), QLatin1String(PROJECT_VERSION), i18n("Central configuration center by KDE."), KAboutLicense::GPL, i18n("(c) 2009, Ben Cooksley")); | ||
68 | aboutData.addAuthor(i18n("Ben Cooksley"), i18n("Maintainer"), QStringLiteral("bcooksley@kde.org")); | ||||
ovichiro: The authors should maybe be moved outside if-else since they are the same for both branches. | |||||
69 | aboutData.addAuthor(i18n("Mathias Soeken"), i18n("Developer"), QStringLiteral("msoeken@informatik.uni-bremen.de")); | ||||
70 | aboutData.addAuthor(i18n("Will Stephenson"), i18n("Internal module representation, internal module model"), QStringLiteral("wstephenson@kde.org")); | ||||
57 | } | 71 | } | ||
58 | 72 | | |||
59 | KAboutData::setApplicationData(aboutData); | | |||
60 | | ||||
61 | application.setAttribute(Qt::AA_UseHighDpiPixmaps, true); | 73 | application.setAttribute(Qt::AA_UseHighDpiPixmaps, true); | ||
62 | application.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system"))); | 74 | | ||
63 | QCommandLineParser parser; | 75 | QCommandLineParser parser; | ||
76 | | ||||
As an alternative, we could switch based on our binary name, from arg[0] and then install a symlink. davidedmundson: As an alternative, we could switch based on our binary name, from arg[0] and then install a… | |||||
64 | aboutData.setupCommandLine(&parser); | 77 | aboutData.setupCommandLine(&parser); | ||
65 | parser.process(application); | 78 | parser.process(application); | ||
66 | aboutData.processCommandLine(&parser); | 79 | aboutData.processCommandLine(&parser); | ||
67 | 80 | | |||
68 | SettingsBase *mainWindow = new SettingsBase(); | 81 | if (mode == BaseMode::InfoCenter) { | ||
82 | aboutData.setDesktopFileName(QStringLiteral("org.kde.kinfocenter")); | ||||
83 | application.setWindowIcon(QIcon::fromTheme(QStringLiteral("hwinfo"))); | ||||
broulik: Can we not just create a different `KAboutData` instance? | |||||
84 | | ||||
85 | } else { | ||||
86 | application.setWindowIcon(QIcon::fromTheme(QStringLiteral("preferences-system"))); | ||||
87 | | ||||
88 | if (qEnvironmentVariableIsSet("KDE_FULL_SESSION")) { | ||||
broulik: `i18n` | |||||
89 | aboutData.setDesktopFileName(QStringLiteral("systemsettings")); | ||||
90 | } else { | ||||
91 | aboutData.setDesktopFileName(QStringLiteral("kdesystemsettings")); | ||||
92 | } | ||||
93 | } | ||||
94 | | ||||
95 | KAboutData::setApplicationData(aboutData); | ||||
96 | | ||||
97 | | ||||
98 | SettingsBase *mainWindow = new SettingsBase(mode); | ||||
meven: You can use mode here | |||||
69 | mainWindow->show(); | 99 | mainWindow->show(); | ||
70 | application.setMainWindow(mainWindow); | 100 | application.setMainWindow(mainWindow); | ||
71 | return application.exec(); | 101 | return application.exec(); | ||
72 | } | 102 | } |
The authors should maybe be moved outside if-else since they are the same for both branches.