Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colorsmodel.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 53 | { | |||
---|---|---|---|---|---|
56 | } | 56 | } | ||
57 | 57 | | |||
58 | const auto &item = m_data.at(index.row()); | 58 | const auto &item = m_data.at(index.row()); | ||
59 | 59 | | |||
60 | switch (role) { | 60 | switch (role) { | ||
61 | case Qt::DisplayRole: return item.display; | 61 | case Qt::DisplayRole: return item.display; | ||
62 | case SchemeNameRole: return item.schemeName; | 62 | case SchemeNameRole: return item.schemeName; | ||
63 | case PaletteRole: return item.palette; | 63 | case PaletteRole: return item.palette; | ||
64 | case ActiveTitleBarBackgroundRole: return item.activeTitleBarBackground; | ||||
65 | case ActiveTitleBarForegroundRole: return item.activeTitleBarForeground; | ||||
64 | case PendingDeletionRole: return item.pendingDeletion; | 66 | case PendingDeletionRole: return item.pendingDeletion; | ||
65 | case RemovableRole: return item.removable; | 67 | case RemovableRole: return item.removable; | ||
66 | } | 68 | } | ||
67 | 69 | | |||
68 | return QVariant(); | 70 | return QVariant(); | ||
69 | } | 71 | } | ||
70 | 72 | | |||
71 | bool ColorsModel::setData(const QModelIndex &index, const QVariant &value, int role) | 73 | bool ColorsModel::setData(const QModelIndex &index, const QVariant &value, int role) | ||
Show All 26 Lines | |||||
98 | } | 100 | } | ||
99 | 101 | | |||
100 | QHash<int, QByteArray> ColorsModel::roleNames() const | 102 | QHash<int, QByteArray> ColorsModel::roleNames() const | ||
101 | { | 103 | { | ||
102 | return { | 104 | return { | ||
103 | {Qt::DisplayRole, QByteArrayLiteral("display")}, | 105 | {Qt::DisplayRole, QByteArrayLiteral("display")}, | ||
104 | {SchemeNameRole, QByteArrayLiteral("schemeName")}, | 106 | {SchemeNameRole, QByteArrayLiteral("schemeName")}, | ||
105 | {PaletteRole, QByteArrayLiteral("palette")}, | 107 | {PaletteRole, QByteArrayLiteral("palette")}, | ||
108 | {ActiveTitleBarBackgroundRole, QByteArrayLiteral("activeTitleBarBackground")}, | ||||
109 | {ActiveTitleBarForegroundRole, QByteArrayLiteral("activeTitleBarForeground")}, | ||||
106 | {RemovableRole, QByteArrayLiteral("removable")}, | 110 | {RemovableRole, QByteArrayLiteral("removable")}, | ||
107 | {PendingDeletionRole, QByteArrayLiteral("pendingDeletion")} | 111 | {PendingDeletionRole, QByteArrayLiteral("pendingDeletion")} | ||
108 | }; | 112 | }; | ||
109 | } | 113 | } | ||
110 | 114 | | |||
111 | QString ColorsModel::selectedScheme() const | 115 | QString ColorsModel::selectedScheme() const | ||
112 | { | 116 | { | ||
113 | return m_selectedScheme; | 117 | return m_selectedScheme; | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 154 | { | |||
175 | for (const QString &schemeFile : schemeFiles) { | 179 | for (const QString &schemeFile : schemeFiles) { | ||
176 | const QFileInfo fi(schemeFile); | 180 | const QFileInfo fi(schemeFile); | ||
177 | const QString baseName = fi.baseName(); | 181 | const QString baseName = fi.baseName(); | ||
178 | 182 | | |||
179 | KSharedConfigPtr config = KSharedConfig::openConfig(schemeFile, KConfig::SimpleConfig); | 183 | KSharedConfigPtr config = KSharedConfig::openConfig(schemeFile, KConfig::SimpleConfig); | ||
180 | KConfigGroup group(config, "General"); | 184 | KConfigGroup group(config, "General"); | ||
181 | const QString name = group.readEntry("Name", baseName); | 185 | const QString name = group.readEntry("Name", baseName); | ||
182 | 186 | | |||
187 | const QPalette palette = KColorScheme::createApplicationPalette(config); | ||||
188 | | ||||
189 | KConfigGroup wmConfig(config, QStringLiteral("WM")); | ||||
190 | | ||||
191 | // from kwin/decorations/decorationpalette.cpp | ||||
192 | const QColor activeTitleBarBackground = wmConfig.readEntry("activeBackground", palette.color(QPalette::Active, QPalette::Highlight)); | ||||
193 | const QColor activeTitleBarForeground = wmConfig.readEntry("activeForeground", palette.color(QPalette::Active, QPalette::HighlightedText)); | ||||
194 | | ||||
183 | ColorsModelData item{ | 195 | ColorsModelData item{ | ||
184 | name, | 196 | name, | ||
185 | baseName, | 197 | baseName, | ||
186 | KColorScheme::createApplicationPalette(config), | 198 | palette, | ||
199 | activeTitleBarBackground, | ||||
200 | activeTitleBarForeground, | ||||
187 | fi.isWritable(), | 201 | fi.isWritable(), | ||
188 | false, // pending deletion | 202 | false, // pending deletion | ||
189 | }; | 203 | }; | ||
190 | 204 | | |||
191 | m_data.append(item); | 205 | m_data.append(item); | ||
192 | } | 206 | } | ||
193 | 207 | | |||
194 | QCollator collator; | 208 | QCollator collator; | ||
Show All 35 Lines |