Changeset View
Changeset View
Standalone View
Standalone View
kcms/desktoptheme/package/contents/ui/ThemePreview.qml
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 53 | RowLayout { | |||
---|---|---|---|---|---|
92 | Item { | 92 | Item { | ||
93 | id: clock | 93 | id: clock | ||
94 | Layout.fillHeight: true | 94 | Layout.fillHeight: true | ||
95 | Layout.preferredWidth: height | 95 | Layout.preferredWidth: height | ||
96 | 96 | | |||
97 | property int hours: 9 | 97 | property int hours: 9 | ||
98 | property int minutes: 5 | 98 | property int minutes: 5 | ||
99 | 99 | | |||
100 | readonly property double svgScale: face.width / face.naturalSize.width | ||||
101 | readonly property double horizontalShadowOffset: | ||||
102 | Math.round(clockSvg.naturalHorizontalHandShadowOffset * svgScale) + Math.round(clockSvg.naturalHorizontalHandShadowOffset * svgScale) % 2 | ||||
103 | readonly property double verticalShadowOffset: | ||||
104 | Math.round(clockSvg.naturalVerticalHandShadowOffset * svgScale) + Math.round(clockSvg.naturalVerticalHandShadowOffset * svgScale) % 2 | ||||
105 | | ||||
100 | PlasmaCore.Svg { | 106 | PlasmaCore.Svg { | ||
101 | id: clockSvg | 107 | id: clockSvg | ||
102 | imagePath: "widgets/clock" | 108 | imagePath: "widgets/clock" | ||
109 | function estimateHorizontalHandShadowOffset() { | ||||
110 | var id = "hint-hands-shadow-offset-to-west"; | ||||
111 | if (hasElement(id)) { | ||||
112 | return -elementSize(id).width; | ||||
113 | } | ||||
114 | id = "hint-hands-shadows-offset-to-east"; | ||||
115 | if (hasElement(id)) { | ||||
116 | return elementSize(id).width; | ||||
117 | } | ||||
118 | return 0; | ||||
119 | } | ||||
120 | function estimateVerticalHandShadowOffset() { | ||||
121 | var id = "hint-hands-shadow-offset-to-north"; | ||||
122 | if (hasElement(id)) { | ||||
123 | return -elementSize(id).height; | ||||
124 | } | ||||
125 | id = "hint-hands-shadow-offset-to-south"; | ||||
126 | if (hasElement(id)) { | ||||
127 | return elementSize(id).height; | ||||
128 | } | ||||
129 | return 0; | ||||
130 | } | ||||
131 | property double naturalHorizontalHandShadowOffset: estimateHorizontalHandShadowOffset() | ||||
132 | property double naturalVerticalHandShadowOffset: estimateVerticalHandShadowOffset() | ||||
133 | onRepaintNeeded: { | ||||
134 | naturalHorizontalHandShadowOffset = estimateHorizontalHandShadowOffset(); | ||||
135 | naturalVerticalHandShadowOffset = estimateVerticalHandShadowOffset(); | ||||
136 | } | ||||
103 | } | 137 | } | ||
104 | 138 | | |||
105 | PlasmaCore.SvgItem { | 139 | PlasmaCore.SvgItem { | ||
106 | id: face | 140 | id: face | ||
107 | anchors.centerIn: parent | 141 | anchors.centerIn: parent | ||
108 | width: Math.min(parent.width, parent.height) | 142 | width: Math.min(parent.width, parent.height) | ||
109 | height: Math.min(parent.width, parent.height) | 143 | height: Math.min(parent.width, parent.height) | ||
110 | svg: clockSvg | 144 | svg: clockSvg | ||
111 | elementId: "ClockFace" | 145 | elementId: "ClockFace" | ||
112 | } | 146 | } | ||
113 | 147 | | |||
114 | Hand { | 148 | Hand { | ||
115 | elementId: "HourHand" | 149 | elementId: "HourHand" | ||
150 | rotationCenterHintId: "hint-hourhand-rotation-center-offset" | ||||
116 | rotation: 180 + clock.hours * 30 + (clock.minutes/2) | 151 | rotation: 180 + clock.hours * 30 + (clock.minutes/2) | ||
117 | svgScale: face.width / face.naturalSize.width | 152 | svgScale: clock.svgScale | ||
118 | } | 153 | } | ||
119 | 154 | | |||
120 | Hand { | 155 | Hand { | ||
121 | elementId: "MinuteHand" | 156 | elementId: "MinuteHand" | ||
157 | rotationCenterHintId: "hint-minutehand-rotation-center-offset" | ||||
122 | rotation: 180 + clock.minutes * 6 | 158 | rotation: 180 + clock.minutes * 6 | ||
123 | svgScale: face.width / face.naturalSize.width | 159 | svgScale: clock.svgScale | ||
124 | } | 160 | } | ||
125 | 161 | | |||
126 | PlasmaCore.SvgItem { | 162 | PlasmaCore.SvgItem { | ||
127 | id: center | 163 | id: center | ||
128 | width: naturalSize.width * face.width / face.naturalSize.width | 164 | width: naturalSize.width * clock.svgScale | ||
129 | height: naturalSize.height * face.width / face.naturalSize.width | 165 | height: naturalSize.height * clock.svgScale | ||
130 | anchors.centerIn: clock | 166 | anchors.centerIn: clock | ||
131 | svg: clockSvg | 167 | svg: clockSvg | ||
132 | elementId: "HandCenterScrew" | 168 | elementId: "HandCenterScrew" | ||
133 | z: 1000 | 169 | z: 1000 | ||
134 | } | 170 | } | ||
135 | 171 | | |||
136 | PlasmaCore.SvgItem { | 172 | PlasmaCore.SvgItem { | ||
137 | anchors.fill: face | 173 | anchors.fill: face | ||
138 | svg: clockSvg | 174 | svg: clockSvg | ||
139 | elementId: "Glass" | 175 | elementId: "Glass" | ||
140 | width: naturalSize.width * face.width / face.naturalSize.width | 176 | width: naturalSize.width * clock.svgScale | ||
141 | height: naturalSize.height * face.width / face.naturalSize.width | 177 | height: naturalSize.height * clock.svgScale | ||
142 | } | 178 | } | ||
143 | } | 179 | } | ||
144 | } | 180 | } | ||
145 | 181 | | |||
146 | Component.onCompleted: { | 182 | Component.onCompleted: { | ||
147 | kcm.applyPlasmaTheme(root, themeName); | 183 | kcm.applyPlasmaTheme(root, themeName); | ||
148 | } | 184 | } | ||
149 | } | 185 | } |