diff options
author | Owen Williams <owen-github@ywwg.com> | 2014-11-17 22:11:57 -0500 |
---|---|---|
committer | Owen Williams <owen-github@ywwg.com> | 2014-11-17 22:11:57 -0500 |
commit | c21f0c6559e5c19ed7a9acd301e2100823a43e00 (patch) | |
tree | 84645ee791438ad1de1d4244a525c278f7f53e65 | |
parent | 9d56993719002a157716a294b20e21021307c651 (diff) | |
parent | b39fd583ac3167d9ee27070126e83342e78a8429 (diff) |
Merge pull request #391 from ywwg/spinny-cover-art
Show cover art in spinny underneath spinny background.
-rw-r--r-- | res/skins/LateNight/spinny.xml | 4 | ||||
-rw-r--r-- | res/skins/LateNight/style.qss | 4 | ||||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny1_background-s.png | bin | 3124 -> 2519 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny1_background.png | bin | 8649 -> 4503 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny1_foreground-s.png | bin | 703 -> 158 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny1_foreground.png | bin | 778 -> 169 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny1_foreground_ghost-s.png | bin | 308 -> 273 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny1_foreground_ghost.png | bin | 523 -> 485 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny2_background-s.png | bin | 3219 -> 2545 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny2_background.png | bin | 9091 -> 4552 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny2_foreground-s.png | bin | 158 -> 158 bytes | |||
-rw-r--r-- | res/skins/LateNight/vinyl_spinny2_foreground.png | bin | 169 -> 169 bytes | |||
-rw-r--r-- | src/skin/legacyskinparser.cpp | 12 | ||||
-rw-r--r-- | src/widget/wspinny.cpp | 96 | ||||
-rw-r--r-- | src/widget/wspinny.h | 20 |
15 files changed, 125 insertions, 11 deletions
diff --git a/res/skins/LateNight/spinny.xml b/res/skins/LateNight/spinny.xml index 9f29d0560d..bdc6802faf 100644 --- a/res/skins/LateNight/spinny.xml +++ b/res/skins/LateNight/spinny.xml @@ -5,7 +5,7 @@ <WidgetGroup> <ObjectName>SpinnyContainer</ObjectName> <Layout>horizontal</Layout> - <MinimumSize>20,20</MinimumSize> + <MinimumSize>95,95</MinimumSize> <SizePolicy>min,min</SizePolicy> <Children> <Spinny> @@ -13,6 +13,7 @@ <PathBackground>vinyl_spinny<Variable name="color"/>_background.png</PathBackground> <PathForeground>vinyl_spinny<Variable name="color"/>_foreground.png</PathForeground> <PathGhost>vinyl_spinny<Variable name="color"/>_foreground_ghost.png</PathGhost> + <ShowCover>true</ShowCover> </Spinny> </Children> </WidgetGroup> @@ -27,6 +28,7 @@ <PathBackground>vinyl_spinny<Variable name="color"/>_background-s.png</PathBackground> <PathForeground>vinyl_spinny<Variable name="color"/>_foreground-s.png</PathForeground> <PathGhost>vinyl_spinny<Variable name="color"/>_foreground_ghost-s.png</PathGhost> + <ShowCover>true</ShowCover> </Spinny> </Children> </WidgetGroup> diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index 60d69fc4aa..1711a3e881 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -19,8 +19,8 @@ qproperty-layoutAlignment: 'AlignHCenter | AlignTop'; } -#RightSpinny { - qproperty-layoutAlignment: 'AlignRight | AlignTop'; +#SpinnyContainer { + background-color: #0f0f0f; } #Library { diff --git a/res/skins/LateNight/vinyl_spinny1_background-s.png b/res/skins/LateNight/vinyl_spinny1_background-s.png Binary files differindex 5fdbb05794..7c87efb984 100644 --- a/res/skins/LateNight/vinyl_spinny1_background-s.png +++ b/res/skins/LateNight/vinyl_spinny1_background-s.png diff --git a/res/skins/LateNight/vinyl_spinny1_background.png b/res/skins/LateNight/vinyl_spinny1_background.png Binary files differindex 5d44ba4a48..af5497b512 100644 --- a/res/skins/LateNight/vinyl_spinny1_background.png +++ b/res/skins/LateNight/vinyl_spinny1_background.png diff --git a/res/skins/LateNight/vinyl_spinny1_foreground-s.png b/res/skins/LateNight/vinyl_spinny1_foreground-s.png Binary files differindex b336510cec..6057e98a94 100644 --- a/res/skins/LateNight/vinyl_spinny1_foreground-s.png +++ b/res/skins/LateNight/vinyl_spinny1_foreground-s.png diff --git a/res/skins/LateNight/vinyl_spinny1_foreground.png b/res/skins/LateNight/vinyl_spinny1_foreground.png Binary files differindex 1f0213520e..c366c1ec95 100644 --- a/res/skins/LateNight/vinyl_spinny1_foreground.png +++ b/res/skins/LateNight/vinyl_spinny1_foreground.png diff --git a/res/skins/LateNight/vinyl_spinny1_foreground_ghost-s.png b/res/skins/LateNight/vinyl_spinny1_foreground_ghost-s.png Binary files differindex 1e91662e89..7aae6f6bbb 100644 --- a/res/skins/LateNight/vinyl_spinny1_foreground_ghost-s.png +++ b/res/skins/LateNight/vinyl_spinny1_foreground_ghost-s.png diff --git a/res/skins/LateNight/vinyl_spinny1_foreground_ghost.png b/res/skins/LateNight/vinyl_spinny1_foreground_ghost.png Binary files differindex e9f0f81f8c..19037856db 100644 --- a/res/skins/LateNight/vinyl_spinny1_foreground_ghost.png +++ b/res/skins/LateNight/vinyl_spinny1_foreground_ghost.png diff --git a/res/skins/LateNight/vinyl_spinny2_background-s.png b/res/skins/LateNight/vinyl_spinny2_background-s.png Binary files differindex 29e8d7a6d9..76e2f53085 100644 --- a/res/skins/LateNight/vinyl_spinny2_background-s.png +++ b/res/skins/LateNight/vinyl_spinny2_background-s.png diff --git a/res/skins/LateNight/vinyl_spinny2_background.png b/res/skins/LateNight/vinyl_spinny2_background.png Binary files differindex f04242940b..aa2162ebdc 100644 --- a/res/skins/LateNight/vinyl_spinny2_background.png +++ b/res/skins/LateNight/vinyl_spinny2_background.png diff --git a/res/skins/LateNight/vinyl_spinny2_foreground-s.png b/res/skins/LateNight/vinyl_spinny2_foreground-s.png Binary files differindex d8976cb59b..14d65c833a 100644 --- a/res/skins/LateNight/vinyl_spinny2_foreground-s.png +++ b/res/skins/LateNight/vinyl_spinny2_foreground-s.png diff --git a/res/skins/LateNight/vinyl_spinny2_foreground.png b/res/skins/LateNight/vinyl_spinny2_foreground.png Binary files differindex a6589f7cde..f74027bea3 100644 --- a/res/skins/LateNight/vinyl_spinny2_foreground.png +++ b/res/skins/LateNight/vinyl_spinny2_foreground.png diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 4ca19a0949..006754791a 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -928,7 +928,7 @@ QWidget* LegacySkinParser::parseTrackProperty(QDomElement node) { QWidget* LegacySkinParser::parseStarRating(QDomElement node) { QString channelStr = lookupNodeGroup(node); const char* pSafeChannelStr = safeChannelString(channelStr); - + BaseTrackPlayer* pPlayer = m_pPlayerManager->getPlayer(channelStr); if (!pPlayer) @@ -1019,6 +1019,16 @@ QWidget* LegacySkinParser::parseSpinny(QDomElement node) { connect(spinny, SIGNAL(trackDropped(QString, QString)), m_pPlayerManager, SLOT(slotLoadToPlayer(QString, QString))); + BaseTrackPlayer* pPlayer = m_pPlayerManager->getPlayer(channelStr); + if (pPlayer != NULL) { + connect(pPlayer, SIGNAL(newTrackLoaded(TrackPointer)), + spinny, SLOT(slotLoadTrack(TrackPointer))); + connect(pPlayer, SIGNAL(unloadingTrack(TrackPointer)), + spinny, SLOT(slotReset())); + // just in case a track is already loaded + spinny->slotLoadTrack(pPlayer->getLoadedTrack()); + } + spinny->setup(node, *m_pContext, pSafeChannelStr); spinny->installEventFilter(m_pKeyboard); spinny->installEventFilter(m_pControllerManager->getControllerLearningEventFilter()); diff --git a/src/widget/wspinny.cpp b/src/widget/wspinny.cpp index a39c65d106..1a974e47e2 100644 --- a/src/widget/wspinny.cpp +++ b/src/widget/wspinny.cpp @@ -3,16 +3,17 @@ #include <QUrl> #include <QMimeData> -#include "wimagestore.h" #include "controlobject.h" #include "controlobjectthread.h" +#include "library/coverartcache.h" #include "sharedglcontext.h" -#include "visualplayposition.h" -#include "widget/wspinny.h" -#include "vinylcontrol/vinylcontrolmanager.h" -#include "vinylcontrol/vinylcontrol.h" #include "util/dnd.h" #include "util/math.h" +#include "visualplayposition.h" +#include "vinylcontrol/vinylcontrol.h" +#include "vinylcontrol/vinylcontrolmanager.h" +#include "widget/wspinny.h" +#include "wimagestore.h" WSpinny::WSpinny(QWidget* parent, VinylControlManager* pVCMan) : QGLWidget(parent, SharedGLContext::getWidget()), @@ -32,6 +33,7 @@ WSpinny::WSpinny(QWidget* parent, VinylControlManager* pVCMan) m_pSignalEnabled(NULL), m_pSlipEnabled(NULL), m_pSlipPosition(NULL), + m_bShowCover(true), m_dInitialPos(0.), m_iVinylInput(-1), m_bVinylActive(false), @@ -60,6 +62,15 @@ WSpinny::WSpinny(QWidget* parent, VinylControlManager* pVCMan) qDebug() << "WSpinny(): Created QGLWidget, Context" << "Valid:" << context()->isValid() << "Sharing:" << context()->isSharing(); + + CoverArtCache* pCache = CoverArtCache::instance(); + if (pCache != NULL) { + connect(pCache, SIGNAL(coverFound(const QObject*, const int, + const CoverInfo&, QPixmap, bool)), + this, SLOT(slotCoverFound(const QObject*, const int, + const CoverInfo&, QPixmap, bool))); + } + } WSpinny::~WSpinny() { @@ -133,6 +144,8 @@ void WSpinny::setup(QDomNode node, const SkinContext& context, QString group) { setFixedSize(m_pBgImage->size()); } + m_bShowCover = context.selectBool(node, "ShowCover", true); + #ifdef __VINYLCONTROL__ // Find the vinyl input we should listen to reports about. if (m_pVCManager) { @@ -209,6 +222,64 @@ void WSpinny::maybeUpdate() { } } +void WSpinny::slotLoadTrack(TrackPointer pTrack) { + if (m_loadedTrack) { + disconnect(m_loadedTrack.data(), SIGNAL(coverArtUpdated()), + this, SLOT(slotTrackCoverArtUpdated())); + } + m_lastRequestedCover = CoverInfo(); + m_loadedCover = QPixmap(); + m_loadedCoverScaled = QPixmap(); + m_loadedTrack = pTrack; + if (m_loadedTrack) { + connect(m_loadedTrack.data(), SIGNAL(coverArtUpdated()), + this, SLOT(slotTrackCoverArtUpdated())); + } + + slotTrackCoverArtUpdated(); +} + +void WSpinny::slotReset() { + if (m_loadedTrack) { + disconnect(m_loadedTrack.data(), SIGNAL(coverArtUpdated()), + this, SLOT(slotTrackCoverArtUpdated())); + } + m_loadedTrack = TrackPointer(); + m_lastRequestedCover = CoverInfo(); + m_loadedCover = QPixmap(); + m_loadedCoverScaled = QPixmap(); + update(); +} + +void WSpinny::slotTrackCoverArtUpdated() { + if (m_loadedTrack) { + m_lastRequestedCover = m_loadedTrack->getCoverInfo(); + m_lastRequestedCover.trackLocation = m_loadedTrack->getLocation(); + CoverArtCache* pCache = CoverArtCache::instance(); + if (pCache != NULL) { + // TODO(rryan): Don't use track id. + pCache->requestCover(m_lastRequestedCover, this, m_loadedTrack->getId()); + } + } +} + +void WSpinny::slotCoverFound(const QObject* pRequestor, int requestReference, + const CoverInfo& info, QPixmap pixmap, + bool fromCache) { + Q_UNUSED(info); + Q_UNUSED(fromCache); + + if (pRequestor == this && m_loadedTrack && + m_loadedTrack->getId() == requestReference) { + qDebug() << "WSpinny::slotCoverFound" << pRequestor << info + << pixmap.size(); + m_loadedCover = pixmap; + m_loadedCoverScaled = scaledCoverArt(pixmap); + update(); + } +} + + void WSpinny::paintEvent(QPaintEvent *e) { Q_UNUSED(e); //ditch unused param warning m_bWidgetDirty = false; @@ -216,6 +287,10 @@ void WSpinny::paintEvent(QPaintEvent *e) { QPainter p(this); p.setRenderHint(QPainter::SmoothPixmapTransform); + if (m_bShowCover && !m_loadedCoverScaled.isNull()) { + p.drawPixmap(0, 0, m_loadedCoverScaled); + } + if (m_pBgImage) { p.drawImage(0, 0, *m_pBgImage); } @@ -270,6 +345,17 @@ void WSpinny::paintEvent(QPaintEvent *e) { } } +QPixmap WSpinny::scaledCoverArt(const QPixmap& normal) { + if (normal.isNull()) { + return QPixmap(); + } + return normal.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); +} + +void WSpinny::resizeEvent(QResizeEvent*) { + m_loadedCoverScaled = scaledCoverArt(m_loadedCover); +} + /* Convert between a normalized playback position (0.0 - 1.0) and an angle in our polar coordinate system. Returns an angle clamped between -180 and 180 degrees. */ diff --git a/src/widget/wspinny.h b/src/widget/wspinny.h index bc4469322f..10dacc3ae9 100644 --- a/src/widget/wspinny.h +++ b/src/widget/wspinny.h @@ -7,10 +7,11 @@ #include <QHideEvent> #include <QEvent> -#include "widget/wwidget.h" -#include "vinylcontrol/vinylsignalquality.h" #include "skin/skincontext.h" +#include "trackinfoobject.h" +#include "vinylcontrol/vinylsignalquality.h" #include "widget/wbasewidget.h" +#include "widget/wwidget.h" class ControlObjectThread; class VisualPlayPosition; @@ -29,6 +30,8 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL void dropEvent(QDropEvent *event); public slots: + void slotLoadTrack(TrackPointer); + void slotReset(); void updateVinylControlSpeed(double rpm); void updateVinylControlEnabled(double enabled); void updateVinylControlSignalEnabled(double enabled); @@ -36,6 +39,10 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL protected slots: void maybeUpdate(); + void slotCoverFound(const QObject* pRequestor, int requestReference, + const CoverInfo& info, QPixmap pixmap, bool fromCache); + void slotTrackCoverArtUpdated(); + signals: void trackDropped(QString filename, QString group); @@ -46,6 +53,7 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL void mouseMoveEvent(QMouseEvent * e); void mousePressEvent(QMouseEvent * e); void mouseReleaseEvent(QMouseEvent * e); + void resizeEvent(QResizeEvent*); void showEvent(QShowEvent* event); void hideEvent(QHideEvent* event); bool event(QEvent* pEvent); @@ -53,6 +61,7 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL double calculateAngle(double playpos); int calculateFullRotations(double playpos); double calculatePositionFromAngle(double angle); + QPixmap scaledCoverArt(const QPixmap& normal); private: QImage* m_pBgImage; @@ -71,6 +80,13 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL ControlObjectThread* m_pSlipEnabled; ControlObjectThread* m_pSlipPosition; + TrackPointer m_loadedTrack; + QPixmap m_loadedCover; + QPixmap m_loadedCoverScaled; + CoverInfo m_lastRequestedCover; + bool m_bShowCover; + + VinylControlManager* m_pVCManager; double m_dInitialPos; |