@@ -37,6 +37,47 @@ Item {
3737 signal openFileRequested (int index)
3838 signal contextMenuRequested (int index)
3939
40+ component ButtonHandler: Item {
41+ id: handler
42+ required property Button button
43+ Component .onCompleted : () => {
44+ button .Drag .mimeData = {
45+ " text/uri-list" : [GlobalHelper .localFileUrl (button .modelData .path )]
46+ }
47+ button .Drag .supportedActions = Qt .CopyAction
48+ button .Drag .active = Qt .binding (() => dragHandler .active )
49+ button .Drag .dragType = Drag .Automatic
50+ }
51+ DragHandler {
52+ id: dragHandler
53+ parent: handler .button ?? handler
54+ enabled: handler .button .index !== - 1
55+ target: null
56+ }
57+ TapHandler {
58+ parent: handler .button ?? handler
59+ acceptedButtons: Qt .RightButton
60+ enabled: handler .button .index !== - 1
61+ onSingleTapped: view .contextMenuRequested (filesProxyModel .mapIndexToSource (handler .button .index ))
62+ }
63+ Connections {
64+ target: handler .button
65+ function onClicked () {
66+ if (handler .button .index === - 1 ) {
67+ view .newFileRequested ()
68+ } else {
69+ view .openFileRequested (filesProxyModel .mapIndexToSource (handler .button .index ))
70+ }
71+ }
72+ }
73+ Connections {
74+ target: handler .button .Keys
75+ function onMenuPressed () {
76+ view .contextMenuRequested (filesProxyModel .mapIndexToSource (handler .buttonl .index ))
77+ }
78+ }
79+ }
80+
4081 component CellButton: Button {
4182 id: cell
4283 required property int index
@@ -108,18 +149,8 @@ Item {
108149 ThemedItem .foregroundLevel : SVS .FL_Secondary
109150 }
110151 }
111- TapHandler {
112- acceptedButtons: Qt .RightButton
113- enabled: cell .index !== - 1
114- onSingleTapped: view .contextMenuRequested (filesProxyModel .mapIndexToSource (cell .index ))
115- }
116- Keys .onMenuPressed : view .contextMenuRequested (filesProxyModel .mapIndexToSource (cell .index ))
117- onClicked : () => {
118- if (cell .index === - 1 ) {
119- view .newFileRequested ()
120- } else {
121- view .openFileRequested (filesProxyModel .mapIndexToSource (cell .index ))
122- }
152+ ButtonHandler {
153+ button: cell
123154 }
124155 }
125156 component ListItemButton: Button {
@@ -180,18 +211,8 @@ Item {
180211 }
181212 }
182213 }
183- TapHandler {
184- acceptedButtons: Qt .RightButton
185- enabled: cell .index !== - 1
186- onSingleTapped: view .contextMenuRequested (filesProxyModel .mapIndexToSource (cell .index ))
187- }
188- Keys .onMenuPressed : view .contextMenuRequested (filesProxyModel .mapIndexToSource (cell .index ))
189- onClicked : () => {
190- if (cell .index === - 1 ) {
191- view .newFileRequested ()
192- } else {
193- view .openFileRequested (filesProxyModel .mapIndexToSource (cell .index ))
194- }
214+ ButtonHandler {
215+ button: cell
195216 }
196217 }
197218
0 commit comments