diff options
author | Tomasz Olszak <olszak.tomasz@gmail.com> | 2013-06-24 19:52:41 +0000 |
---|---|---|
committer | Jarosław Staniek <staniek@kde.org> | 2013-06-26 19:53:14 +0200 |
commit | 4fa884a79e4fd46a553aa5ad1b8d6b02ff27f414 (patch) | |
tree | 90c72977fc6a452e2e53e95911e122508bde87fe | |
parent | 4c7edecce74747e6b271558c3a65e5e4b6301fa1 (diff) | |
download | qtquickcontrols-tizen-4fa884a79e4fd46a553aa5ad1b8d6b02ff27f414.tar.gz qtquickcontrols-tizen-4fa884a79e4fd46a553aa5ad1b8d6b02ff27f414.tar.bz2 qtquickcontrols-tizen-4fa884a79e4fd46a553aa5ad1b8d6b02ff27f414.zip |
Added TimeEdit
Change-Id: If3fc9aa7fda7c1de5e2239f75c6fd00f0b546211
Reviewed-by: Jarosław Staniek <staniek@kde.org>
-rw-r--r-- | examples/touch/content/DateTimeEditPage.qml | 14 | ||||
-rw-r--r-- | src/controls/TimeEdit.qml | 37 | ||||
-rw-r--r-- | src/controls/controls.pro | 5 | ||||
-rw-r--r-- | src/controls/qmldir | 1 | ||||
-rw-r--r-- | src/styles/TimeEditStyle.qml | 117 | ||||
-rw-r--r-- | src/styles/qmldir | 1 | ||||
-rw-r--r-- | src/styles/styles.pro | 5 |
7 files changed, 175 insertions, 5 deletions
diff --git a/examples/touch/content/DateTimeEditPage.qml b/examples/touch/content/DateTimeEditPage.qml index a208016..8046604 100644 --- a/examples/touch/content/DateTimeEditPage.qml +++ b/examples/touch/content/DateTimeEditPage.qml @@ -65,5 +65,19 @@ Item { enabled: false } } + Column { + Label { + text:"Time" + } + + TimeEdit { amPmDisplay: false } + } + Column { + Label { + text:"Time AM/PM" + } + + TimeEdit { } + } } } diff --git a/src/controls/TimeEdit.qml b/src/controls/TimeEdit.qml new file mode 100644 index 0000000..ab3d2ed --- /dev/null +++ b/src/controls/TimeEdit.qml @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.1 +import QtQuick.Controls.Private 1.0 + +Control { + id: root + + property date time: new Date() + property bool amPmDisplay: true + + onTimeChanged: { + var tmp = new Date(0,0,0,time.getHours(),time.getMinutes()) + if (time !== tmp) { + time = tmp + } + } + + style: Qt.createComponent(Settings.style + "/TimeEditStyle.qml", root) +} diff --git a/src/controls/controls.pro b/src/controls/controls.pro index ef7907b..22c0720 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -9,9 +9,8 @@ QML_FILES += \ ScrollDecorator.qml\ Popup.qml\ BusyIndicator.qml \ - ScrollDecorator.qml \ - BusyIndicator.qml\ - DateEdit.qml + DateEdit.qml\ + TimeEdit.qml \ TitleBar.qml \ ToolBar.qml \ View.qml diff --git a/src/controls/qmldir b/src/controls/qmldir index 2ab4277..245c1e1 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -9,5 +9,6 @@ Popup 1.0 Popup.qml BusyIndicator 1.0 BusyIndicator.qml DateEdit 1.0 DateEdit.qml TitleBar 1.0 TitleBar.qml +TimeEdit 1.0 TimeEdit.qml ToolBar 1.0 ToolBar.qml View 1.0 View.qml diff --git a/src/styles/TimeEditStyle.qml b/src/styles/TimeEditStyle.qml new file mode 100644 index 0000000..eb0df57 --- /dev/null +++ b/src/styles/TimeEditStyle.qml @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.1 +import QtQuick.Controls.Private 1.0 +import QtQuick.Controls 1.0 +import QtQuick.Controls.Tizen 1.0 +import "DefaultSettings.js" as Theme +import "private" +Style { + id:style + property TimeEdit control: __control + + function getHours(amPm) { + return amPm ? Qt.formatTime(control.time,"hh ap").slice(0,2) : Qt.formatTime(control.time,"hh") + } + + property Component panel: Item { + id: timeItem + implicitWidth: row.width + implicitHeight: Theme.dateEdit.content.date.height + anchors.fill: parent + StateGroup { + id:stateGroup + states: [ + State { + name:"" + }, + State { + when: hoursField.pressed + name: "pickHours" + PropertyChanges {target: floater;anchorItem: hoursField; visible: true; timeModel: "Hours"} + }, + State { + when: minutesField.pressed + name: "pickMinutes" + PropertyChanges {target: floater; anchorItem: minutesField; visible: true; timeModel: "Minutes"} + } + ] + } + + Row { + id:row + height: timeItem.height + spacing: Theme.dateEdit.content.margin + anchors.centerIn: parent + DateEditField { + id:hoursField + implicitWidth: 69 + text: getHours(control.amPmDisplay) + } + Text { + width: 12 + 5 + 5 + height: Theme.dateEdit.content.date.height + text: ":" + font.pixelSize: 34 + minimumPixelSize: 1 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + fontSizeMode: Text.Fit + } + DateEditField { + id:minutesField + implicitWidth: 69 + text: Qt.formatTime(control.time,"mm") + } + Button { + visible: control.amPmDisplay + id:yearField + implicitWidth: 95 + implicitHeight: 60 + text: control.time.getHours() >= 12 ? "PM" : "AM" + anchors.verticalCenter: parent.verticalCenter + onClicked: { + var tmp = control.time + if (text == "AM") { + tmp.setHours(tmp.getHours()+12) + } else { + tmp.setHours(tmp.getHours()-12) + } + control.time = tmp + text = Qt.binding(function() {return control.time.getHours() >= 12 ? "PM" : "AM"}) + } + } + } + + Floater { + id: floater + anchors.fill: parent + property Item anchorItem: null + property string timeModel + content: DateEditBarPicker{ + id: floaterContent + root: floater.parent + anchorItem: floater.anchorItem + control: style.control + model: floater.timeModel + } + } + } +} diff --git a/src/styles/qmldir b/src/styles/qmldir index a855663..61c3e1d 100644 --- a/src/styles/qmldir +++ b/src/styles/qmldir @@ -14,6 +14,7 @@ ContextMenuStyle 1.0 ContextMenuStyle.qml PopupStyle 1.0 PopupStyle.qml BusyIndicatorStyle 1.0 BusyIndicatorStyle.qml DateEditStyle 1.0 DateEditStyle.qml +TimeEditStyle 1.0 TimeEditStyle.qml Theme 1.0 DefaultSettings.js TitleBarStyle 1.0 TitleBarStyle.qml ToolBarStyle 1.0 ToolBarStyle.qml diff --git a/src/styles/styles.pro b/src/styles/styles.pro index 379d015..76152ba 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -18,9 +18,10 @@ QML_FILES = \ BusyIndicatorStyle.qml \ TitleBarStyle.qml \ ViewStyle.qml \ + DateEditStyle.qml\ + TimeEditStyle.qml \ ToolBarStyle.qml \ - ToolBarButton.qml \ - DateEditStyle.qml + ToolBarButton.qml QML_FILES += \ |