Warning, /plasma-mobile/calindori/src/contents/ui/TimeSelectorButton.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net>
0003 *
0004 * SPDX-License-Identifier: GPL-3.0-or-later
0005 */
0006
0007 import QtQuick 2.7
0008 import QtQuick.Controls 2.0 as Controls2
0009 import org.kde.kirigami 2.0 as Kirigami
0010
0011 Controls2.ToolButton {
0012 id: root
0013
0014 property string selectorTitle
0015 property date selectorDate
0016 property int selectorHour
0017 property int selectorMinutes
0018 property bool selectorPm
0019
0020 contentItem: Controls2.Label {
0021 leftPadding: Kirigami.Units.largeSpacing
0022 rightPadding: Kirigami.Units.largeSpacing
0023 horizontalAlignment: Text.AlignHCenter
0024 verticalAlignment: Text.AlignVCenter
0025 text: {
0026 if(!isNaN(root.selectorDate)) {
0027 var textDt = root.selectorDate;
0028 textDt.setHours(root.selectorHour + (root.selectorPm ? 12 : 0));
0029 textDt.setMinutes(root.selectorMinutes);
0030 textDt.setSeconds(0);
0031
0032 return textDt.toLocaleTimeString(_appLocale, "HH:mm");
0033 }
0034 else {
0035 return "";
0036 }
0037 }
0038 }
0039
0040 onClicked: {
0041 timePickerSheet.hours = selectorHour;
0042 timePickerSheet.minutes = selectorMinutes;
0043 timePickerSheet.pm = selectorPm;
0044 timePickerSheet.open();
0045 }
0046
0047 TimePickerSheet {
0048 id: timePickerSheet
0049
0050 headerText: root.selectorTitle
0051
0052 onDatePicked: {
0053 root.selectorHour = timePickerSheet.hours;
0054 root.selectorMinutes = timePickerSheet.minutes;
0055 root.selectorPm = timePickerSheet.pm;
0056 }
0057 }
0058 }