Commit 20dd5b94 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Nate Graham
Browse files

Load and use global animation settings

Summary:
In addition to the specific Breeze animation settings, KDE has "global" animation settings primarily used for `Qt::UIEffect`s like `Qt::UI_AnimateMenu`, `Qt::UI_AnimateCombo`, `Qt::UI_AnimateTooltip` and `Qt::UI_AnimateToolBox`.

This patch ensures that Breeze use and respect those settings, which both harmonizes with other styles (if `QGuiApplication::desktopSettingsAware()` is true).

Test Plan:
Turn animations on and off in kdeglobals, and see animations turn off and on when using Breeze.

Also makes https://phabricator.kde.org/D17732 work properly with breeze.

Reviewers: #breeze, ngraham

Reviewed By: #breeze, ngraham

Subscribers: meven, cblack, davidedmundson, ngraham, hpereiradacosta, ndavis, plasma-devel, #breeze

Tags: #plasma, #breeze

Differential Revision: https://phabricator.kde.org/D28651
parent faa24ec4
......@@ -125,6 +125,15 @@ namespace Breeze
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();
......
......@@ -182,6 +182,10 @@ namespace Breeze
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
......@@ -1332,6 +1336,47 @@ namespace Breeze
}
//_____________________________________________________________________
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
{
......@@ -1381,6 +1426,8 @@ namespace Breeze
// load helper configuration
_helper->loadConfig();
loadGlobalAnimationSettings();
// reinitialize engines
_animations->setupEngines();
_windowManager->initialize();
......
......@@ -155,6 +155,10 @@ namespace Breeze
//* 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;
......
......@@ -55,8 +55,6 @@ namespace Breeze
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 @@ namespace Breeze
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 @@ namespace Breeze
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 @@ namespace Breeze
_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() );
......
......@@ -172,75 +172,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Animations</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QLabel" name="_animationsDurationLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>A&amp;nimations duration:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>_animationsDuration</cstring>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QSpinBox" name="_animationsDuration">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> ms</string>
</property>
<property name="maximum">
<number>500</number>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QCheckBox" name="_animationsEnabled">
<property name="text">
<string>Enable animations</string>
</property>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="4">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Frames</string>
......@@ -532,8 +463,6 @@
<tabstop>_splitterProxyEnabled</tabstop>
<tabstop>_mnemonicsMode</tabstop>
<tabstop>_windowDragMode</tabstop>
<tabstop>_animationsEnabled</tabstop>
<tabstop>_animationsDuration</tabstop>
<tabstop>_dockWidgetDrawFrame</tabstop>
<tabstop>_titleWidgetDrawFrame</tabstop>
<tabstop>_sidePanelDrawFrame</tabstop>
......@@ -543,37 +472,5 @@
</tabstops>
<resources/>
<connections>
<connection>
<sender>_animationsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>_animationsDurationLabel</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>90</x>
<y>64</y>
</hint>
<hint type="destinationlabel">
<x>84</x>
<y>98</y>
</hint>
</hints>
</connection>
<connection>
<sender>_animationsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>_animationsDuration</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>161</x>
<y>64</y>
</hint>
<hint type="destinationlabel">
<x>208</x>
<y>98</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Markdown is supported
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