Warning, /pim/kube/views/calendar/qml/DateTimeChooser.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright (C) 2017 Michael Bohlender, <bohlender@kolabsys.com> 0003 * Copyright (C) 2018 Christian Mollekopf, <mollekopf@kolabsys.com> 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License along 0016 * with this program; if not, write to the Free Software Foundation, Inc., 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 import QtQuick 2.7 0021 import QtQuick.Layouts 1.2 0022 import org.kube.framework 1.0 as Kube 0023 import Qt.labs.calendar 1.0 0024 0025 import "dateutils.js" as DateUtils 0026 0027 RowLayout { 0028 id: root 0029 property bool enableTime: true 0030 property var notBefore: new Date(0) 0031 property var initialValue: null 0032 0033 property date dateTime: initialValue ? initialValue : new Date() 0034 0035 spacing: Kube.Units.smallSpacing 0036 0037 Component.onCompleted: { 0038 if (root.initialValue) { 0039 root.dateTime = root.initialValue 0040 } 0041 } 0042 0043 0044 Kube.Button { 0045 id: button 0046 0047 Layout.preferredWidth: implicitWidth 0048 0049 text: selector.selectedDate.toLocaleDateString() 0050 0051 onClicked: { 0052 popup.open() 0053 } 0054 0055 Kube.Popup { 0056 id: popup 0057 0058 x: button.x 0059 y: button.y + button.height 0060 width: selector.implicitWidth + Kube.Units.largeSpacing * 2 0061 height: selector.implicitHeight + Kube.Units.largeSpacing * 2 0062 modal: true 0063 focus: true 0064 0065 DateSelector { 0066 id: selector 0067 anchors.fill: parent 0068 notBefore: root.notBefore 0069 backgroundColor: Kube.Colors.backgroundColor 0070 textColor: Kube.Colors.textColor 0071 invertIcons: false 0072 selectedDate: root.dateTime 0073 onSelected: root.dateTime = date 0074 onNext: root.dateTime = DateUtils.nextMonth(selectedDate) 0075 onPrevious: root.dateTime = DateUtils.previousMonth(selectedDate) 0076 } 0077 } 0078 } 0079 0080 TimeSelector { 0081 id: timeEdit 0082 Layout.preferredWidth: Kube.Units.gridUnit * 3 0083 notBefore: root.notBefore 0084 dateTime: root.dateTime 0085 onDateTimeChanged: { 0086 //Intermediate variable is necessary for binding to be updated 0087 var newDate = root.dateTime 0088 newDate.setHours(dateTime.getHours(), dateTime.getMinutes()) 0089 root.dateTime = newDate 0090 } 0091 0092 visible: root.enableTime 0093 } 0094 }