Changeset View
Changeset View
Standalone View
Standalone View
kcms/lookandfeel/kcm.cpp
Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 144 | { | |||
---|---|---|---|---|---|
145 | for (int i = 0; i < m_model->rowCount(); ++i) { | 145 | for (int i = 0; i < m_model->rowCount(); ++i) { | ||
146 | if (m_model->data(m_model->index(i, 0), PluginNameRole).toString() == m_selectedPlugin) { | 146 | if (m_model->data(m_model->index(i, 0), PluginNameRole).toString() == m_selectedPlugin) { | ||
147 | return i; | 147 | return i; | ||
148 | } | 148 | } | ||
149 | } | 149 | } | ||
150 | return -1; | 150 | return -1; | ||
151 | } | 151 | } | ||
152 | 152 | | |||
153 | QList<Plasma::Package> KCMLookandFeel::availablePackages(const QString &component) | 153 | QList<Plasma::Package> KCMLookandFeel::availablePackages(const QStringList &components) | ||
154 | { | 154 | { | ||
155 | QList<Plasma::Package> packages; | 155 | QList<Plasma::Package> packages; | ||
156 | QStringList paths; | 156 | QStringList paths; | ||
157 | const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); | 157 | const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); | ||
158 | 158 | | |||
159 | paths.reserve(dataPaths.count()); | 159 | paths.reserve(dataPaths.count()); | ||
160 | for (const QString &path : dataPaths) { | 160 | for (const QString &path : dataPaths) { | ||
161 | QDir dir(path + QStringLiteral("/plasma/look-and-feel")); | 161 | QDir dir(path + QStringLiteral("/plasma/look-and-feel")); | ||
162 | paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); | 162 | paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); | ||
163 | } | 163 | } | ||
164 | 164 | | |||
165 | for (const QString &path : paths) { | 165 | for (const QString &path : paths) { | ||
166 | Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | 166 | Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | ||
167 | pkg.setPath(path); | 167 | pkg.setPath(path); | ||
168 | pkg.setFallbackPackage(Plasma::Package()); | 168 | pkg.setFallbackPackage(Plasma::Package()); | ||
169 | if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { | 169 | if (components.isEmpty()) { | ||
170 | packages << pkg; | 170 | packages << pkg; | ||
171 | } else { | ||||
172 | for (const auto &component : components) { | ||||
173 | if (!pkg.filePath(component.toUtf8()).isEmpty()) { | ||||
174 | packages << pkg; | ||||
175 | break; | ||||
176 | } | ||||
177 | } | ||||
171 | } | 178 | } | ||
172 | } | 179 | } | ||
173 | 180 | | |||
174 | return packages; | 181 | return packages; | ||
175 | } | 182 | } | ||
176 | 183 | | |||
177 | void KCMLookandFeel::load() | 184 | void KCMLookandFeel::load() | ||
178 | { | 185 | { | ||
179 | m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | 186 | m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); | ||
180 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | 187 | KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); | ||
181 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | 188 | const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); | ||
182 | if (!packageName.isEmpty()) { | 189 | if (!packageName.isEmpty()) { | ||
183 | m_package.setPath(packageName); | 190 | m_package.setPath(packageName); | ||
184 | } | 191 | } | ||
185 | 192 | | |||
186 | if (!m_package.metadata().isValid()) { | 193 | if (!m_package.metadata().isValid()) { | ||
187 | return; | 194 | return; | ||
188 | } | 195 | } | ||
189 | 196 | | |||
190 | setSelectedPlugin(m_package.metadata().pluginName()); | 197 | setSelectedPlugin(m_package.metadata().pluginName()); | ||
191 | 198 | | |||
192 | m_model->clear(); | 199 | m_model->clear(); | ||
193 | 200 | | |||
194 | const QList<Plasma::Package> pkgs = availablePackages(); | 201 | const QList<Plasma::Package> pkgs = availablePackages({"defaults", "layouts"}); | ||
195 | for (const Plasma::Package &pkg : pkgs) { | 202 | for (const Plasma::Package &pkg : pkgs) { | ||
196 | if (!pkg.metadata().isValid()) { | 203 | if (!pkg.metadata().isValid()) { | ||
197 | continue; | 204 | continue; | ||
198 | } | 205 | } | ||
199 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | 206 | QStandardItem* row = new QStandardItem(pkg.metadata().name()); | ||
200 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | 207 | row->setData(pkg.metadata().pluginName(), PluginNameRole); | ||
201 | row->setData(pkg.filePath("preview"), ScreenhotRole); | 208 | row->setData(pkg.filePath("preview"), ScreenhotRole); | ||
202 | row->setData(pkg.filePath("fullscreenpreview"), FullScreenPreviewRole); | 209 | row->setData(pkg.filePath("fullscreenpreview"), FullScreenPreviewRole); | ||
▲ Show 20 Lines • Show All 608 Lines • Show Last 20 Lines |