Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colors.cpp
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | |||||
108 | 108 | | |||
109 | int KCMColors::selectedSchemeIndex() const | 109 | int KCMColors::selectedSchemeIndex() const | ||
110 | { | 110 | { | ||
111 | return indexOfScheme(m_selectedScheme); | 111 | return indexOfScheme(m_selectedScheme); | ||
112 | } | 112 | } | ||
113 | 113 | | |||
114 | int KCMColors::indexOfScheme(const QString &schemeName) const | 114 | int KCMColors::indexOfScheme(const QString &schemeName) const | ||
115 | { | 115 | { | ||
116 | const auto results = m_model->match(m_model->index(0, 0), SchemeNameRole, schemeName); | 116 | // Matches the scheme file name (without .colors suffix) | ||
117 | auto results = m_model->match(m_model->index(0, 0), SchemeNameRole, schemeName); | ||||
117 | if (results.count() == 1) { | 118 | if (results.count() == 1) { | ||
118 | return results.first().row(); | 119 | return results.constFirst().row(); | ||
120 | } | ||||
121 | | ||||
122 | // Also try matching for the untranslated theme name | ||||
123 | results = m_model->match(m_model->index(0, 0), UntranslatedNameRole, schemeName); | ||||
124 | if (results.count() == 1) { | ||||
125 | return results.constFirst().row(); | ||||
119 | } | 126 | } | ||
120 | 127 | | |||
121 | return -1; | 128 | return -1; | ||
122 | } | 129 | } | ||
123 | 130 | | |||
124 | bool KCMColors::downloadingFile() const | 131 | bool KCMColors::downloadingFile() const | ||
125 | { | 132 | { | ||
126 | return m_tempCopyJob; | 133 | return m_tempCopyJob; | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 173 | for (const QString &schemeFile : schemeFiles) { | |||
168 | const QString baseName = fi.baseName(); | 175 | const QString baseName = fi.baseName(); | ||
169 | 176 | | |||
170 | KSharedConfigPtr config = KSharedConfig::openConfig(schemeFile, KConfig::SimpleConfig); | 177 | KSharedConfigPtr config = KSharedConfig::openConfig(schemeFile, KConfig::SimpleConfig); | ||
171 | KConfigGroup group(config, "General"); | 178 | KConfigGroup group(config, "General"); | ||
172 | const QString name = group.readEntry("Name", baseName); | 179 | const QString name = group.readEntry("Name", baseName); | ||
173 | 180 | | |||
174 | QStandardItem *item = new QStandardItem(name); | 181 | QStandardItem *item = new QStandardItem(name); | ||
175 | item->setData(baseName, SchemeNameRole); | 182 | item->setData(baseName, SchemeNameRole); | ||
183 | item->setData(group.readEntryUntranslated("Name", baseName), UntranslatedNameRole); | ||||
176 | item->setData(fi.isWritable(), RemovableRole); | 184 | item->setData(fi.isWritable(), RemovableRole); | ||
177 | item->setData(false, PendingDeletionRole); | 185 | item->setData(false, PendingDeletionRole); | ||
178 | 186 | | |||
179 | item->setData(KColorScheme::createApplicationPalette(config), PaletteRole); | 187 | item->setData(KColorScheme::createApplicationPalette(config), PaletteRole); | ||
180 | 188 | | |||
181 | m_model->appendRow(item); | 189 | m_model->appendRow(item); | ||
182 | } | 190 | } | ||
183 | 191 | | |||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Line(s) | |||||
375 | void KCMColors::load() | 383 | void KCMColors::load() | ||
376 | { | 384 | { | ||
377 | loadModel(); | 385 | loadModel(); | ||
378 | 386 | | |||
379 | m_config->markAsClean(); | 387 | m_config->markAsClean(); | ||
380 | m_config->reparseConfiguration(); | 388 | m_config->reparseConfiguration(); | ||
381 | 389 | | |||
382 | KConfigGroup group(m_config, "General"); | 390 | KConfigGroup group(m_config, "General"); | ||
383 | const QString schemeName = group.readEntry("ColorScheme", s_defaultColorSchemeName); | 391 | const QString schemeName = group.readEntryUntranslated("ColorScheme", s_defaultColorSchemeName); | ||
384 | 392 | | |||
385 | // If the scheme named in kdeglobals doesn't exist, show a warning and use default scheme | 393 | // If the scheme named in kdeglobals doesn't exist, show a warning and use default scheme | ||
386 | if (indexOfScheme(schemeName) == -1) { | 394 | if (indexOfScheme(schemeName) == -1) { | ||
387 | setSelectedScheme(s_defaultColorSchemeName); | 395 | setSelectedScheme(s_defaultColorSchemeName); | ||
388 | emit showSchemeNotInstalledWarning(schemeName); | 396 | emit showSchemeNotInstalledWarning(schemeName); | ||
389 | } else { | 397 | } else { | ||
390 | setSelectedScheme(schemeName); | 398 | setSelectedScheme(schemeName); | ||
391 | } | 399 | } | ||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |