Skip to content

Commit

Permalink
Merge pull request #4004 from Holzhaus/qml-deck-cloning
Browse files Browse the repository at this point in the history
QML: Add support for deck cloning
  • Loading branch information
Swiftb0y authored Jun 20, 2021
2 parents 5204d31 + dba59c7 commit dd6928e
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
21 changes: 21 additions & 0 deletions res/skins/QMLDemo/Deck.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions res/skins/QMLDemo/Mixxx/PlayerDropArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions res/skins/QMLDemo/Sampler.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/skin/qml/qmlplayermanagerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions src/skin/qml/qmlplayerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void QmlPlayerProxy::slotTrackChanged() {
emit keyTextChanged();
emit colorChanged();
emit coverArtUrlChanged();
emit trackLocationUrlChanged();
}

PROPERTY_IMPL(QString, artist, getArtist, setArtist)
Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/skin/qml/qmlplayerproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -81,6 +83,7 @@ class QmlPlayerProxy : public QObject {
void trackLoaded();
void trackUnloaded();
void trackChanged();
void cloneFromGroup(const QString& group);

void albumChanged();
void titleChanged();
Expand All @@ -96,6 +99,7 @@ class QmlPlayerProxy : public QObject {
void keyTextChanged();
void colorChanged();
void coverArtUrlChanged();
void trackLocationUrlChanged();

void loadTrackFromLocationRequested(const QString& trackLocation);

Expand Down

0 comments on commit dd6928e

Please sign in to comment.