Changeset View
Changeset View
Standalone View
Standalone View
kcms/ksplash/kcm.cpp
Show All 31 Lines | |||||
32 | #include <QMessageBox> | 32 | #include <QMessageBox> | ||
33 | #include <QStandardItemModel> | 33 | #include <QStandardItemModel> | ||
34 | #include <QQmlContext> | 34 | #include <QQmlContext> | ||
35 | #include <QDir> | 35 | #include <QDir> | ||
36 | 36 | | |||
37 | #include <KLocalizedString> | 37 | #include <KLocalizedString> | ||
38 | #include <Plasma/PluginLoader> | 38 | #include <Plasma/PluginLoader> | ||
39 | 39 | | |||
40 | #include <KNewStuff3/KNS3/DownloadDialog> | ||||
41 | | ||||
40 | K_PLUGIN_FACTORY_WITH_JSON(KCMSplashScreenFactory, "kcm_splashscreen.json", registerPlugin<KCMSplashScreen>();) | 42 | K_PLUGIN_FACTORY_WITH_JSON(KCMSplashScreenFactory, "kcm_splashscreen.json", registerPlugin<KCMSplashScreen>();) | ||
41 | 43 | | |||
42 | KCMSplashScreen::KCMSplashScreen(QObject* parent, const QVariantList& args) | 44 | KCMSplashScreen::KCMSplashScreen(QObject* parent, const QVariantList& args) | ||
43 | : KQuickAddons::ConfigModule(parent, args) | 45 | : KQuickAddons::ConfigModule(parent, args) | ||
44 | , m_config(QStringLiteral("ksplashrc")) | 46 | , m_config(QStringLiteral("ksplashrc")) | ||
45 | , m_configGroup(m_config.group("KSplash")) | 47 | , m_configGroup(m_config.group("KSplash")) | ||
46 | { | 48 | { | ||
47 | qmlRegisterType<QStandardItemModel>(); | 49 | qmlRegisterType<QStandardItemModel>(); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 97 | { | |||
99 | 101 | | |||
100 | if (!m_selectedPlugin.isEmpty()) { | 102 | if (!m_selectedPlugin.isEmpty()) { | ||
101 | setNeedsSave(true); | 103 | setNeedsSave(true); | ||
102 | } | 104 | } | ||
103 | m_selectedPlugin = plugin; | 105 | m_selectedPlugin = plugin; | ||
104 | emit selectedPluginChanged(); | 106 | emit selectedPluginChanged(); | ||
105 | } | 107 | } | ||
106 | 108 | | |||
109 | void KCMSplashScreen::getNewClicked() | ||||
110 | { | ||||
111 | KNS3::DownloadDialog dialog("ksplash.knsrc", 0); | ||||
112 | if (dialog.exec()) { | ||||
113 | KNS3::Entry::List list = dialog.changedEntries(); | ||||
114 | if (list.count() > 0) { | ||||
115 | load(); | ||||
116 | } | ||||
117 | } | ||||
118 | } | ||||
119 | | ||||
107 | void KCMSplashScreen::load() | 120 | void KCMSplashScreen::load() | ||
108 | { | 121 | { | ||
109 | m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | 122 | m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | ||
110 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | 123 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | ||
111 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | 124 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | ||
112 | if (!packageName.isEmpty()) { | 125 | if (!packageName.isEmpty()) { | ||
113 | m_package.setPath(packageName); | 126 | m_package.setPath(packageName); | ||
114 | } | 127 | } | ||
115 | 128 | | |||
116 | QString currentPlugin = m_configGroup.readEntry("Theme", QString()); | 129 | QString currentPlugin = m_configGroup.readEntry("Theme", QString()); | ||
117 | if (currentPlugin.isEmpty()) { | 130 | if (currentPlugin.isEmpty()) { | ||
118 | currentPlugin = m_package.metadata().pluginName(); | 131 | currentPlugin = m_package.metadata().pluginName(); | ||
119 | } | 132 | } | ||
120 | setSelectedPlugin(currentPlugin); | 133 | setSelectedPlugin(currentPlugin); | ||
121 | 134 | | |||
122 | m_model->clear(); | 135 | m_model->clear(); | ||
123 | 136 | | |||
124 | QStandardItem* row = new QStandardItem(i18n("None")); | 137 | QStandardItem* row = new QStandardItem(i18n("None")); | ||
125 | row->setData("None", PluginNameRole); | 138 | row->setData("None", PluginNameRole); | ||
126 | m_model->appendRow(row); | 139 | m_model->appendRow(row); | ||
127 | 140 | | |||
128 | const QList<Plasma::Package> pkgs = availablePackages(QStringLiteral("splashmainscript")); | 141 | const QList<Plasma::Package> pkgs = availablePackages(QStringLiteral("splashmainscript")); | ||
davidedmundson: This is loading separate splash packages | |||||
availablepackages goes trough all the installed lnf packages and takes all those which actually do provide a splashscreen in it. mart: availablepackages goes trough all the installed lnf packages and takes all those which actually… | |||||
129 | for (const Plasma::Package &pkg : pkgs) { | 142 | for (const Plasma::Package &pkg : pkgs) { | ||
130 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | 143 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | ||
131 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | 144 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | ||
132 | row->setData(pkg.filePath("previews", QStringLiteral("splash.png")), ScreenhotRole); | 145 | row->setData(pkg.filePath("previews", QStringLiteral("splash.png")), ScreenhotRole); | ||
133 | m_model->appendRow(row); | 146 | m_model->appendRow(row); | ||
134 | } | 147 | } | ||
135 | setNeedsSave(false); | 148 | setNeedsSave(false); | ||
136 | } | 149 | } | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
This is loading separate splash packages