Changeset View
Changeset View
Standalone View
Standalone View
kcms/lookandfeel/lnftool.cpp
Show All 33 Lines | |||||
34 | 34 | | |||
35 | int main(int argc, char **argv) | 35 | int main(int argc, char **argv) | ||
36 | { | 36 | { | ||
37 | QApplication app(argc, argv); | 37 | QApplication app(argc, argv); | ||
38 | 38 | | |||
39 | const char version[] = "1.0"; | 39 | const char version[] = "1.0"; | ||
40 | 40 | | |||
41 | // About data | 41 | // About data | ||
42 | KAboutData aboutData("lookandfeeltool", i18n("Look and feel tool"), version, i18n("Command line tool to apply look and feel packages."), KAboutLicense::GPL, i18n("Copyright 2017, Marco Martin")); | 42 | KAboutData aboutData("lookandfeeltool", i18n("Global Theme Tool"), version, i18n("Command line tool to apply global theme packages for changing the look and feel."), KAboutLicense::GPL, i18n("Copyright 2017, Marco Martin")); | ||
GB_2: Uppercase T in "tool" while at it :-) | |||||
43 | aboutData.addAuthor(i18n("Marco Martin"), i18n("Maintainer"), QStringLiteral("mart@kde.org")); | 43 | aboutData.addAuthor(i18n("Marco Martin"), i18n("Maintainer"), QStringLiteral("mart@kde.org")); | ||
44 | aboutData.setDesktopFileName("org.kde.lookandfeeltool"); | 44 | aboutData.setDesktopFileName("org.kde.lookandfeeltool"); | ||
45 | KAboutData::setApplicationData(aboutData); | 45 | KAboutData::setApplicationData(aboutData); | ||
46 | 46 | | |||
47 | const static auto _l = QStringLiteral("list"); | 47 | const static auto _l = QStringLiteral("list"); | ||
48 | const static auto _a = QStringLiteral("apply"); | 48 | const static auto _a = QStringLiteral("apply"); | ||
49 | const static auto _r = QStringLiteral("resetLayout"); | 49 | const static auto _r = QStringLiteral("resetLayout"); | ||
50 | 50 | | |||
51 | QCommandLineOption _list = QCommandLineOption(QStringList() << QStringLiteral("l") << _l, | 51 | QCommandLineOption _list = QCommandLineOption(QStringList() << QStringLiteral("l") << _l, | ||
52 | i18n("List available Look and feel packages")); | 52 | i18n("List available global theme packages")); | ||
53 | QCommandLineOption _apply = QCommandLineOption(QStringList() << QStringLiteral("a") << _a, | 53 | QCommandLineOption _apply = QCommandLineOption(QStringList() << QStringLiteral("a") << _a, | ||
54 | i18n("Apply a look and feel package"), i18n("packagename")); | 54 | i18n("Apply a global theme package"), i18n("packagename")); | ||
55 | QCommandLineOption _resetLayout = QCommandLineOption(QStringList() << | 55 | QCommandLineOption _resetLayout = QCommandLineOption(QStringList() << | ||
56 | _r, i18n("Reset the Plasma Desktop layout")); | 56 | _r, i18n("Reset the Plasma Desktop layout")); | ||
57 | 57 | | |||
58 | QCommandLineParser parser; | 58 | QCommandLineParser parser; | ||
59 | parser.addOption(_list); | 59 | parser.addOption(_list); | ||
60 | parser.addOption(_apply); | 60 | parser.addOption(_apply); | ||
61 | parser.addOption(_resetLayout); | 61 | parser.addOption(_resetLayout); | ||
62 | aboutData.setupCommandLine(&parser); | 62 | aboutData.setupCommandLine(&parser); | ||
Show All 13 Lines | 71 | if (parser.isSet(_list)) { | |||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | } else if (parser.isSet(_apply)) { | 78 | } else if (parser.isSet(_apply)) { | ||
79 | KPackage::Package p = KPackage::PackageLoader::self()->loadPackage("Plasma/LookAndFeel"); | 79 | KPackage::Package p = KPackage::PackageLoader::self()->loadPackage("Plasma/LookAndFeel"); | ||
80 | p.setPath(parser.value(_apply)); | 80 | p.setPath(parser.value(_apply)); | ||
81 | 81 | | |||
82 | //can't use package.isValid as lnf packages always fallback, even when not existing | 82 | //can't use package.isValid as lnf packages always fallback, even when not existing | ||
83 | if (p.metadata().pluginId() != parser.value(_apply)) { | 83 | if (p.metadata().pluginId() != parser.value(_apply)) { | ||
84 | std::cout << "Unable to find the look and feel package named " << parser.value(_apply).toStdString() << std::endl; | 84 | std::cout << "Unable to find the theme named " << parser.value(_apply).toStdString() << std::endl; | ||
85 | return 1; | 85 | return 1; | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | KCMLookandFeel *kcm = new KCMLookandFeel(nullptr, QVariantList()); | 88 | KCMLookandFeel *kcm = new KCMLookandFeel(nullptr, QVariantList()); | ||
89 | kcm->load(); | 89 | kcm->load(); | ||
90 | kcm->setResetDefaultLayout(parser.isSet(_resetLayout)); | 90 | kcm->setResetDefaultLayout(parser.isSet(_resetLayout)); | ||
91 | kcm->setSelectedPlugin(parser.value(_apply)); | 91 | kcm->setSelectedPlugin(parser.value(_apply)); | ||
92 | kcm->save(); | 92 | kcm->save(); | ||
93 | delete kcm; | 93 | delete kcm; | ||
94 | } | 94 | } | ||
95 | 95 | | |||
96 | return 0; | 96 | return 0; | ||
97 | } | 97 | } | ||
98 | 98 | |
Uppercase T in "tool" while at it :-)