Warning, /utilities/ktrip/src/qml/TimePickerButton.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 import QtQuick 2.2
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Controls 2.5
0010 import org.kde.kirigami 2.4 as Kirigami
0011 
0012 import org.kde.kirigamiaddons.dateandtime 0.1 as KDT
0013 
0014 Button {
0015 
0016     signal timePicked(date theTime)
0017 
0018     onClicked: {
0019         if (_isAndroid) {
0020             _androidUtils.showTimePicker()
0021         } else {
0022             dialog.open()
0023         }
0024     }
0025 
0026      Connections {
0027         target: _androidUtils
0028         onTimePickerFinished: {
0029             timePicked(time)
0030         }
0031     }
0032 
0033     Dialog {
0034         id: dialog
0035         anchors.centerIn: Overlay.overlay
0036         contentItem: KDT.TimePicker {
0037             id: picker
0038             implicitWidth: 300
0039             implicitHeight: 300
0040         }
0041 
0042         standardButtons: Dialog.Ok | Dialog.Cancel
0043 
0044         onAccepted: {
0045             var hours = picker.hours
0046 
0047             if (picker.pm && hours != 12) {
0048                 hours += 12
0049             }
0050             var d = new Date()
0051             d.setHours(hours)
0052             d.setMinutes(picker.minutes)
0053             timePicked(d)
0054         }
0055     }
0056 }