Kirigami-addons

DatePopup.qml
1// SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>
2// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
3// SPDX-License-Identifier: LGPL-2.0-or-later
4
5import QtQuick 2.15
6import QtQuick.Window 2.15
7import QtQuick.Layouts 1.15
8import QtQuick.Controls 2.15 as QQC2
9import org.kde.kirigami 2.19 as Kirigami
10import org.kde.kirigamiaddons.components 1.0 as Components
11import './private/' as P
12
13/**
14 * A popup that prompts the user to select a date
15 */
16QQC2.Dialog {
17 id: root
18
19 /**
20 * @brief The current date and time selected by the user.
21 */
22 property date value: new Date()
23
24 /**
25 * Emitted when the user accepts the dialog.
26 * The selected date is available from the selectedDate property.
27 */
28 signal accepted()
29
30 /**
31 * Emitted when the user cancells the popup
32 */
33 signal cancelled()
35 /**
36 * This property holds the minimum date (inclusive) that the user can select.
37 *
38 * By default, no limit is applied to the date selection.
39 */
40 property date minimumDate
41
42 /**
43 * This property holds the maximum date (inclusive) that the user can select.
44 *
45 * By default, no limit is applied to the date selection.
46 */
47 property date maximumDate
48
49 padding: 0
50 topPadding: undefined
51 leftPadding: undefined
52 rightPadding: undefined
53 bottomPadding: undefined
54 verticalPadding: undefined
55 horizontalPadding: undefined
56
57 header: null
58
59 contentItem: P.DatePicker {
60 id: datePicker
61 selectedDate: root.value
62 minimumDate: root.minimumDate
63 maximumDate: root.maximumDate
64 focus: true
65 }
66
67 footer: QQC2.DialogButtonBox {
68 id: box
69
70 QQC2.Button {
71 text: i18ndc("kirigami-addons6", "@action:button", "Cancel")
72 icon.name: "dialog-cancel"
73 onClicked: {
74 root.cancelled()
75 root.close()
76 }
77
78 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
79 }
80
81 QQC2.Button {
82 text: i18ndc("kirigami-addons6", "@action:button", "Select")
83 icon.name: "dialog-ok-apply"
84
85 onClicked: {
86 root.value = datePicker.selectedDate;
87 root.accepted()
88 root.close()
89 }
90
91 QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
92 }
93 }
94
95 background: Components.DialogRoundedBackground {}
96
97 // black background, fades in and out
98 QQC2.Overlay.modal: Rectangle {
99 color: Qt.rgba(0, 0, 0, 0.3)
100
101 // the opacity of the item is changed internally by QQuickPopup on open/close
102 Behavior on opacity {
103 OpacityAnimator {
104 duration: Kirigami.Units.longDuration
105 easing.type: Easing.InOutQuad
106 }
107 }
108 }
109}
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 Tue Mar 26 2024 11:16:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.