[effects] Add Scale effect
Summary: The new effect scales windows as they appear and disappear. As the the most of window animation effects, it is a monolithic effect, i.e., if you enable scale effect, it will animate *both* the appearing and disappearing. The main difference between the Scale effect and the Scale in effect is that the Scale in effect only animates windows as they appear. There is no corresponding "the Scale out" effect, which is odd. Other points that differentiate the Scale effect from the Scale in effect: * it is more subtle; * it doesn't animate the log out screen; * it doesn't conflict with the Fade effect, etc. ... and overall, the Scale effect supersedes the Scale in effect. {F5904947} //Window open animation.// {F5904948} //Window close animation.// {F5905283, layout=center, size=full} //KCM.// Test Plan: * Enabled this effect * Opened/closed System Settings Reviewers: #kwin, #plasma, #vdg, davidedmundson Reviewed By: #kwin, #plasma, #vdg, davidedmundson Subscribers: ngraham, davidedmundson, fvogt, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13461
This commit is contained in:
parent
a8563304f2
commit
9d197e8cb6
15 changed files with 695 additions and 0 deletions
|
@ -103,6 +103,7 @@ void TestBuiltInEffectLoader::testHasEffect_data()
|
|||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << true;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << true;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << true;
|
||||
QTest::newRow("Scale") << QStringLiteral("scale") << true;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << true;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << true;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << true;
|
||||
|
@ -159,6 +160,7 @@ void TestBuiltInEffectLoader::testKnownEffects()
|
|||
<< QStringLiteral("mousemark")
|
||||
<< QStringLiteral("presentwindows")
|
||||
<< QStringLiteral("resize")
|
||||
<< QStringLiteral("scale")
|
||||
<< QStringLiteral("screenedge")
|
||||
<< QStringLiteral("screenshot")
|
||||
<< QStringLiteral("sheet")
|
||||
|
@ -237,6 +239,7 @@ void TestBuiltInEffectLoader::testSupported_data()
|
|||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << true << xc << true;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << true << xc << true;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << true << xc << true;
|
||||
QTest::newRow("Scale") << QStringLiteral("scale") << true << xc << true;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << true << xc << true;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << true << xc << true;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << false << xc << true;
|
||||
|
@ -325,6 +328,7 @@ void TestBuiltInEffectLoader::testLoadEffect_data()
|
|||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << true << xc;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << true << xc;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << true << xc;
|
||||
QTest::newRow("Scale") << QStringLiteral("scale") << true << xc;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << true << xc;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << true << xc;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << false << xc;
|
||||
|
|
|
@ -95,6 +95,7 @@ void TestPluginEffectLoader::testHasEffect_data()
|
|||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << false;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << false;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << false;
|
||||
QTest::newRow("Scale") << QStringLiteral("scale") << false;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << false;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << false;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << false;
|
||||
|
|
|
@ -125,6 +125,7 @@ void TestScriptedEffectLoader::testHasEffect_data()
|
|||
QTest::newRow("MouseMark") << QStringLiteral("mousemark") << false;
|
||||
QTest::newRow("PresentWindows") << QStringLiteral("presentwindows") << false;
|
||||
QTest::newRow("Resize") << QStringLiteral("resize") << false;
|
||||
QTest::newRow("Scale") << QStringLiteral("scale") << false;
|
||||
QTest::newRow("ScreenEdge") << QStringLiteral("screenedge") << false;
|
||||
QTest::newRow("ScreenShot") << QStringLiteral("screenshot") << false;
|
||||
QTest::newRow("Sheet") << QStringLiteral("sheet") << false;
|
||||
|
|
|
@ -90,6 +90,7 @@ set( kwin4_effect_builtins_sources
|
|||
presentwindows/presentwindows.cpp
|
||||
presentwindows/presentwindows_proxy.cpp
|
||||
resize/resize.cpp
|
||||
scale/scale.cpp
|
||||
showfps/showfps.cpp
|
||||
slide/slide.cpp
|
||||
thumbnailaside/thumbnailaside.cpp
|
||||
|
@ -119,6 +120,7 @@ kconfig_add_kcfg_files(kwin4_effect_builtins_sources
|
|||
mousemark/mousemarkconfig.kcfgc
|
||||
presentwindows/presentwindowsconfig.kcfgc
|
||||
resize/resizeconfig.kcfgc
|
||||
scale/scaleconfig.kcfgc
|
||||
showfps/showfpsconfig.kcfgc
|
||||
slide/slideconfig.kcfgc
|
||||
slidingpopups/slidingpopupsconfig.kcfgc
|
||||
|
@ -179,6 +181,7 @@ add_subdirectory( lookingglass )
|
|||
add_subdirectory( magnifier )
|
||||
add_subdirectory( mouseclick )
|
||||
add_subdirectory( mousemark )
|
||||
add_subdirectory( scale )
|
||||
include( screenshot/CMakeLists.txt )
|
||||
include( sheet/CMakeLists.txt )
|
||||
include( snaphelper/CMakeLists.txt )
|
||||
|
|
|
@ -37,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "magiclamp/magiclamp.h"
|
||||
#include "minimizeanimation/minimizeanimation.h"
|
||||
#include "resize/resize.h"
|
||||
#include "scale/scale.h"
|
||||
#include "showfps/showfps.h"
|
||||
#include "showpaint/showpaint.h"
|
||||
#include "slide/slide.h"
|
||||
|
@ -441,6 +442,21 @@ EFFECT_FALLBACK
|
|||
nullptr,
|
||||
nullptr
|
||||
#endif
|
||||
EFFECT_FALLBACK
|
||||
}, {
|
||||
QStringLiteral("scale"),
|
||||
i18ndc("kwin_effects", "Name of a KWin Effect", "Scale"),
|
||||
i18ndc("kwin_effects", "Comment describing the KWin Effect", "Make windows smoothly scale in and out when they are shown or hidden"),
|
||||
QStringLiteral("Appearance"),
|
||||
QString(),
|
||||
QUrl(),
|
||||
false,
|
||||
false,
|
||||
#ifdef EFFECT_BUILTINS
|
||||
&createHelper<ScaleEffect>,
|
||||
&ScaleEffect::supported,
|
||||
nullptr
|
||||
#endif
|
||||
EFFECT_FALLBACK
|
||||
}, {
|
||||
QStringLiteral("screenedge"),
|
||||
|
|
|
@ -57,6 +57,7 @@ enum class BuiltInEffect
|
|||
MouseMark,
|
||||
PresentWindows,
|
||||
Resize,
|
||||
Scale,
|
||||
ScreenEdge,
|
||||
ScreenShot,
|
||||
Sheet,
|
||||
|
|
25
effects/scale/CMakeLists.txt
Normal file
25
effects/scale/CMakeLists.txt
Normal file
|
@ -0,0 +1,25 @@
|
|||
#######################################
|
||||
# Config
|
||||
set(kwin_scale_config_SRCS scale_config.cpp)
|
||||
ki18n_wrap_ui(kwin_scale_config_SRCS scale_config.ui)
|
||||
qt5_add_dbus_interface(kwin_scale_config_SRCS ${kwin_effects_dbus_xml} kwineffects_interface)
|
||||
kconfig_add_kcfg_files(kwin_scale_config_SRCS scaleconfig.kcfgc)
|
||||
|
||||
add_library(kwin_scale_config MODULE ${kwin_scale_config_SRCS})
|
||||
|
||||
target_link_libraries(kwin_scale_config
|
||||
Qt5::DBus
|
||||
KF5::ConfigWidgets
|
||||
KF5::I18n
|
||||
KF5::Service
|
||||
)
|
||||
|
||||
kcoreaddons_desktop_to_json(kwin_scale_config scale_config.desktop SERVICE_TYPES kcmodule.desktop)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
kwin_scale_config
|
||||
DESTINATION
|
||||
${PLUGIN_INSTALL_DIR}/kwin/effects/configs
|
||||
)
|
||||
|
284
effects/scale/scale.cpp
Normal file
284
effects/scale/scale.cpp
Normal file
|
@ -0,0 +1,284 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
// own
|
||||
#include "scale.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "scaleconfig.h"
|
||||
|
||||
// Qt
|
||||
#include <QSet>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
static const QSet<QString> s_blacklist {
|
||||
// The logout screen has to be animated only by the logout effect.
|
||||
QStringLiteral("ksmserver ksmserver"),
|
||||
|
||||
// KDE Plasma splash screen has to be animated only by the login effect.
|
||||
QStringLiteral("ksplashqml ksplashqml"),
|
||||
QStringLiteral("ksplashsimple ksplashsimple"),
|
||||
QStringLiteral("ksplashx ksplashx")
|
||||
};
|
||||
|
||||
ScaleEffect::ScaleEffect()
|
||||
{
|
||||
initConfig<ScaleConfig>();
|
||||
reconfigure(ReconfigureAll);
|
||||
|
||||
connect(effects, &EffectsHandler::windowAdded, this, &ScaleEffect::windowAdded);
|
||||
connect(effects, &EffectsHandler::windowClosed, this, &ScaleEffect::windowClosed);
|
||||
connect(effects, &EffectsHandler::windowDeleted, this, &ScaleEffect::windowDeleted);
|
||||
connect(effects, &EffectsHandler::windowDataChanged, this, &ScaleEffect::windowDataChanged);
|
||||
}
|
||||
|
||||
ScaleEffect::~ScaleEffect()
|
||||
{
|
||||
}
|
||||
|
||||
void ScaleEffect::reconfigure(ReconfigureFlags flags)
|
||||
{
|
||||
Q_UNUSED(flags)
|
||||
|
||||
ScaleConfig::self()->read();
|
||||
m_duration = std::chrono::milliseconds(animationTime<ScaleConfig>(160));
|
||||
|
||||
m_inParams.scale.from = ScaleConfig::inScale();
|
||||
m_inParams.scale.to = 1.0;
|
||||
m_inParams.opacity.from = ScaleConfig::inOpacity();
|
||||
m_inParams.opacity.to = 1.0;
|
||||
|
||||
m_outParams.scale.from = 1.0;
|
||||
m_outParams.scale.to = ScaleConfig::outScale();
|
||||
m_outParams.opacity.from = 1.0;
|
||||
m_outParams.opacity.to = ScaleConfig::outOpacity();
|
||||
}
|
||||
|
||||
void ScaleEffect::prePaintScreen(ScreenPrePaintData &data, int time)
|
||||
{
|
||||
const std::chrono::milliseconds delta(time);
|
||||
|
||||
auto animationIt = m_animations.begin();
|
||||
while (animationIt != m_animations.end()) {
|
||||
(*animationIt).update(delta);
|
||||
++animationIt;
|
||||
}
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void ScaleEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
|
||||
{
|
||||
if (m_animations.contains(w)) {
|
||||
data.setTransformed();
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
||||
}
|
||||
|
||||
effects->prePaintWindow(w, data, time);
|
||||
}
|
||||
|
||||
void ScaleEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
||||
{
|
||||
auto animationIt = m_animations.constFind(w);
|
||||
if (animationIt == m_animations.constEnd()) {
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
return;
|
||||
}
|
||||
|
||||
const ScaleParams params = w->isDeleted() ? m_outParams : m_inParams;
|
||||
const qreal t = (*animationIt).value();
|
||||
const qreal scale = interpolate(params.scale.from, params.scale.to, t);
|
||||
|
||||
data.setXScale(scale);
|
||||
data.setYScale(scale);
|
||||
data.setXTranslation(0.5 * (1.0 - scale) * w->width());
|
||||
data.setYTranslation(0.5 * (1.0 - scale) * w->height());
|
||||
data.multiplyOpacity(interpolate(params.opacity.from, params.opacity.to, t));
|
||||
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void ScaleEffect::postPaintScreen()
|
||||
{
|
||||
auto animationIt = m_animations.begin();
|
||||
while (animationIt != m_animations.end()) {
|
||||
EffectWindow *w = animationIt.key();
|
||||
|
||||
const QRect geo = w->expandedGeometry();
|
||||
const ScaleParams params = w->isDeleted() ? m_outParams : m_inParams;
|
||||
const qreal scale = qMax(params.scale.from, params.scale.to);
|
||||
const QRect repaintRect(
|
||||
geo.topLeft() + 0.5 * (1.0 - scale) * QPoint(geo.width(), geo.height()),
|
||||
geo.size() * scale);
|
||||
effects->addRepaint(repaintRect);
|
||||
|
||||
if ((*animationIt).done()) {
|
||||
if (w->isDeleted()) {
|
||||
w->unrefWindow();
|
||||
} else {
|
||||
w->setData(WindowForceBackgroundContrastRole, QVariant());
|
||||
w->setData(WindowForceBlurRole, QVariant());
|
||||
}
|
||||
animationIt = m_animations.erase(animationIt);
|
||||
} else {
|
||||
++animationIt;
|
||||
}
|
||||
}
|
||||
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
bool ScaleEffect::isActive() const
|
||||
{
|
||||
return !m_animations.isEmpty();
|
||||
}
|
||||
|
||||
bool ScaleEffect::supported()
|
||||
{
|
||||
return effects->animationsSupported();
|
||||
}
|
||||
|
||||
void ScaleEffect::windowAdded(EffectWindow *w)
|
||||
{
|
||||
if (effects->activeFullScreenEffect()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isScaleWindow(w)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!w->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const void *addGrab = w->data(WindowAddedGrabRole).value<void*>();
|
||||
if (addGrab && addGrab != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
TimeLine &timeLine = m_animations[w];
|
||||
timeLine.reset();
|
||||
timeLine.setDirection(TimeLine::Forward);
|
||||
timeLine.setDuration(m_duration);
|
||||
timeLine.setEasingCurve(QEasingCurve::InCurve);
|
||||
|
||||
w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
||||
w->setData(WindowForceBlurRole, QVariant(true));
|
||||
|
||||
w->addRepaintFull();
|
||||
}
|
||||
|
||||
void ScaleEffect::windowClosed(EffectWindow *w)
|
||||
{
|
||||
if (effects->activeFullScreenEffect()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isScaleWindow(w)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!w->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const void *closeGrab = w->data(WindowClosedGrabRole).value<void*>();
|
||||
if (closeGrab && closeGrab != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
w->refWindow();
|
||||
|
||||
TimeLine &timeLine = m_animations[w];
|
||||
timeLine.reset();
|
||||
timeLine.setDirection(TimeLine::Forward);
|
||||
timeLine.setDuration(m_duration);
|
||||
timeLine.setEasingCurve(QEasingCurve::OutCurve);
|
||||
|
||||
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
||||
w->setData(WindowForceBlurRole, QVariant(true));
|
||||
|
||||
w->addRepaintFull();
|
||||
}
|
||||
|
||||
void ScaleEffect::windowDeleted(EffectWindow *w)
|
||||
{
|
||||
m_animations.remove(w);
|
||||
}
|
||||
|
||||
void ScaleEffect::windowDataChanged(EffectWindow *w, int role)
|
||||
{
|
||||
if (role != WindowAddedGrabRole && role != WindowClosedGrabRole) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (w->data(role).value<void*>() == this) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto animationIt = m_animations.find(w);
|
||||
if (animationIt == m_animations.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (w->isDeleted() && role == WindowClosedGrabRole) {
|
||||
w->unrefWindow();
|
||||
}
|
||||
|
||||
m_animations.erase(animationIt);
|
||||
|
||||
w->setData(WindowForceBackgroundContrastRole, QVariant());
|
||||
w->setData(WindowForceBlurRole, QVariant());
|
||||
}
|
||||
|
||||
bool ScaleEffect::isScaleWindow(EffectWindow *w) const
|
||||
{
|
||||
// We don't want to animate most of plasmashell's windows, yet, some
|
||||
// of them we want to, for example, Task Manager Settings window.
|
||||
// The problem is that all those window share single window class.
|
||||
// So, the only way to decide whether a window should be animated is
|
||||
// to use a heuristic: if a window has decoration, then it's most
|
||||
// likely a dialog or a settings window so we have to animate it.
|
||||
if (w->windowClass() == QLatin1String("plasmashell plasmashell")) {
|
||||
return w->hasDecoration();
|
||||
}
|
||||
|
||||
if (s_blacklist.contains(w->windowClass())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (w->hasDecoration()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!w->isManaged()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return w->isNormalWindow()
|
||||
|| w->isDialog();
|
||||
}
|
||||
|
||||
} // namespace KWin
|
116
effects/scale/scale.h
Normal file
116
effects/scale/scale.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef KWIN_SCALE_H
|
||||
#define KWIN_SCALE_H
|
||||
|
||||
// kwineffects
|
||||
#include <kwineffects.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class ScaleEffect : public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int duration READ duration)
|
||||
Q_PROPERTY(qreal inScale READ inScale)
|
||||
Q_PROPERTY(qreal inOpacity READ inOpacity)
|
||||
Q_PROPERTY(qreal outScale READ outScale)
|
||||
Q_PROPERTY(qreal outOpacity READ outOpacity)
|
||||
|
||||
public:
|
||||
ScaleEffect();
|
||||
~ScaleEffect() override;
|
||||
|
||||
void reconfigure(ReconfigureFlags flags) override;
|
||||
|
||||
void prePaintScreen(ScreenPrePaintData &data, int time) override;
|
||||
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override;
|
||||
void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
|
||||
void postPaintScreen() override;
|
||||
|
||||
bool isActive() const override;
|
||||
int requestedEffectChainPosition() const override;
|
||||
|
||||
static bool supported();
|
||||
|
||||
int duration() const;
|
||||
qreal inScale() const;
|
||||
qreal inOpacity() const;
|
||||
qreal outScale() const;
|
||||
qreal outOpacity() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void windowAdded(EffectWindow *w);
|
||||
void windowClosed(EffectWindow *w);
|
||||
void windowDeleted(EffectWindow *w);
|
||||
void windowDataChanged(EffectWindow *w, int role);
|
||||
|
||||
private:
|
||||
bool isScaleWindow(EffectWindow *w) const;
|
||||
|
||||
std::chrono::milliseconds m_duration;
|
||||
QHash<EffectWindow*, TimeLine> m_animations;
|
||||
|
||||
struct ScaleParams {
|
||||
struct {
|
||||
qreal from;
|
||||
qreal to;
|
||||
} scale, opacity;
|
||||
};
|
||||
|
||||
ScaleParams m_inParams;
|
||||
ScaleParams m_outParams;
|
||||
};
|
||||
|
||||
inline int ScaleEffect::requestedEffectChainPosition() const
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
inline int ScaleEffect::duration() const
|
||||
{
|
||||
return m_duration.count();
|
||||
}
|
||||
|
||||
inline qreal ScaleEffect::inScale() const
|
||||
{
|
||||
return m_inParams.scale.from;
|
||||
}
|
||||
|
||||
inline qreal ScaleEffect::inOpacity() const
|
||||
{
|
||||
return m_inParams.opacity.from;
|
||||
}
|
||||
|
||||
inline qreal ScaleEffect::outScale() const
|
||||
{
|
||||
return m_outParams.scale.to;
|
||||
}
|
||||
|
||||
inline qreal ScaleEffect::outOpacity() const
|
||||
{
|
||||
return m_outParams.opacity.to;
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#endif
|
28
effects/scale/scale.kcfg
Normal file
28
effects/scale/scale.kcfg
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile arg="true"/>
|
||||
<group name="Effect-Scale">
|
||||
<entry name="Duration" type="UInt">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="InScale" type="Double">
|
||||
<default>0.96</default>
|
||||
</entry>
|
||||
<entry name="InOpacity" type="Double">
|
||||
<default>0.4</default>
|
||||
<min>0.0</min>
|
||||
<max>1.0</max>
|
||||
</entry>
|
||||
<entry name="OutScale" type="Double">
|
||||
<default>0.96</default>
|
||||
</entry>
|
||||
<entry name="OutOpacity" type="Double">
|
||||
<default>0.0</default>
|
||||
<min>0.0</min>
|
||||
<max>1.0</max>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
62
effects/scale/scale_config.cpp
Normal file
62
effects/scale/scale_config.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#include "scale_config.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "scaleconfig.h"
|
||||
#include <config-kwin.h>
|
||||
|
||||
#include <kwineffects_interface.h>
|
||||
#include <KAboutData>
|
||||
#include <KPluginFactory>
|
||||
|
||||
K_PLUGIN_FACTORY_WITH_JSON(ScaleEffectConfigFactory,
|
||||
"scale_config.json",
|
||||
registerPlugin<KWin::ScaleEffectConfig>();)
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
ScaleEffectConfig::ScaleEffectConfig(QWidget *parent, const QVariantList &args)
|
||||
: KCModule(KAboutData::pluginData(QStringLiteral("scale")), parent, args)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
ScaleConfig::instance(KWIN_CONFIG);
|
||||
addConfig(ScaleConfig::self(), this);
|
||||
load();
|
||||
}
|
||||
|
||||
ScaleEffectConfig::~ScaleEffectConfig()
|
||||
{
|
||||
}
|
||||
|
||||
void ScaleEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Effects"),
|
||||
QDBusConnection::sessionBus());
|
||||
interface.reconfigureEffect(QStringLiteral("scale"));
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#include "scale_config.moc"
|
8
effects/scale/scale_config.desktop
Normal file
8
effects/scale/scale_config.desktop
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
|
||||
X-KDE-Library=kwin_scale_config
|
||||
X-KDE-ParentComponents=scale
|
||||
|
||||
Name=Scale
|
48
effects/scale/scale_config.h
Normal file
48
effects/scale/scale_config.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef SCALE_CONFIG_H
|
||||
#define SCALE_CONFIG_H
|
||||
|
||||
#include "ui_scale_config.h"
|
||||
|
||||
#include <KCModule>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class ScaleEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScaleEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
|
||||
~ScaleEffectConfig() override;
|
||||
|
||||
void save() override;
|
||||
|
||||
private:
|
||||
::Ui::ScaleEffectConfig ui;
|
||||
};
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#endif
|
||||
|
93
effects/scale/scale_config.ui
Normal file
93
effects/scale/scale_config.ui
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ScaleEffectConfig</class>
|
||||
<widget class="QWidget" name="ScaleEffectConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>177</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_Duration">
|
||||
<property name="text">
|
||||
<string>Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_Duration">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="specialValueText">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> milliseconds</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_InScale">
|
||||
<property name="text">
|
||||
<string>Window open scale:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_OutScale">
|
||||
<property name="text">
|
||||
<string>Window close scale:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="kcfg_InScale">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9.990000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="kcfg_OutScale">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9.990000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.050000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
5
effects/scale/scaleconfig.kcfgc
Normal file
5
effects/scale/scaleconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=scale.kcfg
|
||||
ClassName=ScaleConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue