diff --git a/res/skins/QMLDemo/Deck.qml b/res/skins/QMLDemo/Deck.qml index 0d10bc96ee9..22fa9575507 100644 --- a/res/skins/QMLDemo/Deck.qml +++ b/res/skins/QMLDemo/Deck.qml @@ -13,6 +13,27 @@ Item { property bool minimized: false property var deckPlayer: Mixxx.PlayerManager.getPlayer(group) + Drag.active: dragArea.drag.active + Drag.dragType: Drag.Automatic + Drag.supportedActions: Qt.CopyAction + Drag.mimeData: { + let data = { + "mixxx/player": group + }; + const trackLocationUrl = deckPlayer.trackLocationUrl; + if (trackLocationUrl) + data["text/uri-list"] = trackLocationUrl; + + return data; + } + + MouseArea { + id: dragArea + + anchors.fill: root + drag.target: root + } + Skin.SectionBackground { anchors.fill: parent } diff --git a/res/skins/QMLDemo/Mixxx/PlayerDropArea.qml b/res/skins/QMLDemo/Mixxx/PlayerDropArea.qml index 53a81a93161..187dd616576 100644 --- a/res/skins/QMLDemo/Mixxx/PlayerDropArea.qml +++ b/res/skins/QMLDemo/Mixxx/PlayerDropArea.qml @@ -7,6 +7,16 @@ DropArea { property var player: Mixxx.PlayerManager.getPlayer(group) onDropped: { + if (drop.formats.includes("mixxx/player")) { + const sourceGroup = drop.getDataAsString("mixxx/player"); + // Prevent dropping a deck onto itself + if (sourceGroup != this.group) + return ; + + console.log("Drag from group " + sourceGroup); + player.cloneFromGroup(sourceGroup); + return ; + } if (drop.hasUrls) { let url = drop.urls[0]; console.log("Dropped URL '" + url + "' on deck " + group); diff --git a/res/skins/QMLDemo/Sampler.qml b/res/skins/QMLDemo/Sampler.qml index ca56973c389..7d4460ed372 100644 --- a/res/skins/QMLDemo/Sampler.qml +++ b/res/skins/QMLDemo/Sampler.qml @@ -21,6 +21,26 @@ Rectangle { return Qt.darker(root.deckPlayer.color, 2); } implicitHeight: gainKnob.height + 10 + Drag.active: dragArea.drag.active + Drag.dragType: Drag.Automatic + Drag.supportedActions: Qt.CopyAction + Drag.mimeData: { + let data = { + "mixxx/player": group + }; + const trackLocationUrl = deckPlayer.trackLocationUrl; + if (trackLocationUrl) + data["text/uri-list"] = trackLocationUrl; + + return data; + } + + MouseArea { + id: dragArea + + anchors.fill: root + drag.target: root + } Skin.SectionBackground { anchors.fill: parent diff --git a/src/skin/qml/qmlplayermanagerproxy.cpp b/src/skin/qml/qmlplayermanagerproxy.cpp index 817cba2d622..4230ecd0c4f 100644 --- a/src/skin/qml/qmlplayermanagerproxy.cpp +++ b/src/skin/qml/qmlplayermanagerproxy.cpp @@ -35,6 +35,12 @@ QObject* QmlPlayerManagerProxy::getPlayer(const QString& group) { [this, group](const QString& trackLocation) { emit loadLocationToPlayer(trackLocation, group); }); + connect(pPlayerProxy, + &QmlPlayerProxy::cloneFromGroup, + this, + [this, group](const QString& sourceGroup) { + m_pPlayerManager->slotCloneDeck(sourceGroup, group); + }); return pPlayerProxy; } diff --git a/src/skin/qml/qmlplayerproxy.cpp b/src/skin/qml/qmlplayerproxy.cpp index bd9823d9f78..49a9f998161 100644 --- a/src/skin/qml/qmlplayerproxy.cpp +++ b/src/skin/qml/qmlplayerproxy.cpp @@ -139,6 +139,7 @@ void QmlPlayerProxy::slotTrackChanged() { emit keyTextChanged(); emit colorChanged(); emit coverArtUrlChanged(); + emit trackLocationUrlChanged(); } PROPERTY_IMPL(QString, artist, getArtist, setArtist) @@ -180,6 +181,15 @@ QUrl QmlPlayerProxy::getCoverArtUrl() const { return AsyncImageProvider::trackLocationToCoverArtUrl(coverInfo.trackLocation); } +QUrl QmlPlayerProxy::getTrackLocationUrl() const { + const TrackPointer pTrack = m_pCurrentTrack; + if (pTrack == nullptr) { + return QUrl(); + } + + return QUrl::fromLocalFile(pTrack->getLocation()); +} + } // namespace qml } // namespace skin } // namespace mixxx diff --git a/src/skin/qml/qmlplayerproxy.h b/src/skin/qml/qmlplayerproxy.h index bcef1b415b9..f912770cdc5 100644 --- a/src/skin/qml/qmlplayerproxy.h +++ b/src/skin/qml/qmlplayerproxy.h @@ -29,6 +29,7 @@ class QmlPlayerProxy : public QObject { Q_PROPERTY(QString keyText READ getKeyText WRITE setKeyText NOTIFY keyTextChanged) Q_PROPERTY(QColor color READ getColor WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QUrl coverArtUrl READ getCoverArtUrl NOTIFY coverArtUrlChanged) + Q_PROPERTY(QUrl trackLocationUrl READ getTrackLocationUrl NOTIFY trackLocationUrlChanged) public: explicit QmlPlayerProxy(BaseTrackPlayer* pTrackPlayer, QObject* parent = nullptr); @@ -48,6 +49,7 @@ class QmlPlayerProxy : public QObject { QString getKeyText() const; QColor getColor() const; QUrl getCoverArtUrl() const; + QUrl getTrackLocationUrl() const; /// Needed for interacting with the raw track player object. BaseTrackPlayer* internalTrackPlayer() const { @@ -81,6 +83,7 @@ class QmlPlayerProxy : public QObject { void trackLoaded(); void trackUnloaded(); void trackChanged(); + void cloneFromGroup(const QString& group); void albumChanged(); void titleChanged(); @@ -96,6 +99,7 @@ class QmlPlayerProxy : public QObject { void keyTextChanged(); void colorChanged(); void coverArtUrlChanged(); + void trackLocationUrlChanged(); void loadTrackFromLocationRequested(const QString& trackLocation);