Commit f68dd31a authored by David Redondo's avatar David Redondo 🏎
Browse files

Reset altered config in the decoration bridge

Otherwise we alter the config for everything in the same process.
Leading to for example a wrong initial read of the AnimationDurationFactor
inside ConfigValueProvider.


(cherry picked from commit c3523cce)
parent 7e61802b
......@@ -45,12 +45,13 @@ DummyDecorationBridge::DummyDecorationBridge(const QString &decorationTheme, QOb
} else { // for Breeze window decorations and its forks
m_decorationsConfigFileName = QStringLiteral("breezerc");
}
disableAnimations();
const QString pluginPath = windowDecorationPluginPath(decorationTheme);
m_loader = std::unique_ptr<KPluginLoader>(new KPluginLoader {pluginPath});
m_factory = m_loader->factory();
disableAnimations();
QVariantMap args({ {QStringLiteral("bridge"), QVariant::fromValue(this)} });
m_decoration = m_factory->create<KDecoration2::Decoration>(m_factory, QVariantList({args}));
......@@ -62,6 +63,7 @@ DummyDecorationBridge::DummyDecorationBridge(const QString &decorationTheme, QOb
if (m_settings) {
Q_EMIT m_settings->decorationSettings()->reconfigured();
}
enableAnimations();
}
DummyDecorationBridge::~DummyDecorationBridge()
......@@ -91,6 +93,7 @@ std::unique_ptr< KDecoration2::DecoratedClientPrivate > DummyDecorationBridge::c
void DummyDecorationBridge::paintButton(QPainter &painter, const QString &buttonType, const QString &buttonState)
{
disableAnimations();
std::unique_ptr<KDecoration2::DecorationButton> button {m_factory->create<KDecoration2::DecorationButton>(
QStringLiteral("button"),
m_decoration,
......@@ -133,6 +136,7 @@ void DummyDecorationBridge::paintButton(QPainter &painter, const QString &button
}
button->paint(&painter, DecorationPainter::ButtonGeometry);
enableAnimations();
}
void DummyDecorationBridge::disableAnimations()
......@@ -147,10 +151,20 @@ void DummyDecorationBridge::disableAnimations()
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig();
if (globalConfig) {
auto group = globalConfig->group(QStringLiteral("KDE"));
globalAnimationEntryValue = group.readEntry(QStringLiteral("AnimationDurationFactor"), 1.0);
group.writeEntry(QStringLiteral("AnimationDurationFactor"), 0, KConfig::WriteConfigFlags());
}
}
void DummyDecorationBridge::enableAnimations()
{
KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig();
if (globalConfig) {
auto group = globalConfig->group(QStringLiteral("KDE"));
group.writeEntry(QStringLiteral("AnimationDurationFactor"), globalAnimationEntryValue, KConfig::WriteConfigFlags());
}
}
QString DummyDecorationBridge::windowDecorationPluginPath(const QString &decorationTheme) const
{
const auto decorationPlugins = KPluginLoader::findPlugins(QStringLiteral("org.kde.kdecoration2"));
......
......@@ -40,6 +40,7 @@ public:
private:
void disableAnimations();
void enableAnimations();
QString windowDecorationPluginPath(const QString &decorationTheme) const;
......@@ -49,6 +50,7 @@ private:
KDecoration2::DecorationButtonType strToButtonType(const QString &type) const;
QString m_decorationsConfigFileName;
QString globalAnimationEntryValue;
std::unique_ptr<KPluginLoader> m_loader;
KPluginFactory *m_factory;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment