Merge lp:~osomon/unity-2d/drag-from-dash into lp:unity-2d/3.0

Proposed by Olivier Tilloy
Status: Merged
Approved by: Florian Boucault
Approved revision: 571
Merged at revision: 579
Proposed branch: lp:~osomon/unity-2d/drag-from-dash
Merge into: lp:unity-2d/3.0
Diff against target: 543 lines (+426/-5)
10 files modified
launcher/UnityApplications/place.cpp (+2/-2)
launcher/app/launcherview.cpp (+1/-2)
libunity-2d-private/Unity2d/CMakeLists.txt (+4/-0)
libunity-2d-private/Unity2d/dragitem.cpp (+159/-0)
libunity-2d-private/Unity2d/dragitem.h (+77/-0)
libunity-2d-private/Unity2d/dragitemwithurl.cpp (+82/-0)
libunity-2d-private/Unity2d/dragitemwithurl.h (+62/-0)
libunity-2d-private/Unity2d/plugin.cpp (+2/-0)
places/AbstractButton.qml (+8/-1)
places/UnityDefaultRenderer.qml (+29/-0)
To merge this branch: bzr merge lp:~osomon/unity-2d/drag-from-dash
Reviewer Review Type Date Requested Status
Florian Boucault (community) code Needs Fixing
Review via email: mp+61438@code.launchpad.net

Commit message

[dash] Support dragging files and installed applications from the dash to the launcher, the desktop or file managers.

Description of the change

This branch introduces a new QML item, DragItemWithUrl, used in the dash to allow initiating drag events from the elements displayed in the places.

Installed applications and files can be dragged to the launcher, to the desktop or to any window that accepts drag events with "file://" URLs (e.g. file managers).

Available (non installed) applications cannot be dragged.

The careful reviewer will test that the functionality works as expected, that this doesn’t introduce regressions in the dash (in particular opening files/folders and launching applications) and in the launcher (drag’n’drop of desktop files from a file manager, drag’n’drop of files to the trash, drag’n’drop of URLs from the browser’s address bar).

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

WARNING: THIS IS NOT A COMPLETE REVIEW

I did a quick functional test and it's pretty neat, well done!
One thing I noticed, the icons are very aliased whereas if I drag&drop an app in /usr/share/applications from Nautilus for example it will look antialiased. Any idea?

Revision history for this message
Olivier Tilloy (osomon) wrote :

No, unfortunately I have no idea how to improve this. The code is quite simple so I’m probably missing something obvious. Any suggestions are welcome.

lp:~osomon/unity-2d/drag-from-dash updated
568. By Olivier Tilloy

Nice antialiased icons during drag’n’drop if compositing is enabled.

569. By Olivier Tilloy

Cheap solution to avoid aliasing when compositiong is disabled: draw a solid white background.

Revision history for this message
Olivier Tilloy (osomon) wrote :

The last two revisions fix the aliasing problem. There are two possible cases:

 - if compositing is enabled, the icon is nicely antialiased, as one would expect
 - if compositing is disabled, the icon is drawn on a solid white background (with rounded corners to make it easier on the eye), so that aliasing is not visible

Comments on the fallback when compositing is disabled are welcome, we can probably implement something different if needed.

Revision history for this message
Florian Boucault (fboucault) wrote :

Functionally beautiful now!

review: Approve (functional)
Revision history for this message
Florian Boucault (fboucault) wrote :

Overall the code is nice and simple.
A few comments:

- a Component should be passed as DragItemWithUrl's delegate as to not create Image instances unless necessary. Instead of:

  DragItemWithUrl {
    delegate: Image {...}
  }

Use:

  DragItemWithUrl {
    delegate: imageComponentId
  }

  Component {
    id: imageComponentId
    Image {...}
  }

- DeclarativeDragItem::drop signal name should have a better name, for example 'dragInitiated'

