Paste P442

Masterwork From Distant Lands
ActivePublic

Authored by davidedmundson on Aug 1 2019, 9:22 PM.
commit b78d4e4883b36db337e6af0efb9b1e0060ba2fb9
Author: David Edmundson <kde@davidedmundson.co.uk>
Date: Thu Jul 18 22:57:05 2019 +0200
animation speed
diff --git a/kcms/workspaceoptions/package/contents/ui/main.qml b/kcms/workspaceoptions/package/contents/ui/main.qml
index 1f69c0156..53bbd3d15 100644
--- a/kcms/workspaceoptions/package/contents/ui/main.qml
+++ b/kcms/workspaceoptions/package/contents/ui/main.qml
@@ -17,7 +17,7 @@
*/
import QtQuick 2.7
import QtQuick.Controls 2.4 as Controls
-import QtQuick.Layouts 1.3 as Layouts
+import QtQuick.Layouts 1.3
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kcm 1.2 as KCM
@@ -47,6 +47,38 @@ KCM.SimpleKCM {
onCheckedChanged: kcm.visualFeedback = checked
}
+ // Value is logarithmic, we want to represent this on a linear scale
+ RowLayout {
+ Kirigami.FormData.label: i18n("Animation speed:")
+
+ Controls.Label {
+ text: i18nc("Animation speed", "Slow")
+ }
+ Controls.Slider {
+ id: slider
+ Layout.fillWidth: true
+ from: -4
+ to: 5
+ stepSize: 1
+ snapMode: Controls.Slider.SnapAlways
+ onMoved: {
+ if(value === to) {
+ kcm.animationSpeed = 0;
+ } else {
+ kcm.animationSpeed = Math.pow(2, value);
+ }
+ }
+ value: if (kcm.animationSpeed === 0) {
+ return slider.to;
+ } else {
+ return Math.log(kcm.animationSpeed) / Math.log(2);
+ }
+ }
+ Controls.Label {
+ text: i18nc("Animation speed", "Instant")
+ }
+ }
+
Connections {
target: kcm
onToolTipChanged: showToolTips.checked = kcm.toolTip
diff --git a/kcms/workspaceoptions/workspaceoptions.cpp b/kcms/workspaceoptions/workspaceoptions.cpp
index b912a668c..882f9ab3d 100644
--- a/kcms/workspaceoptions/workspaceoptions.cpp
+++ b/kcms/workspaceoptions/workspaceoptions.cpp
@@ -127,6 +127,21 @@ void KCMWorkspaceOptions::setSingleClick(bool state)
handleNeedsSave();
}
+qreal KCMWorkspaceOptions::getAnimationSpeed() const
+{
+ return m_animationSpeed;
+}
+
+void KCMWorkspaceOptions::setAnimationSpeed(qreal speed)
+{
+ if (m_animationSpeed == speed) {
+ return;
+ }
+ m_animationSpeed = speed;
+ emit animationSpeedChanged();
+ handleNeedsSave();
+}
+
void KCMWorkspaceOptions::loadPlasmarc()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc"));
@@ -135,7 +150,6 @@ void KCMWorkspaceOptions::loadPlasmarc()
// Load toolTip
{
const KConfigGroup cg(config, QStringLiteral("PlasmaToolTips"));
-
state = cg.readEntry("Delay", 0.7) > 0;
setToolTip(state);
m_toolTipOriginalState = state;
@@ -154,16 +168,15 @@ void KCMWorkspaceOptions::loadPlasmarc()
void KCMWorkspaceOptions::loadKdeglobals()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kdeglobals"));
- bool state;
- // Load singleClick
- {
- const KConfigGroup cg(config, QStringLiteral("KDE"));
+ const KConfigGroup cg(config, QStringLiteral("KDE"));
- state = cg.readEntry(QStringLiteral("SingleClick"), true);
- setSingleClick(state);
- m_singleClickOriginalState = state;
- }
+ bool state = cg.readEntry(QStringLiteral("SingleClick"), true);
+ setSingleClick(state);
+ m_singleClickOriginalState = state;
+
+ setAnimationSpeed(cg.readEntry("AnimationSpeed", 1.0));
+ m_animationOriginalSpeed = m_animationSpeed;
}
void KCMWorkspaceOptions::savePlasmarc()
@@ -197,13 +210,15 @@ void KCMWorkspaceOptions::saveKdeglobals()
KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("kdeglobals"));
bool state;
- // Save singleClick
{
KConfigGroup cg(config, QStringLiteral("KDE"));
state = getSingleClick();
cg.writeEntry("SingleClick", state);
m_singleClickOriginalState = state;
+
+ cg.writeEntry("AnimationSpeed", m_animationSpeed, KConfig::Notify);
+ m_animationOriginalSpeed = m_animationSpeed;
}
config->sync();
@@ -223,7 +238,8 @@ void KCMWorkspaceOptions::handleNeedsSave()
{
setNeedsSave(m_toolTipOriginalState != getToolTip() ||
m_visualFeedbackOriginalState != getVisualFeedback() ||
- m_singleClickOriginalState != getSingleClick());
+ m_singleClickOriginalState != getSingleClick() ||
+ !qFuzzyCompare(m_animationOriginalSpeed, getAnimationSpeed()));
}
#include "workspaceoptions.moc"
diff --git a/kcms/workspaceoptions/workspaceoptions.h b/kcms/workspaceoptions/workspaceoptions.h
index 412b86048..96905e887 100644
--- a/kcms/workspaceoptions/workspaceoptions.h
+++ b/kcms/workspaceoptions/workspaceoptions.h
@@ -26,6 +26,7 @@ class KCMWorkspaceOptions : public KQuickAddons::ConfigModule
Q_PROPERTY(bool toolTip READ getToolTip WRITE setToolTip NOTIFY toolTipChanged)
Q_PROPERTY(bool visualFeedback READ getVisualFeedback WRITE setVisualFeedback NOTIFY visualFeedbackChanged)
Q_PROPERTY(bool singleClick READ getSingleClick WRITE setSingleClick NOTIFY singleClickChanged)
+ Q_PROPERTY(qreal animationSpeed READ getAnimationSpeed WRITE setAnimationSpeed NOTIFY animationSpeedChanged)
public:
KCMWorkspaceOptions(QObject* parent, const QVariantList& args);
@@ -41,6 +42,9 @@ public:
bool getSingleClick() const;
void setSingleClick(bool state);
+ qreal getAnimationSpeed() const;
+ void setAnimationSpeed(qreal speed);
+
public Q_SLOTS:
void load() override;
void save() override;
@@ -50,6 +54,7 @@ Q_SIGNALS:
void toolTipChanged();
void visualFeedbackChanged();
void singleClickChanged();
+ void animationSpeedChanged();
private:
void loadPlasmarc();
@@ -69,6 +74,9 @@ private:
bool m_singleClickOriginalState;
bool m_singleClickCurrentState;
+
+ qreal m_animationSpeed = 1.0;
+ qreal m_animationOriginalSpeed = 1.0;
};
#endif // _KCM_WORKSPACEOPTIONS_H
davidedmundson edited the content of this paste. (Show Details)Aug 1 2019, 9:22 PM
davidedmundson changed the title of this paste from untitled to Masterwork From Distant Lands.