kcm: Add reduced animation mode

Implement #190 reduced animations mode
This commit is contained in:
Devin Lin 2022-04-29 20:02:33 -04:00
parent 2201ebd1d7
commit 62e7dce24a
8 changed files with 80 additions and 11 deletions

View file

@ -27,6 +27,7 @@ MobileShellSettings::MobileShellSettings(QObject *parent)
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) -> void {
if (group.name() == GENERAL_CONFIG_GROUP) {
Q_EMIT vibrationsEnabledChanged();
Q_EMIT animationsEnabledChanged();
Q_EMIT navigationPanelEnabledChanged();
} else if (group.name() == QUICKSETTINGS_CONFIG_GROUP) {
Q_EMIT enabledQuickSettingsChanged();
@ -48,6 +49,19 @@ void MobileShellSettings::setVibrationsEnabled(bool vibrationsEnabled)
m_config->sync();
}
bool MobileShellSettings::animationsEnabled() const
{
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
return group.readEntry("animationsEnabled", true);
}
void MobileShellSettings::setAnimationsEnabled(bool animationsEnabled)
{
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};
group.writeEntry("animationsEnabled", animationsEnabled, KConfigGroup::Notify);
m_config->sync();
}
bool MobileShellSettings::navigationPanelEnabled() const
{
auto group = KConfigGroup{m_config, GENERAL_CONFIG_GROUP};

View file

@ -15,6 +15,7 @@ class MobileShellSettings : public QObject
{
Q_OBJECT
Q_PROPERTY(bool vibrationsEnabled READ vibrationsEnabled WRITE setVibrationsEnabled NOTIFY vibrationsEnabledChanged)
Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled NOTIFY animationsEnabledChanged)
Q_PROPERTY(bool navigationPanelEnabled READ navigationPanelEnabled WRITE setNavigationPanelEnabled NOTIFY navigationPanelEnabledChanged)
public:
@ -25,6 +26,9 @@ public:
bool vibrationsEnabled() const;
void setVibrationsEnabled(bool vibrationsEnabled);
bool animationsEnabled() const;
void setAnimationsEnabled(bool animationsEnabled);
bool navigationPanelEnabled() const;
void setNavigationPanelEnabled(bool navigationPanelEnabled);
@ -37,6 +41,7 @@ public:
Q_SIGNALS:
void vibrationsEnabledChanged();
void navigationPanelEnabledChanged();
void animationsEnabledChanged();
void enabledQuickSettingsChanged();
void disabledQuickSettingsChanged();

View file

@ -136,11 +136,49 @@ MouseArea { // use mousearea to ensure clicks don't go behind
]
transitions: [
// no-animation mode transition
Transition {
from: "closed"
enabled: !MobileShell.MobileShellSettings.animationsEnabled
SequentialAnimation {
ScriptAction {
script: {
root.opacity = 0;
root.visible = true;
background.scale = 1;
iconParent.scale = 1;
backgroundParent.x = 0;
backgroundParent.y = 0;
}
}
NumberAnimation {
target: root
properties: "opacity"
from: 0
to: 1
duration: PlasmaCore.Units.longDuration
easing.type: Easing.OutCubic
}
ScriptAction {
script: {
// close the app drawer after it isn't visible
MobileShell.HomeScreenControls.resetHomeScreenPosition();
}
}
}
},
// full animation transition
Transition {
from: "closed"
enabled: MobileShell.MobileShellSettings.animationsEnabled
SequentialAnimation {
ScriptAction {
script: {
root.opacity = 1;
root.visible = true;
}
}

View file

@ -13,6 +13,7 @@ import QtQuick.Controls 2.2 as QQC2
import org.kde.taskmanager 0.1 as TaskManager
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
Item {
id: delegate
@ -195,7 +196,7 @@ Item {
clip: true
// scale animation on press
property real zoomScale: tapHandler.pressed ? 0.9 : 1
property real zoomScale: (MobileShell.MobileShellSettings.animationsEnabled && tapHandler.pressed) ? 0.9 : 1
Behavior on zoomScale {
NumberAnimation {
duration: 200

View file

@ -201,7 +201,7 @@ QtObject {
target: root
property: "yPosition"
to: openedYPosition
duration: 300
duration: MobileShell.MobileShellSettings.animationsEnabled ? 300 : 0
easing.type: Easing.OutBack
onFinished: {
@ -213,7 +213,7 @@ QtObject {
target: root
property: "yPosition"
to: 0
duration: PlasmaCore.Units.longDuration
duration: MobileShell.MobileShellSettings.animationsEnabled ? PlasmaCore.Units.longDuration : 0
easing.type: Easing.InOutQuad
onFinished: {
@ -230,7 +230,7 @@ QtObject {
target: root
property: "yPosition"
to: 0
duration: 300
duration: MobileShell.MobileShellSettings.animationsEnabled ? 300 : 0
easing.type: Easing.OutQuint
onFinished: {

View file

@ -114,8 +114,8 @@ ContainmentLayoutManager.ItemContainer {
NumberAnimation on zoomScale {
id: shrinkAnim
running: false
duration: 80
to: 0.8
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
to: MobileShell.MobileShellSettings.animationsEnabled ? 0.8 : 1
onFinished: {
if (!mouseArea.pressed) {
growAnim.restart();
@ -126,7 +126,7 @@ ContainmentLayoutManager.ItemContainer {
NumberAnimation on zoomScale {
id: growAnim
running: false
duration: 80
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
to: 1
onFinished: {
if (mouseArea.launchAppRequested) {

View file

@ -58,8 +58,8 @@ MouseArea {
NumberAnimation on zoomScale {
id: shrinkAnim
running: false
duration: 80
to: 0.8
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
to: MobileShell.MobileShellSettings.animationsEnabled ? 0.8 : 1
onFinished: {
if (!delegate.pressed) {
growAnim.restart();
@ -70,7 +70,7 @@ MouseArea {
NumberAnimation on zoomScale {
id: growAnim
running: false
duration: 80
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
to: 1
onFinished: {
if (delegate.launchAppRequested) {

View file

@ -40,13 +40,24 @@ KCM.SimpleKCM {
MobileForm.FormSwitchDelegate {
text: i18n("Shell Vibrations")
description: i18n("Whether to have vibrations enabled in the shell.")
checked: !MobileShell.MobileShellSettings.vibrationsEnabled
checked: MobileShell.MobileShellSettings.vibrationsEnabled
onCheckedChanged: {
if (checked != !MobileShell.MobileShellSettings.vibrationsEnabled) {
MobileShell.MobileShellSettings.vibrationsEnabled = !checked;
}
}
}
MobileForm.FormSwitchDelegate {
text: i18n("Animations")
description: i18n("If this is off, animations will be reduced as much as possible.")
checked: MobileShell.MobileShellSettings.animationsEnabled
onCheckedChanged: {
if (checked != !MobileShell.MobileShellSettings.animationsEnabled) {
MobileShell.MobileShellSettings.animationsEnabled = !checked;
}
}
}
}
}