-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support dragging track from deck to deck #173
Changes from all commits
c3bc444
4bb95ec
c88540a
1715d72
eb41f88
b449fb6
1604115
a33bb76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -782,19 +782,22 @@ QWidget* LegacySkinParser::parseVisual(QDomElement node) { | |
|
||
QWidget* LegacySkinParser::parseText(QDomElement node) { | ||
QString channelStr = lookupNodeGroup(node); | ||
const char* pSafeChannelStr = safeChannelString(channelStr); | ||
|
||
BaseTrackPlayer* pPlayer = m_pPlayerManager->getPlayer(channelStr); | ||
|
||
if (!pPlayer) | ||
return NULL; | ||
|
||
WTrackText* p = new WTrackText(m_pParent); | ||
WTrackText* p = new WTrackText(pSafeChannelStr, m_pConfig, m_pParent); | ||
setupLabelWidget(node, p); | ||
|
||
connect(pPlayer, SIGNAL(newTrackLoaded(TrackPointer)), | ||
p, SLOT(slotTrackLoaded(TrackPointer))); | ||
connect(pPlayer, SIGNAL(unloadingTrack(TrackPointer)), | ||
p, SLOT(slotTrackUnloaded(TrackPointer))); | ||
connect(p, SIGNAL(trackDropped(QString,QString)), | ||
m_pPlayerManager, SLOT(slotLoadToPlayer(QString,QString))); | ||
|
||
TrackPointer pTrack = pPlayer->getLoadedTrack(); | ||
if (pTrack) { | ||
|
@@ -806,20 +809,22 @@ QWidget* LegacySkinParser::parseText(QDomElement node) { | |
|
||
QWidget* LegacySkinParser::parseTrackProperty(QDomElement node) { | ||
QString channelStr = lookupNodeGroup(node); | ||
|
||
const char* pSafeChannelStr = safeChannelString(channelStr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use a QString? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it looks like we usually use const char* for group names. nevermind. |
||
|
||
BaseTrackPlayer* pPlayer = m_pPlayerManager->getPlayer(channelStr); | ||
|
||
if (!pPlayer) | ||
return NULL; | ||
|
||
WTrackProperty* p = new WTrackProperty(m_pParent); | ||
WTrackProperty* p = new WTrackProperty(pSafeChannelStr, m_pConfig, m_pParent); | ||
setupLabelWidget(node, p); | ||
|
||
connect(pPlayer, SIGNAL(newTrackLoaded(TrackPointer)), | ||
p, SLOT(slotTrackLoaded(TrackPointer))); | ||
connect(pPlayer, SIGNAL(unloadingTrack(TrackPointer)), | ||
p, SLOT(slotTrackUnloaded(TrackPointer))); | ||
connect(p, SIGNAL(trackDropped(QString,QString)), | ||
m_pPlayerManager, SLOT(slotLoadToPlayer(QString,QString))); | ||
|
||
TrackPointer pTrack = pPlayer->getLoadedTrack(); | ||
if (pTrack) { | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,8 +1,15 @@ | ||||
#include "widget/wtrackproperty.h" | ||||
|
||||
WTrackProperty::WTrackProperty(QWidget* pParent) | ||||
: WLabel(pParent) { | ||||
#include <QDebug> | ||||
#include <QUrl> | ||||
|
||||
#include "controlobject.h" | ||||
#include "widget/wtrackproperty.h" | ||||
|
||||
WTrackProperty::WTrackProperty(const char* group, ConfigObject<ConfigValue>* pConfig, QWidget* pParent) | ||||
: WLabel(pParent), | ||||
m_pGroup(group), | ||||
m_pConfig(pConfig) { | ||||
setAcceptDrops(true); | ||||
} | ||||
|
||||
WTrackProperty::~WTrackProperty() { | ||||
|
@@ -41,3 +48,47 @@ void WTrackProperty::updateLabel(TrackInfoObject*) { | |||
} | ||||
} | ||||
} | ||||
|
||||
void WTrackProperty::mouseMoveEvent(QMouseEvent *event) { | ||||
if ((event->buttons() & Qt::LeftButton) && m_pCurrentTrack) { | ||||
QList<QUrl> locationUrls; | ||||
locationUrls.append(QUrl::fromLocalFile(m_pCurrentTrack->getLocation())); | ||||
|
||||
QMimeData* mimeData = new QMimeData(); | ||||
mimeData->setUrls(locationUrls); | ||||
|
||||
QDrag* drag = new QDrag(this); | ||||
drag->setMimeData(mimeData); | ||||
drag->setPixmap(QPixmap(":images/library/ic_library_drag_and_drop.png")); | ||||
drag->exec(Qt::CopyAction); | ||||
} | ||||
} | ||||
|
||||
void WTrackProperty::dragEnterEvent(QDragEnterEvent *event) { | ||||
if (event->mimeData()->hasUrls() && | ||||
event->mimeData()->urls().size() > 0) { | ||||
// Accept if the Deck isn't playing or the settings allow to interrupt a playing deck | ||||
if ((!ControlObject::get(ConfigKey(m_pGroup, "play")) || | ||||
m_pConfig->getValueString(ConfigKey("[Controls]", "AllowTrackLoadToPlayingDeck")).toInt())) { | ||||
event->acceptProposedAction(); | ||||
} else { | ||||
event->ignore(); | ||||
} | ||||
} | ||||
} | ||||
|
||||
void WTrackProperty::dropEvent(QDropEvent *event) { | ||||
if (event->mimeData()->hasUrls() && | ||||
event->mimeData()->urls().size() > 0) { | ||||
QUrl url = event->mimeData()->urls().first(); | ||||
QString filename = url.toLocalFile(); | ||||
// If the file is on a network share, try just converting the URL to a string | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment did not at additional information. You might want to explain why this will work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually a question I had myself. I saw this was how it was done in mixxx/src/widget/wwaveformviewer.cpp Line 169 in 7905a7e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #169 I've created a helper class for this so I'll just update it to use that once it merges. |
||||
if (filename == "") { | ||||
filename = url.toString(); | ||||
} | ||||
event->accept(); | ||||
emit(trackDropped(filename, m_pGroup)); | ||||
} else { | ||||
event->ignore(); | ||||
} | ||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is off topic and the rest of the code is also effected (not your fault):
IMHO it should be "save" = de:gespeichert not "safe" (security) = de:gesichert
The string is saved into heap, because channelStr will be deleted from stack after returning from parseText().
Maybe a native speaker can verify it.
Because of this, pSafeChannelStr should become pSavedChannelStr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe in this case means "safe to use without crashing" not "save it for later" so I think the current wording is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then safe us from the work ;-)