Changeset View
Standalone View
containments/desktop/package/contents/ui/AppletAppearance.qml
Show All 36 Lines | 31 | Item { | |||
---|---|---|---|---|---|
37 | property string category | 37 | property string category | ||
38 | 38 | | |||
39 | property bool showAppletHandle: false | 39 | property bool showAppletHandle: false | ||
40 | property real controlsOpacity: (plasmoid.immutable || !showAppletHandle) ? 0 : 1 | 40 | property real controlsOpacity: (plasmoid.immutable || !showAppletHandle) ? 0 : 1 | ||
41 | property string backgroundHints: "NoBackground" | 41 | property string backgroundHints: "NoBackground" | ||
42 | property bool hasBackground: false | 42 | property bool hasBackground: false | ||
43 | property bool handleMerged: (height > minimumHandleHeight && !appletHandle.forceFloating) | 43 | property bool handleMerged: (height > minimumHandleHeight && !appletHandle.forceFloating) | ||
44 | property bool animationsEnabled: false | 44 | property bool animationsEnabled: false | ||
45 | property bool floating: true // turns off layoutManagment space handling for appletItem | ||||
46 | | ||||
47 | property alias innerEndHeight: mouseListener.endHeight | ||||
48 | property alias innerEndWidth: mouseListener.endWidth | ||||
49 | property alias innerHeight: mouseListener.height | ||||
50 | property alias innerWidth: mouseListener.width | ||||
mart: mouseListener just has a simple anchors.fill:parent to this, so makes innerWidth/innerHeight… | |||||
It did. It doesn't after this patch. It's detached so that appletItem can store the final width/height and this container then animates to that position. davidedmundson: It did. It doesn't after this patch.
It's detached so that appletItem can store the final… | |||||
45 | 51 | | |||
46 | property int minimumWidth: Math.max(root.layoutManager.cellSize.width, | 52 | property int minimumWidth: Math.max(root.layoutManager.cellSize.width, | ||
47 | appletContainer.minimumWidth + | 53 | appletContainer.minimumWidth + | ||
48 | appletItem.contents.anchors.leftMargin + | 54 | margins.left + | ||
49 | appletItem.contents.anchors.rightMargin) | 55 | margins.right); | ||
50 | 56 | | |||
51 | property int minimumHeight: Math.max(root.layoutManager.cellSize.height, | 57 | property int minimumHeight: Math.max(root.layoutManager.cellSize.height, | ||
52 | appletContainer.minimumHeight + | 58 | appletContainer.minimumHeight + | ||
53 | appletItem.contents.anchors.topMargin + | 59 | margins.top + | ||
why are you including handleWidth here? From what I can see in the code; Then on line 290 it creates a container that's bigger than the parent item and does include the handle davidedmundson: why are you including handleWidth here?
From what I can see in the code;
appletItem should be… | |||||
54 | appletItem.contents.anchors.bottomMargin) | 60 | margins.bottom); | ||
61 | | ||||
62 | property int maximumWidth: appletContainer.maximumWidth + | ||||
63 | margins.left + | ||||
64 | margins.right; | ||||
65 | | ||||
66 | property int maximumHeight: appletContainer.maximumHeight + | ||||
67 | margins.top + | ||||
68 | margins.bottom; | ||||
why do you do property int foo instead of just property int foo: Math.max ? davidedmundson: why do you do
property int foo
Binding on foo {
value: Math.max()
}
instead of just… | |||||
Binding on properties used because these properties assigned in JS(in handlers onMinimumWidthChanged and others) as lvalue and it breaks normal bindings. If someone could bring better idea how to handle situation when minimum size > maximum size without these bindings then they can be removed. konstantinshtepa: Binding on properties used because these properties assigned in JS(in handlers… | |||||
55 | 69 | | |||
56 | property alias applet: appletContainer.applet | 70 | property alias applet: appletContainer.applet | ||
57 | 71 | | |||
58 | property Item contents: appletContainer | 72 | property Item contents: appletContainer | ||
59 | property alias margins: plasmoidBackground.margins | 73 | property alias margins: plasmoidBackground.margins | ||
60 | property alias imagePath: plasmoidBackground.imagePath | 74 | property alias imagePath: plasmoidBackground.imagePath | ||
61 | 75 | | |||
62 | visible: false | 76 | visible: false | ||
63 | 77 | | |||
64 | onMinimumWidthChanged: if (!widthAnimation.running) appletItem.width = Math.max(minimumWidth, width); | 78 | QtObject { | ||
65 | onMinimumHeightChanged: if (!heightAnimation.running) appletItem.height = Math.max(minimumHeight, height); | 79 | id: d | ||
80 | | ||||
81 | property real lastX: 0 | ||||
82 | property real lastY: 0 | ||||
83 | } | ||||
84 | | ||||
85 | onMinimumWidthChanged: { | ||||
86 | if (width < minimumWidth) { | ||||
87 | releasePosition(); | ||||
this is broken. if I'm an applet and do: this appletItem.maximumWidth == 58 (assuming 4px margins) Now if I do: Plasmoid.Layout.minimumWidth = 60 this appletItem.maximumWidth == 68 But, now if I do: Plasmoid.Layout.maximumWidth = 70 because we've broken the binding. We're going to need to move the if (minimumWidth > maximumWidth) logic somewhere lower. davidedmundson: this is broken.
if I'm an applet and do:
Plasmoid.Layout.maximumWidth = 50
this appletItem. | |||||
That's strange. I didn't expirienced any of this when testing. konstantinshtepa: That's strange. I didn't expirienced any of this when testing.
Binding on level appletItem. | |||||
88 | width = minimumWidth; | ||||
89 | positionItem(); | ||||
90 | if (showAppletHandle && !handleMerged) | ||||
91 | appletHandle.positionHandle(); | ||||
92 | } | ||||
93 | } | ||||
94 | onMinimumHeightChanged: { | ||||
95 | if (height < minimumHeight) { | ||||
96 | releasePosition(); | ||||
97 | height = minimumHeight; | ||||
98 | positionItem(); | ||||
99 | if (showAppletHandle && !handleMerged) | ||||
100 | appletHandle.positionHandle(); | ||||
101 | } | ||||
102 | } | ||||
103 | onMaximumWidthChanged: { | ||||
104 | if (width > maximumWidth) { | ||||
105 | releasePosition(); | ||||
106 | width = maximumWidth; | ||||
107 | positionItem(); | ||||
108 | if (showAppletHandle && !handleMerged) | ||||
109 | appletHandle.positionHandle(); | ||||
110 | } | ||||
111 | } | ||||
112 | onMaximumHeightChanged: { | ||||
113 | if (height > maximumHeight) { | ||||
114 | releasePosition(); | ||||
115 | height = maximumHeight; | ||||
116 | positionItem(); | ||||
117 | if (showAppletHandle && !handleMerged) | ||||
118 | appletHandle.positionHandle(); | ||||
119 | } | ||||
120 | } | ||||
121 | | ||||
122 | onHeightChanged: { | ||||
123 | if (height > maximumHeight) | ||||
124 | innerEndHeight = maximumHeight; | ||||
125 | else if (height < minimumHeight) | ||||
126 | innerEndHeight = minimumHeight; | ||||
127 | else | ||||
128 | innerEndHeight = height; | ||||
129 | } | ||||
130 | onWidthChanged: { | ||||
131 | if (width > maximumWidth) | ||||
132 | innerEndWidth = maximumWidth; | ||||
133 | else if (width < minimumWidth) | ||||
134 | innerEndWidth = minimumWidth; | ||||
135 | else | ||||
136 | innerEndWidth = width; | ||||
137 | } | ||||
138 | | ||||
139 | onXChanged: { | ||||
140 | if (animationsEnabled) { | ||||
141 | animationsEnabled = false; | ||||
142 | mouseListener.x += d.lastX - x; | ||||
143 | animationsEnabled = true; | ||||
144 | } | ||||
145 | mouseListener.x = mouseListener.endX = (width - innerEndWidth)/2; | ||||
146 | d.lastX = x; | ||||
147 | } | ||||
148 | onYChanged: { | ||||
149 | if (animationsEnabled) { | ||||
150 | animationsEnabled = false; | ||||
151 | mouseListener.y += d.lastY - y; | ||||
152 | animationsEnabled = true; | ||||
153 | } | ||||
154 | mouseListener.y = mouseListener.endY = (height - innerEndHeight)/2; | ||||
155 | d.lastY = y; | ||||
156 | } | ||||
157 | | ||||
158 | // use this function to position appletItem instead of root.layoutManager.positionItem(appletItem) | ||||
159 | function positionItem() { | ||||
160 | if (floating) | ||||
161 | return; | ||||
162 | root.layoutManager.positionItem(appletItem); | ||||
163 | root.layoutManager.saveItem(appletItem); | ||||
164 | } | ||||
165 | | ||||
166 | // use this function to free appletItem position instead of | ||||
167 | // root.layoutManager.setSpaceAvailable(appletItem.x, appletItem.y, appletItem.width, appletItem.height, true) | ||||
168 | function releasePosition() { | ||||
169 | if (!floating) | ||||
170 | root.layoutManager.setSpaceAvailable(x, y, width, height, true); | ||||
171 | } | ||||
66 | 172 | | |||
67 | function updateBackgroundHints() { | 173 | function updateBackgroundHints() { | ||
68 | hasBackground = (applet.backgroundHints != "NoBackground"); | 174 | hasBackground = (applet.backgroundHints != "NoBackground"); | ||
69 | if (applet.backgroundHints == 1) { | 175 | if (applet.backgroundHints == 1) { | ||
70 | appletItem.imagePath = "widgets/background"; | 176 | appletItem.imagePath = "widgets/background"; | ||
71 | backgroundHints = "StandardBackground"; | 177 | backgroundHints = "StandardBackground"; | ||
72 | } else if (applet.backgroundHints == 2) { | 178 | } else if (applet.backgroundHints == 2) { | ||
73 | appletItem.imagePath = "widgets/translucentbackground" | 179 | appletItem.imagePath = "widgets/translucentbackground" | ||
74 | backgroundHints = "TranslucentBackground"; | 180 | backgroundHints = "TranslucentBackground"; | ||
75 | } else if (applet.backgroundHints == 0) { | 181 | } else if (applet.backgroundHints == 0) { | ||
76 | appletItem.imagePath = "" | 182 | appletItem.imagePath = "" | ||
77 | backgroundHints = "NoBackground"; | 183 | backgroundHints = "NoBackground"; | ||
78 | } else { | 184 | } else { | ||
79 | backgroundHints = "DefaultBackground"; | 185 | backgroundHints = "DefaultBackground"; | ||
80 | appletItem.imagePath = "widgets/background"; | 186 | appletItem.imagePath = "widgets/background"; | ||
81 | } | 187 | } | ||
82 | //print("Backgroundhints changed: " + appletItem.imagePath); | 188 | //print("Backgroundhints changed: " + appletItem.imagePath); | ||
83 | } | 189 | } | ||
84 | 190 | | |||
85 | KQuickControlsAddons.MouseEventListener { | 191 | KQuickControlsAddons.MouseEventListener { | ||
Point is a native QML type. property point lastPoint then use that in your logic above. davidedmundson: Point is a native QML type.
http://doc.qt.io/qt-5/qml-point.html
property point lastPoint… | |||||
You can go without links. I know Qt, commited there. konstantinshtepa: You can go without links. I know Qt, commited there.
One signal when it doesn't have any… | |||||
86 | id: mouseListener | 192 | id: mouseListener | ||
193 | // used as inner applet (which would not be sized over or under size limits ) | ||||
194 | // centered in appletItem.onXChanged and onYChanged due to allow animations on X and Y | ||||
87 | 195 | | |||
88 | anchors { | 196 | property int pressX: -1 | ||
89 | fill: parent | 197 | property int pressY: -1 | ||
90 | } | 198 | | ||
199 | // for animations | ||||
200 | property int endHeight: minimumHeight | ||||
201 | property int endWidth: minimumWidth | ||||
202 | property int endX: 0 | ||||
203 | property int endY: 0 | ||||
204 | | ||||
205 | height: endHeight | ||||
206 | width: endWidth | ||||
91 | z: 10 | 207 | z: 10 | ||
92 | 208 | | |||
93 | hoverEnabled: true | 209 | hoverEnabled: true | ||
94 | 210 | | |||
95 | property int pressX: -1 | | |||
96 | property int pressY: -1 | | |||
97 | | ||||
98 | onPressed: { | 211 | onPressed: { | ||
99 | pressX = mouse.x; | 212 | pressX = mouse.x; | ||
100 | pressY = mouse.y; | 213 | pressY = mouse.y; | ||
101 | } | 214 | } | ||
102 | 215 | | |||
103 | onPressAndHold: { | 216 | onPressAndHold: { | ||
104 | if (!plasmoid.immutable && plasmoid.configuration.pressToMove) { | 217 | if (!plasmoid.immutable && plasmoid.configuration.pressToMove) { | ||
105 | if (!dragMouseArea.dragging && !root.isDrag(pressX, pressY, mouse.x, mouse.y)) { | 218 | if (!dragMouseArea.dragging && !root.isDrag(pressX, pressY, mouse.x, mouse.y)) { | ||
Show All 32 Lines | 250 | } else if (!dragMouseArea.dragging) { | |||
138 | showAppletHandle = false; | 251 | showAppletHandle = false; | ||
139 | } | 252 | } | ||
140 | } | 253 | } | ||
141 | } | 254 | } | ||
142 | 255 | | |||
143 | Item { | 256 | Item { | ||
144 | anchors { left: parent.left; top: parent.top; bottom: parent.bottom; } | 257 | anchors { left: parent.left; top: parent.top; bottom: parent.bottom; } | ||
145 | width: parent.width+handleWidth; | 258 | width: parent.width+handleWidth; | ||
146 | | ||||
147 | z: mouseListener.z + 4 | 259 | z: mouseListener.z + 4 | ||
148 | 260 | | |||
149 | PlasmaCore.FrameSvgItem { | 261 | PlasmaCore.FrameSvgItem { | ||
150 | id: plasmoidBackground | 262 | id: plasmoidBackground | ||
151 | visible: backgroundHints != PlasmaCore.Types.NoBackground | 263 | visible: backgroundHints != PlasmaCore.Types.NoBackground | ||
152 | imagePath: "widgets/background" | 264 | imagePath: "widgets/background" | ||
153 | anchors { left: parent.left; top: parent.top; bottom: parent.bottom; } | 265 | anchors { left: parent.left; top: parent.top; bottom: parent.bottom; } | ||
154 | width: (showAppletHandle && handleMerged) ? parent.width : parent.width-handleWidth; | 266 | width: parent.width - _handleWidth | ||
155 | smooth: true | 267 | smooth: true | ||
156 | 268 | | |||
157 | Behavior on width { | 269 | property real _handleWidth: (showAppletHandle && handleMerged) ? 0 : handleWidth | ||
270 | | ||||
271 | Behavior on _handleWidth { | ||||
158 | enabled: animationsEnabled | 272 | enabled: animationsEnabled | ||
159 | NumberAnimation { | 273 | NumberAnimation { | ||
160 | duration: units.longDuration | 274 | duration: units.longDuration | ||
161 | easing.type: Easing.InOutQuad | 275 | easing.type: Easing.InOutQuad | ||
162 | } | 276 | } | ||
163 | } | 277 | } | ||
164 | } | 278 | } | ||
165 | 279 | | |||
166 | Connections { | 280 | Connections { | ||
167 | target: plasmoid | 281 | target: plasmoid | ||
168 | onImmutableChanged: { | 282 | onImmutableChanged: { | ||
169 | // print(" TB dragMouseArea.visible: " + plasmoid.immutable) | 283 | // print(" TB dragMouseArea.visible: " + plasmoid.immutable) | ||
170 | dragMouseArea.visible = !plasmoid.immutable; | 284 | dragMouseArea.visible = !plasmoid.immutable; | ||
171 | showAppletHandle = false; | 285 | showAppletHandle = false; | ||
172 | } | 286 | } | ||
173 | onAppletRemoved: { | 287 | onAppletRemoved: { | ||
174 | // print("Applet removed Applet-" + applet.id) | 288 | // print("Applet removed Applet-" + applet.id) | ||
175 | if (applet.id == appletItem.applet.id) { | 289 | if (applet.id == appletItem.applet.id) { | ||
176 | // print("Destroying Applet-" + applet.id) | 290 | // print("Destroying Applet-" + applet.id) | ||
177 | root.layoutManager.saveRotation(appletItem); | 291 | root.layoutManager.saveRotation(appletItem); | ||
178 | root.layoutManager.setSpaceAvailable(appletItem.x, appletItem.y, appletItem.width, appletItem.height, true) | 292 | appletItem.releasePosition(); | ||
179 | //applet.action("remove").trigger(); | 293 | //applet.action("remove").trigger(); | ||
180 | //appletItem.destroy() | 294 | //appletItem.destroy() | ||
181 | appletItem.destroy(); | 295 | appletItem.destroy(); | ||
182 | } | 296 | } | ||
183 | } | 297 | } | ||
184 | } | 298 | } | ||
185 | Connections { | 299 | Connections { | ||
186 | target: applet | 300 | target: applet | ||
Show All 16 Lines | 308 | MouseArea { | |||
203 | drag.target: appletItem | 317 | drag.target: appletItem | ||
204 | property bool dragging: false // Set by mouseListener.onPressAndHold -- drag.active only becomes true on movement. | 318 | property bool dragging: false // Set by mouseListener.onPressAndHold -- drag.active only becomes true on movement. | ||
205 | 319 | | |||
206 | function endDrag() { | 320 | function endDrag() { | ||
207 | appletItem.z = appletItem.z - zoffset; | 321 | appletItem.z = appletItem.z - zoffset; | ||
208 | repositionTimer.running = false; | 322 | repositionTimer.running = false; | ||
209 | placeHolderPaint.opacity = 0; | 323 | placeHolderPaint.opacity = 0; | ||
210 | animationsEnabled = true; | 324 | animationsEnabled = true; | ||
211 | root.layoutManager.positionItem(appletItem); | 325 | appletItem.floating = false; | ||
326 | appletItem.positionItem(); | ||||
212 | root.layoutManager.save(); | 327 | root.layoutManager.save(); | ||
213 | dragging = false; | 328 | dragging = false; | ||
214 | } | 329 | } | ||
215 | 330 | | |||
216 | onDraggingChanged: { | 331 | onDraggingChanged: { | ||
217 | cursorShape = dragging ? Qt.DragMoveCursor : Qt.ArrowCursor; | 332 | cursorShape = dragging ? Qt.DragMoveCursor : Qt.ArrowCursor; | ||
218 | } | 333 | } | ||
219 | 334 | | |||
220 | onPressed: { | 335 | onPressed: { | ||
221 | appletItem.z = appletItem.z + zoffset; | 336 | appletItem.z = appletItem.z + zoffset; | ||
222 | animationsEnabled = plasmoid.configuration.pressToMove ? true : false; | 337 | animationsEnabled = false; | ||
223 | mouse.accepted = true; | 338 | mouse.accepted = true; | ||
224 | root.layoutManager.setSpaceAvailable(appletItem.x, appletItem.y, appletItem.width, appletItem.height, true); | 339 | appletItem.releasePosition(); | ||
340 | appletItem.floating = true; | ||||
225 | 341 | | |||
226 | placeHolder.syncWithItem(appletItem); | 342 | placeHolder.syncWithItem(appletItem); | ||
227 | placeHolderPaint.opacity = root.haloOpacity; | 343 | placeHolderPaint.opacity = root.haloOpacity; | ||
228 | } | 344 | } | ||
229 | 345 | | |||
230 | onPositionChanged: { | 346 | onPositionChanged: { | ||
231 | var pos = mapToItem(root.parent, mouse.x, mouse.y); | 347 | var pos = mapToItem(root.parent, mouse.x, mouse.y); | ||
232 | var newCont = plasmoid.containmentAt(pos.x, pos.y); | 348 | var newCont = plasmoid.containmentAt(pos.x, pos.y); | ||
Show All 25 Lines | 372 | anchors { | |||
258 | leftMargin: plasmoidBackground.margins.left | 374 | leftMargin: plasmoidBackground.margins.left | ||
259 | rightMargin: plasmoidBackground.margins.right + handleWidth | 375 | rightMargin: plasmoidBackground.margins.right + handleWidth | ||
260 | topMargin: plasmoidBackground.margins.top | 376 | topMargin: plasmoidBackground.margins.top | ||
261 | bottomMargin: plasmoidBackground.margins.bottom | 377 | bottomMargin: plasmoidBackground.margins.bottom | ||
262 | } | 378 | } | ||
263 | z: mouseListener.z+1 | 379 | z: mouseListener.z+1 | ||
264 | 380 | | |||
265 | property QtObject applet | 381 | property QtObject applet | ||
382 | readonly property int maxInt: 1000000 // dirty hack to convert js number to qml int | ||||
266 | 383 | | |||
267 | property var minimumSize: { | 384 | property var minimumSize: { | ||
268 | var size; | 385 | var size; | ||
269 | if (applet && applet.Layout) { | 386 | if (applet && applet.Layout) { | ||
270 | var layout = applet.Layout | 387 | var layout = applet.Layout | ||
271 | size = { 'width': layout.minimumWidth, | 388 | size = { 'width': layout.minimumWidth, | ||
272 | 'height': layout.minimumHeight }; | 389 | 'height': layout.minimumHeight }; | ||
273 | } else { | 390 | } else { | ||
274 | size = { 'width': 0, 'height': 0 }; | 391 | size = { 'width': 0, 'height': 0 }; | ||
275 | } | 392 | } | ||
276 | 393 | | |||
277 | return size; | 394 | return size; | ||
278 | } | 395 | } | ||
279 | 396 | | |||
280 | property int minimumWidth: minimumSize.width; | 397 | property var maximumSize: { | ||
Edit, maybe it won't - that's why you have the separate Binding. However changing this to: for all 4 would still be a bit cleaner as then appletItem can trust these values are correct davidedmundson: Edit, maybe it won't - that's why you have the separate Binding.
However changing this to… | |||||
Ok. I didn't think about this possibility. Maybe you are right and it would be better. If so then I can remove separate bindings. I will test it. konstantinshtepa: Ok. I didn't think about this possibility. Maybe you are right and it would be better. If so… | |||||
It wouldn't work. konstantinshtepa: It wouldn't work.
For example:
plasmoid.Layout.minimumHeight = 150
plasmoid.Layout. | |||||
konstantinshtepa: Ok, I removed bindings at cost of two additional handlers. | |||||
281 | property int minimumHeight: minimumSize.height; | 398 | var size; | ||
399 | if (applet && applet.Layout) { | ||||
400 | var layout = applet.Layout | ||||
401 | size = { 'width': layout.maximumWidth, | ||||
402 | 'height': layout.maximumHeight }; | ||||
403 | } else { | ||||
404 | size = { 'width': Number.POSITIVE_INFINITY, | ||||
405 | 'height': Number.POSITIVE_INFINITY }; | ||||
406 | | ||||
407 | } | ||||
408 | | ||||
409 | if (size.width > maxInt) | ||||
if maximum is infinite, (so undefined in QtQuick.Layouts) set it to 1000000 why? davidedmundson: if maximum is infinite, (so undefined in QtQuick.Layouts) set it to 1000000
why?
It's far… | |||||
Just a few lines below this size is assigned for property with int as a base. Then this property is used in operations with others int-based kde sizes. And keep it as double is not a option because of default Qt maximumSize(Number.POSITIVE_INFINITY). So there goes 1000000. Is there better way? konstantinshtepa: Just a few lines below this size is assigned for property with int as a base. Then this… | |||||
410 | size.width = maxInt; | ||||
411 | if (size.height > maxInt) | ||||
412 | size.height = maxInt; | ||||
413 | | ||||
414 | return size; | ||||
415 | } | ||||
416 | | ||||
417 | onMinimumSizeChanged: { | ||||
418 | minimumHeight = minimumSize.height | ||||
419 | if (minimumHeight > maximumSize.height) | ||||
420 | maximumHeight = minimumHeight | ||||
421 | else if (maximumHeight !== maximumSize.height) | ||||
422 | maximumHeight = maximumSize.height | ||||
423 | | ||||
424 | minimumWidth = minimumSize.width | ||||
425 | if (minimumWidth > maximumSize.width) | ||||
426 | maximumWidth = minimumWidth | ||||
427 | else if (maximumWidth !== maximumSize.width) | ||||
428 | maximumWidth = maximumSize.width | ||||
429 | } | ||||
430 | | ||||
431 | onMaximumSizeChanged: { | ||||
432 | maximumHeight = maximumSize.height | ||||
433 | if (maximumHeight < minimumSize.height) | ||||
434 | minimumHeight = maximumHeight | ||||
435 | else if (minimumHeight !== minimumSize.height) | ||||
436 | minimumHeight = minimumSize.height | ||||
437 | | ||||
438 | maximumWidth = maximumSize.width | ||||
439 | if (maximumWidth < minimumSize.width) | ||||
440 | minimumWidth = maximumWidth | ||||
441 | else if (minimumWidth !== minimumSize.width) | ||||
442 | minimumWidth = minimumSize.width | ||||
443 | } | ||||
444 | | ||||
445 | property int minimumWidth: 0 | ||||
446 | property int minimumHeight: 0 | ||||
447 | | ||||
448 | property int maximumWidth: maxInt | ||||
449 | property int maximumHeight: maxInt | ||||
282 | 450 | | |||
283 | function appletDestroyed() { | 451 | function appletDestroyed() { | ||
284 | // print("Applet DESTROYED."); | 452 | // print("Applet DESTROYED."); | ||
285 | root.layoutManager.setSpaceAvailable(appletItem.x, appletItem.y, appletItem.width, appletItem.height, true) | 453 | appletItem.releasePosition(); | ||
286 | applet.action("remove").trigger(); | 454 | applet.action("remove").trigger(); | ||
287 | appletItem.destroy() | 455 | appletItem.destroy() | ||
288 | } | 456 | } | ||
289 | 457 | | |||
290 | onAppletChanged: { | 458 | onAppletChanged: { | ||
291 | if (!applet) { | 459 | if (!applet) { | ||
292 | return; | 460 | return; | ||
293 | } | 461 | } | ||
294 | | ||||
295 | applet.parent = appletContainer; | 462 | applet.parent = appletContainer; | ||
296 | applet.anchors.fill = appletContainer; | 463 | applet.anchors.fill = appletContainer; | ||
297 | 464 | | |||
298 | updateBackgroundHints(); | 465 | updateBackgroundHints(); | ||
299 | } | 466 | } | ||
300 | Connections { | 467 | Connections { | ||
301 | target: appletHandle.item | 468 | target: appletHandle.item | ||
302 | onRemoveApplet: { | 469 | onRemoveApplet: { | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 540 | onMoveFinished: { | |||
374 | appletHandle.positionHandle(); | 541 | appletHandle.positionHandle(); | ||
375 | } | 542 | } | ||
376 | } | 543 | } | ||
377 | 544 | | |||
378 | function positionHandle() | 545 | function positionHandle() | ||
379 | { | 546 | { | ||
380 | // Don't show handle outside of desktop | 547 | // Don't show handle outside of desktop | ||
381 | var available = plasmoid.availableScreenRect; | 548 | var available = plasmoid.availableScreenRect; | ||
382 | var x = Math.min(Math.max(0, appletItem.x), available.width - appletItem.width); | 549 | var x = Math.min(Math.max(0, appletItem.x + mouseListener.endX), available.width - appletItem.width + mouseListener.endX); | ||
383 | var y = Math.min(Math.max(0, appletItem.y), available.height - appletItem.height); | 550 | var y = Math.min(Math.max(0, appletItem.y + mouseListener.endY), available.height - appletItem.height + mouseListener.endY); | ||
384 | var verticalCenter = (y + appletItem.height / 2); | 551 | var verticalCenter = (y + mouseListener.endHeight / 2); | ||
385 | var topOutside = (verticalCenter - minimumHandleHeight / 2); | 552 | var topOutside = (verticalCenter - minimumHandleHeight / 2); | ||
386 | var bottomOutside = verticalCenter + minimumHandleHeight / 2 - available.height; | 553 | var bottomOutside = verticalCenter + minimumHandleHeight / 2 - available.height; | ||
387 | if (bottomOutside > 0) { | 554 | if (bottomOutside > 0) { | ||
388 | anchors.verticalCenterOffset = -bottomOutside; | 555 | anchors.verticalCenterOffset = -bottomOutside; | ||
389 | } else if (topOutside < 0) { | 556 | } else if (topOutside < 0) { | ||
390 | anchors.verticalCenterOffset = -topOutside; | 557 | anchors.verticalCenterOffset = -topOutside; | ||
391 | } else { | 558 | } else { | ||
392 | anchors.verticalCenterOffset = 0; | 559 | anchors.verticalCenterOffset = 0; | ||
393 | } | 560 | } | ||
394 | var rightOutside = x + appletItem.width + handleWidth - available.width; | 561 | var rightOutside = x + mouseListener.endWidth + handleWidth - available.width; | ||
395 | appletHandle.anchors.rightMargin = appletItem.margins.right + Math.max(0, rightOutside); | 562 | appletHandle.anchors.rightMargin = appletItem.margins.right + Math.max(0, rightOutside); | ||
396 | appletHandle.forceFloating = rightOutside > 0; | 563 | appletHandle.forceFloating = rightOutside > 0; | ||
397 | } | 564 | } | ||
398 | } | 565 | } | ||
399 | } | 566 | } | ||
400 | } | | |||
401 | 567 | | |||
402 | Behavior on controlsOpacity { | | |||
403 | NumberAnimation { | | |||
404 | duration: units.longDuration | | |||
405 | easing.type: Easing.InOutQuad | | |||
406 | } | | |||
407 | } | | |||
408 | Behavior on x { | 568 | Behavior on x { | ||
409 | enabled: animationsEnabled | 569 | enabled: animationsEnabled | ||
410 | NumberAnimation { | 570 | NumberAnimation { | ||
411 | duration: units.longDuration | 571 | duration: units.longDuration | ||
412 | easing.type: Easing.InOutQuad | 572 | easing.type: Easing.InOutQuad | ||
413 | } | 573 | } | ||
414 | } | 574 | } | ||
415 | Behavior on y { | 575 | Behavior on y { | ||
Show All 14 Lines | |||||
430 | Behavior on height { | 590 | Behavior on height { | ||
431 | enabled: animationsEnabled | 591 | enabled: animationsEnabled | ||
432 | NumberAnimation { | 592 | NumberAnimation { | ||
433 | id: heightAnimation | 593 | id: heightAnimation | ||
434 | duration: units.longDuration | 594 | duration: units.longDuration | ||
435 | easing.type: Easing.InOutQuad | 595 | easing.type: Easing.InOutQuad | ||
436 | } | 596 | } | ||
437 | } | 597 | } | ||
598 | } | ||||
599 | | ||||
600 | Behavior on controlsOpacity { | ||||
601 | NumberAnimation { | ||||
602 | duration: units.longDuration | ||||
603 | easing.type: Easing.InOutQuad | ||||
604 | } | ||||
605 | } | ||||
438 | 606 | | |||
439 | Component.onCompleted: { | 607 | Component.onCompleted: { | ||
608 | floating = false; | ||||
440 | layoutTimer.running = true | 609 | layoutTimer.running = true | ||
441 | layoutTimer.restart() | 610 | layoutTimer.restart() | ||
442 | visible = false | 611 | visible = false | ||
443 | } | 612 | } | ||
444 | } | 613 | } |
mouseListener just has a simple anchors.fill:parent to this, so makes innerWidth/innerHeight redundant as they are the same as the parent?