Commit 7dd80c42 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Create a time picker sheet component

The time picker sheet will make easier the co-existence of start/end time pickers in a single page and will be re-used wherever needed.
parent 734a7b27
......@@ -38,7 +38,6 @@ Kirigami.Page {
property alias location: location.text
property var calendar
property var eventData
property alias timePicker: timePickerSheet
property date enddt
property alias endHour: endTimeSelector.endHour
property alias endMinute: endTimeSelector.endMinutes
......@@ -105,23 +104,20 @@ Kirigami.Page {
enabled: !allDaySelector.checked
onClicked: {
timePickerSheet.hours = startTimeSelector.startHour
timePickerSheet.minutes = startTimeSelector.startMinutes
timePickerSheet.pm = startTimeSelector.startPm
timePickerSheet.type = "start-picker"
startTimePickerSheet.hours = startTimeSelector.startHour
startTimePickerSheet.minutes = startTimeSelector.startMinutes
startTimePickerSheet.pm = startTimeSelector.startPm
timePickerSheet.open()
startTimePickerSheet.open()
}
Connections {
target: timePickerSheet
target: startTimePickerSheet
onDatePicked: {
if(timePickerSheet.type == "start-picker") {
startTimeSelector.startHour = timePickerSheet.hours
startTimeSelector.startMinutes = timePickerSheet.minutes
startTimeSelector.startPm = timePickerSheet.pm
}
startTimeSelector.startHour = startTimePickerSheet.hours
startTimeSelector.startMinutes = startTimePickerSheet.minutes
startTimeSelector.startPm = startTimePickerSheet.pm
}
}
}
......@@ -134,7 +130,7 @@ Kirigami.Page {
Controls2.ToolButton {
id: endTimeSelector
property int endHour: root.eventData ? root.eventData.dtend.toLocaleTimeString(Qt.locale(), "hh") % 12 : 0
property int endHour: root.eventData ? root.eventData.dtend.toLocaleTimeString(Qt.locale(), "hh") % 12 : 0
property int endMinutes: root.eventData ? root.eventData.dtend.toLocaleTimeString(Qt.locale(), "mm") : 0
property bool endPm : (root.eventData && root.eventData.dtend.toLocaleTimeString(Qt.locale("en_US"), "AP") == "PM") ? true : false
......@@ -143,23 +139,20 @@ Kirigami.Page {
enabled: !allDaySelector.checked
onClicked: {
timePickerSheet.hours = endTimeSelector.endHour
timePickerSheet.minutes = endTimeSelector.endMinutes
timePickerSheet.pm = endTimeSelector.endPm
timePickerSheet.type = "end-picker"
endTimePickerSheet.hours = endTimeSelector.endHour
endTimePickerSheet.minutes = endTimeSelector.endMinutes
endTimePickerSheet.pm = endTimeSelector.endPm
timePickerSheet.open()
endTimePickerSheet.open()
}
Connections {
target: timePickerSheet
target: endTimePickerSheet
onDatePicked: {
if(timePickerSheet.type == "end-picker") {
endTimeSelector.endHour = timePickerSheet.hours
endTimeSelector.endMinutes = timePickerSheet.minutes
endTimeSelector.endPm = timePickerSheet.pm
}
endTimeSelector.endHour = endTimePickerSheet.hours
endTimeSelector.endMinutes = endTimePickerSheet.minutes
endTimeSelector.endPm = endTimePickerSheet.pm
}
}
}
......@@ -251,51 +244,12 @@ Kirigami.Page {
}
}
Kirigami.OverlaySheet {
id: timePickerSheet
property int hours
property int minutes
property bool pm
property string type
signal datePicked
rightPadding: 0
leftPadding: 0
contentItem: TimePicker {
id: timePicker
hours: timePickerSheet.hours
minutes: timePickerSheet.minutes
pm: timePickerSheet.pm
}
TimePickerSheet {
id: startTimePickerSheet
}
footer: RowLayout {
Item {
Layout.fillWidth: true
}
Controls2.ToolButton {
text: qsTr("OK")
onClicked: {
timePickerSheet.hours = timePicker.hours
timePickerSheet.minutes = timePicker.minutes
timePickerSheet.pm = timePicker.pm
timePickerSheet.datePicked()
timePickerSheet.close()
}
}
Controls2.ToolButton {
text: qsTr("Cancel")
onClicked: {
timePicker.hours = timePickerSheet.hours
timePicker.minutes = timePickerSheet.minutes
timePicker.pm = timePickerSheet.pm
timePickerSheet.close()
}
}
}
TimePickerSheet {
id: endTimePickerSheet
}
Component {
......
/*
* Copyright 2019 Dimitris Kardarakos
*
* 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.0
import QtQuick.Controls 2.4 as Controls2
import QtQuick.Layouts 1.11
import org.kde.kirigami 2.4 as Kirigami
import org.kde.phone.calindori 0.1 as Calindori
Kirigami.OverlaySheet {
id: timePickerSheet
property int hours
property int minutes
property bool pm
signal datePicked
rightPadding: 0
leftPadding: 0
contentItem: TimePicker {
id: timePicker
hours: timePickerSheet.hours
minutes: timePickerSheet.minutes
pm: timePickerSheet.pm
}
footer: RowLayout {
Item {
Layout.fillWidth: true
}
Controls2.ToolButton {
text: qsTr("OK")
onClicked: {
timePickerSheet.hours = timePicker.hours
timePickerSheet.minutes = timePicker.minutes
timePickerSheet.pm = timePicker.pm
timePickerSheet.datePicked()
timePickerSheet.close()
}
}
Controls2.ToolButton {
text: qsTr("Cancel")
onClicked: {
timePicker.hours = timePickerSheet.hours
timePicker.minutes = timePickerSheet.minutes
timePicker.pm = timePickerSheet.pm
timePickerSheet.close()
}
}
}
}
......@@ -16,5 +16,6 @@
<file alias="ConfirmationSheet.qml">contents/ui/ConfirmationSheet.qml</file>
<file alias="EventsView.qml">contents/ui/EventsView.qml</file>
<file alias="EventEditor.qml">contents/ui/EventEditor.qml</file>
<file alias="TimePickerSheet.qml">contents/ui/TimePickerSheet.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