https://bugs.kde.org/show_bug.cgi?id=258570
Tobias Koenig <to...@kde.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #1 from Tobias Koenig <tokoe kde org> 2011-01-06 12:52:48 --- A mobile/lib/Switch.qml [License: Trivialfile.] commit a848ee55ada0936d52dd73e96865e80878182031 Author: Tobias Koenig <to...@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 -- Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. _______________________________________________ Kdepim-bugs mailing list Kdepim-bugs@kde.org https://mail.kde.org/mailman/listinfo/kdepim-bugs