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 cancells the popup
20 */
21 signal cancelled()
22
23 property date _value: new Date()
24
25 modal: true
26
27 contentItem: TimePicker {
28 id: popupContent
29 implicitWidth: applicationWindow().width
30 minutes: root.value.getMinutes()
31 hours: root.value.getHours()
32 onMinutesChanged: {
33 root._value.setHours(hours, minutes);
34 }
35 onHoursChanged: {
36 root._value.setHours(hours, minutes);
37 }
38 }
39
40 background: Components.DialogRoundedBackground {}
41
42 footer: QQC2.DialogButtonBox {
43 id: box
44
45 QQC2.Button {
46 text: i18ndc("kirigami-addons6", "@action:button", "Cancel")
47 icon.name: "dialog-cancel"
48 onClicked: {
49 root.cancelled()
50 root.close()
51 }
52
53 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
54 }
55
56 QQC2.Button {
57 text: i18ndc("kirigami-addons6", "@action:button", "Select")
58 icon.name: "dialog-ok-apply"
59 onClicked: {
60 root.value = root._value;
61 root.accepted()
62 root.close()
63 }
64
65 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
66 }
67 }
68
69 // black background, fades in and out
70 QQC2.Overlay.modal: Rectangle {
71 color: Qt.rgba(0, 0, 0, 0.3)
72
73 // the opacity of the item is changed internally by QQuickPopup on open/close
74 Behavior on opacity {
75 OpacityAnimator {
76 duration: Kirigami.Units.longDuration
77 easing.type: Easing.InOutQuad
78 }
79 }
80 }
81}
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 Fri Dec 20 2024 11:49:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.