Changeset View
Changeset View
Standalone View
Standalone View
applets/binary-clock/package/contents/ui/BinaryClock.qml
Show All 31 Lines | |||||
32 | import QtQuick 2.0 | 32 | import QtQuick 2.0 | ||
33 | import QtQuick.Layouts 1.1 | 33 | import QtQuick.Layouts 1.1 | ||
34 | import org.kde.plasma.core 2.0 as PlasmaCore | 34 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
35 | import org.kde.plasma.components 2.0 as Components | 35 | import org.kde.plasma.components 2.0 as Components | ||
36 | 36 | | |||
37 | Item { | 37 | Item { | ||
38 | id: main | 38 | id: main | ||
39 | 39 | | |||
40 | readonly property real w1: (main.height-5*units.smallSpacing)*dots/4 | 40 | readonly property int gridThickness: plasmoid.configuration.gridThickness | ||
41 | readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16 | ||||
42 | readonly property bool showOffLeds: plasmoid.configuration.showOffLeds | ||||
43 | readonly property bool showGrid: plasmoid.configuration.showGrid | ||||
44 | readonly property int formFactor: plasmoid.formFactor | ||||
45 | readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal | ||||
46 | readonly property bool showSeconds: root.showSeconds | ||||
41 | 47 | | |||
42 | Layout.minimumWidth: w1 < 20 ? 20 : w1 | 48 | readonly property int dots: showSeconds ? 6 : 4 | ||
49 | readonly property int dotSize: plasmoid.formFactor == PlasmaCore.Types.Horizontal | ||||
50 | ? (height-(showGrid ? 5 : 3)*gridThickness)/4 // for horizontal taskbar | ||||
51 | : (width-(dots+(showGrid ? 1 : -1))*gridThickness)/dots // for vertical taskbar | ||||
52 | readonly property real appletWidth: dots*dotSize+gridThickness*(dots+(showGrid ? 3 : 1)) | ||||
53 | | ||||
54 | Layout.minimumWidth: Math.max(20, appletWidth) | ||||
43 | Layout.maximumWidth: Infinity | 55 | Layout.maximumWidth: Infinity | ||
44 | Layout.preferredWidth: Layout.minimumWidth | 56 | Layout.preferredWidth: Layout.minimumWidth | ||
45 | 57 | | |||
46 | Layout.minimumHeight: 16+(units.smallSpacing*5) | 58 | Layout.minimumHeight: 16+(gridThickness*5) | ||
47 | //Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity | 59 | //Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity | ||
48 | //Layout.preferredHeight: Layout.minimumHeight | 60 | //Layout.preferredHeight: Layout.minimumHeight | ||
49 | 61 | | |||
50 | readonly property int formFactor: plasmoid.formFactor | | |||
51 | | ||||
52 | readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal | | |||
53 | | ||||
54 | readonly property bool showSeconds: root.showSeconds | | |||
55 | | ||||
56 | readonly property int hours: root.hours | 62 | readonly property int hours: root.hours | ||
57 | readonly property int minutes: root.minutes | 63 | readonly property int minutes: root.minutes | ||
58 | readonly property int seconds: root.seconds | 64 | readonly property int seconds: root.seconds | ||
59 | 65 | | |||
60 | readonly property bool showOffLeds: plasmoid.configuration.showOffLeds | | |||
61 | readonly property bool showGrid: plasmoid.configuration.showGrid | | |||
62 | | ||||
63 | readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16 | | |||
64 | | ||||
65 | readonly property int dots: showSeconds ? 6 : 4 | | |||
66 | | ||||
67 | readonly property color onColor: plasmoid.configuration.useCustomColorForActive ? plasmoid.configuration.customColorForActive : theme.textColor | 66 | 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) | 67 | 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) | 68 | readonly property color gridColor: plasmoid.configuration.useCustomColorForGrid ? plasmoid.configuration.customColorForGrid : Qt.rgba(onColor.r, onColor.g, onColor.b, 0.6) | ||
70 | 69 | | |||
71 | readonly property int dotSize: Math.min((height-5*units.smallSpacing)/4, (width-(dots+1)*units.smallSpacing)/dots) | 70 | readonly property real displayTop: (height - 4*dotSize-3*gridThickness)/2 | ||
72 | readonly property real displayTop: (height - 4*dotSize-3*units.smallSpacing)/2 | 71 | readonly property real displayLeft: (width - dots*dotSize-(dots-1)*gridThickness)/2 | ||
73 | readonly property real displayLeft: (width - dots*dotSize-(dots-1)*units.smallSpacing)/2 | | |||
74 | 72 | | |||
75 | /* displaying calendar after clicking binary clock applet */ | 73 | /* displaying calendar after clicking binary clock applet */ | ||
76 | MouseArea { | 74 | MouseArea { | ||
77 | id: mouseArea | 75 | id: mouseArea | ||
78 | anchors.fill: parent | 76 | anchors.fill: parent | ||
79 | hoverEnabled: true | 77 | hoverEnabled: true | ||
80 | onClicked: plasmoid.expanded = !plasmoid.expanded | 78 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
81 | } | 79 | } | ||
82 | 80 | | |||
83 | /* hours */ | 81 | /* hours */ | ||
84 | DotColumn { | 82 | DotColumn { | ||
85 | x: displayLeft | 83 | x: displayLeft | ||
86 | y: displayTop | 84 | y: displayTop | ||
87 | val: hours/base | 85 | val: hours/base | ||
88 | } | 86 | } | ||
89 | DotColumn { | 87 | DotColumn { | ||
90 | x: displayLeft+(dotSize+units.smallSpacing) | 88 | x: displayLeft+(dotSize+gridThickness) | ||
91 | y: displayTop | 89 | y: displayTop | ||
92 | val: hours%base | 90 | val: hours%base | ||
93 | } | 91 | } | ||
94 | 92 | | |||
95 | /* minutes */ | 93 | /* minutes */ | ||
96 | DotColumn { | 94 | DotColumn { | ||
97 | x: displayLeft+(dotSize+units.smallSpacing)*2 | 95 | x: displayLeft+(dotSize+gridThickness)*2 | ||
98 | y: displayTop | 96 | y: displayTop | ||
99 | val: minutes/base | 97 | val: minutes/base | ||
100 | } | 98 | } | ||
101 | DotColumn { | 99 | DotColumn { | ||
102 | x: displayLeft+(dotSize+units.smallSpacing)*3 | 100 | x: displayLeft+(dotSize+gridThickness)*3 | ||
103 | y: displayTop | 101 | y: displayTop | ||
104 | val: minutes%base | 102 | val: minutes%base | ||
105 | } | 103 | } | ||
106 | 104 | | |||
107 | /* seconds */ | 105 | /* seconds */ | ||
108 | DotColumn { | 106 | DotColumn { | ||
109 | x: displayLeft+(dotSize+units.smallSpacing)*4 | 107 | x: displayLeft+(dotSize+gridThickness)*4 | ||
110 | y: displayTop | 108 | y: displayTop | ||
111 | val: seconds/base | 109 | val: seconds/base | ||
112 | visible: showSeconds | 110 | visible: showSeconds | ||
113 | } | 111 | } | ||
114 | DotColumn { | 112 | DotColumn { | ||
115 | x: displayLeft+(dotSize+units.smallSpacing)*5 | 113 | x: displayLeft+(dotSize+gridThickness)*5 | ||
116 | y: displayTop | 114 | y: displayTop | ||
117 | val: seconds%base | 115 | val: seconds%base | ||
118 | visible: showSeconds | 116 | visible: showSeconds | ||
119 | } | 117 | } | ||
120 | 118 | | |||
121 | /* upper grid border */ | 119 | /* upper grid border */ | ||
122 | Rectangle { | 120 | Rectangle { | ||
123 | x: displayLeft-units.smallSpacing | 121 | x: displayLeft-gridThickness | ||
124 | y: displayTop-units.smallSpacing | 122 | y: displayTop-gridThickness | ||
125 | width: dots*(dotSize+units.smallSpacing)+units.smallSpacing | 123 | width: dots*(dotSize+gridThickness)+gridThickness | ||
126 | height: units.smallSpacing | 124 | height: gridThickness | ||
127 | visible: showGrid | 125 | visible: showGrid | ||
128 | color: gridColor | 126 | color: gridColor | ||
129 | } | 127 | } | ||
130 | 128 | | |||
131 | /* left grid border */ | 129 | /* left grid border */ | ||
132 | Rectangle { | 130 | Rectangle { | ||
133 | x: displayLeft-units.smallSpacing | 131 | x: displayLeft-gridThickness | ||
134 | y: displayTop | 132 | y: displayTop | ||
135 | width: units.smallSpacing | 133 | width: gridThickness | ||
136 | height: 4*(dotSize+units.smallSpacing) | 134 | height: 4*(dotSize+gridThickness) | ||
137 | visible: showGrid | 135 | visible: showGrid | ||
138 | color: gridColor | 136 | color: gridColor | ||
139 | } | 137 | } | ||
140 | } | 138 | } |