Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/decorationmodel.cpp
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 55 | { | |||
---|---|---|---|---|---|
61 | case Qt::DisplayRole: | 61 | case Qt::DisplayRole: | ||
62 | return d.visibleName; | 62 | return d.visibleName; | ||
63 | case PluginNameRole: | 63 | case PluginNameRole: | ||
64 | return d.pluginName; | 64 | return d.pluginName; | ||
65 | case ThemeNameRole: | 65 | case ThemeNameRole: | ||
66 | return d.themeName; | 66 | return d.themeName; | ||
67 | case ConfigurationRole: | 67 | case ConfigurationRole: | ||
68 | return d.configuration; | 68 | return d.configuration; | ||
69 | case RecommendedBorderSizeRole: | ||||
70 | return Utils::borderSizeToString(d.recommendedBorderSize); | ||||
69 | } | 71 | } | ||
70 | return QVariant(); | 72 | return QVariant(); | ||
71 | } | 73 | } | ||
72 | 74 | | |||
73 | QHash< int, QByteArray > DecorationsModel::roleNames() const | 75 | QHash< int, QByteArray > DecorationsModel::roleNames() const | ||
74 | { | 76 | { | ||
75 | QHash<int, QByteArray> roles({ | 77 | QHash<int, QByteArray> roles({ | ||
76 | {Qt::DisplayRole, QByteArrayLiteral("display")}, | 78 | {Qt::DisplayRole, QByteArrayLiteral("display")}, | ||
77 | {PluginNameRole, QByteArrayLiteral("plugin")}, | 79 | {PluginNameRole, QByteArrayLiteral("plugin")}, | ||
78 | {ThemeNameRole, QByteArrayLiteral("theme")}, | 80 | {ThemeNameRole, QByteArrayLiteral("theme")}, | ||
79 | {ConfigurationRole, QByteArrayLiteral("configureable")} | 81 | {ConfigurationRole, QByteArrayLiteral("configureable")}, | ||
82 | {RecommendedBorderSizeRole, QByteArrayLiteral("recommendedbordersize")} | ||||
80 | }); | 83 | }); | ||
81 | return roles; | 84 | return roles; | ||
82 | } | 85 | } | ||
83 | 86 | | |||
84 | static bool isThemeEngine(const QVariantMap &decoSettingsMap) | 87 | static bool isThemeEngine(const QVariantMap &decoSettingsMap) | ||
85 | { | 88 | { | ||
86 | auto it = decoSettingsMap.find(QStringLiteral("themes")); | 89 | auto it = decoSettingsMap.find(QStringLiteral("themes")); | ||
87 | if (it == decoSettingsMap.end()) { | 90 | if (it == decoSettingsMap.end()) { | ||
88 | return false; | 91 | return false; | ||
89 | } | 92 | } | ||
90 | return it.value().toBool(); | 93 | return it.value().toBool(); | ||
91 | } | 94 | } | ||
92 | 95 | | |||
93 | static bool isConfigureable(const QVariantMap &decoSettingsMap) | 96 | static bool isConfigureable(const QVariantMap &decoSettingsMap) | ||
94 | { | 97 | { | ||
95 | auto it = decoSettingsMap.find(QStringLiteral("kcmodule")); | 98 | auto it = decoSettingsMap.find(QStringLiteral("kcmodule")); | ||
96 | if (it == decoSettingsMap.end()) { | 99 | if (it == decoSettingsMap.end()) { | ||
97 | return false; | 100 | return false; | ||
98 | } | 101 | } | ||
99 | return it.value().toBool(); | 102 | return it.value().toBool(); | ||
100 | } | 103 | } | ||
101 | 104 | | |||
105 | static KDecoration2::BorderSize recommendedBorderSize(const QVariantMap &decoSettingsMap) | ||||
106 | { | ||||
107 | auto it = decoSettingsMap.find(QStringLiteral("recommendedBorderSize")); | ||||
108 | if (it == decoSettingsMap.end()) { | ||||
109 | return KDecoration2::BorderSize::Normal; | ||||
110 | } | ||||
111 | return Utils::stringToBorderSize(it.value().toString()); | ||||
112 | } | ||||
113 | | ||||
102 | static QString themeListKeyword(const QVariantMap &decoSettingsMap) | 114 | static QString themeListKeyword(const QVariantMap &decoSettingsMap) | ||
103 | { | 115 | { | ||
104 | auto it = decoSettingsMap.find(QStringLiteral("themeListKeyword")); | 116 | auto it = decoSettingsMap.find(QStringLiteral("themeListKeyword")); | ||
105 | if (it == decoSettingsMap.end()) { | 117 | if (it == decoSettingsMap.end()) { | ||
106 | return QString(); | 118 | return QString(); | ||
107 | } | 119 | } | ||
108 | return it.value().toString(); | 120 | return it.value().toString(); | ||
109 | } | 121 | } | ||
Show All 14 Lines | 133 | { | |||
124 | const auto plugins = KPluginTrader::self()->query(s_pluginName, s_pluginName); | 136 | const auto plugins = KPluginTrader::self()->query(s_pluginName, s_pluginName); | ||
125 | for (const auto &info : plugins) { | 137 | for (const auto &info : plugins) { | ||
126 | KPluginLoader loader(info.libraryPath()); | 138 | KPluginLoader loader(info.libraryPath()); | ||
127 | KPluginFactory *factory = loader.factory(); | 139 | KPluginFactory *factory = loader.factory(); | ||
128 | if (!factory) { | 140 | if (!factory) { | ||
129 | continue; | 141 | continue; | ||
130 | } | 142 | } | ||
131 | auto metadata = loader.metaData().value(QStringLiteral("MetaData")).toObject().value(s_pluginName); | 143 | auto metadata = loader.metaData().value(QStringLiteral("MetaData")).toObject().value(s_pluginName); | ||
132 | bool config = false; | 144 | Data data; | ||
133 | if (!metadata.isUndefined()) { | 145 | if (!metadata.isUndefined()) { | ||
134 | const auto decoSettingsMap = metadata.toObject().toVariantMap(); | 146 | const auto decoSettingsMap = metadata.toObject().toVariantMap(); | ||
135 | const QString &kns = findKNewStuff(decoSettingsMap); | 147 | const QString &kns = findKNewStuff(decoSettingsMap); | ||
136 | if (!kns.isEmpty() && !m_knsProviders.contains(kns)) { | 148 | if (!kns.isEmpty() && !m_knsProviders.contains(kns)) { | ||
137 | m_knsProviders.append(kns); | 149 | m_knsProviders.append(kns); | ||
138 | } | 150 | } | ||
139 | if (isThemeEngine(decoSettingsMap)) { | 151 | if (isThemeEngine(decoSettingsMap)) { | ||
140 | const QString keyword = themeListKeyword(decoSettingsMap); | 152 | const QString keyword = themeListKeyword(decoSettingsMap); | ||
Show All 19 Lines | 171 | QMetaObject::invokeMethod(themeFinder.data(), "hasConfiguration", | |||
160 | Q_RETURN_ARG(bool, d.configuration), | 172 | Q_RETURN_ARG(bool, d.configuration), | ||
161 | Q_ARG(QString, d.themeName)); | 173 | Q_ARG(QString, d.themeName)); | ||
162 | m_plugins.emplace_back(std::move(d)); | 174 | m_plugins.emplace_back(std::move(d)); | ||
163 | } | 175 | } | ||
164 | 176 | | |||
165 | // it's a theme engine, we don't want to show this entry | 177 | // it's a theme engine, we don't want to show this entry | ||
166 | continue; | 178 | continue; | ||
167 | } | 179 | } | ||
168 | config = isConfigureable(decoSettingsMap); | 180 | data.configuration = isConfigureable(decoSettingsMap); | ||
181 | data.recommendedBorderSize = recommendedBorderSize(decoSettingsMap); | ||||
169 | } | 182 | } | ||
170 | Data data; | | |||
171 | data.pluginName = info.pluginName(); | 183 | data.pluginName = info.pluginName(); | ||
172 | data.visibleName = info.name().isEmpty() ? info.pluginName() : info.name(); | 184 | data.visibleName = info.name().isEmpty() ? info.pluginName() : info.name(); | ||
173 | data.themeName = data.visibleName; | 185 | data.themeName = data.visibleName; | ||
174 | data.configuration = config; | | |||
175 | 186 | | |||
176 | m_plugins.emplace_back(std::move(data)); | 187 | m_plugins.emplace_back(std::move(data)); | ||
177 | } | 188 | } | ||
178 | endResetModel(); | 189 | endResetModel(); | ||
179 | } | 190 | } | ||
180 | 191 | | |||
181 | QModelIndex DecorationsModel::findDecoration(const QString &pluginName, const QString &themeName) const | 192 | QModelIndex DecorationsModel::findDecoration(const QString &pluginName, const QString &themeName) const | ||
182 | { | 193 | { | ||
Show All 14 Lines |