Changeset View
Changeset View
Standalone View
Standalone View
kcms/ksplash/kcm.cpp
Show All 33 Lines | |||||
34 | 34 | | |||
35 | #include <KNewStuff3/KNS3/DownloadDialog> | 35 | #include <KNewStuff3/KNS3/DownloadDialog> | ||
36 | 36 | | |||
37 | #include "splashscreensettings.h" | 37 | #include "splashscreensettings.h" | ||
38 | 38 | | |||
39 | K_PLUGIN_FACTORY_WITH_JSON(KCMSplashScreenFactory, "kcm_splashscreen.json", registerPlugin<KCMSplashScreen>();) | 39 | K_PLUGIN_FACTORY_WITH_JSON(KCMSplashScreenFactory, "kcm_splashscreen.json", registerPlugin<KCMSplashScreen>();) | ||
40 | 40 | | |||
41 | KCMSplashScreen::KCMSplashScreen(QObject* parent, const QVariantList& args) | 41 | KCMSplashScreen::KCMSplashScreen(QObject* parent, const QVariantList& args) | ||
42 | : KQuickAddons::ConfigModule(parent, args) | 42 | : KQuickAddons::ManagedConfigModule(parent, args) | ||
43 | , m_settings(new SplashScreenSettings(this)) | 43 | , m_settings(new SplashScreenSettings(this)) | ||
44 | , m_model(new QStandardItemModel(this)) | 44 | , m_model(new QStandardItemModel(this)) | ||
45 | { | 45 | { | ||
46 | connect(m_settings, &SplashScreenSettings::engineChanged, this, [this]{ setNeedsSave(true); }); | | |||
47 | connect(m_settings, &SplashScreenSettings::themeChanged, this, [this]{ setNeedsSave(true); }); | | |||
48 | | ||||
49 | qmlRegisterType<SplashScreenSettings>(); | 46 | qmlRegisterType<SplashScreenSettings>(); | ||
50 | qmlRegisterType<QStandardItemModel>(); | 47 | qmlRegisterType<QStandardItemModel>(); | ||
51 | 48 | | |||
52 | KAboutData* about = new KAboutData(QStringLiteral("kcm_splashscreen"), i18n("Splash Screen"), | 49 | KAboutData* about = new KAboutData(QStringLiteral("kcm_splashscreen"), i18n("Splash Screen"), | ||
53 | QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); | 50 | QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); | ||
54 | about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); | 51 | about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); | ||
55 | setAboutData(about); | 52 | setAboutData(about); | ||
56 | setButtons(Help | Apply | Default); | 53 | setButtons(Help | Apply | Default); | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 108 | { | |||
128 | 125 | | |||
129 | if (-1 == pluginIndex(m_settings->theme())) { | 126 | if (-1 == pluginIndex(m_settings->theme())) { | ||
130 | defaults(); | 127 | defaults(); | ||
131 | } | 128 | } | ||
132 | 129 | | |||
133 | emit m_settings->themeChanged(); | 130 | emit m_settings->themeChanged(); | ||
134 | } | 131 | } | ||
135 | 132 | | |||
136 | void KCMSplashScreen::load() | | |||
137 | { | | |||
138 | m_settings->load(); | | |||
139 | setNeedsSave(false); | | |||
140 | } | | |||
141 | | ||||
142 | void KCMSplashScreen::save() | 133 | void KCMSplashScreen::save() | ||
143 | { | 134 | { | ||
144 | m_settings->setEngine(m_settings->theme() == QStringLiteral("None") ? QStringLiteral("none") : QStringLiteral("KSplashQML")); | 135 | m_settings->setEngine(m_settings->theme() == QStringLiteral("None") ? QStringLiteral("none") : QStringLiteral("KSplashQML")); | ||
145 | m_settings->save(); | 136 | ManagedConfigModule::save(); | ||
davidedmundson: doesn't managed module take care of this? | |||||
crossi: it needs an explicit call, like load() and save() | |||||
crossi: My bad. setNeedsSave() is no longer needed. | |||||
146 | } | | |||
147 | | ||||
148 | void KCMSplashScreen::defaults() | | |||
149 | { | | |||
150 | m_settings->setDefaults(); | | |||
151 | setNeedsSave(m_settings->isSaveNeeded()); | | |||
152 | } | 137 | } | ||
153 | 138 | | |||
154 | int KCMSplashScreen::pluginIndex(const QString &pluginName) const | 139 | int KCMSplashScreen::pluginIndex(const QString &pluginName) const | ||
155 | { | 140 | { | ||
156 | const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName); | 141 | const auto results = m_model->match(m_model->index(0, 0), PluginNameRole, pluginName); | ||
157 | if (results.count() == 1) { | 142 | if (results.count() == 1) { | ||
158 | return results.first().row(); | 143 | return results.first().row(); | ||
159 | } | 144 | } | ||
Show All 35 Lines |
doesn't managed module take care of this?