Introduce a templated animationTime overload for the KConfigXT case
This method can be used to get the animationTime in case a configuration class generated through KConfigXT is used. In general the configuration stores the magic value 0 for a property "duration". This magic value indicates that a hard-coded default value should be used. So the common logic to test the stored value for 0 and then either pass the stored value or the default value to animationTime is encapsulated in this method in a generic way. A MyEffect can use it in the following way: animationTime<MyEffectConfig>(200); BUG: 310646 FIXED-IN: 4.10 REVIEW: 107460
This commit is contained in:
parent
40400167b9
commit
18cccad806
10 changed files with 23 additions and 6 deletions
|
@ -91,7 +91,7 @@ bool CoverSwitchEffect::supported()
|
|||
void CoverSwitchEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
CoverSwitchConfig::self()->readConfig();
|
||||
animationDuration = animationTime(CoverSwitchConfig::duration());
|
||||
animationDuration = animationTime<CoverSwitchConfig>(200);
|
||||
animateSwitch = CoverSwitchConfig::animateSwitch();
|
||||
animateStart = CoverSwitchConfig::animateStart();
|
||||
animateStop = CoverSwitchConfig::animateStop();
|
||||
|
|
|
@ -159,6 +159,7 @@ void CubeEffect::reconfigure(ReconfigureFlags)
|
|||
opacityDesktopOnly = CubeConfig::opacityDesktopOnly();
|
||||
displayDesktopName = CubeConfig::displayDesktopName();
|
||||
reflection = CubeConfig::reflection();
|
||||
// TODO: rename rotationDuration to duration
|
||||
rotationDuration = animationTime(CubeConfig::rotationDuration() != 0 ? CubeConfig::rotationDuration() : 500);
|
||||
backgroundColor = CubeConfig::backgroundColor();
|
||||
capColor = CubeConfig::capColor();
|
||||
|
|
|
@ -57,6 +57,7 @@ bool CubeSlideEffect::supported()
|
|||
void CubeSlideEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
CubeSlideConfig::self()->readConfig();
|
||||
// TODO: rename rotationDuration to duration
|
||||
rotationDuration = animationTime(CubeSlideConfig::rotationDuration() != 0 ? CubeSlideConfig::rotationDuration() : 500);
|
||||
timeLine.setCurveShape(QTimeLine::EaseInOutCurve);
|
||||
timeLine.setDuration(rotationDuration);
|
||||
|
|
|
@ -71,10 +71,9 @@ void DashboardEffect::reconfigure(ReconfigureFlags)
|
|||
{
|
||||
brightness = DashboardConfig::brightness()/ 100.0;
|
||||
saturation = DashboardConfig::saturation()/ 100.0;
|
||||
duration = DashboardConfig::duration() != 0 ? DashboardConfig::duration() : 500;
|
||||
blur = DashboardConfig::blur();
|
||||
|
||||
timeline.setDuration(animationTime(duration));
|
||||
timeline.setDuration(animationTime<DashboardConfig>(500));
|
||||
}
|
||||
|
||||
void DashboardEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
|
|
|
@ -73,7 +73,6 @@ private:
|
|||
long atom;
|
||||
qreal brightness;
|
||||
qreal saturation;
|
||||
int duration;
|
||||
EffectWindow* window;
|
||||
};
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ void DesktopGridEffect::reconfigure(ReconfigureFlags)
|
|||
effects->reserveElectricBorder(ElectricBorder(i));
|
||||
}
|
||||
|
||||
// TODO: rename zoomDuration to duration
|
||||
zoomDuration = animationTime(DesktopGridConfig::zoomDuration() != 0 ? DesktopGridConfig::zoomDuration() : 300);
|
||||
timeline.setCurveShape(QTimeLine::EaseInOutCurve);
|
||||
timeline.setDuration(zoomDuration);
|
||||
|
|
|
@ -114,7 +114,7 @@ void FlipSwitchEffect::reconfigure(ReconfigureFlags)
|
|||
}
|
||||
m_tabbox = FlipSwitchConfig::tabBox();
|
||||
m_tabboxAlternative = FlipSwitchConfig::tabBoxAlternative();
|
||||
const int duration = animationTime(FlipSwitchConfig::duration() != 0 ? FlipSwitchConfig::duration() : 200);
|
||||
const int duration = animationTime<FlipSwitchConfig>(200);
|
||||
m_timeLine.setDuration(duration);
|
||||
m_startStopTimeLine.setDuration(duration);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void GlideEffect::reconfigure(ReconfigureFlags)
|
|||
{
|
||||
// Fetch config with KConfigXT
|
||||
GlideConfig::self()->readConfig();
|
||||
duration = animationTime(GlideConfig::duration() != 0 ? GlideConfig::duration() : 350);
|
||||
duration = animationTime<GlideConfig>(350);
|
||||
effect = (EffectStyle) GlideConfig::glideEffect();
|
||||
angle = GlideConfig::glideAngle();
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ bool MagicLampEffect::supported()
|
|||
void MagicLampEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
MagicLampConfig::self()->readConfig();
|
||||
// TODO: rename animationDuration to duration
|
||||
mAnimationDuration = animationTime(MagicLampConfig::animationDuration() != 0 ? MagicLampConfig::animationDuration() : 250);
|
||||
|
||||
KConfigGroup conf = effects->effectConfig("MagicLamp");
|
||||
|
|
|
@ -477,6 +477,12 @@ public:
|
|||
* in the effect itself.
|
||||
*/
|
||||
static double animationTime(int defaultTime);
|
||||
/**
|
||||
* @overload Use this variant if animation time is provided through a KConfigXT generated class
|
||||
* having a property called "duration".
|
||||
**/
|
||||
template <typename T>
|
||||
int animationTime(int defaultDuration);
|
||||
/**
|
||||
* Linearly interpolates between @p x and @p y.
|
||||
*
|
||||
|
@ -2713,6 +2719,15 @@ void Motion<T>::finish()
|
|||
m_velocity = T();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Effect
|
||||
***************************************************************/
|
||||
template <typename T>
|
||||
int Effect::animationTime(int defaultDuration)
|
||||
{
|
||||
return animationTime(T::duration() != 0 ? T::duration() : defaultDuration);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
Q_DECLARE_METATYPE(KWin::EffectWindow*)
|
||||
Q_DECLARE_METATYPE(QList<KWin::EffectWindow*>)
|
||||
|
|
Loading…
Reference in a new issue