Warning, /maui/era/src/controls/AnalogClock.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.0
0002 import QtQuick.Controls 2.15
0003 import QtQuick.Layouts 1.12
0004 
0005 import org.mauikit.controls 1.3 as Maui
0006 import QtGraphicalEffects 1.0
0007 
0008 Control
0009 {
0010     id : clock
0011     implicitHeight: _layout.implicitHeight + topPadding + bottomPadding
0012     implicitWidth: _layout.implicitWidth + leftPadding + rightPadding
0013     spacing: Maui.Style.space.big
0014     font.bold: true
0015     font.weight: Font.Black
0016     font.pointSize: 24
0017     font.family: "Open 24 Display St"
0018     font.letterSpacing: Maui.Style.space.big
0019     padding: Maui.Style.space.big
0020 
0021     property string city: i18n("Local")
0022     property int hours
0023     property int minutes
0024     property int seconds
0025     property real shift
0026     property bool night: false
0027     property bool internationalTime: false //Unset for local time
0028 
0029     function timeChanged() {
0030         var date = new Date;
0031         hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
0032         night = ( hours < 7 || hours > 17 )
0033         minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
0034         seconds = date.getUTCSeconds();
0035     }
0036 
0037     Timer {
0038         interval: 100; running: true; repeat: true;
0039         onTriggered: clock.timeChanged()
0040     }
0041 
0042     contentItem: ColumnLayout
0043     {
0044         id: _layout
0045         spacing: clock.spacing
0046 
0047         Column
0048         {
0049             Layout.fillWidth: true
0050             Label
0051             {
0052                 width: parent.width
0053 //                font.pointSize: Maui.Style.fontSizes.small
0054                 font.weight: Font.Bold
0055                 font.bold: true
0056                 opacity : 0.7
0057                 horizontalAlignment: Qt.AlignHCenter
0058                 text: clock.city + "  +" + clock.shift + " HRS"
0059             }
0060 
0061 
0062             Label
0063             {
0064                 font: clock.font
0065                 width: parent.width
0066                 horizontalAlignment: Qt.AlignHCenter
0067                 text: clock.hours + ":" + clock.minutes
0068             }
0069         }
0070 
0071         Item
0072         {
0073             Layout.preferredHeight: 200
0074             Layout.preferredWidth: 200
0075 
0076             Layout.alignment: Qt.AlignCenter
0077             Rectangle
0078             {
0079                 id: _clockBg
0080                 height: 200
0081                 width: 200
0082                 radius: height
0083                 color: clock.night ? "#333" : "#fafafa"
0084                 layer.enabled: true
0085                 layer.effect: DropShadow
0086                 {
0087                     horizontalOffset: 0
0088                     verticalOffset: 0
0089                     radius: 8
0090                     samples: 16
0091                     color: "#80000000"
0092                     transparentBorder: true
0093                 }
0094 
0095             }
0096 
0097 
0098 
0099             Rectangle
0100             {
0101                 id: _hourHandle
0102                 x: 100; y: Math.floor(_clockBg.height/2 - height)
0103                 height:50
0104                 width: 5
0105                 radius: width
0106                 color: clock.night? "#fafafa" : "#333"
0107                 transform: Rotation {
0108                     id: hourRotation
0109                     origin.x: _hourHandle.width/2; origin.y: _hourHandle.height;
0110                     angle: (clock.hours * 30) + (clock.minutes * 0.5)
0111                     Behavior on angle {
0112                         SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
0113                     }
0114                 }
0115             }
0116 
0117             Rectangle
0118             {
0119                 id: _minuteHandle
0120                 opacity: 0.5
0121                 x: 100; y: Math.floor(_clockBg.height/2 - height)
0122                 height: 60
0123                 width: 5
0124                 radius: width
0125                 color: clock.night? "#fafafa" : "#333"
0126 
0127                 transform: Rotation {
0128                     id: minuteRotation
0129                     origin.x: _minuteHandle.width/2; origin.y: _minuteHandle.height;
0130                     angle: clock.minutes * 6
0131                     Behavior on angle {
0132                         SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
0133                     }
0134                 }
0135             }
0136 
0137             Rectangle
0138             {
0139                 id: _secondHandle
0140                 x: 100; y: Math.floor(_clockBg.height/2 - height)
0141                 height: 80
0142                 width: 2
0143                 radius: width
0144                 color: Maui.Theme.highlightColor
0145                 transform: Rotation {
0146                     id: secondRotation
0147                     origin.x: _secondHandle.width/2; origin.y: _secondHandle.height;
0148                     angle: clock.seconds * 6
0149                     Behavior on angle {
0150                         SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
0151                     }
0152                 }
0153             }
0154 
0155             Rectangle
0156             {
0157                 anchors.centerIn: _clockBg
0158                 height: 16
0159                 width: 16
0160                 radius: width
0161                 color: Qt.darker(_clockBg.color, 1.2)
0162 
0163                 Rectangle
0164                 {
0165                     anchors.fill: parent
0166                     anchors.margins: 4
0167                     color: _clockBg.color
0168                     radius: width
0169                 }
0170             }
0171         }
0172     }
0173 }