diff --git a/kdecoration/config/breezeconfigwidget.cpp b/kdecoration/config/breezeconfigwidget.cpp --- a/kdecoration/config/breezeconfigwidget.cpp +++ b/kdecoration/config/breezeconfigwidget.cpp @@ -125,6 +125,15 @@ m_internalSettings->setShadowStrength( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) ); m_internalSettings->setShadowColor( m_ui.shadowColor->color() ); + // Store in the global animation settings + KSharedConfig::Ptr config = KSharedConfig::openConfig(); + KConfigGroup cg(config, QStringLiteral("KDE")); + if (m_ui.animationsEnabled->isChecked()) { + cg.writeEntry("AnimationDurationFactor", float(m_ui.animationsDuration->value()) / m_ui.animationsDuration->maximum()); + } else { + cg.writeEntry("AnimationDurationFactor", 0.f); + } + // save configuration m_internalSettings->save(); diff --git a/kstyle/breezestyle.h b/kstyle/breezestyle.h --- a/kstyle/breezestyle.h +++ b/kstyle/breezestyle.h @@ -154,6 +154,10 @@ //* update configuration void configurationChanged(); + //* global configuration changed + void globalConfigurationChanged(int type, int arg); + void loadGlobalAnimationSettings(); + //* standard icons QIcon standardIconImplementation( StandardPixmap, const QStyleOption*, const QWidget* ) const; diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -183,6 +183,10 @@ QStringLiteral( "/BreezeDecoration" ), QStringLiteral( "org.kde.Breeze.Style" ), QStringLiteral( "reparseConfiguration" ), this, SLOT(configurationChanged()) ); + dbus.connect( QString(), + QStringLiteral( "/KGlobalSettings" ), + QStringLiteral( "org.kde.KGlobalSettings" ), + QStringLiteral( "notifyChange" ), this, SLOT(configurationChanged()) ); #if QT_VERSION < 0x050D00 // Check if Qt version < 5.13 this->addEventFilter(qApp); #else @@ -1333,6 +1337,47 @@ } + //_____________________________________________________________________ + void Style::loadGlobalAnimationSettings() + { + KSharedConfig::Ptr config = KSharedConfig::openConfig(); + const KConfigGroup cg(config, QStringLiteral("KDE")); + + // Don't override if it isn't set by the user + if (!cg.hasKey("AnimationDurationFactor")) { + return; + } + + const int animationsDuration = cg.readEntry("AnimationDurationFactor", StyleConfigData::animationsDuration() / 100.0f) * 100; + if (animationsDuration > 0) { + StyleConfigData::setAnimationsDuration(animationsDuration); + StyleConfigData::setAnimationsEnabled(true); + } else { + StyleConfigData::setAnimationsEnabled(false); + } + } + + //_____________________________________________________________________ + void Style::globalConfigurationChanged(int type, int arg) + { + Q_UNUSED(arg); + + // 3 == SettingsChanged, which is manually redefined in + // plasma-integration/src/platformtheme/khintssettings.h and fetched + // from KGlobalConfig in kdelibs4support in plasma-desktop/kcms/*, + // seems to be agreed on by everything in plasma is what sets the + // animation duration + if (type != 3) { + return; + } + + // Reload the new values + loadGlobalAnimationSettings(); + + // reinitialize engines + _animations->setupEngines(); + } + //____________________________________________________________________ QIcon Style::standardIconImplementation( StandardPixmap standardPixmap, const QStyleOption* option, const QWidget* widget ) const { @@ -1382,6 +1427,8 @@ // load helper configuration _helper->loadConfig(); + loadGlobalAnimationSettings(); + // reinitialize engines _animations->setupEngines(); _windowManager->initialize(); diff --git a/kstyle/config/breezestyleconfig.cpp b/kstyle/config/breezestyleconfig.cpp --- a/kstyle/config/breezestyleconfig.cpp +++ b/kstyle/config/breezestyleconfig.cpp @@ -55,8 +55,6 @@ connect( _sliderDrawTickMarks, &QAbstractButton::toggled, this, &StyleConfig::updateChanged ); connect( _splitterProxyEnabled, &QAbstractButton::toggled, this, &StyleConfig::updateChanged ); connect( _mnemonicsMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); - connect( _animationsEnabled, &QAbstractButton::toggled, this, &StyleConfig::updateChanged ); - connect( _animationsDuration, SIGNAL(valueChanged(int)), SLOT(updateChanged()) ); connect( _scrollBarAddLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( _scrollBarSubLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); @@ -79,8 +77,6 @@ StyleConfigData::setMnemonicsMode( _mnemonicsMode->currentIndex() ); StyleConfigData::setScrollBarAddLineButtons( _scrollBarAddLineButtons->currentIndex() ); StyleConfigData::setScrollBarSubLineButtons( _scrollBarSubLineButtons->currentIndex() ); - StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() ); - StyleConfigData::setAnimationsDuration( _animationsDuration->value() ); StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex() ); StyleConfigData::setMenuOpacity( _menuOpacity->value() ); @@ -127,8 +123,6 @@ else if( _scrollBarAddLineButtons->currentIndex() != StyleConfigData::scrollBarAddLineButtons() ) modified = true; else if( _scrollBarSubLineButtons->currentIndex() != StyleConfigData::scrollBarSubLineButtons() ) modified = true; else if( _splitterProxyEnabled->isChecked() != StyleConfigData::splitterProxyEnabled() ) modified = true; - else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true; - else if( _animationsDuration->value() != StyleConfigData::animationsDuration() ) modified = true; else if( _windowDragMode->currentIndex() != StyleConfigData::windowDragMode() ) modified = true; else if( _menuOpacity->value() != StyleConfigData::menuOpacity() ) modified = true; @@ -152,8 +146,6 @@ _splitterProxyEnabled->setChecked( StyleConfigData::splitterProxyEnabled() ); _scrollBarAddLineButtons->setCurrentIndex( StyleConfigData::scrollBarAddLineButtons() ); _scrollBarSubLineButtons->setCurrentIndex( StyleConfigData::scrollBarSubLineButtons() ); - _animationsEnabled->setChecked( StyleConfigData::animationsEnabled() ); - _animationsDuration->setValue( StyleConfigData::animationsDuration() ); _windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() ); _menuOpacity->setValue( StyleConfigData::menuOpacity() ); diff --git a/kstyle/config/ui/breezestyleconfig.ui b/kstyle/config/ui/breezestyleconfig.ui --- a/kstyle/config/ui/breezestyleconfig.ui +++ b/kstyle/config/ui/breezestyleconfig.ui @@ -172,75 +172,6 @@ - - - Animations - - - - - - false - - - A&nimations duration: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - _animationsDuration - - - - - - - false - - - ms - - - 500 - - - - - - - Enable animations - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - Frames @@ -532,8 +463,6 @@ _splitterProxyEnabled _mnemonicsMode _windowDragMode - _animationsEnabled - _animationsDuration _dockWidgetDrawFrame _titleWidgetDrawFrame _sidePanelDrawFrame @@ -543,37 +472,5 @@ - - _animationsEnabled - toggled(bool) - _animationsDurationLabel - setEnabled(bool) - - - 90 - 64 - - - 84 - 98 - - - - - _animationsEnabled - toggled(bool) - _animationsDuration - setEnabled(bool) - - - 161 - 64 - - - 208 - 98 - - -