Warning, /libraries/kirigami-addons/src/dateandtime/private/MobileDateInput.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.2 0008 import QtQuick.Controls 2.3 as Controls 0009 import org.kde.kirigami 2.8 as Kirigami 0010 import org.kde.kirigamiaddons.dateandtime 0.1 as KDT 0011 0012 Controls.TextField { //inherited for style reasons to show we're interactive 0013 id: root 0014 property date selectedDate 0015 readOnly: true 0016 text: selectedDate.toLocaleDateString(Qt.locale(), Locale.ShortFormat) 0017 MouseArea { 0018 id: mouseArea 0019 anchors.fill: parent 0020 property bool androidPickerActive: false 0021 onClicked: { 0022 if (Qt.platform.os === 'android') { 0023 androidPickerActive = true; 0024 KDT.AndroidIntegration.showDatePicker(root.selectedDate.getTime()); 0025 } else { 0026 popupLoader.active = true 0027 popupLoader.item.year = root.selectedDate.getFullYear() 0028 popupLoader.item.month = root.selectedDate.getMonth() + 1 0029 popupLoader.item.selectedDate = root.selectedDate 0030 0031 popupLoader.item.open(); 0032 } 0033 } 0034 0035 Connections { 0036 enabled: Qt.platform.os === 'android' && mouseArea.androidPickerActive 0037 ignoreUnknownSignals: !enabled 0038 target: enabled ? KDT.AndroidIntegration : null 0039 function onDatePickerFinished(accepted, newDate) { 0040 mouseArea.androidPickerActive = false; 0041 if (accepted) { 0042 root.selectedDate = newDate; 0043 } 0044 } 0045 } 0046 } 0047 0048 Loader { 0049 id: popupLoader 0050 active: false 0051 0052 sourceComponent: Component { 0053 KDT.DatePopup { 0054 onAccepted: { 0055 root.selectedDate = item.selectedDate 0056 active = false 0057 } 0058 onCancelled: { 0059 active = false 0060 } 0061 } 0062 } 0063 } 0064 }