Commit a241f669 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

modules: time: Port Dialogs to Kirigami Sheets

parent c28d8da6
Pipeline #7338 passed with stage
in 12 minutes and 38 seconds
......@@ -29,6 +29,19 @@ SimpleKCM {
id: timeModule
objectName: "timeModule"
Component {
id: listDelegateComponent
Kirigami.BasicListItem {
text: display
onClicked: {
kcm.saveTimeZone(display)
close()
}
}
}
ColumnLayout {
width: parent.width
spacing: 0
......@@ -58,7 +71,7 @@ SimpleKCM {
Controls.ToolButton {
id: timeZoneButton
text: kcm.timeZone
onClicked: timeZonePickerDialog.open()
onClicked: timeZonePickerSheet.open()
}
}
......@@ -91,7 +104,7 @@ SimpleKCM {
var date = new Date(kcm.currentTime);
return date.toTimeString()
}
onClicked: timePickerDialog.open()
onClicked: timePickerSheet.open()
}
}
......@@ -103,51 +116,47 @@ SimpleKCM {
var date = new Date(kcm.currentDate);
return date.toDateString()
}
onClicked: datePickerDialog.open()
onClicked: datePickerSheet.open()
}
}
}
Controls.Dialog {
id: timeZonePickerDialog
title: i18n("Pick Timezone... (%1)", kcm.timeZone)
modal: true
standardButtons: Controls.Dialog.Ok
x: (parent.width - width) / 2
y: (parent.height - height) / 2
onAccepted: close()
width: Kirigami.Units.gridUnit * 20
height: Kirigami.Units.gridUnit * 25
Kirigami.OverlaySheet {
id: timeZonePickerSheet
header: Kirigami.Heading { text: i18nc("@title:window", "Pick Timezone") }
footer: RowLayout {
Controls.Button {
Layout.alignment: Qt.AlignHCenter
text: i18nc("@action:button", "Close")
onClicked: timePickerSheet.close()
}
}
ListView {
clip: true
anchors.fill: parent
delegate: Kirigami.BasicListItem {
text: display
implicitWidth: 18 * Kirigami.Units.gridUnit
model: kcm.timeZonesModel
delegate: Kirigami.DelegateRecycler {
width: parent.width
onClicked: {
kcm.saveTimeZone(display)
timeZonePickerDialog.accept()
}
sourceComponent: listDelegateComponent
}
model: kcm.timeZonesModel
}
}
Controls.Dialog {
id: timePickerDialog
title: i18n("Pick Time")
modal: true
standardButtons: Controls.Dialog.Ok
x: (parent.width - width) / 2
y: (parent.height - height) / 2
onAccepted: close()
width: Kirigami.Units.gridUnit * 20
height: Kirigami.Units.gridUnit * 15
contentItem: TimePicker {
Kirigami.OverlaySheet {
id: timePickerSheet
header: Kirigami.Heading { text: i18n("Pick Time") }
TimePicker {
id: timePicker
enabled: !ntpCheckBox.checked
twentyFour: twentyFourSwitch.checked
implicitWidth: width > Kirigami.Units.gridUnit * 15 ? width : Kirigami.Units.gridUnit * 15
Component.onCompleted: {
var date = new Date(kcm.currentTime);
timePicker.hours = date.getHours();
......@@ -172,22 +181,26 @@ SimpleKCM {
kcm.saveTime()
}
}
footer: RowLayout {
Controls.Button {
Layout.alignment: Qt.AlignRight
text: i18nc("@action:button", "Close")
onClicked: timePickerSheet.close()
}
}
}
Controls.Dialog {
id: datePickerDialog
title: i18n("Pick Date")
modal: true
standardButtons: Controls.Dialog.Ok
x: (parent.width - width) / 2
y: (parent.height - height) / 2
onAccepted: close()
width: Kirigami.Units.gridUnit * 20
height: Kirigami.Units.gridUnit * 15
contentItem: DatePicker {
Kirigami.OverlaySheet {
id: datePickerSheet
header: Kirigami.Heading { text: i18n("Pick Date") }
DatePicker {
id: datePicker
enabled: !ntpCheckBox.checked
implicitWidth: width > Kirigami.Units.gridUnit * 15 ? width : Kirigami.Units.gridUnit * 15
Component.onCompleted: {
var date = new Date(kcm.currentDate)
datePicker.day = date.getDate()
......@@ -213,5 +226,14 @@ SimpleKCM {
kcm.saveTime()
}
}
footer: RowLayout {
Controls.Button {
Layout.alignment: Qt.AlignRight
text: i18nc("@action:button", "Close")
onClicked: timePickerSheet.close()
}
}
}
}
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