Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/main.qml
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2011-2013 Sebastian Kügler <sebas@kde.org> * | 2 | * Copyright (C) 2011-2013 Sebastian Kügler <sebas@kde.org> * | ||
3 | * Copyright (C) 2011 Marco Martin <mart@kde.org> * | 3 | * Copyright (C) 2011-2019 Marco Martin <mart@kde.org> * | ||
4 | * Copyright (C) 2014-2015 by Eike Hein <hein@kde.org> * | 4 | * Copyright (C) 2014-2015 by Eike Hein <hein@kde.org> * | ||
5 | * * | 5 | * * | ||
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * | ||
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * | ||
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * | ||
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * | ||
10 | * * | 10 | * * | ||
11 | * This program is distributed in the hope that it will be useful, * | 11 | * This program is distributed in the hope that it will be useful, * | ||
Show All 14 Lines | |||||
26 | import org.kde.plasma.core 2.0 as PlasmaCore | 26 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
27 | import org.kde.plasma.components 2.0 as PlasmaComponents | 27 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
28 | import org.kde.draganddrop 2.0 as DragDrop | 28 | import org.kde.draganddrop 2.0 as DragDrop | ||
29 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | 29 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | ||
30 | 30 | | |||
31 | import org.kde.private.desktopcontainment.desktop 0.1 as Desktop | 31 | import org.kde.private.desktopcontainment.desktop 0.1 as Desktop | ||
32 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | 32 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | ||
33 | 33 | | |||
34 | import "code/LayoutManager.js" as LayoutManager | 34 | import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager | ||
35 | | ||||
35 | import "code/FolderTools.js" as FolderTools | 36 | import "code/FolderTools.js" as FolderTools | ||
36 | 37 | | |||
37 | FolderViewDropArea { | 38 | FolderViewDropArea { | ||
38 | id: root | 39 | id: root | ||
39 | objectName: isFolder ? "folder" : "desktop" | 40 | objectName: isFolder ? "folder" : "desktop" | ||
40 | 41 | | |||
41 | width: isPopup ? undefined : preferredWidth(false) // Initial size when adding to e.g. desktop. | 42 | width: isPopup ? undefined : preferredWidth(false) // Initial size when adding to e.g. desktop. | ||
42 | height: isPopup ? undefined : preferredHeight(false) // Initial size when adding to e.g. desktop. | 43 | height: isPopup ? undefined : preferredHeight(false) // Initial size when adding to e.g. desktop. | ||
Show All 30 Lines | |||||
73 | 74 | | |||
74 | property bool isFolder: (plasmoid.pluginName === "org.kde.plasma.folder") | 75 | property bool isFolder: (plasmoid.pluginName === "org.kde.plasma.folder") | ||
75 | property bool isContainment: ("containmentType" in plasmoid) | 76 | property bool isContainment: ("containmentType" in plasmoid) | ||
76 | property bool isPopup: (plasmoid.location !== PlasmaCore.Types.Floating) | 77 | property bool isPopup: (plasmoid.location !== PlasmaCore.Types.Floating) | ||
77 | property bool useListViewMode: isPopup && plasmoid.configuration.viewMode === 0 | 78 | property bool useListViewMode: isPopup && plasmoid.configuration.viewMode === 0 | ||
78 | 79 | | |||
79 | property Component appletAppearanceComponent | 80 | property Component appletAppearanceComponent | ||
80 | property Item toolBox | 81 | property Item toolBox | ||
81 | property var layoutManager: LayoutManager | | |||
82 | 82 | | |||
83 | property int handleDelay: 800 | 83 | property int handleDelay: 800 | ||
84 | property real haloOpacity: 0.5 | 84 | property real haloOpacity: 0.5 | ||
85 | 85 | | |||
86 | property int iconSize: units.iconSizes.small | 86 | property int iconSize: units.iconSizes.small | ||
87 | property int iconWidth: iconSize | 87 | property int iconWidth: iconSize | ||
88 | property int iconHeight: iconWidth | 88 | property int iconHeight: iconWidth | ||
89 | 89 | | |||
Show All 30 Lines | 119 | Behavior on anchors.rightMargin { | |||
120 | NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } | 120 | NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } | ||
121 | } | 121 | } | ||
122 | Behavior on anchors.bottomMargin { | 122 | Behavior on anchors.bottomMargin { | ||
123 | NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } | 123 | NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } | ||
124 | } | 124 | } | ||
125 | 125 | | |||
126 | function updateGridSize() | 126 | function updateGridSize() | ||
127 | { | 127 | { | ||
128 | LayoutManager.cellSize.width = root.iconWidth + toolBoxSvg.elementSize("left").width + toolBoxSvg.elementSize("right").width | 128 | appletsLayout.cellWidth = root.iconWidth + toolBoxSvg.elementSize("left").width + toolBoxSvg.elementSize("right").width | ||
129 | LayoutManager.cellSize.height = root.iconHeight + toolBoxSvg.elementSize("top").height + toolBoxSvg.elementSize("bottom").height; | 129 | appletsLayout.cellHeight = root.iconHeight + toolBoxSvg.elementSize("top").height + toolBoxSvg.elementSize("bottom").height; | ||
130 | LayoutManager.defaultAppletSize.width = LayoutManager.cellSize.width * 6; | 130 | appletsLayout.defaultItemWidth = appletsLayout.cellWidth * 6; | ||
131 | LayoutManager.defaultAppletSize.height = LayoutManager.cellSize.height * 6; | 131 | appletsLayout.defaultItemHeight = appletsLayout.cellHeight * 6; | ||
132 | layoutTimer.restart(); | 132 | layoutTimer.restart(); | ||
133 | } | 133 | } | ||
134 | 134 | | |||
135 | function addLauncher(desktopUrl) { | 135 | function addLauncher(desktopUrl) { | ||
136 | if (!isFolder) { | 136 | if (!isFolder) { | ||
137 | return; | 137 | return; | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | folderViewLayer.view.linkHere(desktopUrl); | 140 | folderViewLayer.view.linkHere(desktopUrl); | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | function addApplet(applet, x, y) { | | |||
144 | if (!appletAppearanceComponent) { | | |||
145 | appletAppearanceComponent = Qt.createComponent("AppletAppearance.qml"); | | |||
146 | } | | |||
147 | | ||||
148 | if (appletAppearanceComponent.status !== Component.Ready) { | | |||
149 | console.warn("Error loading AppletAppearance.qml:", appletAppearanceComponent.errorString()); | | |||
150 | return; | | |||
151 | } | | |||
152 | | ||||
153 | var category = "Applet-" + applet.id; | | |||
154 | | ||||
155 | var container = appletAppearanceComponent.createObject(resultsFlow, { | | |||
156 | category: category | | |||
157 | }); | | |||
158 | | ||||
159 | applet.parent = container | | |||
160 | applet.visible = true; | | |||
161 | | ||||
162 | var config = LayoutManager.itemsConfig[category]; | | |||
163 | | ||||
164 | // We have it in the config. | | |||
165 | if (config !== undefined && config.width !== undefined && | | |||
166 | config.height !== undefined && | | |||
167 | config.width > 0 && config.height > 0) { | | |||
168 | container.width = config.width; | | |||
169 | container.height = config.height; | | |||
170 | // We have a default. | | |||
171 | } else if (applet.width > 0 && applet.height > 0) { | | |||
172 | container.width = applet.width; | | |||
173 | container.height = applet.height; | | |||
174 | // The container needs to be bigger than applet of margins factor. | | |||
175 | if (applet.backgroundHints !== PlasmaCore.Types.NoBackground) { | | |||
176 | container.width += container.margins.left + container.margins.right; | | |||
177 | container.height += container.margins.top + container.margins.bottom; | | |||
178 | } | | |||
179 | // Give up, assign the global default. | | |||
180 | } else { | | |||
181 | container.width = LayoutManager.defaultAppletSize.width; | | |||
182 | container.height = LayoutManager.defaultAppletSize.height; | | |||
183 | } | | |||
184 | | ||||
185 | container.applet = applet; | | |||
186 | | ||||
187 | // Coordinated passed by param? | | |||
188 | if ( x >= 0 && y >= 0) { | | |||
189 | if (x + container.width > root.width) { | | |||
190 | x = root.width - container.width - 10; | | |||
191 | } | | |||
192 | if (y + container.height > root.height) { | | |||
193 | x = root.height - container.height; | | |||
194 | } | | |||
195 | | ||||
196 | // On applet undo or via scripting, the applet position will be saved | | |||
197 | // in applet's scene coordinates so remap it to resultsflow's coordinates. | | |||
198 | var pos = root.parent.mapToItem(resultsFlow, x, y); | | |||
199 | | ||||
200 | container.x = pos.x; | | |||
201 | container.y = pos.y; | | |||
202 | | ||||
203 | // To be sure it's restored at the same position, take margins into account | | |||
204 | // if there is a background. | | |||
205 | if (applet.backgroundHints !== PlasmaCore.Types.NoBackground) { | | |||
206 | container.x -= container.margins.left; | | |||
207 | container.y -= container.margins.top; | | |||
208 | } | | |||
209 | | ||||
210 | // Coordinates stored? | | |||
211 | } else if (config !== undefined && config.x !== undefined && config.y !== undefined && | | |||
212 | config.x >= 0 && config.y >= 0) { | | |||
213 | container.x = config.x; | | |||
214 | container.y = config.y; | | |||
215 | } | | |||
216 | | ||||
217 | // Rotation stored and significant? | | |||
218 | if (config !== undefined && config.rotation !== undefined && | | |||
219 | (config.rotation > 5 || config.rotation < -5)) { | | |||
220 | container.rotation = config.rotation; | | |||
221 | } else { | | |||
222 | LayoutManager.restoreRotation(container); | | |||
223 | } | | |||
224 | | ||||
225 | LayoutManager.itemGroups[container.category] = container; | | |||
226 | | ||||
227 | if (container.x >= 0 && container.y >= 0) { | | |||
228 | LayoutManager.positionItem(container); | | |||
229 | } | | |||
230 | } | | |||
231 | | ||||
232 | function preferredWidth(minimum) { | 143 | function preferredWidth(minimum) { | ||
233 | if (isContainment || !folderViewLayer.ready) { | 144 | if (isContainment || !folderViewLayer.ready) { | ||
234 | return -1; | 145 | return -1; | ||
235 | } else if (useListViewMode) { | 146 | } else if (useListViewMode) { | ||
236 | return (minimum ? folderViewLayer.view.cellHeight * 4 : units.gridUnit * 16); | 147 | return (minimum ? folderViewLayer.view.cellHeight * 4 : units.gridUnit * 16); | ||
237 | } | 148 | } | ||
238 | 149 | | |||
239 | return (folderViewLayer.view.cellWidth * (minimum ? 1 : 3)) + (units.largeSpacing * 2); | 150 | return (folderViewLayer.view.cellWidth * (minimum ? 1 : 3)) + (units.largeSpacing * 2); | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 197 | onDragMove: { | |||
287 | // TODO: We should reject drag moves onto file items that don't accept drops | 198 | // TODO: We should reject drag moves onto file items that don't accept drops | ||
288 | // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently | 199 | // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently | ||
289 | // is currently incapable of rejecting drag events. | 200 | // is currently incapable of rejecting drag events. | ||
290 | 201 | | |||
291 | // Trigger autoscroll. | 202 | // Trigger autoscroll. | ||
292 | if (isFolder && FolderTools.isFileDrag(event)) { | 203 | if (isFolder && FolderTools.isFileDrag(event)) { | ||
293 | handleDragMove(folderViewLayer.view, mapToItem(folderViewLayer.view, event.x, event.y)); | 204 | handleDragMove(folderViewLayer.view, mapToItem(folderViewLayer.view, event.x, event.y)); | ||
294 | } else if (isContainment) { | 205 | } else if (isContainment) { | ||
295 | placeHolder.width = LayoutManager.defaultAppletSize.width; | 206 | appletsLayout.showPlaceHolderAt( | ||
296 | placeHolder.height = LayoutManager.defaultAppletSize.height; | 207 | Qt.rect(event.x - appletsLayout.minimumItemWidth / 2, | ||
297 | placeHolder.minimumWidth = placeHolder.minimumHeight = 0; | 208 | event.y - appletsLayout.minimumItemHeight / 2, | ||
298 | placeHolder.x = event.x - placeHolder.width / 2; | 209 | appletsLayout.minimumItemWidth, | ||
299 | placeHolder.y = event.y - placeHolder.width / 2; | 210 | appletsLayout.minimumItemHeight) | ||
300 | LayoutManager.positionItem(placeHolder); | 211 | ); | ||
301 | LayoutManager.setSpaceAvailable(placeHolder.x, placeHolder.y, placeHolder.width, placeHolder.height, true); | | |||
302 | placeHolderPaint.opacity = root.haloOpacity; | | |||
303 | } | 212 | } | ||
304 | } | 213 | } | ||
305 | 214 | | |||
306 | onDragLeave: { | 215 | onDragLeave: { | ||
307 | // Cancel autoscroll. | 216 | // Cancel autoscroll. | ||
308 | if (isFolder) { | 217 | if (isFolder) { | ||
309 | handleDragEnd(folderViewLayer.view); | 218 | handleDragEnd(folderViewLayer.view); | ||
310 | } | 219 | } | ||
311 | 220 | | |||
312 | if (isContainment) { | 221 | if (isContainment) { | ||
313 | placeHolderPaint.opacity = 0; | 222 | appletsLayout.hidePlaceHolder(); | ||
314 | } | 223 | } | ||
315 | } | 224 | } | ||
316 | 225 | | |||
317 | onDrop: { | 226 | onDrop: { | ||
318 | if (isFolder && FolderTools.isFileDrag(event)) { | 227 | if (isFolder && FolderTools.isFileDrag(event)) { | ||
319 | handleDragEnd(folderViewLayer.view); | 228 | handleDragEnd(folderViewLayer.view); | ||
320 | folderViewLayer.view.drop(root, event, mapToItem(folderViewLayer.view, event.x, event.y)); | 229 | folderViewLayer.view.drop(root, event, mapToItem(folderViewLayer.view, event.x, event.y)); | ||
321 | } else if (isContainment) { | 230 | } else if (isContainment) { | ||
322 | placeHolderPaint.opacity = 0; | 231 | plasmoid.processMimeData(event.mimeData, | ||
323 | var pos = root.parent.mapFromItem(resultsFlow, event.x - placeHolder.width / 2, event.y - placeHolder.height / 2); | 232 | event.x - appletsLayout.placeHolder.width / 2, event.y - appletsLayout.placeHolder.height / 2); | ||
324 | plasmoid.processMimeData(event.mimeData, pos.x, pos.y); | | |||
325 | event.accept(event.proposedAction); | 233 | event.accept(event.proposedAction); | ||
234 | appletsLayout.hidePlaceHolder(); | ||||
326 | } | 235 | } | ||
327 | } | 236 | } | ||
328 | 237 | | |||
329 | Component { | 238 | Component { | ||
330 | id: compactRepresentation | 239 | id: compactRepresentation | ||
331 | CompactRepresentation { folderView: folderViewLayer.view } | 240 | CompactRepresentation { folderView: folderViewLayer.view } | ||
332 | } | 241 | } | ||
333 | 242 | | |||
334 | Connections { | 243 | Connections { | ||
335 | target: plasmoid | 244 | target: plasmoid | ||
336 | 245 | | |||
337 | ignoreUnknownSignals: true | 246 | ignoreUnknownSignals: true | ||
338 | 247 | | |||
339 | onAppletAdded: { | | |||
340 | addApplet(applet, x, y); | | |||
341 | // Clean any eventual invalid chunks in the config. | | |||
342 | LayoutManager.save(); | | |||
343 | } | | |||
344 | | ||||
345 | onAppletRemoved: { | | |||
346 | // Clean any eventual invalid chunks in the config. | | |||
347 | LayoutManager.removeApplet(applet); | | |||
348 | LayoutManager.save(); | | |||
349 | } | | |||
350 | 248 | | |||
351 | onImmutableChanged: { | 249 | onImmutableChanged: { | ||
352 | if (root.isContainment && !plasmoid.immutable) { | 250 | if (root.isContainment && !plasmoid.immutable) { | ||
353 | pressToMoveHelp.show(); | 251 | pressToMoveHelp.show(); | ||
354 | } | 252 | } | ||
355 | } | 253 | } | ||
356 | 254 | | |||
357 | onAvailableScreenRegionChanged: layoutTimer.restart(); | 255 | onAvailableScreenRegionChanged: layoutTimer.restart(); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 307 | PlasmaCore.Svg { | |||
410 | id: toolBoxSvg | 308 | id: toolBoxSvg | ||
411 | imagePath: "widgets/toolbox" | 309 | imagePath: "widgets/toolbox" | ||
412 | property int rightBorder: elementSize("right").width | 310 | property int rightBorder: elementSize("right").width | ||
413 | property int topBorder: elementSize("top").height | 311 | property int topBorder: elementSize("top").height | ||
414 | property int bottomBorder: elementSize("bottom").height | 312 | property int bottomBorder: elementSize("bottom").height | ||
415 | property int leftBorder: elementSize("left").width | 313 | property int leftBorder: elementSize("left").width | ||
416 | } | 314 | } | ||
417 | 315 | | |||
418 | PlasmaCore.Svg { | 316 | // Can be removed? | ||
419 | id: configIconsSvg | | |||
420 | imagePath: "widgets/configuration-icons" | | |||
421 | } | | |||
422 | | ||||
423 | KQuickControlsAddons.EventGenerator { | 317 | KQuickControlsAddons.EventGenerator { | ||
424 | id: eventGenerator | 318 | id: eventGenerator | ||
425 | } | 319 | } | ||
426 | 320 | | |||
427 | MouseArea { // unfocus any plasmoid when clicking empty desktop area | 321 | Connections { | ||
ngraham: The feature seems to work without this commented code; can we remove it? | |||||
322 | target: plasmoid | ||||
323 | onEditModeChanged: appletsLayout.editMode = plasmoid.editMode | ||||
324 | } | ||||
325 | | ||||
326 | ContainmentLayoutManager.AppletsLayout { | ||||
327 | id: appletsLayout | ||||
428 | anchors.fill: parent | 328 | anchors.fill: parent | ||
429 | onPressed: { | 329 | // NOTE: use plasmoid.availableScreenRect and not own width and height as they are updated not atomically | ||
430 | root.forceActiveFocus(); | 330 | configKey: plasmoid.availableScreenRect.width > plasmoid.availableScreenRect.height ? "ItemGeometriesHorizontal" : "ItemGeometriesVertical" | ||
431 | mouse.accepted = false // Bug 351277 | 331 | containment: plasmoid | ||
332 | editModeCondition: plasmoid.immutable | ||||
333 | ? ContainmentLayoutManager.AppletsLayout.Locked | ||||
334 | : ContainmentLayoutManager.AppletsLayout.Manual | ||||
335 | | ||||
336 | // Sets the containment in edit mode when we go in edit mode as well | ||||
337 | onEditModeChanged: plasmoid.editMode = editMode | ||||
338 | | ||||
339 | minimumItemWidth: units.gridUnit * 3 | ||||
340 | minimumItemHeight: minimumItemWidth | ||||
432 | 341 | | |||
433 | if (toolBox && toolBox.open) { | 342 | cellWidth: units.iconSizes.small | ||
434 | toolBox.open = false; | 343 | cellHeight: cellWidth | ||
344 | | ||||
345 | appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer { | ||||
346 | id: appletContainer | ||||
davidedmundson: leftover debug | |||||
347 | editModeCondition: plasmoid.immutable | ||||
348 | ? ContainmentLayoutManager.ItemContainer.Locked | ||||
349 | : (plasmoid.configuration.pressToMove ? ContainmentLayoutManager.ItemContainer.AfterPressAndHold : ContainmentLayoutManager.ItemContainer.AfterMouseOver) | ||||
350 | configOverlayComponent: ConfigOverlay {} | ||||
351 | onUserDrag: { | ||||
352 | var pos = mapToItem(root.parent, dragCenter.x, dragCenter.y); | ||||
353 | var newCont = plasmoid.containmentAt(pos.x, pos.y); | ||||
354 | | ||||
355 | if (newCont && newCont !== plasmoid) { | ||||
356 | var newPos = newCont.mapFromApplet(plasmoid, pos.x, pos.y); | ||||
357 | | ||||
358 | newCont.addApplet(appletContainer.applet, newPos.x, newPos.y); | ||||
359 | appletsLayout.hidePlaceHolder(); | ||||
435 | } | 360 | } | ||
436 | } | 361 | } | ||
437 | } | 362 | } | ||
438 | 363 | | |||
364 | placeHolder: ContainmentLayoutManager.PlaceHolder {} | ||||
365 | | ||||
439 | Loader { | 366 | Loader { | ||
440 | id: folderViewLayer | 367 | id: folderViewLayer | ||
441 | 368 | | |||
442 | anchors.fill: parent | 369 | anchors.fill: parent | ||
443 | 370 | | |||
444 | property bool ready: status == Loader.Ready | 371 | property bool ready: status == Loader.Ready | ||
445 | property Item view: item ? item.view : null | 372 | property Item view: item ? item.view : null | ||
446 | property QtObject model: item ? item.model : null | 373 | property QtObject model: item ? item.model : null | ||
Show All 15 Lines | 388 | Connections { | |||
462 | target: folderViewLayer.view | 389 | target: folderViewLayer.view | ||
463 | 390 | | |||
464 | // `FolderViewDropArea` is not a FocusScope. We need to forward manually. | 391 | // `FolderViewDropArea` is not a FocusScope. We need to forward manually. | ||
465 | onPressed: { | 392 | onPressed: { | ||
466 | folderViewLayer.forceActiveFocus(); | 393 | folderViewLayer.forceActiveFocus(); | ||
467 | } | 394 | } | ||
468 | } | 395 | } | ||
469 | } | 396 | } | ||
470 | | ||||
471 | Item { | | |||
472 | id: resultsFlow | | |||
473 | anchors.fill: parent | | |||
474 | | ||||
475 | anchors { | | |||
476 | top: parent.top | | |||
477 | topMargin: 5 | | |||
478 | horizontalCenter: parent.horizontalCenter | | |||
479 | } | | |||
480 | | ||||
481 | visible: isContainment | | |||
482 | enabled: isContainment | | |||
483 | | ||||
484 | // This is just for event compression when a lot of boxes are created one after the other. | | |||
485 | Timer { | | |||
486 | id: layoutTimer | | |||
487 | repeat: false | | |||
488 | running: false | | |||
489 | interval: 100 | | |||
490 | onTriggered: { | | |||
491 | LayoutManager.resetPositions() | | |||
492 | for (var i=0; i<resultsFlow.children.length; ++i) { | | |||
493 | var child = resultsFlow.children[i] | | |||
494 | if (!child.applet) | | |||
495 | continue | | |||
496 | if (child.enabled) { | | |||
497 | if (LayoutManager.itemsConfig[child.category]) { | | |||
498 | var rect = LayoutManager.itemsConfig[child.category] | | |||
499 | child.x = rect.x | | |||
500 | child.y = rect.y | | |||
501 | child.width = rect.width | | |||
502 | child.height = rect.height | | |||
503 | child.rotation = rect.rotation | | |||
504 | } else { | | |||
505 | child.x = 0 | | |||
506 | child.y = 0 | | |||
507 | child.width = Math.min(470, 32+child.categoryCount*140) | | |||
508 | } | | |||
509 | child.visible = true | | |||
510 | LayoutManager.positionItem(child) | | |||
511 | } else { | | |||
512 | child.visible = false | | |||
513 | } | | |||
514 | } | | |||
515 | LayoutManager.save() | | |||
516 | } | | |||
517 | } | | |||
518 | } | | |||
519 | | ||||
520 | Item { | | |||
521 | id: placerHolderWrapper | | |||
522 | | ||||
523 | anchors.fill: resultsFlow | | |||
524 | z: 0 | | |||
525 | | ||||
526 | visible: isContainment | | |||
527 | enabled: isContainment | | |||
528 | | ||||
529 | Item { | | |||
530 | id: placeHolder | | |||
531 | | ||||
532 | x: -10000 // Move offscreen initially to avoid flickering. | | |||
533 | width: 100 | | |||
534 | height: 100 | | |||
535 | | ||||
536 | property bool animationsEnabled | | |||
537 | property int minimumWidth | | |||
538 | property int minimumHeight | | |||
539 | property Item syncItem | | |||
540 | | ||||
541 | function syncWithItem(item) { | | |||
542 | syncItem = item; | | |||
543 | minimumWidth = item.minimumWidth; | | |||
544 | minimumHeight = item.minimumHeight; | | |||
545 | repositionTimer.running = true; | | |||
546 | if (placeHolderPaint.opacity < 1) { | | |||
547 | placeHolder.delayedSyncWithItem(); | | |||
548 | } | | |||
549 | } | | |||
550 | | ||||
551 | function delayedSyncWithItem() { | | |||
552 | placeHolder.x = placeHolder.syncItem.x; | | |||
553 | placeHolder.y = placeHolder.syncItem.y; | | |||
554 | placeHolder.width = placeHolder.syncItem.width + (plasmoid.immutable || !syncItem.showAppletHandle ? 0 : syncItem.handleWidth) | | |||
555 | placeHolder.height = placeHolder.syncItem.height; | | |||
556 | // Only positionItem here, we don't want to save. | | |||
557 | LayoutManager.positionItem(placeHolder); | | |||
558 | LayoutManager.setSpaceAvailable(placeHolder.x, placeHolder.y, placeHolder.width, placeHolder.height, true); | | |||
559 | } | | |||
560 | | ||||
561 | Timer { | | |||
562 | id: repositionTimer | | |||
563 | interval: 100 | | |||
564 | repeat: false | | |||
565 | running: false | | |||
566 | onTriggered: placeHolder.delayedSyncWithItem() | | |||
567 | } | | |||
568 | } | | |||
569 | | ||||
570 | PlasmaComponents.Highlight { | | |||
571 | id: placeHolderPaint | | |||
572 | | ||||
573 | x: placeHolder.x | | |||
574 | y: placeHolder.y | | |||
575 | width: placeHolder.width | | |||
576 | height: placeHolder.height | | |||
577 | z: 0 | | |||
578 | | ||||
579 | opacity: 0 | | |||
580 | visible: opacity > 0 | | |||
581 | | ||||
582 | Behavior on opacity { | | |||
583 | NumberAnimation { | | |||
584 | duration: units.longDuration | | |||
585 | easing.type: Easing.InOutQuad | | |||
586 | } | | |||
587 | } | | |||
588 | } | | |||
589 | } | 397 | } | ||
590 | 398 | | |||
591 | Component.onCompleted: { | 399 | Component.onCompleted: { | ||
592 | if (!isContainment) { | 400 | if (!isContainment) { | ||
593 | return; | 401 | return; | ||
594 | } | 402 | } | ||
595 | 403 | | |||
596 | // Customize the icon and text to improve discoverability | 404 | // Customize the icon and text to improve discoverability | ||
597 | plasmoid.setAction("configure", i18n("Configure Desktop..."), "preferences-desktop-wallpaper") | 405 | plasmoid.setAction("configure", i18n("Configure Desktop..."), "preferences-desktop-wallpaper") | ||
598 | 406 | | |||
599 | // WORKAROUND: that's the only place where we can inject a sensible size. | 407 | // WORKAROUND: that's the only place where we can inject a sensible size. | ||
600 | // if root has width defined, it will override the value we set before | 408 | // if root has width defined, it will override the value we set before | ||
601 | // the component completes | 409 | // the component completes | ||
602 | root.width = plasmoid.width; | 410 | root.width = plasmoid.width; | ||
603 | 411 | | |||
604 | LayoutManager.resultsFlow = resultsFlow; | | |||
605 | LayoutManager.plasmoid = plasmoid; | | |||
606 | updateGridSize(); | 412 | updateGridSize(); | ||
607 | | ||||
608 | LayoutManager.restore(); | | |||
609 | | ||||
610 | for (var i = 0; i < plasmoid.applets.length; ++i) { | | |||
611 | var applet = plasmoid.applets[i]; | | |||
612 | addApplet(applet, -1, -1); | | |||
613 | } | | |||
614 | | ||||
615 | // Clean any eventual invalid chunks in the config. | | |||
616 | LayoutManager.save(); | | |||
617 | } | 413 | } | ||
618 | } | 414 | } |
The feature seems to work without this commented code; can we remove it?