summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/library/autodj/autodjfeature.cpp8
-rw-r--r--src/library/cratefeature.cpp6
-rw-r--r--src/library/mixxxlibraryfeature.cpp4
-rw-r--r--src/library/parser.h12
-rw-r--r--src/library/playlistfeature.cpp8
-rw-r--r--src/playermanager.cpp17
-rw-r--r--src/playermanager.h4
-rw-r--r--src/skin/legacyskinparser.cpp6
-rw-r--r--src/util/dnd.h64
-rw-r--r--src/widget/wbasewidget.h1
-rw-r--r--src/widget/wcoverart.cpp43
-rw-r--r--src/widget/wlibrarysidebar.cpp6
-rw-r--r--src/widget/woverview.cpp28
-rw-r--r--src/widget/wspinny.cpp97
-rw-r--r--src/widget/wspinny.h10
-rw-r--r--src/widget/wtrackproperty.cpp27
-rw-r--r--src/widget/wtracktableview.cpp28
-rw-r--r--src/widget/wtracktext.cpp27
-rw-r--r--src/widget/wtracktext.h1
-rw-r--r--src/widget/wwaveformviewer.cpp32
20 files changed, 228 insertions, 201 deletions
diff --git a/src/library/autodj/autodjfeature.cpp b/src/library/autodj/autodjfeature.cpp
index 429df8bde6..c2ca56e74e 100644
--- a/src/library/autodj/autodjfeature.cpp
+++ b/src/library/autodj/autodjfeature.cpp
@@ -10,6 +10,7 @@
#include "library/autodj/autodjfeature.h"
+#include "library/parser.h"
#include "library/autodj/autodjprocessor.h"
#include "library/trackcollection.h"
#include "dlgautodj.h"
@@ -139,7 +140,6 @@ void AutoDJFeature::activate() {
}
bool AutoDJFeature::dropAccept(QList<QUrl> urls, QObject* pSource) {
- //TODO: Filter by supported formats regex and reject anything that doesn't match.
TrackDAO &trackDao = m_pTrackCollection->getTrackDAO();
// If a track is dropped onto a playlist's name, but the track isn't in the
@@ -154,7 +154,6 @@ bool AutoDJFeature::dropAccept(QList<QUrl> urls, QObject* pSource) {
trackIds = trackDao.addTracks(files, true);
}
- int playlistId = m_playlistDao.getPlaylistIdFromName(AUTODJ_TABLE);
// remove tracks that could not be added
for (int trackId = 0; trackId < trackIds.size(); trackId++) {
if (trackIds.at(trackId) < 0) {
@@ -163,12 +162,13 @@ bool AutoDJFeature::dropAccept(QList<QUrl> urls, QObject* pSource) {
}
// Return whether the tracks were appended.
- return m_playlistDao.appendTracksToPlaylist(trackIds, playlistId);
+ return m_playlistDao.appendTracksToPlaylist(trackIds, m_iAutoDJPlaylistId);
}
bool AutoDJFeature::dragMoveAccept(QUrl url) {
QFileInfo file(url.toLocalFile());
- return SoundSourceProxy::isFilenameSupported(file.fileName());
+ return SoundSourceProxy::isFilenameSupported(file.fileName()) ||
+ Parser::isPlaylistFilenameSupported(file.fileName());
}
// Add a crate to the auto-DJ queue.
diff --git a/src/library/cratefeature.cpp b/src/library/cratefeature.cpp
index 10fb6f2597..62cc31bc0b 100644
--- a/src/library/cratefeature.cpp
+++ b/src/library/cratefeature.cpp
@@ -149,7 +149,7 @@ bool CrateFeature::dropAcceptChild(const QModelIndex& index, QList<QUrl> urls,
qDebug() << "CrateFeature::dropAcceptChild adding tracks"
<< trackIds.size() << " to crate "<< crateId;
// remove tracks that could not be added
- for (int trackId =0; trackId<trackIds.size() ; trackId++) {
+ for (int trackId = 0; trackId < trackIds.size(); ++trackId) {
if (trackIds.at(trackId) < 0) {
trackIds.removeAt(trackId--);
}
@@ -159,14 +159,14 @@ bool CrateFeature::dropAcceptChild(const QModelIndex& index, QList<QUrl> urls,
}
bool CrateFeature::dragMoveAcceptChild(const QModelIndex& index, QUrl url) {
- //TODO: Filter by supported formats regex and reject anything that doesn't match.
int crateId = crateIdFromIndex(index);
if (crateId == -1) {
return false;
}
bool locked = m_crateDao.isCrateLocked(crateId);
QFileInfo file(url.toLocalFile());
- bool formatSupported = SoundSourceProxy::isFilenameSupported(file.fileName());
+ bool formatSupported = SoundSourceProxy::isFilenameSupported(file.fileName()) ||
+ Parser::isPlaylistFilenameSupported(file.fileName());
return !locked && formatSupported;
}
diff --git a/src/library/mixxxlibraryfeature.cpp b/src/library/mixxxlibraryfeature.cpp
index ebf8b471c3..9de35da910 100644
--- a/src/library/mixxxlibraryfeature.cpp
+++ b/src/library/mixxxlibraryfeature.cpp
@@ -5,6 +5,7 @@
#include "library/mixxxlibraryfeature.h"
+#include "library/parser.h"
#include "library/basetrackcache.h"
#include "library/librarytablemodel.h"
#include "library/missingtablemodel.h"
@@ -184,5 +185,6 @@ bool MixxxLibraryFeature::dropAccept(QList<QUrl> urls, QObject* pSource) {
bool MixxxLibraryFeature::dragMoveAccept(QUrl url) {
QFileInfo file(url.toLocalFile());
- return SoundSourceProxy::isFilenameSupported(file.fileName());
+ return SoundSourceProxy::isFilenameSupported(file.fileName()) ||
+ Parser::isPlaylistFilenameSupported(file.fileName());
}
diff --git a/src/library/parser.h b/src/library/parser.h
index 7164ec60bf..893060e881 100644
--- a/src/library/parser.h
+++ b/src/library/parser.h
@@ -25,9 +25,15 @@ it afterwards fro proper functioning
#include <QString>
#include <QList>
-class Parser : public QObject
-{
-public:
+class Parser : public QObject {
+ public:
+ static bool isPlaylistFilenameSupported(const QString& fileName) {
+ return fileName.endsWith(".m3u", Qt::CaseInsensitive) ||
+ fileName.endsWith(".m3u8", Qt::CaseInsensitive) ||
+ fileName.endsWith(".pls", Qt::CaseInsensitive) ||
+ fileName.endsWith(".csv", Qt::CaseInsensitive);
+ }
+
Parser();
~Parser();
/**Can be called to parse a pls file
diff --git a/src/library/playlistfeature.cpp b/src/library/playlistfeature.cpp
index 11cf1a5efd..bdab84be8b 100644
--- a/src/library/playlistfeature.cpp
+++ b/src/library/playlistfeature.cpp
@@ -12,6 +12,7 @@
#include "library/playlisttablemodel.h"
#include "library/treeitem.h"
#include "library/queryutil.h"
+#include "library/parser.h"
#include "mixxxkeyboard.h"
#include "soundsourceproxy.h"
#include "util/dnd.h"
@@ -83,7 +84,6 @@ void PlaylistFeature::onRightClickChild(const QPoint& globalPos, QModelIndex ind
bool PlaylistFeature::dropAcceptChild(const QModelIndex& index, QList<QUrl> urls,
QObject* pSource) {
- //TODO: Filter by supported formats regex and reject anything that doesn't match.
int playlistId = playlistIdFromIndex(index);
//m_playlistDao.appendTrackToPlaylist(url.toLocalFile(), playlistId);
@@ -102,7 +102,7 @@ bool PlaylistFeature::dropAcceptChild(const QModelIndex& index, QList<QUrl> urls
}
// remove tracks that could not be added
- for (int trackId =0; trackId<trackIds.size() ; trackId++) {
+ for (int trackId = 0; trackId < trackIds.size(); ++trackId) {
if (trackIds.at(trackId) < 0) {
trackIds.removeAt(trackId--);
}
@@ -113,14 +113,12 @@ bool PlaylistFeature::dropAcceptChild(const QModelIndex& index, QList<QUrl> urls
}
bool PlaylistFeature::dragMoveAcceptChild(const QModelIndex& index, QUrl url) {
- //TODO: Filter by supported formats regex and reject anything that doesn't match.
int playlistId = playlistIdFromIndex(index);
bool locked = m_playlistDao.isPlaylistLocked(playlistId);
QFileInfo file(url.toLocalFile());
bool formatSupported = SoundSourceProxy::isFilenameSupported(file.fileName()) ||
- file.fileName().endsWith(".m3u") || file.fileName().endsWith(".m3u8") ||
- file.fileName().endsWith(".pls");
+ Parser::isPlaylistFilenameSupported(file.fileName());
return !locked && formatSupported;
}
diff --git a/src/playermanager.cpp b/src/playermanager.cpp
index 30ca6ce628..fb111e3752 100644
--- a/src/playermanager.cpp
+++ b/src/playermanager.cpp
@@ -146,6 +146,23 @@ bool PlayerManager::isDeckGroup(const QString& group, int* number) {
}
// static
+bool PlayerManager::isPreviewDeckGroup(const QString& group, int* number) {
+ if (!group.startsWith("[PreviewDeck")) {
+ return false;
+ }
+
+ bool ok = false;
+ int deckNum = group.mid(8,group.lastIndexOf("]")-8).toInt(&ok);
+ if (!ok || deckNum <= 0) {
+ return false;
+ }
+ if (number != NULL) {
+ *number = deckNum;
+ }
+ return true;
+}
+
+// static
unsigned int PlayerManager::numSamplers() {
// We do this to cache the control once it is created so callers don't incur
// a hashtable lookup every time they call this.
diff --git a/src/playermanager.h b/src/playermanager.h
index 2909821c0c..9225465cef 100644
--- a/src/playermanager.h
+++ b/src/playermanager.h
@@ -51,6 +51,10 @@ class PlayerManager : public QObject {
// populates it with the deck number (1-indexed).
static bool isDeckGroup(const QString& group, int* number=NULL);
+ // Returns true if the group is a preview deck group. If index is non-NULL,
+ // populates it with the deck number (1-indexed).
+ static bool isPreviewDeckGroup(const QString& group, int* number=NULL);
+
// Return the number of samplers. Thread-safe.
static unsigned int numSamplers();
diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp
index 5ad57014f9..f288bd631b 100644
--- a/src/skin/legacyskinparser.cpp
+++ b/src/skin/legacyskinparser.cpp
@@ -987,14 +987,14 @@ QWidget* LegacySkinParser::parseEngineKey(QDomElement node) {
QWidget* LegacySkinParser::parseSpinny(QDomElement node) {
QString channelStr = lookupNodeGroup(node);
- const char* pSafeChannelStr = safeChannelString(channelStr);
if (CmdlineArgs::Instance().getSafeMode()) {
WLabel* dummy = new WLabel(m_pParent);
//: Shown when Mixxx is running in safe mode.
dummy->setText(tr("Safe Mode Enabled"));
return dummy;
}
- WSpinny* spinny = new WSpinny(m_pParent, m_pVCManager);
+ WSpinny* spinny = new WSpinny(m_pParent, channelStr, m_pConfig,
+ m_pVCManager);
if (!spinny->isValid()) {
delete spinny;
WLabel* dummy = new WLabel(m_pParent);
@@ -1018,7 +1018,7 @@ QWidget* LegacySkinParser::parseSpinny(QDomElement node) {
spinny->slotLoadTrack(pPlayer->getLoadedTrack());
}
- spinny->setup(node, *m_pContext, pSafeChannelStr);
+ spinny->setup(node, *m_pContext);
spinny->installEventFilter(m_pKeyboard);
spinny->installEventFilter(m_pControllerManager->getControllerLearningEventFilter());
spinny->Init();
diff --git a/src/util/dnd.h b/src/util/dnd.h
index bd2a9c7ad1..dfcdbc4bae 100644
--- a/src/util/dnd.h
+++ b/src/util/dnd.h
@@ -10,12 +10,15 @@
#include <QRegExp>
#include <QScopedPointer>
+#include "configobject.h"
+#include "controlobject.h"
#include "soundsourceproxy.h"
#include "library/parser.h"
#include "library/parserm3u.h"
#include "library/parserpls.h"
#include "library/parsercsv.h"
#include "util/sandbox.h"
+#include "playermanager.h"
class DragAndDropHelper {
public:
@@ -69,19 +72,69 @@ class DragAndDropHelper {
return fileLocations;
}
- static QDrag* dragTrack(TrackPointer pTrack, QWidget* pDragSource) {
+ // Allow loading to a player if the player isn't playing or the settings
+ // allow interrupting a playing player.
+ static bool allowLoadToPlayer(const QString& group,
+ ConfigObject<ConfigValue>* pConfig) {
+ return allowLoadToPlayer(
+ group, ControlObject::get(ConfigKey(group, "play")) > 0.0,
+ pConfig);
+ }
+
+ // Allow loading to a player if the player isn't playing or the settings
+ // allow interrupting a playing player.
+ static bool allowLoadToPlayer(const QString& group,
+ bool isPlaying,
+ ConfigObject<ConfigValue>* pConfig) {
+ // Always allow loads to preview decks.
+ if (PlayerManager::isPreviewDeckGroup(group)) {
+ return true;
+ }
+
+ return !isPlaying || pConfig->getValueString(
+ ConfigKey("[Controls]",
+ "AllowTrackLoadToPlayingDeck")).toInt();
+ }
+
+ static bool dragEnterAccept(const QMimeData& mimeData,
+ const QString& sourceIdentifier,
+ bool firstOnly,
+ bool acceptPlaylists) {
+ QList<QFileInfo> files = dropEventFiles(mimeData, sourceIdentifier,
+ firstOnly, acceptPlaylists);
+ return !files.isEmpty();
+ }
+
+ static QList<QFileInfo> dropEventFiles(const QMimeData& mimeData,
+ const QString& sourceIdentifier,
+ bool firstOnly,
+ bool acceptPlaylists) {
+ if (!mimeData.hasUrls() ||
+ (mimeData.hasText() && mimeData.text() == sourceIdentifier)) {
+ return QList<QFileInfo>();
+ }
+
+ QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
+ mimeData.urls(), firstOnly, acceptPlaylists);
+ return files;
+ }
+
+
+ static QDrag* dragTrack(TrackPointer pTrack, QWidget* pDragSource,
+ QString sourceIdentifier) {
QList<QUrl> locationUrls;
locationUrls.append(urlFromLocation(pTrack->getLocation()));
- return dragUrls(locationUrls, pDragSource);
+ return dragUrls(locationUrls, pDragSource, sourceIdentifier);
}
static QDrag* dragTrackLocations(const QList<QString>& locations,
- QWidget* pDragSource) {
+ QWidget* pDragSource,
+ QString sourceIdentifier) {
QList<QUrl> locationUrls;
foreach (QString location, locations) {
locationUrls.append(urlFromLocation(location));
}
- return dragUrls(locationUrls, pDragSource);
+ return dragUrls(locationUrls, pDragSource, sourceIdentifier);
}
static QUrl urlFromLocation(const QString& trackLocation) {
@@ -90,13 +143,14 @@ class DragAndDropHelper {
private:
static QDrag* dragUrls(const QList<QUrl>& locationUrls,
- QWidget* pDragSource) {
+ QWidget* pDragSource, QString sourceIdentifier) {
if (locationUrls.isEmpty()) {
return NULL;
}
QMimeData* mimeData = new QMimeData();
mimeData->setUrls(locationUrls);
+ mimeData->setText(sourceIdentifier);
QDrag* drag = new QDrag(pDragSource);
drag->setMimeData(mimeData);
diff --git a/src/widget/wbasewidget.h b/src/widget/wbasewidget.h
index 561e163679..13fcbd8f5a 100644
--- a/src/widget/wbasewidget.h
+++ b/src/widget/wbasewidget.h
@@ -79,7 +79,6 @@ class WBaseWidget {
void updateTooltip();
virtual void fillDebugTooltip(QStringList* debug);
- protected:
QList<ControlParameterWidgetConnection*> m_connections;
ControlParameterWidgetConnection* m_pDisplayConnection;
QList<ControlParameterWidgetConnection*> m_leftConnections;
diff --git a/src/widget/wcoverart.cpp b/src/widget/wcoverart.cpp
index 2c9b42a6fb..f4ba1f1034 100644
--- a/src/widget/wcoverart.cpp
+++ b/src/widget/wcoverart.cpp
@@ -231,43 +231,30 @@ void WCoverArt::leaveEvent(QEvent*) {
void WCoverArt::mouseMoveEvent(QMouseEvent* event) {
if ((event->buttons() & Qt::LeftButton) && m_loadedTrack) {
- DragAndDropHelper::dragTrack(m_loadedTrack, this);
+ DragAndDropHelper::dragTrack(m_loadedTrack, this, m_group);
}
}
void WCoverArt::dragEnterEvent(QDragEnterEvent* event) {
- // We don't have a group to load the track into.
- if (m_group.isEmpty()) {
+ // If group is empty then we are a library cover art widget and we don't
+ // accept track drops.
+ if (!m_group.isEmpty() &&
+ DragAndDropHelper::allowLoadToPlayer(m_group, m_pConfig) &&
+ DragAndDropHelper::dragEnterAccept(*event->mimeData(), m_group,
+ true, false)) {
+ event->acceptProposedAction();
+ } else {
event->ignore();
- return;
}
-
- 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_group, "play")) ||
- m_pConfig->getValueString(ConfigKey("[Controls]", "AllowTrackLoadToPlayingDeck")).toInt())) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
- if (!files.isEmpty()) {
- event->acceptProposedAction();
- return;
- }
- }
- }
- event->ignore();
}
void WCoverArt::dropEvent(QDropEvent *event) {
- // We don't have a group to load the track into.
- if (m_group.isEmpty()) {
- event->ignore();
- return;
- }
-
- if (event->mimeData()->hasUrls()) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
+ // If group is empty then we are a library cover art widget and we don't
+ // accept track drops.
+ if (!m_group.isEmpty() &&
+ DragAndDropHelper::allowLoadToPlayer(m_group, m_pConfig)) {
+ QList<QFileInfo> files = DragAndDropHelper::dropEventFiles(
+ *event->mimeData(), m_group, true, false);
if (!files.isEmpty()) {
event->accept();
emit(trackDropped(files.at(0).canonicalFilePath(), m_group));
diff --git a/src/widget/wlibrarysidebar.cpp b/src/widget/wlibrarysidebar.cpp
index e839bf97c2..8ba2088b16 100644
--- a/src/widget/wlibrarysidebar.cpp
+++ b/src/widget/wlibrarysidebar.cpp
@@ -44,8 +44,12 @@ void WLibrarySidebar::contextMenuEvent(QContextMenuEvent *event) {
void WLibrarySidebar::dragEnterEvent(QDragEnterEvent * event) {
qDebug() << "WLibrarySidebar::dragEnterEvent" << event->mimeData()->formats();
if (event->mimeData()->hasUrls()) {
+ // We don't have a way to ask the LibraryFeatures whether to accept a
+ // drag so for now we accept all drags. Since almost every
+ // LibraryFeature accepts all files in the drop and accepts playlist
+ // drops we default to those flags to DragAndDropHelper.
QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
+ event->mimeData()->urls(), false, true);
if (!files.isEmpty()) {
event->acceptProposedAction();
return;
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp
index a468135883..1eabb61d2d 100644
--- a/src/widget/woverview.cpp
+++ b/src/widget/woverview.cpp
@@ -502,26 +502,22 @@ void WOverview::resizeEvent(QResizeEvent *) {
}
void WOverview::dragEnterEvent(QDragEnterEvent* event) {
- // Accept the enter event if the thing is a filepath and nothing's playing
- // in this deck or the settings allow to interrupt the playing deck.
- if (event->mimeData()->hasUrls() && event->mimeData()->urls().size() > 0) {
- if ((m_playControl->get() == 0.0 ||
- m_pConfig->getValueString(ConfigKey("[Controls]","AllowTrackLoadToPlayingDeck")).toInt()) || (m_group=="[PreviewDeck1]")) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
- if (!files.isEmpty()) {
- event->acceptProposedAction();
- return;
- }
- }
+ if (DragAndDropHelper::allowLoadToPlayer(m_group,
+ m_playControl->get() > 0.0,
+ m_pConfig) &&
+ DragAndDropHelper::dragEnterAccept(*event->mimeData(), m_group,
+ true, false)) {
+ event->acceptProposedAction();
+ } else {
+ event->ignore();
}
- event->ignore();
}
void WOverview::dropEvent(QDropEvent* event) {
- if (event->mimeData()->hasUrls()) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
+ if (DragAndDropHelper::allowLoadToPlayer(m_group, m_playControl->get() > 0.0,
+ m_pConfig)) {
+ QList<QFileInfo> files = DragAndDropHelper::dropEventFiles(
+ *event->mimeData(), m_group, true, false);
if (!files.isEmpty()) {
event->accept();
emit(trackDropped(files.at(0).canonicalFilePath(), m_group));
diff --git a/src/widget/wspinny.cpp b/src/widget/wspinny.cpp
index ea3dbdd5a4..9e3a3b35c3 100644
--- a/src/widget/wspinny.cpp
+++ b/src/widget/wspinny.cpp
@@ -15,9 +15,13 @@
#include "widget/wspinny.h"
#include "wimagestore.h"
-WSpinny::WSpinny(QWidget* parent, VinylControlManager* pVCMan)
+WSpinny::WSpinny(QWidget* parent, const QString& group,
+ ConfigObject<ConfigValue>* pConfig,
+ VinylControlManager* pVCMan)
: QGLWidget(parent, SharedGLContext::getWidget()),
WBaseWidget(this),
+ m_group(group),
+ m_pConfig(pConfig),
m_pBgImage(NULL),
m_pFgImage(NULL),
m_pGhostImage(NULL),
@@ -76,24 +80,21 @@ WSpinny::~WSpinny() {
#ifdef __VINYLCONTROL__
m_pVCManager->removeSignalQualityListener(this);
#endif
- // No need to delete anything if m_group is empty because setup() was not called.
- if (!m_group.isEmpty()) {
- WImageStore::deleteImage(m_pBgImage);
- WImageStore::deleteImage(m_pFgImage);
- WImageStore::deleteImage(m_pGhostImage);
- delete m_pPlay;
- delete m_pPlayPos;
- delete m_pTrackSamples;
- delete m_pTrackSampleRate;
- delete m_pScratchToggle;
- delete m_pScratchPos;
- delete m_pSlipEnabled;
- #ifdef __VINYLCONTROL__
- delete m_pVinylControlSpeedType;
- delete m_pVinylControlEnabled;
- delete m_pSignalEnabled;
- #endif
- }
+ WImageStore::deleteImage(m_pBgImage);
+ WImageStore::deleteImage(m_pFgImage);
+ WImageStore::deleteImage(m_pGhostImage);
+ delete m_pPlay;
+ delete m_pPlayPos;
+ delete m_pTrackSamples;
+ delete m_pTrackSampleRate;
+ delete m_pScratchToggle;
+ delete m_pScratchPos;
+ delete m_pSlipEnabled;
+#ifdef __VINYLCONTROL__
+ delete m_pVinylControlSpeedType;
+ delete m_pVinylControlEnabled;
+ delete m_pSignalEnabled;
+#endif
}
void WSpinny::onVinylSignalQualityUpdate(const VinylSignalQualityReport& report) {
@@ -128,9 +129,7 @@ void WSpinny::onVinylSignalQualityUpdate(const VinylSignalQualityReport& report)
#endif
}
-void WSpinny::setup(QDomNode node, const SkinContext& context, QString group) {
- m_group = group;
-
+void WSpinny::setup(QDomNode node, const SkinContext& context) {
// Set images
m_pBgImage = WImageStore::getImage(context.getPixmapSource(
context.selectNode(node, "PathBackground")));
@@ -157,28 +156,28 @@ void WSpinny::setup(QDomNode node, const SkinContext& context, QString group) {
#endif
m_pPlay = new ControlObjectThread(
- group, "play");
+ m_group, "play");
m_pPlayPos = new ControlObjectThread(
- group, "playposition");
- m_pVisualPlayPos = VisualPlayPosition::getVisualPlayPosition(group);
+ m_group, "playposition");
+ m_pVisualPlayPos = VisualPlayPosition::getVisualPlayPosition(m_group);
m_pTrackSamples = new ControlObjectThread(
- group, "track_samples");
+ m_group, "track_samples");
m_pTrackSampleRate = new ControlObjectThread(
- group, "track_samplerate");
+ m_group, "track_samplerate");
m_pScratchToggle = new ControlObjectThread(
- group, "scratch_position_enable");
+ m_group, "scratch_position_enable");
m_pScratchPos = new ControlObjectThread(
- group, "scratch_position");
+ m_group, "scratch_position");
m_pSlipEnabled = new ControlObjectThread(
- group, "slip_enabled");
+ m_group, "slip_enabled");
connect(m_pSlipEnabled, SIGNAL(valueChanged(double)),
this, SLOT(updateSlipEnabled(double)));
#ifdef __VINYLCONTROL__
m_pVinylControlSpeedType = new ControlObjectThread(
- group, "vinylcontrol_speed_type");
+ m_group, "vinylcontrol_speed_type");
if (m_pVinylControlSpeedType)
{
//Initialize the rotational speed.
@@ -186,12 +185,12 @@ void WSpinny::setup(QDomNode node, const SkinContext& context, QString group) {
}
m_pVinylControlEnabled = new ControlObjectThread(
- group, "vinylcontrol_enabled");
+ m_group, "vinylcontrol_enabled");
connect(m_pVinylControlEnabled, SIGNAL(valueChanged(double)),
this, SLOT(updateVinylControlEnabled(double)));
m_pSignalEnabled = new ControlObjectThread(
- group, "vinylcontrol_signal_enabled");
+ m_group, "vinylcontrol_signal_enabled");
connect(m_pSignalEnabled, SIGNAL(valueChanged(double)),
this, SLOT(updateVinylControlSignalEnabled(double)));
@@ -600,30 +599,22 @@ bool WSpinny::event(QEvent* pEvent) {
return QGLWidget::event(pEvent);
}
-/** DRAG AND DROP **/
-void WSpinny::dragEnterEvent(QDragEnterEvent * event)
-{
- // Accept the enter event if the thing is a filepath and nothing's playing
- // in this deck.
- if (event->mimeData()->hasUrls()) {
- if (m_pPlay && m_pPlay->get()) {
- event->ignore();
- } else {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
- if (!files.isEmpty()) {
- event->acceptProposedAction();
- return;
- }
- }
+void WSpinny::dragEnterEvent(QDragEnterEvent* event) {
+ if (DragAndDropHelper::allowLoadToPlayer(m_group, m_pPlay->get() > 0.0,
+ m_pConfig) &&
+ DragAndDropHelper::dragEnterAccept(*event->mimeData(), m_group,
+ true, false)) {
+ event->acceptProposedAction();
+ } else {
+ event->ignore();
}
- event->ignore();
}
void WSpinny::dropEvent(QDropEvent * event) {
- if (event->mimeData()->hasUrls()) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
+ if (DragAndDropHelper::allowLoadToPlayer(m_group, m_pPlay->get() > 0.0,
+ m_pConfig)) {
+ QList<QFileInfo> files = DragAndDropHelper::dropEventFiles(
+ *event->mimeData(), m_group, true, false);
if (!files.isEmpty()) {
event->accept();
emit(trackDropped(files.at(0).canonicalFilePath(), m_group));
diff --git a/src/widget/wspinny.h b/src/widget/wspinny.h
index 6060b3ecb4..c654abc73e 100644
--- a/src/widget/wspinny.h
+++ b/src/widget/wspinny.h
@@ -7,6 +7,7 @@
#include <QHideEvent>
#include <QEvent>
+#include "configobject.h"
#include "skin/skincontext.h"
#include "trackinfoobject.h"
#include "vinylcontrol/vinylsignalquality.h"
@@ -20,12 +21,14 @@ class VinylControlManager;
class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityListener {
Q_OBJECT
public:
- WSpinny(QWidget* parent, VinylControlManager* pVCMan);
+ WSpinny(QWidget* parent, const QString& group,
+ ConfigObject<ConfigValue>* pConfig,
+ VinylControlManager* pVCMan);
virtual ~WSpinny();
void onVinylSignalQualityUpdate(const VinylSignalQualityReport& report);
- void setup(QDomNode node, const SkinContext& context, QString group);
+ void setup(QDomNode node, const SkinContext& context);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
@@ -64,6 +67,8 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL
QPixmap scaledCoverArt(const QPixmap& normal);
private:
+ QString m_group;
+ ConfigObject<ConfigValue>* m_pConfig;
QImage* m_pBgImage;
QImage* m_pFgImage;
QImage* m_pGhostImage;
@@ -95,7 +100,6 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL
QImage m_qImage;
int m_iVinylScopeSize;
- QString m_group;
float m_fAngle; //Degrees
double m_dAngleCurrentPlaypos;
double m_dAngleLastPlaypos;
diff --git a/src/widget/wtrackproperty.cpp b/src/widget/wtrackproperty.cpp
index d22696d584..123249e837 100644
--- a/src/widget/wtrackproperty.cpp
+++ b/src/widget/wtrackproperty.cpp
@@ -53,31 +53,24 @@ void WTrackProperty::updateLabel(TrackInfoObject*) {
void WTrackProperty::mouseMoveEvent(QMouseEvent *event) {
if ((event->buttons() & Qt::LeftButton) && m_pCurrentTrack) {
- DragAndDropHelper::dragTrack(m_pCurrentTrack, this);
+ DragAndDropHelper::dragTrack(m_pCurrentTrack, this, m_pGroup);
}
}
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())) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
- if (!files.isEmpty()) {
- event->acceptProposedAction();
- return;
- }
- }
+ if (DragAndDropHelper::allowLoadToPlayer(m_pGroup, m_pConfig) &&
+ DragAndDropHelper::dragEnterAccept(*event->mimeData(), m_pGroup,
+ true, false)) {
+ event->acceptProposedAction();
+ } else {
+ event->ignore();
}
- event->ignore();
}
void WTrackProperty::dropEvent(QDropEvent *event) {
- if (event->mimeData()->hasUrls()) {
- QList<QFileInfo> files = DragAndDropHelper::supportedTracksFromUrls(
- event->mimeData()->urls(), true, false);
+ if (DragAndDropHelper::allowLoadToPlayer(m_pGroup, m_pConfig)) {
+ QList<QFileInfo> files = DragAndDropHelper::dropEventFiles(
+ *event->mimeData(), m_pGroup, true, false);
if (!files.isEmpty()) {
event->accept();
emit(trackDropped(files.at(0).canonicalFilePath(), m_pGroup));
diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp
index 28263f232c..23c371c45a 100644
--- a/src/widget/wtracktableview.cpp
+++ b/src/widget/wtracktableview.cpp
@@ -961,37 +961,25 @@ void WTrackTableView::mouseMoveEvent(QMouseEvent* pEvent) {
}
locations.append(trackModel->getTrackLocation(index));
}
- DragAndDropHelper::dragTrackLocations(locations, this);
+ DragAndDropHelper::dragTrackLocations(locations, this, "library");
}
// Drag enter event, happens when a dragged item hovers over the track table view
void WTrackTableView::dragEnterEvent(QDragEnterEvent * event) {
//qDebug() << "dragEnterEvent" << event->mimeData()->formats();
- if (event->mimeData()->hasUrls())
- {
+ if (event->mimeData()->hasUrls()) {
if (event->source() == this) {
if (modelHasCapabilities(TrackModel::TRACKMODELCAPS_REORDER)) {
event->acceptProposedAction();
- } else {</