From 62e7dce24ab9c7121fb0dcd87ab022d4db4fee03 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Fri, 29 Apr 2022 20:02:33 -0400 Subject: [PATCH] kcm: Add reduced animation mode Implement #190 reduced animations mode --- .../mobileshell/mobileshellsettings.cpp | 14 +++++++ components/mobileshell/mobileshellsettings.h | 5 +++ .../qml/components/StartupFeedback.qml | 38 +++++++++++++++++++ .../mobileshell/qml/taskswitcher/Task.qml | 3 +- .../qml/taskswitcher/TaskSwitcherState.qml | 6 +-- .../package/contents/ui/HomeDelegate.qml | 6 +-- .../ui/appdrawer/DrawerGridDelegate.qml | 6 +-- kcms/mobileshell/package/contents/ui/main.qml | 13 ++++++- 8 files changed, 80 insertions(+), 11 deletions(-) diff --git a/components/mobileshell/mobileshellsettings.cpp b/components/mobileshell/mobileshellsettings.cpp index ce87987a..ea8f7eae 100644 --- a/components/mobileshell/mobileshellsettings.cpp +++ b/components/mobileshell/mobileshellsettings.cpp @@ -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}; diff --git a/components/mobileshell/mobileshellsettings.h b/components/mobileshell/mobileshellsettings.h index 742f4f81..1bc5d2bc 100644 --- a/components/mobileshell/mobileshellsettings.h +++ b/components/mobileshell/mobileshellsettings.h @@ -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(); diff --git a/components/mobileshell/qml/components/StartupFeedback.qml b/components/mobileshell/qml/components/StartupFeedback.qml index c849ce8c..cd057c55 100644 --- a/components/mobileshell/qml/components/StartupFeedback.qml +++ b/components/mobileshell/qml/components/StartupFeedback.qml @@ -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; } } diff --git a/components/mobileshell/qml/taskswitcher/Task.qml b/components/mobileshell/qml/taskswitcher/Task.qml index d1455fa8..68c86e92 100644 --- a/components/mobileshell/qml/taskswitcher/Task.qml +++ b/components/mobileshell/qml/taskswitcher/Task.qml @@ -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 diff --git a/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml b/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml index 98f6abcf..242567f0 100644 --- a/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml +++ b/components/mobileshell/qml/taskswitcher/TaskSwitcherState.qml @@ -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: { diff --git a/containments/homescreen/package/contents/ui/HomeDelegate.qml b/containments/homescreen/package/contents/ui/HomeDelegate.qml index fbf16e38..b13b2231 100644 --- a/containments/homescreen/package/contents/ui/HomeDelegate.qml +++ b/containments/homescreen/package/contents/ui/HomeDelegate.qml @@ -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) { diff --git a/containments/homescreen/package/contents/ui/appdrawer/DrawerGridDelegate.qml b/containments/homescreen/package/contents/ui/appdrawer/DrawerGridDelegate.qml index 69ff42af..3b777d07 100644 --- a/containments/homescreen/package/contents/ui/appdrawer/DrawerGridDelegate.qml +++ b/containments/homescreen/package/contents/ui/appdrawer/DrawerGridDelegate.qml @@ -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) { diff --git a/kcms/mobileshell/package/contents/ui/main.qml b/kcms/mobileshell/package/contents/ui/main.qml index ff9dea2f..f8eefee1 100644 --- a/kcms/mobileshell/package/contents/ui/main.qml +++ b/kcms/mobileshell/package/contents/ui/main.qml @@ -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; + } + } + } } }