diff options
author | Marcos CARDINOT <mcardinot@gmail.com> | 2014-05-05 02:08:12 +0100 |
---|---|---|
committer | Marcos CARDINOT <mcardinot@gmail.com> | 2014-05-05 02:08:12 +0100 |
commit | 5b40ccd4a6c266d15d0af687b582e4e431fac10c (patch) | |
tree | d7550479037a00f02e0fef03e8a4fdf660b59030 | |
parent | ab170b1aff8a07aea26bc139ed1bf77f06c95b88 (diff) |
load covers into wcoverart
-rw-r--r-- | src/library/library.cpp | 4 | ||||
-rw-r--r-- | src/library/library.h | 4 | ||||
-rw-r--r-- | src/skin/legacyskinparser.cpp | 4 | ||||
-rw-r--r-- | src/widget/wcoverart.cpp | 38 | ||||
-rw-r--r-- | src/widget/wcoverart.h | 8 |
5 files changed, 30 insertions, 28 deletions
diff --git a/src/library/library.cpp b/src/library/library.cpp index e2d9668580..6f86746006 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -154,7 +154,7 @@ void Library::bindWidget(WLibrary* pLibraryWidget, pLibraryWidget, SLOT(switchToView(const QString&))); connect(pTrackTableView, SIGNAL(trackSelected(TrackPointer)), - pLibraryWidget, SLOT(slotLoadCoverArt(TrackPointer))); + this, SLOT(slotLoadCoverArt(TrackPointer))); m_pLibraryControl->bindWidget(pLibraryWidget, pKeyboard); @@ -239,7 +239,7 @@ void Library::slotCreateCrate() { } void Library::slotLoadCoverArt(TrackPointer pTrack) { - emit(loadCoverArt(pTrack)); + emit(loadCoverArt(pTrack->getCoverArt())); } void Library::onSkinLoadFinished() { diff --git a/src/library/library.h b/src/library/library.h index ca14ea3615..1dd3c26702 100644 --- a/src/library/library.h +++ b/src/library/library.h @@ -75,7 +75,7 @@ public: void slotRequestRemoveDir(QString directory, Library::RemovalType removalType); void slotRequestRelocateDir(QString previousDirectory, QString newDirectory); void onSkinLoadFinished(); - void slotLoadCoverArt(TrackPointer pTrack); + void slotLoadCoverArt(TrackPointer); signals: void showTrackModel(QAbstractItemModel* model); @@ -86,7 +86,7 @@ public: void search(const QString& text); void searchCleared(); void searchStarting(); - void loadCoverArt(TrackPointer pTrack); + void loadCoverArt(QImage picture); private: ConfigObject<ConfigValue>* m_pConfig; diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 92782d65c6..4b94fe9abf 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -965,8 +965,8 @@ QWidget* LegacySkinParser::parseCoverArt(QDomElement node) { // Connect cover art signals to the library connect(m_pLibrary, SIGNAL(switchToView(const QString&)), pCoverArt, SLOT(slotHideCoverArt())); - connect(m_pLibrary, SIGNAL(trackSelected(pTrack)), - pCoverArt, SLOT(slotLoadCoverArt(pTrack))); + connect(m_pLibrary, SIGNAL(loadCoverArt(QImage)), + pCoverArt, SLOT(slotLoadCoverArt(QImage))); return pCoverArt; } diff --git a/src/widget/wcoverart.cpp b/src/widget/wcoverart.cpp index 9610e9e064..e16a4168da 100644 --- a/src/widget/wcoverart.cpp +++ b/src/widget/wcoverart.cpp @@ -12,9 +12,9 @@ WCoverArt::WCoverArt(QWidget* parent, WBaseWidget(this), m_pConfig(pConfig), m_bCoverIsHovered(false), - m_bCoverIsVisible(false), - m_sDefaultCover(":/images/library/vinyl-record.png"), - m_sCurrentCover(m_sDefaultCover) { + m_bCoverIsVisible(false) { + m_defaultCover = QImage(":/images/library/vinyl-record.png"); + m_currentCover = m_defaultCover; } WCoverArt::~WCoverArt() { @@ -49,7 +49,12 @@ void WCoverArt::slotHideCoverArt() { setMinimumSize(0, 20); } -void WCoverArt::slotLoadCoverArt(TrackPointer pTrack) { +void WCoverArt::slotLoadCoverArt(QImage picture) { + if (picture.isNull()) { + m_currentCover = m_defaultCover; + } else { + m_currentCover = picture; + } update(); } @@ -59,13 +64,11 @@ void WCoverArt::paintEvent(QPaintEvent*) { painter.drawLine(0,0,width(),0); if (m_bCoverIsVisible) { - if (!m_coverArt.load(m_sCurrentCover)) { - m_coverArt.load(m_sDefaultCover); - } - m_coverArt = m_coverArt.scaled(QSize(height()-10, height()-10), - Qt::KeepAspectRatioByExpanding, - Qt::SmoothTransformation); - painter.drawImage(width()/2-height()/2+4, 6, m_coverArt); + QImage scaledCover = m_currentCover.scaled( + QSize(height()-10, height()-10), + Qt::KeepAspectRatioByExpanding, + Qt::SmoothTransformation); + painter.drawImage(width()/2-height()/2+4, 6, scaledCover); } else { QImage sc = QImage(":/images/library/ic_library_cover_show.png"); sc = sc.scaled(height()-1, height()-1, @@ -101,17 +104,18 @@ void WCoverArt::mousePressEvent(QMouseEvent* event) { m_bCoverIsVisible = false; resize(sizeHint()); } else { - if (m_sCurrentCover != m_sDefaultCover) { + if (m_currentCover.operator!=(m_defaultCover)) { QLabel *lb = new QLabel(this, Qt::Popup | Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint); lb->setWindowModality(Qt::ApplicationModal); - int index = m_sCurrentCover.lastIndexOf("/"); - QString title = m_sCurrentCover.mid(index + 1); - lb->setWindowTitle(title); + //int index = m_sCurrentCover.lastIndexOf("/"); + //QString title = m_sCurrentCover.mid(index + 1); + //lb->setWindowTitle(title); + lb->setWindowTitle(tr("Cover Art")); - QPixmap px = QPixmap(m_sCurrentCover); + QPixmap px = QPixmap::fromImage(m_currentCover); QSize sz = QApplication::activeWindow()->size(); if (px.height() > sz.height() / 1.2) { @@ -144,7 +148,7 @@ void WCoverArt::mouseMoveEvent(QMouseEvent* event) { && lastPoint.y() < (height() / 5) + 5) { setCursor(Qt::ArrowCursor); } else { - if (m_sCurrentCover == m_sDefaultCover) { + if (m_currentCover.operator==(m_defaultCover)) { setCursor(Qt::ArrowCursor); } else { QPixmap pix(":/images/library/ic_library_zoom_in.png"); diff --git a/src/widget/wcoverart.h b/src/widget/wcoverart.h index 1654a73e84..9eae066cde 100644 --- a/src/widget/wcoverart.h +++ b/src/widget/wcoverart.h @@ -21,7 +21,7 @@ class WCoverArt : public QWidget, public WBaseWidget { public slots: void slotHideCoverArt(); - void slotLoadCoverArt(TrackPointer pTrack); + void slotLoadCoverArt(QImage picture); protected: void paintEvent(QPaintEvent*); @@ -36,10 +36,8 @@ class WCoverArt : public QWidget, public WBaseWidget { bool m_bCoverIsHovered; bool m_bCoverIsVisible; - const QString m_sDefaultCover; - QString m_sCurrentCover; - - QImage m_coverArt; + QImage m_defaultCover; + QImage m_currentCover; }; #endif // WCOVERART_H |