Changeset View
Changeset View
Standalone View
Standalone View
applets/binary-clock/package/contents/ui/BinaryClock.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML | 2 | * Rewrite of the KDE4-Plasma Binary Clock for KF5/Plasma/QML | ||
3 | * | 3 | * | ||
4 | * Copyright 2014 Joseph Wenninger <jowenn@kde.org> | 4 | * Copyright 2014 Joseph Wenninger <jowenn@kde.org> | ||
5 | * Copyright 2018 Piotr Kąkol <piotrkakol@protonmail.com> | ||||
5 | * | 6 | * | ||
6 | * Original code (KDE4): | 7 | * Original code (KDE4): | ||
7 | * Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> * | 8 | * Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org> | ||
8 | * Copyright 2007 by Davide Bettio <davide.bettio@kdemail.net> | 9 | * Copyright 2007 by Davide Bettio <davide.bettio@kdemail.net> | ||
9 | * | 10 | * | ||
10 | * Based on FuzzyClock.qml: | 11 | * Based on FuzzyClock.qml: | ||
11 | * Copyright 2013 Heena Mahour <heena393@gmail.com> | 12 | * Copyright 2013 Heena Mahour <heena393@gmail.com> | ||
12 | * Copyright 2013 Sebastian Kügler <sebas@kde.org> | 13 | * Copyright 2013 Sebastian Kügler <sebas@kde.org> | ||
13 | * Copyright 2013 Martin Klapetek <mklapetek@kde.org> | 14 | * Copyright 2013 Martin Klapetek <mklapetek@kde.org> | ||
14 | * Copyright 2014 David Edmundson <davidedmundson@kde.org> | 15 | * Copyright 2014 David Edmundson <davidedmundson@kde.org> | ||
15 | * Copyright 2014 Kai Uwe Broulik <kde@privat.broulik.de> | 16 | * Copyright 2014 Kai Uwe Broulik <kde@privat.broulik.de> | ||
Show All 21 Lines | 37 | Item { | |||
37 | id: main | 38 | id: main | ||
38 | 39 | | |||
39 | readonly property real w1: (main.height-5*units.smallSpacing)*dots/4 | 40 | readonly property real w1: (main.height-5*units.smallSpacing)*dots/4 | ||
40 | 41 | | |||
41 | Layout.minimumWidth: w1 < 20 ? 20 : w1 | 42 | Layout.minimumWidth: w1 < 20 ? 20 : w1 | ||
42 | Layout.maximumWidth: Infinity | 43 | Layout.maximumWidth: Infinity | ||
43 | Layout.preferredWidth: Layout.minimumWidth | 44 | Layout.preferredWidth: Layout.minimumWidth | ||
44 | 45 | | |||
45 | Layout.minimumHeight: 16+(units.smallSpacing * 5) | 46 | Layout.minimumHeight: 16+(units.smallSpacing*5) | ||
46 | // Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity | 47 | //Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity | ||
47 | //Layout.preferredHeight: Layout.minimumHeight | 48 | //Layout.preferredHeight: Layout.minimumHeight | ||
48 | 49 | | |||
49 | | ||||
50 | readonly property int formFactor: plasmoid.formFactor | 50 | readonly property int formFactor: plasmoid.formFactor | ||
51 | 51 | | |||
52 | readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal | 52 | readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal | ||
53 | 53 | | |||
54 | readonly property bool showSeconds: root.showSeconds | 54 | readonly property bool showSeconds: root.showSeconds | ||
55 | 55 | | |||
56 | readonly property int hours: root.hours | 56 | readonly property int hours: root.hours | ||
57 | readonly property int minutes: root.minutes | 57 | readonly property int minutes: root.minutes | ||
58 | readonly property int seconds: root.seconds | 58 | readonly property int seconds: root.seconds | ||
59 | 59 | | |||
60 | readonly property bool showOffLeds: plasmoid.configuration.showOffLeds | 60 | readonly property bool showOffLeds: plasmoid.configuration.showOffLeds | ||
61 | readonly property bool showGrid: plasmoid.configuration.showGrid | 61 | readonly property bool showGrid: plasmoid.configuration.showGrid | ||
62 | 62 | | |||
63 | readonly property int base: plasmoid.configuration.showBcdFormat? 10:16 | 63 | readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16 | ||
64 | 64 | | |||
65 | readonly property int dots: showSeconds? 6:4 | 65 | readonly property int dots: showSeconds ? 6 : 4 | ||
66 | 66 | | |||
67 | readonly property color onColor: plasmoid.configuration.useCustomColorForActive?plasmoid.configuration.customColorForActive: theme.textColor | 67 | readonly property color onColor: plasmoid.configuration.useCustomColorForActive ? plasmoid.configuration.customColorForActive : theme.textColor | ||
68 | readonly property color offColor: plasmoid.configuration.useCustomColorForInactive?plasmoid.configuration.customColorForInactive:Qt.rgba(onColor.r,onColor.g,onColor.b,0.4) | 68 | readonly property color offColor: plasmoid.configuration.useCustomColorForInactive ? plasmoid.configuration.customColorForInactive : Qt.rgba(onColor.r, onColor.g, onColor.b, 0.4) | ||
69 | readonly property color gridColor: plasmoid.configuration.useCustomColorForGrid?plasmoid.configuration.customColorForGrid:Qt.rgba(onColor.r,onColor.g,onColor.b,0.6) | 69 | readonly property color gridColor: plasmoid.configuration.useCustomColorForGrid ? plasmoid.configuration.customColorForGrid : Qt.rgba(onColor.r, onColor.g, onColor.b, 0.6) | ||
70 | 70 | | |||
71 | readonly property real dotSize: Math.min((height-5*units.smallSpacing)/4,(width-(dots+1)*units.smallSpacing)/dots) | 71 | readonly property real dotSize: Math.min((height-5*units.smallSpacing)/4, (width-(dots+1)*units.smallSpacing)/dots) | ||
72 | readonly property real displayTop: (height - 4*dotSize-3*units.smallSpacing) /2 | 72 | readonly property real displayTop: (height - 4*dotSize-3*units.smallSpacing)/2 | ||
73 | readonly property real displayLeft: (width - dots*dotSize-(dots-1)*units.smallSpacing) /2 | 73 | readonly property real displayLeft: (width - dots*dotSize-(dots-1)*units.smallSpacing)/2 | ||
74 | 74 | | |||
75 | /* displaying calendar after clicking binary clock applet */ | ||||
75 | MouseArea { | 76 | MouseArea { | ||
76 | id: mouseArea | 77 | id: mouseArea | ||
77 | anchors.fill: parent | 78 | anchors.fill: parent | ||
78 | hoverEnabled: true | 79 | hoverEnabled: true | ||
79 | onClicked: plasmoid.expanded = !plasmoid.expanded | 80 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
80 | } | 81 | } | ||
81 | 82 | | |||
82 | | ||||
83 | /*hours*/ | 83 | /* hours */ | ||
84 | DotColumn { | 84 | DotColumn { | ||
85 | x:displayLeft | 85 | x: displayLeft | ||
86 | y:displayTop | 86 | y: displayTop | ||
87 | val:hours/base | 87 | val: hours/base | ||
88 | } | 88 | } | ||
89 | DotColumn { | 89 | DotColumn { | ||
90 | x:displayLeft+(dotSize+units.smallSpacing) | 90 | x: displayLeft+(dotSize+units.smallSpacing) | ||
91 | y:displayTop | 91 | y: displayTop | ||
92 | val:hours%base | 92 | val: hours%base | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | | ||||
96 | /*minutes*/ | 95 | /* minutes */ | ||
97 | DotColumn { | 96 | DotColumn { | ||
98 | x:displayLeft+(dotSize+units.smallSpacing)*2 | 97 | x: displayLeft+(dotSize+units.smallSpacing)*2 | ||
99 | y:displayTop | 98 | y: displayTop | ||
100 | val:minutes/base | 99 | val: minutes/base | ||
101 | } | 100 | } | ||
102 | DotColumn { | 101 | DotColumn { | ||
103 | x:displayLeft+(dotSize+units.smallSpacing)*3 | 102 | x: displayLeft+(dotSize+units.smallSpacing)*3 | ||
104 | y:displayTop | 103 | y: displayTop | ||
105 | val:minutes%base | 104 | val: minutes%base | ||
106 | } | 105 | } | ||
107 | 106 | | |||
108 | /* seconds */ | 107 | /* seconds */ | ||
109 | DotColumn { | 108 | DotColumn { | ||
110 | x:displayLeft+(dotSize+units.smallSpacing)*4 | 109 | x: displayLeft+(dotSize+units.smallSpacing)*4 | ||
111 | y:displayTop | 110 | y: displayTop | ||
112 | val:seconds/base | 111 | val: seconds/base | ||
113 | visible:showSeconds | 112 | visible: showSeconds | ||
114 | } | 113 | } | ||
115 | | ||||
116 | DotColumn { | 114 | DotColumn { | ||
117 | x:displayLeft+(dotSize+units.smallSpacing)*5 | 115 | x: displayLeft+(dotSize+units.smallSpacing)*5 | ||
118 | y:displayTop | 116 | y: displayTop | ||
119 | val:seconds%base | 117 | val: seconds%base | ||
120 | visible:showSeconds | 118 | visible: showSeconds | ||
121 | } | 119 | } | ||
122 | 120 | | |||
121 | /* upper grid border */ | ||||
123 | Rectangle { | 122 | Rectangle { | ||
124 | x:displayLeft-units.smallSpacing | 123 | x: displayLeft-units.smallSpacing | ||
125 | y:displayTop-units.smallSpacing | 124 | y: displayTop-units.smallSpacing | ||
126 | width:dots*(dotSize+units.smallSpacing)+units.smallSpacing | 125 | width: dots*(dotSize+units.smallSpacing)+units.smallSpacing | ||
127 | height:units.smallSpacing | 126 | height: units.smallSpacing | ||
128 | visible:showGrid | 127 | visible: showGrid | ||
129 | color:gridColor | 128 | color: gridColor | ||
130 | } | 129 | } | ||
131 | 130 | | |||
131 | /* left grid border */ | ||||
132 | Rectangle { | 132 | Rectangle { | ||
133 | x:displayLeft-units.smallSpacing | 133 | x: displayLeft-units.smallSpacing | ||
134 | y:displayTop | 134 | y: displayTop | ||
135 | width:units.smallSpacing | 135 | width: units.smallSpacing | ||
136 | height:4*(dotSize+units.smallSpacing) | 136 | height: 4*(dotSize+units.smallSpacing) | ||
137 | visible:showGrid | 137 | visible: showGrid | ||
138 | color:gridColor | 138 | color: gridColor | ||
139 | } | 139 | } | ||
140 | | ||||
141 | } | 140 | } | ||
141 | No newline at end of file |