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

0001 // SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org>
0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
0003 // SPDX-License-Identifier: LGPL-2.0-or-later
0004 
0005 import QtQuick 2.15
0006 import QtQuick.Window 2.15
0007 import QtQuick.Layouts 1.15
0008 import QtQuick.Controls 2.15 as QQC2
0009 import org.kde.kirigami 2.19 as Kirigami
0010 import org.kde.kirigamiaddons.components 1.0 as Components
0011 import './private/' as P
0012 
0013 /**
0014  * A popup that prompts the user to select a date
0015  */
0016 QQC2.Dialog {
0017     id: root
0018 
0019     /**
0020      * @brief The current date and time selected by the user.
0021      */
0022     property date value: new Date()
0023 
0024     /**
0025      * Emitted when the user accepts the dialog.
0026      * The selected date is available from the selectedDate property.
0027      */
0028     signal accepted()
0029 
0030     /**
0031      * Emitted when the user cancells the popup
0032      */
0033     signal cancelled()
0034 
0035     /**
0036      * This property holds the minimum date (inclusive) that the user can select.
0037      *
0038      * By default, no limit is applied to the date selection.
0039      */
0040     property date minimumDate
0041 
0042     /**
0043      * This property holds the maximum date (inclusive) that the user can select.
0044      *
0045      * By default, no limit is applied to the date selection.
0046      */
0047     property date maximumDate
0048 
0049     padding: 0
0050     topPadding: undefined
0051     leftPadding: undefined
0052     rightPadding: undefined
0053     bottomPadding: undefined
0054     verticalPadding: undefined
0055     horizontalPadding: undefined
0056 
0057     header: null
0058 
0059     contentItem: P.DatePicker {
0060         id: datePicker
0061         selectedDate: root.value
0062         minimumDate: root.minimumDate
0063         maximumDate: root.maximumDate
0064         focus: true
0065     }
0066 
0067     footer: Components.MessageDialogButtonBox {
0068         id: box
0069 
0070         Components.MessageDialogButton {
0071             text: i18ndc("kirigami-addons6", "@action:button", "Cancel")
0072             icon.name: "dialog-cancel"
0073             buttonBox: box
0074             onClicked: {
0075                 root.cancelled()
0076                 root.close()
0077             }
0078 
0079             QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
0080         }
0081 
0082         Components.MessageDialogButton {
0083             text: i18ndc("kirigami-addons6", "@action:button", "Select")
0084             icon.name: "dialog-ok-apply"
0085             buttonBox: box
0086 
0087             onClicked: {
0088                 root.value = datePicker.selectedDate;
0089                 root.accepted()
0090                 root.close()
0091             }
0092 
0093             QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
0094         }
0095     }
0096 
0097     background: Components.DialogRoundedBackground {}
0098 
0099     // black background, fades in and out
0100     QQC2.Overlay.modal: Rectangle {
0101         color: Qt.rgba(0, 0, 0, 0.3)
0102 
0103         // the opacity of the item is changed internally by QQuickPopup on open/close
0104         Behavior on opacity {
0105             OpacityAnimator {
0106                 duration: Kirigami.Units.longDuration
0107                 easing.type: Easing.InOutQuad
0108             }
0109         }
0110     }
0111 }