Support themes in decoration loading
A decoration plugin can indicate that it supports themes. For this the decoration plugin needs to specify in the org.kde.kdecoration2 group of the JSON meta data the following: themes: true, defaultTheme: "nameofDefaultTheme" If the themes key/value pair is present and set to true KWin will read the entry "theme" in the [org.kde.kdecoration2] group with the value of defaultTheme as the default value. The read value (if there is one) is passed to the created decoration in the QVariantList. The QVariantList contains a QVariantMap as first entry and the theme name is passed for key "theme".
This commit is contained in:
parent
7e8cce212d
commit
6a580d2b90
2 changed files with 23 additions and 1 deletions
|
@ -89,6 +89,7 @@ void DecorationBridge::loadMetaData(const QJsonObject &object)
|
|||
{
|
||||
// reset all settings
|
||||
m_blur = false;
|
||||
m_theme = QString();
|
||||
|
||||
// load the settings
|
||||
const QJsonValue decoSettings = object.value(s_pluginName);
|
||||
|
@ -101,6 +102,21 @@ void DecorationBridge::loadMetaData(const QJsonObject &object)
|
|||
if (blurIt != decoSettingsMap.end()) {
|
||||
m_blur = blurIt.value().toBool();
|
||||
}
|
||||
findTheme(decoSettingsMap);
|
||||
}
|
||||
|
||||
void DecorationBridge::findTheme(const QVariantMap &map)
|
||||
{
|
||||
auto it = map.find(QStringLiteral("themes"));
|
||||
if (it == map.end()) {
|
||||
return;
|
||||
}
|
||||
if (!it.value().toBool()) {
|
||||
return;
|
||||
}
|
||||
it = map.find(QStringLiteral("defaultTheme"));
|
||||
const KConfigGroup config = KSharedConfig::openConfig(KWIN_CONFIG)->group(s_pluginName);
|
||||
m_theme = config.readEntry("theme", it != map.end() ? it.value().toString() : QString());
|
||||
}
|
||||
|
||||
std::unique_ptr<KDecoration2::DecoratedClientPrivate> DecorationBridge::createClient(KDecoration2::DecoratedClient *client, KDecoration2::Decoration *decoration)
|
||||
|
@ -128,7 +144,11 @@ KDecoration2::Decoration *DecorationBridge::createDecoration(Client *client)
|
|||
if (!m_factory) {
|
||||
return nullptr;
|
||||
}
|
||||
auto deco = m_factory->create<KDecoration2::Decoration>(client);
|
||||
QVariantList args;
|
||||
if (!m_theme.isEmpty()) {
|
||||
args << QVariantMap({ {QStringLiteral("theme"), m_theme} });
|
||||
}
|
||||
auto deco = m_factory->create<KDecoration2::Decoration>(client, args);
|
||||
deco->init();
|
||||
return deco;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,10 @@ public:
|
|||
static DecorationBridge *self();
|
||||
private:
|
||||
void loadMetaData(const QJsonObject &object);
|
||||
void findTheme(const QVariantMap &map);
|
||||
KPluginFactory *m_factory;
|
||||
bool m_blur;
|
||||
QString m_theme;
|
||||
};
|
||||
} // Decoration
|
||||
} // KWin
|
||||
|
|
Loading…
Reference in a new issue