[effects/slide] Add 'Duration' option
Summary: At the moment, there is no way to tweak duration of the slide animation. This change adds a configuration module so it is possible to change the duration. Test Plan: * enable virtual desktops * go to `System Settings > Desktop Behaviour > Desktop Effects` and select Slide effect under "Virtual Desktop Switching Animation" * click settings/options button and change duration Reviewers: #kwin, #plasma, graesslin Reviewed By: #kwin, #plasma, graesslin Subscribers: graesslin, plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D9382
This commit is contained in:
parent
880dd6dc0b
commit
8a02a802ae
9 changed files with 224 additions and 7 deletions
|
@ -91,6 +91,7 @@ set( kwin4_effect_builtins_sources
|
|||
presentwindows/presentwindows_proxy.cpp
|
||||
resize/resize.cpp
|
||||
showfps/showfps.cpp
|
||||
slide/slide.cpp
|
||||
thumbnailaside/thumbnailaside.cpp
|
||||
touchpoints/touchpoints.cpp
|
||||
trackmouse/trackmouse.cpp
|
||||
|
@ -119,6 +120,7 @@ kconfig_add_kcfg_files(kwin4_effect_builtins_sources
|
|||
presentwindows/presentwindowsconfig.kcfgc
|
||||
resize/resizeconfig.kcfgc
|
||||
showfps/showfpsconfig.kcfgc
|
||||
slide/slideconfig.kcfgc
|
||||
slidingpopups/slidingpopupsconfig.kcfgc
|
||||
thumbnailaside/thumbnailasideconfig.kcfgc
|
||||
trackmouse/trackmouseconfig.kcfgc
|
||||
|
@ -158,7 +160,7 @@ add_subdirectory( resize )
|
|||
include( screenedge/CMakeLists.txt )
|
||||
add_subdirectory( showfps )
|
||||
include( showpaint/CMakeLists.txt )
|
||||
include( slide/CMakeLists.txt )
|
||||
add_subdirectory( slide )
|
||||
include( slideback/CMakeLists.txt )
|
||||
include( slidingpopups/CMakeLists.txt )
|
||||
add_subdirectory( thumbnailaside )
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
#######################################
|
||||
# Effect
|
||||
# Config
|
||||
set(kwin_slide_config_SRCS slide_config.cpp)
|
||||
ki18n_wrap_ui(kwin_slide_config_SRCS slide_config.ui)
|
||||
qt5_add_dbus_interface(kwin_slide_config_SRCS ${kwin_effects_dbus_xml} kwineffects_interface)
|
||||
kconfig_add_kcfg_files(kwin_slide_config_SRCS slideconfig.kcfgc)
|
||||
|
||||
# Source files
|
||||
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
|
||||
slide/slide.cpp
|
||||
)
|
||||
add_library(kwin_slide_config MODULE ${kwin_slide_config_SRCS})
|
||||
|
||||
target_link_libraries(kwin_slide_config
|
||||
Qt5::DBus
|
||||
KF5::ConfigWidgets
|
||||
KF5::I18n
|
||||
KF5::Service
|
||||
)
|
||||
|
||||
kcoreaddons_desktop_to_json(kwin_slide_config slide_config.desktop SERVICE_TYPES kcmodule.desktop)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
kwin_slide_config
|
||||
DESTINATION
|
||||
${PLUGIN_INSTALL_DIR}/kwin/effects/configs
|
||||
)
|
||||
|
|
|
@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
|
||||
#include "slide.h"
|
||||
// KConfigSkeleton
|
||||
#include "slideconfig.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -29,6 +31,7 @@ namespace KWin
|
|||
SlideEffect::SlideEffect()
|
||||
: slide(false)
|
||||
{
|
||||
initConfig<SlideConfig>();
|
||||
connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int,int)));
|
||||
connect(effects, &EffectsHandler::windowAdded, this, &SlideEffect::windowAdded);
|
||||
connect(effects, &EffectsHandler::windowDeleted, this, [this](EffectWindow *w) {
|
||||
|
@ -45,7 +48,11 @@ bool SlideEffect::supported()
|
|||
|
||||
void SlideEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
mTimeLine.setDuration(animationTime(250));
|
||||
SlideConfig::self()->read();
|
||||
|
||||
const auto d = animationTime(
|
||||
SlideConfig::duration() != 0 ? SlideConfig::duration() : 250);
|
||||
mTimeLine.setDuration(d);
|
||||
}
|
||||
|
||||
void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
|
|
13
effects/slide/slide.kcfg
Normal file
13
effects/slide/slide.kcfg
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?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-Slide">
|
||||
<entry name="Duration" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
64
effects/slide/slide_config.cpp
Normal file
64
effects/slide/slide_config.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2017 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 "slide_config.h"
|
||||
// KConfigSkeleton
|
||||
#include "slideconfig.h"
|
||||
#include <config-kwin.h>
|
||||
|
||||
#include <kwineffects_interface.h>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KPluginFactory>
|
||||
|
||||
K_PLUGIN_FACTORY_WITH_JSON(SlideEffectConfigFactory,
|
||||
"slide_config.json",
|
||||
registerPlugin<KWin::SlideEffectConfig>();)
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
SlideEffectConfig::SlideEffectConfig(QWidget *parent, const QVariantList &args)
|
||||
: KCModule(KAboutData::pluginData(QStringLiteral("slide")), parent, args)
|
||||
{
|
||||
mUi.setupUi(this);
|
||||
SlideConfig::instance(KWIN_CONFIG);
|
||||
addConfig(SlideConfig::self(), this);
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
SlideEffectConfig::~SlideEffectConfig()
|
||||
{
|
||||
}
|
||||
|
||||
void SlideEffectConfig::save()
|
||||
{
|
||||
KCModule::save();
|
||||
|
||||
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
||||
QStringLiteral("/Effects"),
|
||||
QDBusConnection::sessionBus());
|
||||
interface.reconfigureEffect(QStringLiteral("slide"));
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#include "slide_config.moc"
|
9
effects/slide/slide_config.desktop
Normal file
9
effects/slide/slide_config.desktop
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
|
||||
X-KDE-Library=kwin_slide_config
|
||||
X-KDE-ParentComponents=slide
|
||||
|
||||
Name=Slide
|
||||
Name[x-test]=xxSlidexx
|
47
effects/slide/slide_config.h
Normal file
47
effects/slide/slide_config.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2017 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 SLIDE_CONFIG_H
|
||||
#define SLIDE_CONFIG_H
|
||||
|
||||
#include <KCModule>
|
||||
#include "ui_slide_config.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class SlideEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SlideEffectConfig(QWidget *parent = 0, const QVariantList& args = QVariantList());
|
||||
~SlideEffectConfig();
|
||||
|
||||
void save();
|
||||
|
||||
private:
|
||||
::Ui::SlideEffectConfig mUi;
|
||||
};
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#endif
|
53
effects/slide/slide_config.ui
Normal file
53
effects/slide/slide_config.ui
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SlideEffectConfig</class>
|
||||
<widget class="QWidget" name="SlideEffectConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Duration:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>kcfg_Duration</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" 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 comment="Duration of the slide animation">Default</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> milliseconds</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
5
effects/slide/slideconfig.kcfgc
Normal file
5
effects/slide/slideconfig.kcfgc
Normal file
|
@ -0,0 +1,5 @@
|
|||
File=slide.kcfg
|
||||
ClassName=SlideConfig
|
||||
NameSpace=KWin
|
||||
Singleton=true
|
||||
Mutators=true
|
Loading…
Reference in a new issue