- The workaround that has been added to AbstractButton could use a link to qt bug report 13007 that if I am right should remove the need for it in the future (http://bugreports.qt.nokia.com/browse/QTBUG-13007)

review: Needs Fixing (code)
lp:~osomon/unity-2d/drag-from-dash updated
570. By Olivier Tilloy

Made the delegate a Component so that it’s instantiated on demand only when needed.

571. By Olivier Tilloy

Add a comment and link to QTBUG-13007.

Revision history for this message
Olivier Tilloy (osomon) wrote :

> - a Component should be passed as DragItemWithUrl's delegate as to not create
> Image instances unless necessary. Instead of:

Thanks for pointing this out. I had originally tried to write it this way, but I had failed to do so. I tackled the problem again, this time successfully. This is revision 570.

> - DeclarativeDragItem::drop signal name should have a better name, for example
> 'dragInitiated'

Nope, it’s called 'drop' because it’s actually emitted upon dropping the dragged item, not when the drag action is initiated.

> - The workaround that has been added to AbstractButton could use a link to qt
> bug report 13007 that if I am right should remove the need for it in the
> future (http://bugreports.qt.nokia.com/browse/QTBUG-13007)

You’re right. Added at revision 571.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/UnityApplications/place.cpp'
--- launcher/UnityApplications/place.cpp 2011-05-03 15:38:35 +0000
+++ launcher/UnityApplications/place.cpp 2011-05-30 16:06:44 +0000
@@ -429,8 +429,8 @@
429 /* Cannot set the desktop file to url.host(), because the QUrl constructor429 /* Cannot set the desktop file to url.host(), because the QUrl constructor
430 converts the host name to lower case to conform to the Nameprep430 converts the host name to lower case to conform to the Nameprep
431 RFC (see http://doc.qt.nokia.com/qurl.html#FormattingOption-enum).431 RFC (see http://doc.qt.nokia.com/qurl.html#FormattingOption-enum).
432 Ref: http://bugs.launchpad.net/unity-2d/+bug/723604 */432 Ref: https://bugs.launchpad.net/unity-place-applications/+bug/784478 */
433 QString desktopFile = uri.right(uri.size() - uri.indexOf("://") - 3);433 QString desktopFile = uri.mid(uri.indexOf("://") + 3);
434 application.setDesktopFile(desktopFile);434 application.setDesktopFile(desktopFile);
435 application.activate();435 application.activate();
436 return;436 return;
437437
=== modified file 'launcher/app/launcherview.cpp'
--- launcher/app/launcherview.cpp 2011-05-19 14:12:41 +0000
+++ launcher/app/launcherview.cpp 2011-05-30 16:06:44 +0000
@@ -271,8 +271,7 @@
271 foreach (QUrl url, getEventUrls(event)) {271 foreach (QUrl url, getEventUrls(event)) {
272 if (url.scheme() == "file" && url.path().endsWith(".desktop")) {272 if (url.scheme() == "file" && url.path().endsWith(".desktop")) {
273 emit desktopFileDropped(url.path());273 emit desktopFileDropped(url.path());
274 }274 } else if (url.scheme().startsWith("http")) {
275 else if (url.scheme().startsWith("http")) {
276 emit webpageUrlDropped(url);275 emit webpageUrlDropped(url);
277 }276 }
278 }277 }
279278
=== modified file 'libunity-2d-private/Unity2d/CMakeLists.txt'
--- libunity-2d-private/Unity2d/CMakeLists.txt 2011-02-17 12:04:10 +0000
+++ libunity-2d-private/Unity2d/CMakeLists.txt 2011-05-30 16:06:44 +0000
@@ -15,6 +15,8 @@
15 cacheeffect.cpp15 cacheeffect.cpp
16 workspacesinfo.cpp16 workspacesinfo.cpp
17 signalwaiter.cpp17 signalwaiter.cpp
18 dragitem.cpp
19 dragitemwithurl.cpp
18 dropitem.cpp20 dropitem.cpp
19 )21 )
2022
@@ -27,6 +29,8 @@
27 cacheeffect.h29 cacheeffect.h
28 workspacesinfo.h30 workspacesinfo.h
29 signalwaiter.h31 signalwaiter.h
32 dragitem.h
33 dragitemwithurl.h
30 dropitem.h34 dropitem.h
31 )35 )
3236
3337
=== added file 'libunity-2d-private/Unity2d/dragitem.cpp'
--- libunity-2d-private/Unity2d/dragitem.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/Unity2d/dragitem.cpp 2011-05-30 16:06:44 +0000
@@ -0,0 +1,159 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "dragitem.h"
21
22#include <QDeclarativeEngine>
23#include <QDeclarativeComponent>
24#include <QGraphicsSceneMouseEvent>
25#include <QApplication>
26#include <QDrag>
27#include <QGraphicsScene>
28#include <QPainter>
29#include <QMimeData>
30#include <QX11Info>
31
32DeclarativeDragItem::DeclarativeDragItem(QDeclarativeItem* parent)
33 : QDeclarativeItem(parent)
34 , m_delegate(NULL)
35 , m_supportedActions(Qt::LinkAction)
36 , m_defaultAction(Qt::LinkAction)
37{
38 setAcceptedMouseButtons(Qt::LeftButton);
39}
40
41DeclarativeDragItem::~DeclarativeDragItem()
42{
43}
44
45QDeclarativeComponent*
46DeclarativeDragItem::delegate() const
47{
48 return m_delegate;
49}
50
51void
52DeclarativeDragItem::setDelegate(QDeclarativeComponent* delegate)
53{
54 if (delegate != m_delegate) {
55 m_delegate = delegate;
56 Q_EMIT delegateChanged();
57 }
58}
59
60void
61DeclarativeDragItem::resetDelegate()
62{
63 setDelegate(NULL);
64}
65
66Qt::DropActions
67DeclarativeDragItem::supportedActions() const
68{
69 return m_supportedActions;
70}
71
72void
73DeclarativeDragItem::setSupportedActions(Qt::DropActions actions)
74{
75 if (actions != m_supportedActions) {
76 m_supportedActions = actions;
77 Q_EMIT supportedActionsChanged();
78 }
79}
80
81Qt::DropAction
82DeclarativeDragItem::defaultAction() const
83{
84 return m_defaultAction;
85}
86
87void
88DeclarativeDragItem::setDefaultAction(Qt::DropAction action)
89{
90 if (action != m_defaultAction) {
91 m_defaultAction = action;
92 Q_EMIT defaultActionChanged();
93 }
94}
95
96QMimeData* DeclarativeDragItem::mimeData() const
97{
98 // Default implementation, empty mime data.
99 return new QMimeData;
100}
101
102void
103DeclarativeDragItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
104{
105 int distance = (event->buttonDownScreenPos(Qt::LeftButton) - event->screenPos()).manhattanLength();
106 if (distance < QApplication::startDragDistance()) {
107 return;
108 }
109
110 QDrag* drag = new QDrag(event->widget());
111 drag->setMimeData(mimeData());
112
113 if (m_delegate != NULL) {
114 QObject* delegateObject = m_delegate->create(QDeclarativeEngine::contextForObject(this));
115 QDeclarativeItem* delegate = qobject_cast<QDeclarativeItem*>(delegateObject);
116 if (delegate != NULL) {
117 /* Render the delegate to a pixmap. */
118 QGraphicsScene scene;
119 scene.addItem(delegate);
120
121 QPixmap pixmap(scene.sceneRect().width(), scene.sceneRect().height());
122 bool compositing = QX11Info::isCompositingManagerRunning();
123 if (!compositing) {
124 pixmap.fill(Qt::transparent);
125 }
126 QPainter painter(&pixmap);
127 if (compositing) {
128 painter.setCompositionMode(QPainter::CompositionMode_Source);
129 } else {
130 /* Cheap solution to avoid aliasing: draw a solid white background. */
131 painter.setPen(Qt::white);
132 painter.setBrush(Qt::white);
133 painter.drawRoundedRect(scene.sceneRect(), 5, 5);
134 }
135 scene.render(&painter);
136 scene.removeItem(delegate);
137 delete delegate;
138
139 drag->setPixmap(pixmap);
140 drag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2));
141 }
142 }
143
144 Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction);
145 Q_EMIT drop(action);
146}
147
148void
149DeclarativeDragItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
150{
151 Q_EMIT pressed();
152}
153
154void
155DeclarativeDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
156{
157 Q_EMIT released();
158}
159
0160
=== added file 'libunity-2d-private/Unity2d/dragitem.h'
--- libunity-2d-private/Unity2d/dragitem.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/Unity2d/dragitem.h 2011-05-30 16:06:44 +0000
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef DeclarativeDragItem_H
21#define DeclarativeDragItem_H
22
23#include <QDeclarativeItem>
24
25class QMimeData;
26class QDeclarativeComponent;
27
28class DeclarativeDragItem : public QDeclarativeItem
29{
30 Q_OBJECT
31
32 Q_PROPERTY(QDeclarativeComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged RESET resetDelegate)
33 Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions WRITE setSupportedActions NOTIFY supportedActionsChanged)
34 Q_PROPERTY(Qt::DropAction defaultAction READ defaultAction WRITE setDefaultAction NOTIFY defaultActionChanged)
35
36public:
37 DeclarativeDragItem(QDeclarativeItem* parent=0);
38 ~DeclarativeDragItem();
39
40 // getters and setters
41 QDeclarativeComponent* delegate() const;
42 void setDelegate(QDeclarativeComponent* delegate);
43 void resetDelegate();
44 Qt::DropActions supportedActions() const;
45 void setSupportedActions(Qt::DropActions actions);
46 Qt::DropAction defaultAction() const;
47 void setDefaultAction(Qt::DropAction action);
48
49protected:
50 // override in child classes to set a non-empty mime data
51 virtual QMimeData* mimeData() const;
52
53Q_SIGNALS:
54 void delegateChanged();
55 void supportedActionsChanged();
56 void defaultActionChanged();
57 void drop(int action);
58
59 // Can’t pass around the mouse events as parameters
60 // as QDeclarativeMouseEvent is a private class.
61 void pressed();
62 void released();
63
64protected:
65 // reimplemented
66 void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
67 void mousePressEvent(QGraphicsSceneMouseEvent* event);
68 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
69
70private:
71 QDeclarativeComponent* m_delegate;
72 Qt::DropActions m_supportedActions;
73 Qt::DropAction m_defaultAction;
74};
75
76#endif // DeclarativeDragItem_H
77
078
=== added file 'libunity-2d-private/Unity2d/dragitemwithurl.cpp'
--- libunity-2d-private/Unity2d/dragitemwithurl.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/Unity2d/dragitemwithurl.cpp 2011-05-30 16:06:44 +0000
@@ -0,0 +1,82 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "dragitemwithurl.h"
21
22// libunity-2d
23#include <gscopedpointer.h>
24
25// GIO
26#undef signals
27extern "C" {
28 #include <gio/gdesktopappinfo.h>
29}
30
31// Qt
32#include <QMimeData>
33
34DeclarativeDragItemWithUrl::DeclarativeDragItemWithUrl(QDeclarativeItem* parent)
35 : DeclarativeDragItem(parent)
36{
37}
38
39DeclarativeDragItemWithUrl::~DeclarativeDragItemWithUrl()
40{
41}
42
43const QString& DeclarativeDragItemWithUrl::url() const
44{
45 return m_url;
46}
47
48void DeclarativeDragItemWithUrl::setUrl(const QString& url)
49{
50 if (url != m_url) {
51 m_url = url;
52 Q_EMIT urlChanged(m_url);
53 }
54}
55
56QMimeData* DeclarativeDragItemWithUrl::mimeData() const
57{
58 QMimeData* data = new QMimeData;
59 if (!m_url.isEmpty()) {
60 QList<QUrl> urls;
61 urls.append(decodeUri(m_url));
62 data->setUrls(urls);
63 }
64 return data;
65}
66
67QUrl DeclarativeDragItemWithUrl::decodeUri(const QString& uri)
68{
69 if (uri.startsWith("application://")) {
70 QString desktopFileName = uri.mid(14);
71 QByteArray bytes = desktopFileName.toUtf8();
72 GObjectScopedPointer<GDesktopAppInfo> appInfo(g_desktop_app_info_new(bytes.constData()));
73 if (appInfo.isNull()) {
74 return QUrl(uri);
75 }
76 QString filePath = QString::fromUtf8(g_desktop_app_info_get_filename(appInfo.data()));
77 return QUrl("file://" + filePath);
78 } else {
79 return QUrl(uri);
80 }
81}
82
083
=== added file 'libunity-2d-private/Unity2d/dragitemwithurl.h'
--- libunity-2d-private/Unity2d/dragitemwithurl.h 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/Unity2d/dragitemwithurl.h 2011-05-30 16:06:44 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2011 Canonical, Ltd.
3 *
4 * Authors:
5 * Olivier Tilloy <olivier.tilloy@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef DeclarativeDragItemWithUrl_H
21#define DeclarativeDragItemWithUrl_H
22
23#include "dragitem.h"
24
25// Qt
26#include <QString>
27#include <QUrl>
28
29/* A specialized DragItem with a 'url' property that knows how to convert
30 application:// URLs into the corresponding file:// URLs. */
31class DeclarativeDragItemWithUrl : public DeclarativeDragItem
32{
33 Q_OBJECT
34
35 /* The URL cannot be a QUrl due to the malformed URIs returned by the place
36 backends (see https://bugs.launchpad.net/unity-place-applications/+bug/784478). */
37 Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
38
39public:
40 DeclarativeDragItemWithUrl(QDeclarativeItem* parent=0);
41 ~DeclarativeDragItemWithUrl();
42
43 // getters and setters
44 const QString& url() const;
45 void setUrl(const QString& url);
46
47protected:
48 // overridden
49 QMimeData* mimeData() const;
50
51private:
52 static QUrl decodeUri(const QString& uri);
53
54Q_SIGNALS:
55 void urlChanged(const QString&);
56
57private:
58 QString m_url;
59};
60
61#endif // DeclarativeDragItemWithUrl_H
62
063
=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
--- libunity-2d-private/Unity2d/plugin.cpp 2011-04-28 13:09:25 +0000
+++ libunity-2d-private/Unity2d/plugin.cpp 2011-05-30 16:06:44 +0000
@@ -34,6 +34,7 @@
3434
35#include "mimedata.h"35#include "mimedata.h"
36#include "dragdropevent.h"36#include "dragdropevent.h"
37#include "dragitemwithurl.h"
37#include "dropitem.h"38#include "dropitem.h"
3839
39#include <QtDeclarative/qdeclarative.h>40#include <QtDeclarative/qdeclarative.h>
@@ -76,6 +77,7 @@
76 qmlRegisterType<QGraphicsDropShadowEffect>("Effects", 1, 0, "DropShadow");77 qmlRegisterType<QGraphicsDropShadowEffect>("Effects", 1, 0, "DropShadow");
7778
78 /* Custom drag’n’drop implementation in QML */79 /* Custom drag’n’drop implementation in QML */
80 qmlRegisterType<DeclarativeDragItemWithUrl>(uri, 0, 1, "DragItemWithUrl");
79 qmlRegisterType<DeclarativeDropItem>(uri, 0, 1, "DropItem");81 qmlRegisterType<DeclarativeDropItem>(uri, 0, 1, "DropItem");
80 qmlRegisterType<DeclarativeMimeData>();82 qmlRegisterType<DeclarativeMimeData>();
81 qmlRegisterType<DeclarativeDragDropEvent>();83 qmlRegisterType<DeclarativeDragDropEvent>();
8284
=== modified file 'places/AbstractButton.qml'
--- places/AbstractButton.qml 2011-03-22 06:15:19 +0000
+++ places/AbstractButton.qml 2011-05-30 16:06:44 +0000
@@ -21,6 +21,13 @@
21FocusScope {21FocusScope {
22 property bool enabled: true22 property bool enabled: true
2323
24 /* Use to manually set the "pressed" state of the button. This is not
25 necessary in the normal use case, but is useful when a child item eats
26 the mouse events (e.g. a DragArea).
27 This is a clumsy workaround for the lack of a MouseProxy element
28 (see http://bugreports.qt.nokia.com/browse/QTBUG-13007). */
29 property bool pressed: false
30
24 signal clicked31 signal clicked
2532
26 MouseArea {33 MouseArea {
@@ -45,7 +52,7 @@
45 }52 }
4653
47 state: {54 state: {
48 if(mouse_area.pressed)55 if(pressed || mouse_area.pressed)
49 return "pressed"56 return "pressed"
50 else if(mouse_area.containsMouse)57 else if(mouse_area.containsMouse)
51 return "selected"58 return "selected"
5259
=== modified file 'places/UnityDefaultRenderer.qml'
--- places/UnityDefaultRenderer.qml 2011-04-08 11:10:59 +0000
+++ places/UnityDefaultRenderer.qml 2011-05-30 16:06:44 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19import Qt 4.719import Qt 4.7
20import Unity2d 1.0 /* required for drag’n’drop handling */
2021
21RendererGrid {22RendererGrid {
22 cellWidth: 13623 cellWidth: 136
@@ -37,6 +38,34 @@
37 placeEntryModel.place.activate(decodeURIComponent(uri))38 placeEntryModel.place.activate(decodeURIComponent(uri))
38 }39 }
3940
41 DragItemWithUrl {
42 anchors.fill: parent
43 url: decodeURIComponent(uri)
44 defaultAction: {
45 if (!url.indexOf("application://")) return Qt.CopyAction
46 else if (!url.indexOf("unity-install://")) return Qt.IgnoreAction
47 else return Qt.LinkAction
48 }
49 supportedActions: defaultAction
50 delegate: Component {
51 Image {
52 source: icon.source
53 width: icon.width
54 height: icon.height
55 fillMode: icon.fillMode
56 sourceSize.width: width
57 sourceSize.height: height
58 asynchronous: true
59 }
60 }
61 onPressed: parent.pressed = true
62 onReleased: {
63 parent.pressed = false
64 parent.clicked()
65 }
66 onDrop: parent.pressed = false
67 }
68
40 Image {69 Image {
41 id: icon70 id: icon
4271

Subscribers

People subscribed via source and target branches