Warning, /plasma/plasma-mobile/kcms/time/ui/DatePicker.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import org.kde.kirigami 2.5 as Kirigami 0010 0011 Item { 0012 id: root 0013 0014 //////// API 0015 property int day 0016 property int month 0017 property int year 0018 0019 property bool userConfiguring: false 0020 0021 property string isoDate: year + "-" + clockRow.twoDigitString(month) + "-" + clockRow.twoDigitString(day) 0022 0023 property int fontSize: 14 0024 property int _margin: Kirigami.Units.gridUnit 0025 0026 opacity: enabled ? 1.0 : 0.5 0027 0028 Rectangle { 0029 color: "transparent" 0030 border.width: 1 0031 border.color: Kirigami.Theme.textColor 0032 anchors.fill: parent 0033 opacity: 0.3 0034 } 0035 0036 /////// Implementation 0037 Connections { 0038 target: root 0039 function onDayChanged() { 0040 clockRow.day = root.day; 0041 } 0042 function onMonthChanged() { 0043 clockRow.month = root.month; 0044 } 0045 function onYearChanged() { 0046 clockRow.year = root.year; 0047 } 0048 } 0049 0050 Timer { 0051 id: userConfiguringTimer 0052 repeat: false 0053 interval: 1500 0054 running: false 0055 onTriggered: { 0056 root.day = clockRow.day 0057 root.month = clockRow.month 0058 root.year = clockRow.year 0059 userConfiguring = false 0060 } 0061 } 0062 0063 RowLayout { 0064 id: clockRow 0065 anchors.margins: _margin 0066 anchors.fill: parent 0067 0068 property int day 0069 property int month 0070 property int year 0071 0072 function twoDigitString(number) 0073 { 0074 return number < 10 ? "0"+number : number 0075 } 0076 0077 Digit { 0078 id: dayDigit 0079 Layout.fillWidth: true 0080 model: { 0081 var dd = new Date(year, month, 0); 0082 return dd.getDate() 0083 } 0084 currentIndex: ((day - 1) < model) ? day-1 : 1 0085 onSelectedIndexChanged: { 0086 if (selectedIndex > -1) { 0087 day = selectedIndex+1 0088 } 0089 } 0090 delegate: Text { 0091 horizontalAlignment: Text.AlignHCenter 0092 width: dayDigit.width 0093 property int ownIndex: index 0094 text: index+1 0095 color: Kirigami.Theme.textColor 0096 font.pointSize: root.fontSize 0097 } 0098 } 0099 Item { 0100 Layout.fillHeight: true 0101 Kirigami.Separator { 0102 anchors { 0103 top: parent.top 0104 bottom: parent.bottom 0105 } 0106 } 0107 } 0108 Digit { 0109 id: monthDigit 0110 Layout.fillWidth: true 0111 model: 12 0112 currentIndex: month -1 0113 onSelectedIndexChanged: { 0114 if (selectedIndex > -1) { 0115 month = selectedIndex + 1 0116 } 0117 } 0118 delegate: Text { 0119 horizontalAlignment: Text.AlignHCenter 0120 width: monthDigit.width 0121 property int ownIndex: index 0122 property variant months: Array(i18n("Jan"), i18n("Feb"), i18n("Mar"), i18n("Apr"), i18n("May"), i18n("Jun"), i18n("Jul"), i18n("Aug"), i18n("Sep"), i18n("Oct"), i18n("Nov"), i18n("Dec")) 0123 text: months[index] 0124 font.pointSize: root.fontSize 0125 color: Kirigami.Theme.textColor 0126 opacity: PathView.itemOpacity 0127 } 0128 width: monthPlaceHolder.width 0129 Text { 0130 id: monthPlaceHolder 0131 visible: false 0132 font.pointSize: root.fontSize 0133 text: "0000" 0134 } 0135 } 0136 Item { 0137 Layout.fillHeight: true 0138 Kirigami.Separator { 0139 anchors { 0140 top: parent.top 0141 bottom: parent.bottom 0142 } 0143 } 0144 } 0145 Digit { 0146 id: yearDigit 0147 Layout.fillWidth: true 0148 //FIXME: yes, this is a tad lame ;) 0149 model: 3000 0150 currentIndex: year 0151 onSelectedIndexChanged: { 0152 if (selectedIndex > -1) { 0153 year = selectedIndex 0154 } 0155 } 0156 width: yearPlaceHolder.width*1.3 0157 Text { 0158 id: yearPlaceHolder 0159 visible: false 0160 font.pointSize: root.fontSize 0161 text: "0000" 0162 } 0163 } 0164 } 0165 }