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 squares: showSeconds ? 6 : 4 | ||
41 | readonly property real w1: (main.height-5*units.smallSpacing)*squares/4 | ||||
41 | 42 | | |||
42 | Layout.minimumWidth: w1 < 20 ? 20 : w1 | 43 | Layout.minimumWidth: w1 < 20 ? 20 : w1 | ||
43 | Layout.maximumWidth: Infinity | 44 | Layout.maximumWidth: Infinity | ||
44 | Layout.preferredWidth: Layout.minimumWidth | 45 | Layout.preferredWidth: Layout.minimumWidth | ||
45 | 46 | | |||
46 | Layout.minimumHeight: 16+(units.smallSpacing*5) | 47 | Layout.minimumHeight: 16+(units.smallSpacing*5) | ||
47 | //Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity | 48 | //Layout.maximumHeight: vertical ? Layout.minimumHeight : Infinity | ||
48 | //Layout.preferredHeight: Layout.minimumHeight | 49 | //Layout.preferredHeight: Layout.minimumHeight | ||
49 | 50 | | |||
50 | readonly property int formFactor: plasmoid.formFactor | 51 | readonly property int formFactor: plasmoid.formFactor | ||
51 | 52 | | |||
52 | readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal | 53 | readonly property bool constrained: formFactor == PlasmaCore.Types.Vertical || formFactor == PlasmaCore.Types.Horizontal | ||
53 | 54 | | |||
54 | readonly property bool showSeconds: root.showSeconds | 55 | readonly property bool showSeconds: root.showSeconds | ||
55 | 56 | | |||
56 | readonly property int hours: root.hours | 57 | readonly property int hours: root.hours | ||
57 | readonly property int minutes: root.minutes | 58 | readonly property int minutes: root.minutes | ||
58 | readonly property int seconds: root.seconds | 59 | readonly property int seconds: root.seconds | ||
59 | 60 | | |||
60 | readonly property bool showOffLeds: plasmoid.configuration.showOffLeds | 61 | readonly property bool showOffLeds: plasmoid.configuration.showOffLeds | ||
61 | readonly property bool showGrid: plasmoid.configuration.showGrid | 62 | readonly property bool showGrid: plasmoid.configuration.showGrid | ||
62 | 63 | | |||
63 | readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16 | 64 | readonly property int base: plasmoid.configuration.showBcdFormat ? 10 : 16 | ||
64 | 65 | | |||
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 int squareSize: Math.min((height-5*units.smallSpacing)/4, (width-(squares+1)*units.smallSpacing)/squares) | ||
72 | readonly property real displayTop: (height - 4*dotSize-3*units.smallSpacing)/2 | 71 | readonly property real displayTop: (height - 4*squareSize-3*units.smallSpacing)/2 | ||
73 | readonly property real displayLeft: (width - dots*dotSize-(dots-1)*units.smallSpacing)/2 | 72 | readonly property real displayLeft: (width - squares*squareSize-(squares-1)*units.smallSpacing)/2 | ||
74 | 73 | | |||
75 | /* displaying calendar after clicking binary clock applet */ | 74 | /* displaying calendar after clicking binary clock applet */ | ||
76 | MouseArea { | 75 | MouseArea { | ||
77 | id: mouseArea | 76 | id: mouseArea | ||
78 | anchors.fill: parent | 77 | anchors.fill: parent | ||
79 | hoverEnabled: true | 78 | hoverEnabled: true | ||
80 | onClicked: plasmoid.expanded = !plasmoid.expanded | 79 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
81 | } | 80 | } | ||
82 | 81 | | |||
83 | /* hours */ | 82 | /* hours */ | ||
84 | DotColumn { | 83 | SquareColumn { | ||
85 | x: displayLeft | 84 | x: displayLeft | ||
86 | y: displayTop | 85 | y: displayTop | ||
87 | val: hours/base | 86 | val: hours/base | ||
88 | } | 87 | } | ||
89 | DotColumn { | 88 | SquareColumn { | ||
90 | x: displayLeft+(dotSize+units.smallSpacing) | 89 | x: displayLeft+(squareSize+units.smallSpacing) | ||
91 | y: displayTop | 90 | y: displayTop | ||
92 | val: hours%base | 91 | val: hours%base | ||
93 | } | 92 | } | ||
94 | 93 | | |||
95 | /* minutes */ | 94 | /* minutes */ | ||
96 | DotColumn { | 95 | SquareColumn { | ||
97 | x: displayLeft+(dotSize+units.smallSpacing)*2 | 96 | x: displayLeft+(squareSize+units.smallSpacing)*2 | ||
98 | y: displayTop | 97 | y: displayTop | ||
99 | val: minutes/base | 98 | val: minutes/base | ||
100 | } | 99 | } | ||
101 | DotColumn { | 100 | SquareColumn { | ||
102 | x: displayLeft+(dotSize+units.smallSpacing)*3 | 101 | x: displayLeft+(squareSize+units.smallSpacing)*3 | ||
103 | y: displayTop | 102 | y: displayTop | ||
104 | val: minutes%base | 103 | val: minutes%base | ||
105 | } | 104 | } | ||
106 | 105 | | |||
107 | /* seconds */ | 106 | /* seconds */ | ||
108 | DotColumn { | 107 | SquareColumn { | ||
109 | x: displayLeft+(dotSize+units.smallSpacing)*4 | 108 | x: displayLeft+(squareSize+units.smallSpacing)*4 | ||
110 | y: displayTop | 109 | y: displayTop | ||
111 | val: seconds/base | 110 | val: seconds/base | ||
112 | visible: showSeconds | 111 | visible: showSeconds | ||
113 | } | 112 | } | ||
114 | DotColumn { | 113 | SquareColumn { | ||
115 | x: displayLeft+(dotSize+units.smallSpacing)*5 | 114 | x: displayLeft+(squareSize+units.smallSpacing)*5 | ||
116 | y: displayTop | 115 | y: displayTop | ||
117 | val: seconds%base | 116 | val: seconds%base | ||
118 | visible: showSeconds | 117 | visible: showSeconds | ||
119 | } | 118 | } | ||
120 | 119 | | |||
121 | /* upper grid border */ | 120 | /* upper grid border */ | ||
122 | Rectangle { | 121 | Rectangle { | ||
123 | x: displayLeft-units.smallSpacing | 122 | x: displayLeft-units.smallSpacing | ||
124 | y: displayTop-units.smallSpacing | 123 | y: displayTop-units.smallSpacing | ||
125 | width: dots*(dotSize+units.smallSpacing)+units.smallSpacing | 124 | width: squares*(squareSize+units.smallSpacing)+units.smallSpacing | ||
126 | height: units.smallSpacing | 125 | height: units.smallSpacing | ||
127 | visible: showGrid | 126 | visible: showGrid | ||
128 | color: gridColor | 127 | color: gridColor | ||
129 | } | 128 | } | ||
130 | 129 | | |||
131 | /* left grid border */ | 130 | /* left grid border */ | ||
132 | Rectangle { | 131 | Rectangle { | ||
133 | x: displayLeft-units.smallSpacing | 132 | x: displayLeft-units.smallSpacing | ||
134 | y: displayTop | 133 | y: displayTop | ||
135 | width: units.smallSpacing | 134 | width: units.smallSpacing | ||
136 | height: 4*(dotSize+units.smallSpacing) | 135 | height: 4*(squareSize+units.smallSpacing) | ||
137 | visible: showGrid | 136 | visible: showGrid | ||
138 | color: gridColor | 137 | color: gridColor | ||
139 | } | 138 | } | ||
140 | } | 139 | } | ||
140 | No newline at end of file |