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 Controls 0009 import org.kde.kirigami 2.19 as Kirigami 0010 0011 /** 0012 * A popup that prompts the user to select a date 0013 */ 0014 Kirigami.OverlaySheet { 0015 id: root 0016 /** 0017 * The year of the selected date 0018 */ 0019 property alias year: datePicker.year 0020 /** 0021 * The month of the selected date 0022 */ 0023 property alias month: datePicker.month 0024 /** 0025 * The selected date 0026 */ 0027 property alias selectedDate: datePicker.selectedDate 0028 0029 /** 0030 * Emitted when the user accepts the dialog. 0031 * The selected date is available from the selectedDate property. 0032 */ 0033 signal accepted() 0034 0035 /** 0036 * Emitted when the user cancells the popup 0037 */ 0038 signal cancelled() 0039 0040 header: RowLayout { 0041 implicitWidth: datePicker.width 0042 Kirigami.Heading { 0043 level: 2 0044 text: datePicker.selectedDate.toLocaleDateString(Qt.locale(), "<b>MMMM</b>") 0045 } 0046 Kirigami.Heading { 0047 level: 3 0048 text: datePicker.selectedDate.getFullYear() 0049 opacity: 0.8 0050 Layout.fillWidth: true 0051 } 0052 0053 Controls.Button { 0054 icon.name: "go-previous" 0055 text: i18nd("kirigami-addons", "Previous") 0056 display: Controls.AbstractButton.IconOnly 0057 Controls.ToolTip { 0058 text: parent.text 0059 } 0060 onClicked: datePicker.prevMonth() 0061 } 0062 Controls.Button { 0063 icon.name: "go-jump-today" 0064 text: i18nd("kirigami-addons", "Today") 0065 display: Controls.AbstractButton.IconOnly 0066 Controls.ToolTip { 0067 text: parent.text 0068 } 0069 onClicked: datePicker.goToday() 0070 } 0071 Controls.Button { 0072 icon.name: "go-next" 0073 text: i18nd("kirigami-addons", "Next") 0074 display: Controls.AbstractButton.IconOnly 0075 Controls.ToolTip { 0076 text: parent.text 0077 } 0078 onClicked: datePicker.nextMonth() 0079 } 0080 } 0081 contentItem: DatePicker { 0082 id: datePicker 0083 implicitWidth: Math.min(Window.width, Kirigami.Units.gridUnit * 25) 0084 implicitHeight: width * 0.8 0085 } 0086 footer: RowLayout { 0087 Controls.Label { 0088 text: datePicker.selectedDate.toLocaleDateString(); 0089 Layout.fillWidth: true 0090 } 0091 Controls.Button { 0092 text: i18nd("kirigami-addons", "Cancel") 0093 icon.name: "dialog-cancel" 0094 onClicked: { 0095 root.cancelled() 0096 root.close() 0097 } 0098 0099 } 0100 Controls.Button { 0101 text: i18nd("kirigami-addons", "Accept") 0102 icon.name: "dialog-ok-apply" 0103 onClicked: { 0104 root.selectedDate = datePicker.selectedDate 0105 root.accepted() 0106 root.close() 0107 } 0108 } 0109 } 0110 leftPadding: 0 0111 rightPadding: 0 0112 topPadding: 0 0113 bottomPadding: 0 0114 }