Commit 30c05282 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Proof of concept of alternative time picker

parent 1dcc04e8
......@@ -27,16 +27,17 @@ import org.kde.phone.calindori 0.1 as Calindori
Kirigami.Page {
id: root
property date startdt;
property string uid;
property alias summary: summary.text;
property alias description: description.text;
property alias startHour: startHourSelector.value;
property alias startMinute: startMinuteSelector.value;
property alias allDay: allDaySelector.checked;
property alias location: location.text;
property var calendar;
property var todoData;
property date startdt
property string uid
property alias summary: summary.text
property alias description: description.text
property alias startHour: startTimeSelector.startHour
property alias startMinute: startTimeSelector.startMinutes
property alias allDay: allDaySelector.checked
property alias location: location.text
property var calendar
property var todoData
property alias timePicker: timePickerSheet
signal taskeditcompleted
......@@ -69,21 +70,16 @@ Kirigami.Page {
RowLayout {
Kirigami.FormData.label: qsTr("Start time:")
Controls2.SpinBox {
id: startHourSelector
Controls2.ToolButton {
id: startTimeSelector
enabled: !allDaySelector.checked
value: allDaySelector.checkedtodoData ? todoData.dtstart.toLocaleTimeString(Qt.locale(), "hh") : 0
from: 0
to: 23
}
Controls2.SpinBox {
id: startMinuteSelector
property int startHour: timePickerSheet.hours
property int startMinutes: timePickerSheet.minutes
text: startHour + ":" + startMinutes
enabled: !allDaySelector.checked
value: todoData ? todoData.dtstart.toLocaleTimeString(Qt.locale(), "mm") : 0
from: 0
to: 59
onClicked: timePickerSheet.open()
}
}
......@@ -170,4 +166,38 @@ Kirigami.Page {
}
Kirigami.OverlaySheet {
id: timePickerSheet
property int hours: todoData ? todoData.dtstart.toLocaleTimeString(Qt.locale(), "hh") : 0
property int minutes: todoData ? todoData.dtstart.toLocaleTimeString(Qt.locale(), "mm") : 0
ColumnLayout {
TimePicker {
id: timePicker
hours: timePickerSheet.hours
minutes: timePickerSheet.minutes
}
}
footer: RowLayout {
Item {
Layout.fillWidth: true
}
Controls2.ToolButton {
text: qsTr("OK")
onClicked: {
timePickerSheet.hours = timePicker.hours
timePickerSheet.minutes = timePicker.minutes
timePickerSheet.close()
}
}
Controls2.ToolButton {
text: qsTr("Cancel")
onClicked: timePickerSheet.close()
}
}
}
}
/*
* Copyright 2019 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program 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 or
* (at your option) any later version.
*
* This program 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 program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.12
import QtQuick.Controls 2.5 as Controls2
import org.kde.kirigami 2.0 as Kirigami
import QtQuick.Layouts 1.11
Controls2.ToolButton {
id: hoursButton
property int selectedValue
property string type
checkable: true
checked: index == selectedValue
autoExclusive: true
text: index == selectedValue ? ((type == "hours" && index == 0) ? 12 : index) : "."
contentItem: Controls2.Label {
text: hoursButton.text
color: index < parent.selectedValue ? Kirigami.Theme.activeTextColor : Kirigami.Theme.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
implicitHeight: Kirigami.Units.gridUnit
implicitWidth: width
radius: width*0.5
color: parent.checked ? Kirigami.Theme.buttonBackgroundColor : "transparent"
}
}
/*
* Copyright 2019 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program 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 or
* (at your option) any later version.
*
* This program 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 program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.12
import QtQuick.Controls 2.5 as Controls2
import org.kde.kirigami 2.0 as Kirigami
import QtQuick.Layouts 1.11
ColumnLayout {
id: root
property int hours
property int minutes
implicitWidth: clock.width
implicitHeight: clock.height
RowLayout {
Layout.alignment: Qt.AlignHCenter
Controls2.Label {
text: root.hours + ":" + root.minutes
}
//TODO: Handle AM/PM
// Controls2.ToolButton {
// id: pm
//
// checkable: true
//
// text: checked ? "PM" : "AM"
// }
}
Item {
id: clock
width: Kirigami.Units.gridUnit * 22
height: Kirigami.Units.gridUnit * 22
//Hours clock
PathView {
id: hoursClock
delegate: ClockElement {
type: "hours"
selectedValue: root.hours
onClicked: root.hours = index
}
model: 12
path: Path {
PathAngleArc {
centerX: Kirigami.Units.gridUnit * 10
centerY: Kirigami.Units.gridUnit * 10
radiusX: Kirigami.Units.gridUnit * 5
radiusY: Kirigami.Units.gridUnit * 5
startAngle: -90
sweepAngle: 360
}
}
}
PathView {
Path {
startX: 0
startY: Kirigami.Units.gridUnit * 10
PathArc {
x: 0
y: Kirigami.Units.gridUnit * 10
radiusX: Kirigami.Units.gridUnit * 5
radiusY: Kirigami.Units.gridUnit * 5
useLargeArc: true
}
}
}
//Minutes clock
PathView {
id: minutesClock
model: 60
delegate: ClockElement {
type: "minutes"
selectedValue: root.minutes
onClicked: root.minutes = index
}
path: Path {
PathAngleArc {
centerX: Kirigami.Units.gridUnit * 10
centerY: Kirigami.Units.gridUnit * 10
radiusX: Kirigami.Units.gridUnit * 8
radiusY: Kirigami.Units.gridUnit * 8
startAngle: -90
sweepAngle: 360
}
}
}
}
}
......@@ -10,5 +10,7 @@
<file alias="TodoPage.qml">contents/ui/TodoPage.qml</file>
<file alias="CalendarMonthView.qml">contents/ui/CalendarMonthView.qml</file>
<file alias="CalendarHeader.qml">contents/ui/kirigami-playground/CalendarHeader.qml</file>
<file alias="TimePicker.qml">contents/ui/kirigami-playground/TimePicker.qml</file>
<file alias="ClockElement.qml">contents/ui/kirigami-playground/ClockElement.qml</file>
</qresource>
</RCC>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment