Kirigami-addons

TimePopup.qml
1// SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4import QtQuick
5import QtQuick.Layouts
6import QtQuick.Controls as QQC2
7import org.kde.kirigami as Kirigami
8import org.kde.kirigamiaddons.components as Components
9
10QQC2.Dialog {
11 id: root
12
13 /**
14 * @brief The current date and time selected by the user.
15 */
16 property date value: new Date()
17
18 /**
19 * Emitted when the user accepts the dialog.
20 * The selected date is available from the selectedDate property.
21 */
22 signal accepted()
23
24 /**
25 * Emitted when the user cancells the popup
26 */
27 signal cancelled()
28
29 property date _value: new Date()
30
31 modal: true
32
33 contentItem: TimePicker {
34 id: popupContent
35 implicitWidth: applicationWindow().width
36 minutes: root.value.getMinutes()
37 hours: root.value.getHours()
38 onMinutesChanged: {
39 root._value.setHours(hours, minutes);
40 }
41 onHoursChanged: {
42 root._value.setHours(hours, minutes);
43 }
44 }
45
46 background: Components.DialogRoundedBackground {}
47
48 footer: QQC2.DialogButtonBox {
49 id: box
50
51 QQC2.Button {
52 text: i18ndc("kirigami-addons6", "@action:button", "Cancel")
53 icon.name: "dialog-cancel"
54 onClicked: {
55 root.cancelled()
56 root.close()
57 }
58
59 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
60 }
61
62 QQC2.Button {
63 text: i18ndc("kirigami-addons6", "@action:button", "Select")
64 icon.name: "dialog-ok-apply"
65 onClicked: {
66 root.value = root._value;
67 root.accepted()
68 root.close()
69 }
70
71 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
72 }
73 }
74
75 // black background, fades in and out
76 QQC2.Overlay.modal: Rectangle {
77 color: Qt.rgba(0, 0, 0, 0.3)
78
79 // the opacity of the item is changed internally by QQuickPopup on open/close
80 Behavior on opacity {
81 OpacityAnimator {
82 duration: Kirigami.Units.longDuration
83 easing.type: Easing.InOutQuad
84 }
85 }
86 }
87}
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.