Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QML: Add support for deck cloning #4004

Merged
merged 4 commits into from
Jun 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing problems:

warning [Main] file:///home/swiftb0y/Sourcerepositories/mixxx/res/skins/QMLDemo/DeckRow.qml:71:5: QML Deck (parent or ancestor of QQuickDragAttached): Binding loop detected for property "active"

You can reproduce it by dragging the deck to any Item that has no PlayerDropArea, and then clicking anywhere else in the skin.

Copy link
Member Author

@Holzhaus Holzhaus Jun 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot reproduce this. It's not even possible to drag stuff anywhere else, the mouse pointer becomes a "no waiting" road sign.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, that line is taken from the QML Drag & Drop example: https://doc.qt.io/qt-5/qtquick-draganddrop-example.html

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot reproduce this. It's not even possible to drag stuff anywhere else, the mouse pointer becomes a "no waiting" road sign.

Mhmm. I don't even have a change in mouse pointer. I guess its an underlying bug with Qt and the window manager or something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can worry about this some other time.

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