[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/kde-artwork-active/lockscreen
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2012-01-31 12:46:31
Message-ID: 20120131124631.5245EAC893 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1276958 by aseigo:

implement sleep and shutdown sliders, including auto-sleep countdown on lock


 M  +115 -9    lockscreen-active.qml  


--- trunk/playground/base/plasma/kde-artwork-active/lockscreen/lockscreen-active.qml \
#1276957:1276958 @@ -19,6 +19,7 @@
 
 import QtQuick 1.0
 import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.plasma.components 0.1 as PlasmaComponents
 import org.kde.qtextracomponents 0.1
 
 
@@ -27,8 +28,20 @@
     width: 800
     height: 600
 
+    property bool suspendToRamSupported: false
+    property bool shutdownSupported: false
     signal unlockRequested()
+    signal suspendToRam()
+    signal shutdown()
 
+    onSuspendToRamSupportedChanged: {
+        sleepSlider.visible = suspendToRamSupported
+    }
+
+    onShutdownSupportedChanged: {
+        shutdownSlider.visible = shutdownSupported
+    }
+
     Image {
         source: "wallpaper.png"
         anchors.centerIn: parent
@@ -57,15 +70,7 @@
         height: 120
     }
 
-    PlasmaCore.DataSource {
-        id: timeSource
-        engine: "time"
-        connectedSources: ["Local"]
-        interval: 30000
-    }
-
-    //FIXME: use dataengines (needs bindings from libplasma)
-    // also, format with klocale
+    // TODO: format with klocale
     Timer {
         id: clockTimer
         repeat: true
@@ -107,7 +112,9 @@
             anchors.horizontalCenter: parent.horizontalCenter
             y: 100
         }
+
         Text {
+            id: timeText
             text: clockTimer.time
             font.pixelSize: 75
             font.family: theme.font.family
@@ -139,9 +146,108 @@
             }
         }
 
+        PlasmaComponents.Slider {
+            id: sleepSlider
+            maximumValue: 100
+            value: maximumValue
+            x: -4
+            anchors.top: timeText.top
+            property int autoStep: maximumValue / 50
+            property bool requestSent: false;
+            visible: suspendToRamSupported
+
+            onVisibleChanged: {
+                if (visible) {
+                    autoSleepTimer.running = true
+                } else {
+                    sleepText.text = i18n("Sleep")
     }
+            }
 
+            onValueChanged: {
+                if (value > 5) {
+                    requestSent = false
+                } else if (!requestSent) {
+                    autoSleepTimer.running = false
+                    value = maximumValue
+                    lockScreen.suspendToRam()
+                    requestSent = true
+                }
+            }
 
+            onPressedChanged: {
+                if (pressed) {
+                    autoSleepTimer.running = false
+                } else {
+                    value = maximumValue;
+                }
+            }
+
+            Text {
+                id: sleepText
+                text: i18n("Sleep")
+                anchors.horizontalCenter: parent.horizontalCenter
+                anchors.bottom: parent.top
+            }
+
+            Timer {
+                id: autoSleepTimer
+                repeat: true
+                running: false
+                interval: 100
+
+                onTriggered: {
+                    sleepSlider.value = sleepSlider.value - sleepSlider.autoStep;
+                    sleepText.text = i18np("Sleeping in 1 second", "Sleeping in %1 \
seconds", (sleepSlider.value / sleepSlider.autoStep * interval / 1000)) +             \
} +
+                onRunningChanged: {
+                    if (!running) {
+                        sleepSlider.value = sleepSlider.maximumValue
+                        sleepText.text = i18n("Sleep")
+                    }
+                }
+            }
+        }
+
+        PlasmaComponents.Slider {
+            id: shutdownSlider
+            maximumValue: 100
+            value: maximumValue
+            x: parent.width - width + 4
+            anchors.top: sleepSlider.top
+            visible: shutdownSupported
+            property bool requestSent: false;
+            rotation: 180
+
+            onValueChanged: {
+                if (value > 5) {
+                    requestSent = false;
+                } else if (!requestSent) {
+                    autoSleepTimer.running = false
+                    value = maximumValue
+                    lockScreen.shutdown()
+                    requestSent = true
+                }
+            }
+
+            onPressedChanged: {
+                if (!pressed) {
+                    value = maximumValue;
+                }
+            }
+
+        }
+
+            Text {
+                id: shutdownText
+                text: i18n("Shutdown")
+                //anchors.top: parent.bottom
+                anchors.bottom: shutdownSlider.top
+                anchors.horizontalCenter: shutdownSlider.horizontalCenter
+            }
+    }
+
     Image {
         id: lockerImage
         width: 64


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic