diff --git a/modules/time/package/contents/ui/Time.qml b/modules/time/package/contents/ui/Time.qml index 1c17852..7f0d924 100644 --- a/modules/time/package/contents/ui/Time.qml +++ b/modules/time/package/contents/ui/Time.qml @@ -1,218 +1,217 @@ // -*- coding: iso-8859-1 -*- /* * Copyright 2011 Sebastian Kügler * * 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.7 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.3 as Controls import org.kde.kirigami 2.4 as Kirigami -import org.kde.active.settings 2.0 import org.kde.kcm 1.2 SimpleKCM { id: timeModule objectName: "timeModule" ColumnLayout { width: parent.width spacing: 0 id: formLayout Kirigami.Heading { leftPadding: Kirigami.Units.smallSpacing text: i18n("Time Display") level: 3 } Kirigami.BasicListItem { label: i18n("Use 24-hour clock:") icon: "clock" Controls.Switch { id: twentyFourSwitch checked: kcm.twentyFour onClicked : { kcm.twentyFour = checked print(kcm.timeZone); } } } Kirigami.BasicListItem { label: "Timezone:" Controls.ToolButton { id: timeZoneButton text: kcm.timeZone onClicked: timeZonePickerDialog.open() } } Kirigami.Heading { leftPadding: Kirigami.Units.smallSpacing text: i18n("Set Time and Date") level: 3 } Kirigami.BasicListItem { label: i18n("Set time automatically:") Controls.Switch { id: ntpCheckBox checked: kcm.useNtp onClicked: { kcm.useNtp = checked; if (!checked) { kcm.ntpServer = "" kcm.saveTime() } } } } Kirigami.BasicListItem { label: i18n("Time") icon: "clock" Controls.ToolButton { text: { var date = new Date(kcm.currentTime); return date.toTimeString() } onClicked: timePickerDialog.open() } } Kirigami.BasicListItem { label: i18n("Date") icon: "office-calendar" Controls.ToolButton { text: { var date = new Date(kcm.currentDate); return date.toDateString() } onClicked: datePickerDialog.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 ListView { clip: true anchors.fill: parent delegate: Kirigami.BasicListItem { text: display onClicked: { kcm.saveTimeZone(display) timeZonePickerDialog.accept() } } 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 { id: timePicker enabled: !ntpCheckBox.checked twentyFour: twentyFourSwitch.checked Component.onCompleted: { var date = new Date(kcm.currentTime); timePicker.hours = date.getHours(); timePicker.minutes = date.getMinutes(); timePicker.seconds = date.getSeconds(); } Connections { target: kcm onCurrentTimeChanged: { if (timePicker.userConfiguring) { return; } var date = new Date(kcm.currentTime); timePicker.hours = date.getHours(); timePicker.minutes = date.getMinutes(); timePicker.seconds = date.getSeconds(); } } onUserConfiguringChanged: { kcm.currentTime = timeString kcm.saveTime() } } } 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 { id: datePicker enabled: !ntpCheckBox.checked Component.onCompleted: { var date = new Date(kcm.currentDate) datePicker.day = date.getDate() datePicker.month = date.getMonth()+1 datePicker.year = date.getFullYear() } Connections { target: kcm onCurrentDateChanged: { if (datePicker.userConfiguring) { return } var date = new Date(kcm.currentDate) datePicker.day = date.getDate() datePicker.month = date.getMonth()+1 datePicker.year = date.getFullYear() } } onUserConfiguringChanged: { kcm.currentDate = isoDate kcm.saveTime() } } } } diff --git a/modules/time/package/contents/ui/TimePicker.qml b/modules/time/package/contents/ui/TimePicker.qml index e612114..ededdae 100644 --- a/modules/time/package/contents/ui/TimePicker.qml +++ b/modules/time/package/contents/ui/TimePicker.qml @@ -1,239 +1,238 @@ /* * Copyright 2011 Marco Martin * * 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.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.active.settings 2.0 //FIXME: shouldn't be a FrameSvgItem Item { id: root clip: true //////// API property alias hours: clockRow.hours property alias minutes: clockRow.minutes property alias seconds: clockRow.seconds property bool userConfiguring: false property bool twentyFour: true property int fontSize: 14 property int _margin: units.gridUnit property string timeString: clockRow.twoDigitString(hours) + ":" + clockRow.twoDigitString(minutes) + ":" + clockRow.twoDigitString(seconds) opacity: enabled ? 1.0 : 0.5 Connections { target: root // onHoursChanged: print("H : " + root.hours) // onMinutesChanged: print("M : " + root.minutes) // onSecondsChanged: print("S : " + root.seconds) } Behavior on width { SequentialAnimation { PauseAnimation { duration: 250 } NumberAnimation { //duration: units.longDuration duration: 250 easing.type: Easing.InOutQuad } } } // KLocale.Locale { // id: locale // } //imagePath: "widgets/picker" width: clockRow.width + root._margin height: clockRow.height + root._margin * 2 Timer { id: userConfiguringTimer repeat: false interval: 1500 running: false onTriggered: { root.hours = clockRow.hours root.minutes = clockRow.minutes root.seconds = clockRow.seconds userConfiguring = false } } Rectangle { color: "transparent" opacity: 0.3 border.color: theme.textColor border.width: 1 anchors.fill: parent } Row { id: clockRow spacing: units.gridUnit x: root._margin y: root._margin property int hours property int minutes property int seconds function twoDigitString(number) { return number < 10 ? "0"+number : number } Digit { id: hoursDigit model: root.twentyFour ? 24 : 12 currentIndex: root.twentyFour || hours < 12 ? hours : hours - 12 delegate: Text { horizontalAlignment: Text.AlignHCenter width: hoursDigit.width property int ownIndex: index text: (!root.twentyFour && index == 0) ? "12" : clockRow.twoDigitString(index) font.pointSize: root.fontSize color: theme.textColor opacity: PathView.itemOpacity } onSelectedIndexChanged: { print("Bah"); if (selectedIndex > -1) { if (root.twentyFour || meridiaeDigit.isAm) { hours = selectedIndex } else { hours = selectedIndex + 12 } } } } PlasmaCore.SvgItem { svg: PlasmaCore.Svg {imagePath: "widgets/line"} elementId: "vertical-line" width: naturalSize.width anchors { top: parent.top bottom:parent.bottom } } Digit { id: minutesDigit model: 60 currentIndex: minutes onSelectedIndexChanged: { if (selectedIndex > -1) { minutes = selectedIndex } } } PlasmaCore.SvgItem { svg: PlasmaCore.Svg {imagePath: "widgets/line"} elementId: "vertical-line" width: naturalSize.width anchors { top: parent.top bottom:parent.bottom } } Digit { id: secondsDigit model: 60 currentIndex: seconds onSelectedIndexChanged: { if (selectedIndex > -1) { seconds = selectedIndex } } } PlasmaCore.SvgItem { opacity: meridiaeDigit.opacity == 0 ? 0 : 1 svg: PlasmaCore.Svg {imagePath: "widgets/line"} elementId: "vertical-line" width: naturalSize.width anchors { top: parent.top bottom:parent.bottom } Behavior on opacity { NumberAnimation { duration: 250 easing.type: Easing.InOutQuad } } } Digit { id: meridiaeDigit visible: opacity != 0 opacity: root.twentyFour ? 0 : 1 property bool isAm: (selectedIndex > -1) ? (selectedIndex < 1) : (currentIndex < 1) model: ListModel { ListElement { meridiae: "AM" } ListElement { meridiae: "PM" } } delegate: Text { width: meridiaeDigit.width horizontalAlignment: Text.AlignLeft property int ownIndex: index text: meridiae color: theme.textColor font.pointSize: root.fontSize //opacity: PathView.itemOpacity } currentIndex: hours > 12 ? 1 : 0 onSelectedIndexChanged: { if (selectedIndex > -1) { //AM if (selectedIndex == 0) { hours -= 12 //PM } else { hours += 12 } } } width: meridiaePlaceHolder.width + root._margin Text { id: meridiaePlaceHolder visible: false font.pointSize: root.fontSize text: "00" } Behavior on opacity { NumberAnimation { duration: 250 easing.type: Easing.InOutQuad } } } } }