Changeset View
Changeset View
Standalone View
Standalone View
kcms/ksplash/kcm.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 48 | { | |||
---|---|---|---|---|---|
52 | about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); | 52 | about->addAuthor(i18n("Marco Martin"), QString(), QStringLiteral("mart@kde.org")); | ||
53 | setAboutData(about); | 53 | setAboutData(about); | ||
54 | setButtons(Help | Apply | Default); | 54 | setButtons(Help | Apply | Default); | ||
55 | 55 | | |||
56 | m_model = new QStandardItemModel(this); | 56 | m_model = new QStandardItemModel(this); | ||
57 | QHash<int, QByteArray> roles = m_model->roleNames(); | 57 | QHash<int, QByteArray> roles = m_model->roleNames(); | ||
58 | roles[PluginNameRole] = "pluginName"; | 58 | roles[PluginNameRole] = "pluginName"; | ||
59 | roles[ScreenhotRole] = "screenshot"; | 59 | roles[ScreenhotRole] = "screenshot"; | ||
60 | roles[DescriptionRole] = "description"; | ||||
60 | m_model->setItemRoleNames(roles); | 61 | m_model->setItemRoleNames(roles); | ||
62 | loadModel(); | ||||
61 | } | 63 | } | ||
62 | 64 | | |||
63 | QList<Plasma::Package> KCMSplashScreen::availablePackages(const QString &component) | 65 | QList<Plasma::Package> KCMSplashScreen::availablePackages(const QString &component) | ||
64 | { | 66 | { | ||
65 | QList<Plasma::Package> packages; | 67 | QList<Plasma::Package> packages; | ||
66 | QStringList paths; | 68 | QStringList paths; | ||
67 | const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); | 69 | const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); | ||
68 | 70 | | |||
Show All 30 Lines | 100 | if (m_selectedPlugin == plugin) { | |||
99 | return; | 101 | return; | ||
100 | } | 102 | } | ||
101 | 103 | | |||
102 | if (!m_selectedPlugin.isEmpty()) { | 104 | if (!m_selectedPlugin.isEmpty()) { | ||
103 | setNeedsSave(true); | 105 | setNeedsSave(true); | ||
104 | } | 106 | } | ||
105 | m_selectedPlugin = plugin; | 107 | m_selectedPlugin = plugin; | ||
106 | emit selectedPluginChanged(); | 108 | emit selectedPluginChanged(); | ||
109 | emit selectedPluginIndexChanged(); | ||||
107 | } | 110 | } | ||
108 | 111 | | |||
109 | void KCMSplashScreen::getNewClicked() | 112 | void KCMSplashScreen::getNewClicked() | ||
110 | { | 113 | { | ||
111 | KNS3::DownloadDialog dialog("ksplash.knsrc", 0); | 114 | KNS3::DownloadDialog dialog("ksplash.knsrc", 0); | ||
112 | if (dialog.exec()) { | 115 | if (dialog.exec()) { | ||
113 | KNS3::Entry::List list = dialog.changedEntries(); | 116 | KNS3::Entry::List list = dialog.changedEntries(); | ||
114 | if (list.count() > 0) { | 117 | if (list.count() > 0) { | ||
115 | load(); | 118 | loadModel(); | ||
116 | } | 119 | } | ||
117 | } | 120 | } | ||
118 | } | 121 | } | ||
119 | 122 | | |||
123 | void KCMSplashScreen::loadModel() | ||||
124 | { | ||||
125 | m_model->clear(); | ||||
126 | | ||||
127 | QStandardItem* row = new QStandardItem(i18n("None")); | ||||
128 | row->setData("None", PluginNameRole); | ||||
129 | row->setData(i18n("No splash screen will be shown"), DescriptionRole); | ||||
130 | m_model->appendRow(row); | ||||
131 | | ||||
132 | const QList<Plasma::Package> pkgs = availablePackages(QStringLiteral("splashmainscript")); | ||||
133 | for (const Plasma::Package &pkg : pkgs) { | ||||
134 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | ||||
135 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | ||||
136 | row->setData(pkg.filePath("previews", QStringLiteral("splash.png")), ScreenhotRole); | ||||
137 | row->setData(pkg.metadata().comment(), DescriptionRole); | ||||
138 | m_model->appendRow(row); | ||||
139 | } | ||||
140 | emit selectedPluginIndexChanged(); | ||||
141 | } | ||||
142 | | ||||
120 | void KCMSplashScreen::load() | 143 | void KCMSplashScreen::load() | ||
121 | { | 144 | { | ||
122 | m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | 145 | m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | ||
123 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | 146 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | ||
124 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | 147 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | ||
125 | if (!packageName.isEmpty()) { | 148 | if (!packageName.isEmpty()) { | ||
126 | m_package.setPath(packageName); | 149 | m_package.setPath(packageName); | ||
127 | } | 150 | } | ||
128 | 151 | | |||
129 | QString currentPlugin = m_configGroup.readEntry("Theme", QString()); | 152 | QString currentPlugin = m_configGroup.readEntry("Theme", QString()); | ||
130 | if (currentPlugin.isEmpty()) { | 153 | if (currentPlugin.isEmpty()) { | ||
131 | currentPlugin = m_package.metadata().pluginName(); | 154 | currentPlugin = m_package.metadata().pluginName(); | ||
132 | } | 155 | } | ||
133 | setSelectedPlugin(currentPlugin); | 156 | setSelectedPlugin(currentPlugin); | ||
134 | 157 | | |||
135 | m_model->clear(); | | |||
136 | | ||||
137 | QStandardItem* row = new QStandardItem(i18n("None")); | | |||
138 | row->setData("None", PluginNameRole); | | |||
139 | m_model->appendRow(row); | | |||
140 | | ||||
141 | const QList<Plasma::Package> pkgs = availablePackages(QStringLiteral("splashmainscript")); | | |||
142 | for (const Plasma::Package &pkg : pkgs) { | | |||
143 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | | |||
144 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | | |||
145 | row->setData(pkg.filePath("previews", QStringLiteral("splash.png")), ScreenhotRole); | | |||
146 | m_model->appendRow(row); | | |||
147 | } | | |||
148 | setNeedsSave(false); | 158 | setNeedsSave(false); | ||
149 | } | 159 | } | ||
150 | 160 | | |||
151 | 161 | | |||
152 | void KCMSplashScreen::save() | 162 | void KCMSplashScreen::save() | ||
153 | { | 163 | { | ||
154 | if (m_selectedPlugin.isEmpty()) { | 164 | if (m_selectedPlugin.isEmpty()) { | ||
155 | return; | 165 | return; | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |