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