Warning, /libraries/kirigami-addons/src/dateandtime/TimePicker.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2019 Dimitris Kardarakos <dimkard@posteo.net>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.12
0008 import QtQuick.Controls 2.5 as Controls2
0009 import org.kde.kirigami 2.0 as Kirigami
0010 import QtQuick.Layouts 1.11
0011 import "private"
0012 
0013 /**
0014  * A large time picker
0015  * Represented as a clock provides a very visual way for a user
0016  * to set and visulise a time being chosen
0017  *
0018  * @deprecated The TimePicker element is deprecated. Please switch to use the TimeInput component directly.
0019  */
0020 Item {
0021     id: root
0022 
0023     property int hours
0024     property int minutes
0025     property bool pm
0026 
0027     Component.onCompleted: console.debug("The TimePicker element is deprecated. Please switch to use the TimeInput component directly.")
0028 
0029     ColumnLayout {
0030 
0031         anchors.fill: parent
0032 
0033         Item {
0034             id: clock
0035             Layout.fillWidth: true
0036             Layout.fillHeight: true
0037 
0038             //Hours clock
0039             PathView {
0040                 id: hoursClock
0041 
0042                 anchors.fill: parent
0043                 interactive: false
0044 
0045                 delegate: ClockElement {
0046                     type: "hours"
0047                     selectedValue: root.hours
0048                     onClicked: root.hours = index
0049                 }
0050                 model: 12
0051 
0052                 path: Path {
0053                     PathAngleArc {
0054                         centerX: clock.width / 2
0055                         centerY: clock.height / 2
0056                         radiusX: (Math.min(clock.width, clock.height) - Kirigami.Units.gridUnit) / 4
0057                         radiusY: radiusX
0058                         startAngle: -90
0059                         sweepAngle: 360
0060                     }
0061                 }
0062             }
0063 
0064             //Minutes clock
0065             PathView {
0066                 id: minutesClock
0067 
0068                 anchors.fill: parent
0069                 interactive: false
0070 
0071                 model: 60
0072 
0073                 delegate: ClockElement {
0074                     type: "minutes"
0075                     selectedValue: root.minutes
0076                     onClicked: root.minutes = index
0077                 }
0078 
0079                 path: Path {
0080                     PathAngleArc {
0081                         centerX: clock.width / 2
0082                         centerY: clock.height / 2
0083                         radiusX: (Math.min(clock.width, clock.height) - Kirigami.Units.gridUnit) / 2
0084                         radiusY: radiusX
0085                         startAngle: -90
0086                         sweepAngle: 360
0087                     }
0088                 }
0089             }
0090         }
0091 
0092         RowLayout {
0093             Layout.alignment: Qt.AlignHCenter
0094 
0095             Controls2.Label {
0096                 text: ((root.hours < 10) ? "0" : "" ) + root.hours + ":" + ( (root.minutes < 10) ? "0" : "") + root.minutes
0097                 font.pointSize: Kirigami.Units.fontMetrics.font.pointSize * 1.5
0098             }
0099 
0100             Controls2.ToolButton {
0101                 id: pm
0102 
0103                 checked: root.pm
0104                 checkable: true
0105                 text: checked ? "PM" : "AM"
0106                 font.pointSize: Kirigami.Units.fontMetrics.font.pointSize * 1.5
0107 
0108                 onClicked: root.pm = checked
0109             }
0110         }
0111     }
0112 }