Bug 258570 - Time selection dialog: Can only select hour 0-11 what about 15?
Summary: Time selection dialog: Can only select hour 0-11 what about 15?
Status: CLOSED FIXED
Alias: None
Product: KOrganizer Mobile
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: Maemo 5 Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-02 15:16 UTC by Ludwig Reiter
Modified: 2011-01-21 13:15 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludwig Reiter 2010-12-02 15:16:24 UTC
Version:           unspecified (using Devel) 
OS:                Linux

version 20101202-1202744-1maemo1

Reproducible: Always

Steps to Reproduce:
Start new event
Open time selection dialog.
Try to enter a afternoon time with the clock

Actual Results:  
Not possible.

Expected Results:  
It should be possible to select afternoon times with the clock, too. An am/pm switch is needed.
Comment 1 Tobias Koenig 2011-01-06 12:52:48 UTC
	A	 mobile/lib/Switch.qml	 [License: Trivialfile.]

commit a848ee55ada0936d52dd73e96865e80878182031
Author: Tobias Koenig <tokoe@kde.org>
Date:   Thu Jan 6 12:52:21 2011 +0100

    Add AM/PM switch to ClockDialog
    
    The switch allows to change AM/PM, so that the complete
    time range (0-23) can be set with the Clock QML element.
    
    BUG: 258570

diff --git a/mobile/lib/CMakeLists.txt b/mobile/lib/CMakeLists.txt
index 4dcf5cd..bf8ea53 100644
--- a/mobile/lib/CMakeLists.txt
+++ b/mobile/lib/CMakeLists.txt
@@ -120,6 +120,7 @@ install(FILES
   SearchDialog.qml
   SearchResultScreen.qml
   ItemEditButton.qml
+  Switch.qml
   DESTINATION ${PLUGIN_INSTALL_DIR}/imports/org/kde/pim/mobileui)
 install(FILES
   ${CMAKE_CURRENT_BINARY_DIR}/stylesheet.css
diff --git a/mobile/lib/Switch.qml b/mobile/lib/Switch.qml
new file mode 100644
index 0000000..6f472d0
--- /dev/null
+++ b/mobile/lib/Switch.qml
@@ -0,0 +1,81 @@
+import Qt 4.7
+
+Item {
+  id: toggleswitch
+  width: background.width
+  height: background.height
+
+  property bool on: false
+
+  function setOn( value )
+  {
+    if ( value )
+      toggleswitch.state = "on";
+    else
+      toggleswitch.state = "off";
+  }
+
+  function toggle() {
+    if ( toggleswitch.state == "on" )
+      toggleswitch.state = "off";
+    else
+      toggleswitch.state = "on";
+  }
+
+  function releaseSwitch() {
+    if ( handle.x == 1 ) {
+      if ( toggleswitch.state == "off" )
+        return;
+    }
+    if ( handle.x == 78 ) {
+      if ( toggleswitch.state == "on" )
+        return;
+    }
+
+    toggle();
+  }
+
+  Image {
+    id: background
+    source : "images/sliderbackground.png";
+    MouseArea {
+      anchors.fill: parent
+      onClicked: toggle()
+    }
+  }
+
+  Image {
+    id: handle
+    x: 1;
+    y: 2
+    source : "images/sliderhandle.png";
+
+    MouseArea {
+      anchors.fill: parent
+      drag.target: handle
+      drag.axis: Drag.XAxis
+      drag.minimumX: 1
+      drag.maximumX: 78
+
+      onClicked: toggle()
+      onReleased: releaseSwitch()
+    }
+  }
+
+  states: [
+    State {
+      name: "on"
+      PropertyChanges { target: handle; x: 78 }
+      PropertyChanges { target: toggleswitch; on: true }
+    },
+    State {
+      name: "off"
+      PropertyChanges { target: handle; x: 1 }
+      PropertyChanges { target: toggleswitch; on: false }
+    }
+  ]
+
+  transitions: Transition {
+    NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 }
+  }
+}
diff --git a/mobile/lib/calendar/ClockDialog.qml b/mobile/lib/calendar/ClockDialog.qml
index 1eadf48..679fbff 100644
--- a/mobile/lib/calendar/ClockDialog.qml
+++ b/mobile/lib/calendar/ClockDialog.qml
@@ -40,7 +40,7 @@ Dialog {
         anchors {
           left: parent.left
           top: parent.top
-          bottom: parent.bottom
+          bottom: amPmSwitch.top
 
           topMargin: 25
           bottomMargin: 25
@@ -59,6 +59,24 @@ Dialog {
         }
       }
 
+      KPIM.Switch {
+        id: amPmSwitch
+        anchors.bottom: parent.bottom
+        anchors.horizontalCenter: myClock.horizontalCenter
+
+        onOnChanged: {
+          if ( on ) { // pm selected
+            if ( myClock.hours < 12 ) {
+              myClock.hours = myClock.hours + 12;
+            }
+          } else { // am selected
+            if ( myClock.hours >= 12 ) {
+              myClock.hours = myClock.hours - 12;
+            }
+          }
+        }
+      }
+
       Column {
         spacing: 5
         anchors {
@@ -77,6 +95,7 @@ Dialog {
 
           onValueChanged: {
             myClock.hours = value;
+            amPmSwitch.setOn( myClock.hours >= 12 );
             clockWidgetOk.enabled = true;
           }
           onSelected: {
@@ -107,6 +126,7 @@ Dialog {
               minuteSelector.setValue(myClock.minutes);
           }
         }
+
       }
       Row {
         spacing: 5
diff --git a/mobile/lib/qmldir b/mobile/lib/qmldir
index 98af54b..fafb57d 100644
--- a/mobile/lib/qmldir
+++ b/mobile/lib/qmldir
@@ -43,3 +43,4 @@ ActionButton 4.5 ActionButton.qml
 ItemEditButton 4.5 ItemEditButton.qml
 DecoratedFlickable 4.5 DecoratedFlickable.qml
 DecoratedListView 4.5 DecoratedListView.qml
+Switch 4.5 Switch.qml
Comment 2 Ludwig Reiter 2011-01-21 13:15:01 UTC
Calendar Touch (Windows CE) 2011-01-20 git-d974996

Test of the description: passed.

It is possible with a silder on bottom to select am/pm.

Closed.