Warning, /plasma/plasma-bigscreen/kcms/bigscreen-settings/ui/delegates/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 2.14
0008 import org.kde.kirigami as Kirigami
0009 
0010 Item {
0011     id: root
0012     clip: true
0013     property int day
0014     property int month
0015     property int year
0016 
0017     property bool userConfiguring: visible
0018 
0019     property int fontSize: 14
0020     property int _margin: Kirigami.Units.gridUnit
0021 
0022     opacity: enabled ? 1.0 : 0.5
0023 
0024     onVisibleChanged: {
0025         if(visible){
0026             dayDigit.model = getDaysInMonth()
0027         }
0028     }
0029 
0030     onFocusChanged: {
0031         if(focus) {
0032             dayDigit.forceActiveFocus()
0033         }
0034     }
0035 
0036     function getDaysInMonth() {
0037         // Here January is 1 based
0038         //Day 0 is the last day in the previous month
0039         //return new Date(year, month, 0).getDate();
0040         // Here January is 0 based
0041         var dt = new Date(root.year, root.month+1, 0).getDate()
0042         return dt
0043     }
0044 
0045     Rectangle {
0046         color: "transparent"
0047         border.color: Kirigami.Theme.textColor
0048         border.width: 1
0049         anchors.fill: parent
0050         anchors.margins: Kirigami.Units.largeSpacing
0051 
0052         Row {
0053             id: clockRow
0054             spacing: 3
0055             anchors.fill: parent
0056             anchors.margins: Kirigami.Units.smallSpacing
0057 
0058             property int day
0059             property int month
0060             property int year
0061 
0062             function twoDigitString(number)
0063             {
0064                 return number < 10 ? "0"+number : number
0065             }
0066 
0067             Digit {
0068                 id: dayDigit
0069                 currentIndex: ((day - 1) < model) ? day-1 : 1
0070                 KeyNavigation.right: monthDigit
0071                 KeyNavigation.left: backBtnDTItem
0072 
0073                 onSelectedIndexChanged: {
0074                     if (selectedIndex > -1) {
0075                         day = selectedIndex+1
0076                     }
0077                 }
0078                 delegate: Text {
0079                     horizontalAlignment: Text.AlignHCenter
0080                     width: dayDigit.width
0081                     property int ownIndex: index
0082                     text: clockRow.twoDigitString(index+1)
0083                     color: dayDigit.focus && dayDigit.currentIndex == index ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0084                     font.pointSize: root.fontSize
0085                     opacity: PathView.itemOpacity
0086                 }
0087             }
0088             Kirigami.Separator {
0089                 anchors {
0090                     top: parent.top
0091                     bottom: parent.bottom
0092                 }
0093             }
0094             Digit {
0095                 id: monthDigit
0096                 model: 12
0097                 currentIndex: month -1
0098                 KeyNavigation.right: yearDigit
0099                 KeyNavigation.left: dayDigit
0100 
0101                 onSelectedIndexChanged: {
0102                     if (selectedIndex > -1) {
0103                         month = selectedIndex + 1
0104                     }
0105                 }
0106                 delegate: Text {
0107                     horizontalAlignment: Text.AlignHCenter
0108                     width: monthDigit.width
0109                     property int ownIndex: index
0110                     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"))
0111                     text: months[index]
0112                     font.pointSize: root.fontSize
0113                     color: monthDigit.focus && monthDigit.currentIndex == index ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0114                     opacity: PathView.itemOpacity
0115                 }
0116                 Text {
0117                     id: monthPlaceHolder
0118                     visible: false
0119                     font.pointSize: root.fontSize
0120                     text: "0000"
0121                 }
0122             }
0123             Kirigami.Separator {
0124                 anchors {
0125                     top: parent.top
0126                     bottom: parent.bottom
0127                 }
0128             }
0129             Digit {
0130                 id: yearDigit
0131                 //FIXME: yes, this is a tad lame ;)
0132                 model: 3000
0133                 currentIndex: year
0134                 KeyNavigation.left: monthDigit
0135                 KeyNavigation.right: backBtnDTItem
0136 
0137                 onSelectedIndexChanged: {
0138                     if (selectedIndex > -1) {
0139                         year = selectedIndex
0140                     }
0141                 }
0142                 Text {
0143                     id: yearPlaceHolder
0144                     visible: false
0145                     font.pointSize: root.fontSize
0146                     color: yearDigit.focus && yearDigit.currentIndex == index ? Kirigami.Theme.linkColor : Kirigami.Theme.textColor
0147                     text: "0000"
0148                 }
0149             }
0150         }
0151     }
0152 }