Commit 5d2b7fd7 authored by Marco Martin's avatar Marco Martin
Browse files

use global animation values

use global animation values for duration: as the widget style has the
same, the animations wikll be together
parent 8d82f4be
......@@ -476,7 +476,7 @@ namespace Breeze
// animation
auto d = qobject_cast<Decoration*>(decoration());
if( d ) m_animation->setDuration( d->internalSettings()->animationsDuration() );
if( d ) m_animation->setDuration( d->animationsDuration() );
}
......@@ -485,7 +485,7 @@ namespace Breeze
{
auto d = qobject_cast<Decoration*>(decoration());
if( !(d && d->internalSettings()->animationsEnabled() ) ) return;
if( !(d && d->animationsDuration() > 0 ) ) return;
m_animation->setDirection( hovered ? QAbstractAnimation::Forward : QAbstractAnimation::Backward );
if( m_animation->state() != QAbstractAnimation::Running ) m_animation->start();
......
......@@ -45,7 +45,7 @@
#include <QPainter>
#include <QTextStream>
#include <QTimer>
#include <QVariantAnimation>
#include <QDBusConnection>
#if BREEZE_HAVE_X11
#include <QX11Info>
......@@ -243,11 +243,19 @@ namespace Breeze
// It is important start and end value are of the same type, hence 0.0 and not just 0
m_animation->setStartValue( 0.0 );
m_animation->setEndValue( 1.0 );
m_animation->setEasingCurve( QEasingCurve::InOutQuad );
// Linear to have the same easing as Breeze animations
m_animation->setEasingCurve( QEasingCurve::Linear );
connect(m_animation, &QVariantAnimation::valueChanged, this, [this](const QVariant &value) {
setOpacity(value.toReal());
});
// use DBus connection to update on breeze configuration change
auto dbus = QDBusConnection::sessionBus();
dbus.connect( QString(),
QStringLiteral( "/KGlobalSettings" ),
QStringLiteral( "org.kde.KGlobalSettings" ),
QStringLiteral( "notifyChange" ), this, SLOT(reconfigure()) );
reconfigure();
updateTitleBar();
auto s = settings();
......@@ -309,7 +317,7 @@ namespace Breeze
//________________________________________________________________
void Decoration::updateAnimationState()
{
if( m_internalSettings->animationsEnabled() )
if( m_animation->duration() > 0 )
{
auto c = client().data();
......@@ -376,7 +384,11 @@ namespace Breeze
m_internalSettings = SettingsProvider::self()->internalSettings( this );
// animation
m_animation->setDuration( m_internalSettings->animationsDuration() );
KSharedConfig::Ptr config = KSharedConfig::openConfig();
const KConfigGroup cg(config, QStringLiteral("KDE"));
m_animation->setDuration( cg.readEntry("AnimationDurationFactor", 1.0f) * 100.0f );
// borders
recalculateBorders();
......
......@@ -31,6 +31,7 @@
#include <QPalette>
#include <QVariant>
#include <QVariantAnimation>
class QVariantAnimation;
......@@ -62,6 +63,9 @@ namespace Breeze
InternalSettingsPtr internalSettings() const
{ return m_internalSettings; }
qreal animationsDuration() const
{ return m_animation->duration();}
//* caption height
int captionHeight() const;
......
......@@ -101,15 +101,6 @@
<default>false</default>
</entry>
<!-- animations -->
<entry name="AnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="AnimationsDuration" type = "Int">
<default>150</default>
</entry>
<!-- hide title bar -->
<entry name="HideTitleBar" type = "Bool">
<default>false</default>
......
......@@ -54,10 +54,6 @@ namespace Breeze
connect( m_ui.drawBackgroundGradient, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );
connect( m_ui.drawTitleBarSeparator, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );
// track animations changes
connect( m_ui.animationsEnabled, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged );
connect( m_ui.animationsDuration, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
// track shadows changes
connect( m_ui.shadowSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( m_ui.shadowStrength, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
......@@ -83,8 +79,6 @@ namespace Breeze
m_ui.outlineCloseButton->setChecked( m_internalSettings->outlineCloseButton() );
m_ui.drawSizeGrip->setChecked( m_internalSettings->drawSizeGrip() );
m_ui.drawBackgroundGradient->setChecked( m_internalSettings->drawBackgroundGradient() );
m_ui.animationsEnabled->setChecked( m_internalSettings->animationsEnabled() );
m_ui.animationsDuration->setValue( m_internalSettings->animationsDuration() );
m_ui.drawTitleBarSeparator->setChecked( m_internalSettings->drawTitleBarSeparator() );
// load shadows
......@@ -117,23 +111,12 @@ namespace Breeze
m_internalSettings->setDrawBorderOnMaximizedWindows( m_ui.drawBorderOnMaximizedWindows->isChecked() );
m_internalSettings->setDrawSizeGrip( m_ui.drawSizeGrip->isChecked() );
m_internalSettings->setDrawBackgroundGradient( m_ui.drawBackgroundGradient->isChecked() );
m_internalSettings->setAnimationsEnabled( m_ui.animationsEnabled->isChecked() );
m_internalSettings->setAnimationsDuration( m_ui.animationsDuration->value() );
m_internalSettings->setDrawTitleBarSeparator(m_ui.drawTitleBarSeparator->isChecked());
m_internalSettings->setShadowSize( m_ui.shadowSize->currentIndex() );
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();
......@@ -174,8 +157,6 @@ namespace Breeze
m_ui.drawBorderOnMaximizedWindows->setChecked( m_internalSettings->drawBorderOnMaximizedWindows() );
m_ui.drawSizeGrip->setChecked( m_internalSettings->drawSizeGrip() );
m_ui.drawBackgroundGradient->setChecked( m_internalSettings->drawBackgroundGradient() );
m_ui.animationsEnabled->setChecked( m_internalSettings->animationsEnabled() );
m_ui.animationsDuration->setValue( m_internalSettings->animationsDuration() );
m_ui.drawTitleBarSeparator->setChecked( m_internalSettings->drawTitleBarSeparator() );
m_ui.shadowSize->setCurrentIndex( m_internalSettings->shadowSize() );
......@@ -202,10 +183,6 @@ namespace Breeze
else if( m_ui.drawSizeGrip->isChecked() != m_internalSettings->drawSizeGrip() ) modified = true;
else if( m_ui.drawBackgroundGradient->isChecked() != m_internalSettings->drawBackgroundGradient() ) modified = true;
// animations
else if( m_ui.animationsEnabled->isChecked() != m_internalSettings->animationsEnabled() ) modified = true;
else if( m_ui.animationsDuration->value() != m_internalSettings->animationsDuration() ) modified = true;
// shadows
else if( m_ui.shadowSize->currentIndex() != m_internalSettings->shadowSize() ) modified = true;
else if( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) != m_internalSettings->shadowStrength() ) modified = true;
......
......@@ -11,7 +11,16 @@
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -166,75 +175,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>Anima&amp;tions 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">
<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="1" column="2">
<spacer name="horizontalSpacer_4">
<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="0" column="0" colspan="3">
<widget class="QCheckBox" name="animationsEnabled">
<property name="text">
<string>Enable animations</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<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_4">
<attribute name="title">
<string>Shadows</string>
......@@ -392,45 +332,10 @@
<tabstop>drawBackgroundGradient</tabstop>
<tabstop>drawSizeGrip</tabstop>
<tabstop>drawTitleBarSeparator</tabstop>
<tabstop>animationsEnabled</tabstop>
<tabstop>animationsDuration</tabstop>
<tabstop>shadowSize</tabstop>
<tabstop>shadowStrength</tabstop>
<tabstop>shadowColor</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>animationsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>animationsDurationLabel</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>34</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>84</x>
<y>221</y>
</hint>
</hints>
</connection>
<connection>
<sender>animationsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>animationsDuration</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>108</x>
<y>194</y>
</hint>
<hint type="destinationlabel">
<x>141</x>
<y>229</y>
</hint>
</hints>
</connection>
</connections>
<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