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 20 Lines • Show All 205 Lines • ▼ Show 20 Line(s) | |||||
250 | 250 | | |||
251 | onDragMove: { | 251 | onDragMove: { | ||
252 | // TODO: We should reject drag moves onto file items that don't accept drops | 252 | // TODO: We should reject drag moves onto file items that don't accept drops | ||
253 | // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently | 253 | // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently | ||
254 | // is currently incapable of rejecting drag events. | 254 | // is currently incapable of rejecting drag events. | ||
255 | 255 | | |||
256 | // Trigger autoscroll. | 256 | // Trigger autoscroll. | ||
257 | if (isFolder && FolderTools.isFileDrag(event)) { | 257 | if (isFolder && FolderTools.isFileDrag(event)) { | ||
258 | folderViewLayer.view.scrollLeft = (event.x < (units.largeSpacing * 3)); | 258 | handleDragMove(folderViewLayer.view, event); | ||
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) { | 259 | } else if (isContainment) { | ||
263 | placeHolder.width = LayoutManager.defaultAppletSize.width; | 260 | placeHolder.width = LayoutManager.defaultAppletSize.width; | ||
264 | placeHolder.height = LayoutManager.defaultAppletSize.height; | 261 | placeHolder.height = LayoutManager.defaultAppletSize.height; | ||
265 | placeHolder.minimumWidth = placeHolder.minimumHeight = 0; | 262 | placeHolder.minimumWidth = placeHolder.minimumHeight = 0; | ||
266 | placeHolder.x = event.x - placeHolder.width / 2; | 263 | placeHolder.x = event.x - placeHolder.width / 2; | ||
267 | placeHolder.y = event.y - placeHolder.width / 2; | 264 | placeHolder.y = event.y - placeHolder.width / 2; | ||
268 | LayoutManager.positionItem(placeHolder); | 265 | LayoutManager.positionItem(placeHolder); | ||
269 | LayoutManager.setSpaceAvailable(placeHolder.x, placeHolder.y, placeHolder.width, placeHolder.height, true); | 266 | LayoutManager.setSpaceAvailable(placeHolder.x, placeHolder.y, placeHolder.width, placeHolder.height, true); | ||
270 | placeHolderPaint.opacity = root.haloOpacity; | 267 | placeHolderPaint.opacity = root.haloOpacity; | ||
271 | } | 268 | } | ||
272 | } | 269 | } | ||
273 | 270 | | |||
274 | onDragLeave: { | 271 | onDragLeave: { | ||
275 | // Cancel autoscroll. | 272 | // Cancel autoscroll. | ||
276 | if (isFolder) { | 273 | if (isFolder) { | ||
277 | folderViewLayer.view.scrollLeft = false; | 274 | handleDragEnd(folderViewLayer.view); | ||
278 | folderViewLayer.view.scrollRight = false; | | |||
279 | folderViewLayer.view.scrollUp = false; | | |||
280 | folderViewLayer.view.scrollDown = false; | | |||
281 | } | 275 | } | ||
282 | 276 | | |||
283 | if (isContainment) { | 277 | if (isContainment) { | ||
284 | placeHolderPaint.opacity = 0; | 278 | placeHolderPaint.opacity = 0; | ||
285 | } | 279 | } | ||
286 | } | 280 | } | ||
287 | 281 | | |||
288 | onDrop: { | 282 | onDrop: { | ||
289 | if (isFolder && FolderTools.isFileDrag(event)) { | 283 | if (isFolder && FolderTools.isFileDrag(event)) { | ||
290 | // Cancel autoscroll. | 284 | 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)); | 285 | folderViewLayer.view.drop(root, event, mapToItem(folderViewLayer.view, event.x, event.y)); | ||
297 | } else if (isContainment) { | 286 | } else if (isContainment) { | ||
298 | placeHolderPaint.opacity = 0; | 287 | placeHolderPaint.opacity = 0; | ||
299 | var pos = root.parent.mapFromItem(resultsFlow, event.x - placeHolder.width / 2, event.y - placeHolder.height / 2); | 288 | 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); | 289 | plasmoid.processMimeData(event.mimeData, pos.x, pos.y); | ||
301 | event.accept(event.proposedAction); | 290 | event.accept(event.proposedAction); | ||
302 | } | 291 | } | ||
303 | } | 292 | } | ||
▲ Show 20 Lines • Show All 285 Lines • Show Last 20 Lines |