Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/main.qml
Show All 27 Lines | |||||
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 | 32 | | |||
33 | import "LayoutManager.js" as LayoutManager | 33 | import "LayoutManager.js" as LayoutManager | ||
34 | import "FolderTools.js" as FolderTools | 34 | import "FolderTools.js" as FolderTools | ||
35 | 35 | | |||
36 | DragDrop.DropArea { | 36 | FolderViewDropArea { | ||
37 | id: root | 37 | id: root | ||
38 | objectName: isFolder ? "folder" : "desktop" | 38 | objectName: isFolder ? "folder" : "desktop" | ||
39 | 39 | | |||
40 | width: isPopup ? undefined : preferredWidth(false) // for the initial size when placed on the desktop | 40 | width: isPopup ? undefined : preferredWidth(false) // for the initial size when placed on the desktop | ||
41 | Layout.minimumWidth: preferredWidth(true) | 41 | Layout.minimumWidth: preferredWidth(true) | ||
42 | Layout.preferredWidth: isPopup ? preferredWidth(false) : 0 // for the popup size to change at runtime when view mode changes | 42 | Layout.preferredWidth: isPopup ? preferredWidth(false) : 0 // for the popup size to change at runtime when view mode changes | ||
43 | Plasmoid.switchWidth: preferredWidth(true) | 43 | Plasmoid.switchWidth: preferredWidth(true) | ||
44 | 44 | | |||
Show All 16 Lines | |||||
61 | 61 | | |||
62 | property int handleDelay: 800 | 62 | property int handleDelay: 800 | ||
63 | property real haloOpacity: 0.5 | 63 | property real haloOpacity: 0.5 | ||
64 | 64 | | |||
65 | property int iconSize: units.iconSizes.small | 65 | property int iconSize: units.iconSizes.small | ||
66 | property int iconWidth: iconSize | 66 | property int iconWidth: iconSize | ||
67 | property int iconHeight: iconWidth | 67 | property int iconHeight: iconWidth | ||
68 | 68 | | |||
69 | readonly property int hoverActivateDelay: 750 // Magic number that matches Dolphin's auto-expand folders delay. | ||||
70 | | ||||
69 | preventStealing: true | 71 | preventStealing: true | ||
70 | 72 | | |||
71 | // Plasmoid.title is set by a Binding {} in FolderViewLayer | 73 | // Plasmoid.title is set by a Binding {} in FolderViewLayer | ||
72 | Plasmoid.toolTipSubText: "" | 74 | Plasmoid.toolTipSubText: "" | ||
73 | Plasmoid.icon: (!plasmoid.configuration.useCustomIcon && folderViewLayer.ready) ? folderViewLayer.view.model.iconName : plasmoid.configuration.icon | 75 | Plasmoid.icon: (!plasmoid.configuration.useCustomIcon && folderViewLayer.ready) ? folderViewLayer.view.model.iconName : plasmoid.configuration.icon | ||
74 | Plasmoid.compactRepresentation: (isFolder && !isContainment) ? compactRepresentation : null | 76 | Plasmoid.compactRepresentation: (isFolder && !isContainment) ? compactRepresentation : null | ||
75 | Plasmoid.associatedApplicationUrls: folderViewLayer.ready ? folderViewLayer.model.resolvedUrl : null | 77 | Plasmoid.associatedApplicationUrls: folderViewLayer.ready ? folderViewLayer.model.resolvedUrl : null | ||
76 | 78 | | |||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | |||||
250 | 252 | | |||
251 | onDragMove: { | 253 | onDragMove: { | ||
252 | // TODO: We should reject drag moves onto file items that don't accept drops | 254 | // TODO: We should reject drag moves onto file items that don't accept drops | ||
253 | // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently | 255 | // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently | ||
254 | // is currently incapable of rejecting drag events. | 256 | // is currently incapable of rejecting drag events. | ||
255 | 257 | | |||
256 | // Trigger autoscroll. | 258 | // Trigger autoscroll. | ||
257 | if (isFolder && FolderTools.isFileDrag(event)) { | 259 | if (isFolder && FolderTools.isFileDrag(event)) { | ||
258 | folderViewLayer.view.scrollLeft = (event.x < (units.largeSpacing * 3)); | 260 | handleDragMove(folderViewLayer.view, mapToItem(folderViewLayer.view, event.x, event.y)); | ||
259 | folderViewLayer.view.scrollRight = (event.x > width - (units.largeSpacing * 3)); | | |||
260 | folderViewLayer.view.scrollUp = (event.y < (units.largeSpacing * 3)); | | |||
261 | folderViewLayer.view.scrollDown = (event.y > height - (units.largeSpacing * 3)); | | |||
262 | } else if (isContainment) { | 261 | } else if (isContainment) { | ||
263 | placeHolder.width = LayoutManager.defaultAppletSize.width; | 262 | placeHolder.width = LayoutManager.defaultAppletSize.width; | ||
264 | placeHolder.height = LayoutManager.defaultAppletSize.height; | 263 | placeHolder.height = LayoutManager.defaultAppletSize.height; | ||
265 | placeHolder.minimumWidth = placeHolder.minimumHeight = 0; | 264 | placeHolder.minimumWidth = placeHolder.minimumHeight = 0; | ||
266 | placeHolder.x = event.x - placeHolder.width / 2; | 265 | placeHolder.x = event.x - placeHolder.width / 2; | ||
267 | placeHolder.y = event.y - placeHolder.width / 2; | 266 | placeHolder.y = event.y - placeHolder.width / 2; | ||
268 | LayoutManager.positionItem(placeHolder); | 267 | LayoutManager.positionItem(placeHolder); | ||
269 | LayoutManager.setSpaceAvailable(placeHolder.x, placeHolder.y, placeHolder.width, placeHolder.height, true); | 268 | LayoutManager.setSpaceAvailable(placeHolder.x, placeHolder.y, placeHolder.width, placeHolder.height, true); | ||
270 | placeHolderPaint.opacity = root.haloOpacity; | 269 | placeHolderPaint.opacity = root.haloOpacity; | ||
271 | } | 270 | } | ||
272 | } | 271 | } | ||
273 | 272 | | |||
274 | onDragLeave: { | 273 | onDragLeave: { | ||
275 | // Cancel autoscroll. | 274 | // Cancel autoscroll. | ||
276 | if (isFolder) { | 275 | if (isFolder) { | ||
277 | folderViewLayer.view.scrollLeft = false; | 276 | handleDragEnd(folderViewLayer.view); | ||
278 | folderViewLayer.view.scrollRight = false; | | |||
279 | folderViewLayer.view.scrollUp = false; | | |||
280 | folderViewLayer.view.scrollDown = false; | | |||
281 | } | 277 | } | ||
282 | 278 | | |||
283 | if (isContainment) { | 279 | if (isContainment) { | ||
284 | placeHolderPaint.opacity = 0; | 280 | placeHolderPaint.opacity = 0; | ||
285 | } | 281 | } | ||
286 | } | 282 | } | ||
287 | 283 | | |||
288 | onDrop: { | 284 | onDrop: { | ||
289 | if (isFolder && FolderTools.isFileDrag(event)) { | 285 | if (isFolder && FolderTools.isFileDrag(event)) { | ||
290 | // Cancel autoscroll. | 286 | handleDragEnd(folderViewLayer.view); | ||
291 | folderViewLayer.view.scrollLeft = false; | | |||
292 | folderViewLayer.view.scrollRight = false; | | |||
293 | folderViewLayer.view.scrollUp = false; | | |||
294 | folderViewLayer.view.scrollDown = false; | | |||
295 | | ||||
296 | folderViewLayer.view.drop(root, event, mapToItem(folderViewLayer.view, event.x, event.y)); | 287 | folderViewLayer.view.drop(root, event, mapToItem(folderViewLayer.view, event.x, event.y)); | ||
297 | } else if (isContainment) { | 288 | } else if (isContainment) { | ||
298 | placeHolderPaint.opacity = 0; | 289 | placeHolderPaint.opacity = 0; | ||
299 | var pos = root.parent.mapFromItem(resultsFlow, event.x - placeHolder.width / 2, event.y - placeHolder.height / 2); | 290 | var pos = root.parent.mapFromItem(resultsFlow, event.x - placeHolder.width / 2, event.y - placeHolder.height / 2); | ||
300 | plasmoid.processMimeData(event.mimeData, pos.x, pos.y); | 291 | plasmoid.processMimeData(event.mimeData, pos.x, pos.y); | ||
301 | event.accept(event.proposedAction); | 292 | event.accept(event.proposedAction); | ||
302 | } | 293 | } | ||
303 | } | 294 | } | ||
▲ Show 20 Lines • Show All 285 Lines • Show Last 20 Lines |