Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/FolderViewDialog.qml
Show All 23 Lines | |||||
24 | 24 | | |||
25 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | 25 | import org.kde.private.desktopcontainment.folder 0.1 as Folder | ||
26 | 26 | | |||
27 | Folder.SubDialog { | 27 | Folder.SubDialog { | ||
28 | id: dialog | 28 | id: dialog | ||
29 | 29 | | |||
30 | visible: false | 30 | visible: false | ||
31 | 31 | | |||
32 | property bool containsDrag: { | ||||
33 | if (folderViewDropArea.containsDrag) { | ||||
34 | return true; | ||||
35 | } | ||||
36 | | ||||
37 | if (folderView.hoveredItem && folderView.hoveredItem.popupDialog) { | ||||
38 | return folderView.hoveredItem.popupDialog.containsDrag; | ||||
39 | } | ||||
40 | | ||||
41 | return false; | ||||
42 | } | ||||
43 | | ||||
32 | property QtObject closeTimer: closeTimer | 44 | property QtObject closeTimer: closeTimer | ||
33 | property QtObject childDialog: (folderView.hoveredItem != null) ? folderView.hoveredItem.popupDialog : null | 45 | property QtObject childDialog: (folderView.hoveredItem != null) ? folderView.hoveredItem.popupDialog : null | ||
34 | property bool containsMouse: folderView.containsMouse || (childDialog != null && childDialog.containsMouse) | 46 | property bool containsMouse: folderView.containsMouse || (childDialog != null && childDialog.containsMouse) | ||
35 | 47 | | |||
36 | property alias url: folderView.url | 48 | property alias url: folderView.url | ||
37 | 49 | | |||
38 | location: PlasmaCore.Types.Floating | 50 | location: PlasmaCore.Types.Floating | ||
39 | hideOnWindowDeactivate: (childDialog == null) | 51 | hideOnWindowDeactivate: (childDialog == null) | ||
40 | 52 | | |||
41 | onContainsMouseChanged: { | 53 | onContainsMouseChanged: { | ||
42 | if (containsMouse) { | 54 | if (containsMouse) { | ||
43 | closeTimer.stop(); | 55 | closeTimer.stop(); | ||
44 | } else { | 56 | } else { | ||
45 | closeTimer.start(); | 57 | closeTimer.start(); | ||
46 | } | 58 | } | ||
47 | } | 59 | } | ||
48 | 60 | | |||
49 | mainItem: FolderView { | 61 | mainItem: FolderViewDropArea { | ||
62 | id: folderViewDropArea | ||||
63 | | ||||
64 | width: folderView.cellWidth * 3 + (10 * units.devicePixelRatio) // FIXME HACK: Use actual scrollbar width. | ||||
65 | height: folderView.cellHeight * 2 | ||||
66 | | ||||
67 | folderView: folderView | ||||
68 | | ||||
69 | FolderView { | ||||
50 | id: folderView | 70 | id: folderView | ||
51 | 71 | | |||
52 | width: cellWidth * 3 + (10 * units.devicePixelRatio) // FIXME HACK: Use actual scrollbar width. | 72 | anchors.fill: parent | ||
53 | height: cellHeight * 2 | | |||
54 | 73 | | |||
55 | isRootView: false | 74 | isRootView: false | ||
56 | 75 | | |||
57 | locked: true | 76 | locked: true | ||
58 | 77 | | |||
59 | sortMode: ((plasmoid.configuration.sortMode == 0) ? 1 : plasmoid.configuration.sortMode) | 78 | sortMode: ((plasmoid.configuration.sortMode == 0) ? 1 : plasmoid.configuration.sortMode) | ||
60 | filterMode: 0 | 79 | filterMode: 0 | ||
61 | 80 | | |||
62 | // TODO: Bidi. | 81 | // TODO: Bidi. | ||
63 | flow: GridView.FlowLeftToRight | 82 | flow: GridView.FlowLeftToRight | ||
64 | layoutDirection: Qt.LeftToRight | 83 | layoutDirection: Qt.LeftToRight | ||
84 | | ||||
85 | onDraggingChanged: { | ||||
86 | if (!dragging && !dialog.visible) { | ||||
87 | dialog.destroy(); | ||||
88 | } | ||||
89 | } | ||||
90 | } | ||||
65 | } | 91 | } | ||
66 | 92 | | |||
67 | data: [ | 93 | data: [ | ||
68 | Timer { | 94 | Timer { | ||
69 | id: closeTimer | 95 | id: closeTimer | ||
70 | 96 | | |||
71 | interval: units.longDuration * 2 | 97 | interval: units.longDuration * 2 | ||
72 | 98 | | |||
73 | onTriggered: { | 99 | onTriggered: { | ||
74 | if (childDialog != null) { | 100 | if (childDialog != null) { | ||
75 | childDialog.closeTimer.stop(); | 101 | childDialog.closeTimer.stop(); | ||
76 | childDialog.visible = false; | 102 | childDialog.visible = false; | ||
77 | } | 103 | } | ||
78 | 104 | | |||
79 | dialog.visible = false; | 105 | dialog.visible = false; | ||
80 | delayedDestroy(); | 106 | delayedDestroy(); | ||
81 | } | 107 | } | ||
82 | } | 108 | } | ||
83 | ] | 109 | ] | ||
84 | 110 | | |||
111 | function requestDestroy() { | ||||
112 | if (folderView.dragging) { | ||||
113 | visible = false; | ||||
114 | } else { | ||||
115 | destroy(); | ||||
116 | } | ||||
117 | } | ||||
118 | | ||||
85 | function delayedDestroy() { | 119 | function delayedDestroy() { | ||
86 | var timer = Qt.createQmlObject('import QtQuick 2.0; Timer { onTriggered: itemDialog.destroy() }', itemDialog); | 120 | var timer = Qt.createQmlObject('import QtQuick 2.0; Timer { onTriggered: itemDialog.destroy() }', itemDialog); | ||
87 | timer.interval = 0; | 121 | timer.interval = 0; | ||
88 | timer.start(); | 122 | timer.start(); | ||
89 | } | 123 | } | ||
90 | 124 | | |||
91 | Component.onDestruction: { | 125 | Component.onDestruction: { | ||
92 | closeTimer.stop(); | 126 | closeTimer.stop(); | ||
93 | } | 127 | } | ||
94 | } | 128 | } |