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

Cover art support 2 #1

Merged
merged 65 commits into from
Aug 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
584b6bb
Redesign the dlgtrackinfo layout - add placeholder to cover arts
cardinot Jul 4, 2014
4b9ac29
dlgtrackinfo - stretch last column of cuetable
cardinot Jul 4, 2014
c30a63f
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 6, 2014
890969c
Loading cover art in dlgtrackinfo
cardinot Jul 6, 2014
a6b1983
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 7, 2014
b7cd7b9
Loading default cover art in CoverArtCache
cardinot Jul 8, 2014
65bb689
CoverArtCache - removing unused method
cardinot Jul 8, 2014
44171a7
dlgtrackinfo - getting defaultCover pixmap from CoverArtCache
cardinot Jul 8, 2014
d0177e8
dlgtrackinfo - removing stylesheet
cardinot Jul 8, 2014
c6d0c0d
dlgtrackinfo - rescaling cover art
cardinot Jul 8, 2014
124e19c
dlgtrackinfo - drawing cover art in a qgroupbox to avoid resizing the…
cardinot Jul 8, 2014
c2f35f3
dlgtrackinfo.ui - drawing the fields TITLE and ARTIST in different ro…
cardinot Jul 8, 2014
e35eb22
dlgtrackinfo - show cover art in a QPushButton instead of using a QLabel
cardinot Jul 9, 2014
081e9c9
dlgtrackinfo - removing method to rescale covers
cardinot Jul 9, 2014
b7c8f1f
dlgtrackinfo - editing covers - call filebrowser when user click on t…
cardinot Jul 9, 2014
01669f0
Editing covers - add CoverCache::changeCoverArt(trackId, newCoverLoc)
cardinot Jul 9, 2014
184f1b9
dlgtrackinfo - editing covers - associates a popup menu to the cover art
cardinot Jul 10, 2014
0aab53e
implements removeCover action - it disassociates a cover of a track
cardinot Jul 10, 2014
3474ae5
Editing covers - using the current cover dir as the initial filedialo…
cardinot Jul 10, 2014
45bd2e5
dlgtrackinfo - removing txtfilepath
cardinot Jul 10, 2014
e563131
CoverArtCache - Rename method - using extractEmbeddedCover() instead …
cardinot Jul 10, 2014
c29e450
Reloading cover from metadata + question box
cardinot Jul 10, 2014
a7325f4
Add the action "Reload from Metadata" to the popup menu
cardinot Jul 10, 2014
79286e1
dlgtrackinfo.ui - moving ALBUM_ARTIST field to a unique row + increas…
cardinot Jul 11, 2014
05cbb37
dlgtrackinfo.ui - more space for COMPOSER GENRE GROUPING and less for…
cardinot Jul 11, 2014
54e6ac9
dlgtrackinfo.ui - align left
cardinot Jul 11, 2014
1ff4abd
dlgtrackinfo.ui - move COMMENTS to a new tab
cardinot Jul 11, 2014
6f0e8a4
dlgtrackinfo - increase cover_art size
cardinot Jul 11, 2014
358a707
cover_art popomenu - fixing shortcut key
cardinot Jul 11, 2014
92b4099
dlgtrackinfo.ui - using bold words in non-editable fields
cardinot Jul 12, 2014
bca4840
a better word to change cover action - using "change" instead of "edit"
cardinot Jul 12, 2014
9b0119c
a better word to "remove cover" action - using "unset" instead of "re…
cardinot Jul 12, 2014
d0aacc3
dlgtrackinfo.ui - increasing sizeHint height of vertical spacer - all…
cardinot Jul 12, 2014
dd5c132
dlgtrackinfo - change window title, using "Artist - Title" instead of…
cardinot Jul 13, 2014
86b238c
dlgtrackinfo.ui - Drawing all fields with fixed height (25px)
cardinot Jul 13, 2014
5fd9d5f
Unset Cover Action - changing the cover location to default_cover ins…
cardinot Jul 13, 2014
4da8649
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 13, 2014
4d54410
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 14, 2014
b8b9421
Adpting branch to the latest merge - getting pixmap directly from sig…
cardinot Jul 14, 2014
0fa7e29
dlgtrackinfo - removing unused pixmap member
cardinot Jul 14, 2014
21853e3
Rename default cover art - using default_cover.png instead of vinyl-r…
cardinot Jul 14, 2014
eab7b12
Getting default cover location from CoverCache + fixing warning boxes
cardinot Jul 14, 2014
1de44cf
it avoids starting filebrowser in default_cover location (when user w…
cardinot Jul 14, 2014
5b8c8d8
WCoverArt - avoids loading default_cover as real cover
cardinot Jul 14, 2014
e174de5
dlgtrackinfo.ui - using cover placeholder as a qwidget instead of qgr…
cardinot Jul 15, 2014
4d0f385
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 15, 2014
92314a2
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 16, 2014
5549a23
bulding fix - non-defined var
cardinot Jul 17, 2014
be2298f
dlgtrackinfo.ui - fixing window size
cardinot Jul 17, 2014
689eaec
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 17, 2014
79de63e
dlgtrackinfo - popup menu of cover: rename "reload from metadata" to …
cardinot Jul 18, 2014
fe2a796
it dissociates the coverArtReloading process to the button "reload tr…
cardinot Jul 18, 2014
cce6a05
Remove warning boxes
cardinot Jul 18, 2014
fbad034
Rename method - from reloadEmbeddedCover() to slotReloadCover()
cardinot Jul 18, 2014
24b849a
Remove unused member: m_sLoadedMd5Hash
cardinot Jul 18, 2014
3d1930a
Removing unused method CoverArtCache::getHashOfEmbeddedCover()
cardinot Jul 18, 2014
ba16133
Add an icon for each cover action (popup menu)
cardinot Jul 18, 2014
7514f5d
dlgtrackinfo - Updating member "sLoadedCoverLocation" after cover change
cardinot Jul 19, 2014
35f1ddb
dlgtrackinfo - Add button to open the file browser in the tracklocation
cardinot Jul 19, 2014
0be1909
if the cover comes from an external dir, we copy it to the track dire…
cardinot Jul 20, 2014
5a91b8e
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 21, 2014
e899701
redesign dlgtrackinfo.ui - remove excessive group_layouts + loading c…
cardinot Jul 22, 2014
6f187f0
dlgtrackinfo - rescaling covers before insert as an icon of the pushb…
cardinot Jul 22, 2014
fc0bfe1
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Jul 24, 2014
71dfb45
Merge branch 'coverArtSupport' of https://github.com/cardinot/mixxx i…
cardinot Aug 1, 2014
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
Binary file added res/images/library/ic_cover_change.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/images/library/ic_cover_reload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/images/library/ic_cover_unset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion res/mixxx.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<file>images/library/ic_library_cover_hide.png</file>
<file>images/library/ic_library_cover_show.png</file>
<file>images/library/ic_library_zoom_in.png</file>
<file>images/library/vinyl-record.png</file>
<file>images/library/default_cover.png</file>
<file>images/library/ic_cover_change.png</file>
<file>images/library/ic_cover_reload.png</file>
<file>images/library/ic_cover_unset.png</file>
</qresource>
</RCC>
163 changes: 162 additions & 1 deletion src/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// dlgtrackinfo.cpp
// Created 11/10/2009 by RJ Ryan (rryan@mit.edu)

#include <QDesktopServices>
#include <QFileDialog>
#include <QMenu>
#include <QtDebug>

#include "dlgtrackinfo.h"
#include "library/coverartcache.h"
#include "library/dao/cue.h"
#include "trackinfoobject.h"

Expand Down Expand Up @@ -62,10 +66,41 @@ void DlgTrackInfo::init(){
this, SLOT(slotBpmTap()));
connect(btnReloadFromFile, SIGNAL(clicked()),
this, SLOT(reloadTrackMetadata()));
connect(btnOpenFileBrowser, SIGNAL(clicked()),
this, SLOT(slotOpenInFileBrowser()));
m_bpmTapTimer.start();
for (int i = 0; i < kFilterLength; ++i) {
m_bpmTapFilter[i] = 0.0f;
}

connect(CoverArtCache::instance(), SIGNAL(pixmapFound(int, QPixmap)),
this, SLOT(slotPixmapFound(int, QPixmap)), Qt::DirectConnection);

// Cover art actions
// change cover art location
QAction* changeCover = new QAction(
QIcon(":/images/library/ic_cover_change.png"),
tr("&Change"), this);
connect(changeCover, SIGNAL(triggered()),
this, SLOT(slotChangeCoverArt()));
// unset cover art - load default
QAction* unsetCover = new QAction(
QIcon(":/images/library/ic_cover_unset.png"),
tr("&Unset"), this);
connect(unsetCover, SIGNAL(triggered()),
this, SLOT(slotUnsetCoverArt()));
// reload just cover art using the search algorithm (in CoverArtCache)
QAction* reloadCover = new QAction(
QIcon(":/images/library/ic_cover_reload.png"),
tr("&Reload"), this);
connect(reloadCover, SIGNAL(triggered()),
this, SLOT(slotReloadCover()));
// Cover art popup menu
QMenu* coverMenu = new QMenu(this);
coverMenu->addAction(changeCover);
coverMenu->addAction(unsetCover);
coverMenu->addAction(reloadCover);
coverArt->setMenu(coverMenu);
}

void DlgTrackInfo::OK() {
Expand Down Expand Up @@ -119,7 +154,7 @@ void DlgTrackInfo::cueDelete() {
}

void DlgTrackInfo::populateFields(TrackPointer pTrack) {
setWindowTitle(pTrack->getTitle());
setWindowTitle(pTrack->getArtist() % " - " % pTrack->getTitle());

// Editable fields
txtTrackName->setText(pTrack->getTitle());
Expand Down Expand Up @@ -160,6 +195,124 @@ void DlgTrackInfo::loadTrack(TrackPointer pTrack) {

populateFields(m_pLoadedTrack);
populateCues(m_pLoadedTrack);

// Load Default Cover Art
coverArt->setIcon(scaledCoverArt(CoverArtCache::instance()->getDefaultCoverArt()));
m_sLoadedCoverLocation.clear();
}

QPixmap DlgTrackInfo::scaledCoverArt(QPixmap original) {
return original.scaled(110, 110,
Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}

void DlgTrackInfo::slotPixmapFound(int trackId, QPixmap pixmap) {
if (m_pLoadedTrack == NULL)
return;

if (m_pLoadedTrack->getId() == trackId) {
coverArt->setIcon(scaledCoverArt(pixmap));
update();
}
}

void DlgTrackInfo::slotLoadCoverArt(const QString& coverLocation,
const QString& md5Hash,
int trackId) {
m_sLoadedCoverLocation = coverLocation;
CoverArtCache::instance()->requestPixmap(trackId,
m_sLoadedCoverLocation,
md5Hash);
}

void DlgTrackInfo::slotUnsetCoverArt() {
if (m_pLoadedTrack == NULL) {
return;
}
bool res = CoverArtCache::instance()->changeCoverArt(
m_pLoadedTrack->getId(),
CoverArtCache::instance()->getDefaultCoverLocation());
if (!res) {
QMessageBox::warning(this, tr("Unset Cover Art"),
tr("Could not unset the cover art!"));
}
}

void DlgTrackInfo::slotChangeCoverArt() {
if (m_pLoadedTrack == NULL) {
return;
}

// get initial directory (trackdir or coverdir)
QString initialDir;
QString trackPath = m_pLoadedTrack->getDirectory();
if (m_sLoadedCoverLocation.isEmpty() ||
m_sLoadedCoverLocation == CoverArtCache::instance()
->getDefaultCoverLocation()) {
initialDir = trackPath;
} else {
initialDir = m_sLoadedCoverLocation;
}

// open file dialog
QString selectedCover = QFileDialog::getOpenFileName(
this, tr("Change Cover Art"), initialDir,
tr("Image Files (*.png *.jpg *.jpeg *.bmp)"));

if (selectedCover.isEmpty()) {
return;
}

// if the cover comes from an external dir,
// we copy it to the track directory.
QString newCover;
QFileInfo coverInfo(selectedCover);
QString coverPath = coverInfo.absolutePath();
if (trackPath != coverPath) {
QString ext = coverInfo.suffix();
QStringList filepaths;
filepaths << trackPath % "/cover." % ext
<< trackPath % "/album." % ext
<< trackPath % "/mixxx-cover." % ext;

foreach (QString filepath, filepaths) {
if (QFile::copy(selectedCover, filepath)) {
newCover = filepath;
break;
}
}

if (newCover.isEmpty()) {
// overwrites "mixxx-cover"
QFile::remove(filepaths.last());
if (QFile::copy(selectedCover, filepaths.last())) {
newCover = filepaths.last();
}
}
} else {
newCover = selectedCover;
}

bool res = CoverArtCache::instance()->changeCoverArt(
m_pLoadedTrack->getId(), newCover);
if (res) {
m_sLoadedCoverLocation = newCover;
} else {
QMessageBox::warning(this, tr("Change Cover Art"),
tr("Could not change the cover art!"));
}
}

void DlgTrackInfo::slotOpenInFileBrowser() {
if (m_pLoadedTrack == NULL) {
return;
}
QDir directory(m_pLoadedTrack->getDirectory());
if (!directory.exists()) {
directory = QDir::home();
}
QDesktopServices::openUrl(QUrl::fromLocalFile(directory.absolutePath()));
}

void DlgTrackInfo::populateCues(TrackPointer pTrack) {
Expand Down Expand Up @@ -223,6 +376,7 @@ void DlgTrackInfo::populateCues(TrackPointer pTrack) {
row += 1;
}
cueTable->setSortingEnabled(true);
cueTable->horizontalHeader()->setStretchLastSection(true);
}

void DlgTrackInfo::saveTrack() {
Expand Down Expand Up @@ -377,6 +531,13 @@ void DlgTrackInfo::reloadTrackMetadata() {
}
}

void DlgTrackInfo::slotReloadCover() {
if (m_pLoadedTrack) {
m_sLoadedCoverLocation.clear();
CoverArtCache::instance()->requestPixmap(m_pLoadedTrack->getId());
}
}

void DlgTrackInfo::fetchTag() {
m_DlgTagFetcher.init(m_pLoadedTrack);
m_DlgTagFetcher.show();
Expand Down
16 changes: 16 additions & 0 deletions src/dlgtrackinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo {
// Not thread safe. Only invoke via AutoConnection or QueuedConnection, not
// directly!
void loadTrack(TrackPointer pTrack);
void slotLoadCoverArt(const QString& coverLocation,
const QString& md5Hash,
int trackId);

signals:
void next();
Expand All @@ -50,6 +53,12 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo {
void slotBpmTap();

void reloadTrackMetadata();
void slotOpenInFileBrowser();

void slotPixmapFound(int trackId, QPixmap pixmap);
void slotChangeCoverArt();
void slotUnsetCoverArt();
void slotReloadCover();

private:
void populateFields(TrackPointer pTrack);
Expand All @@ -58,16 +67,23 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo {
void unloadTrack(bool save);
void clear();
void init();
QPixmap scaledCoverArt(QPixmap original);

QHash<int, Cue*> m_cueMap;
TrackPointer m_pLoadedTrack;
QString m_sLoadedCoverLocation;

CSAMPLE m_bpmTapFilter[kFilterLength];
QTime m_bpmTapTimer;

QMutex m_mutex;
DlgTagFetcher& m_DlgTagFetcher;

enum reloadCoverCases {
LOAD,
CHANGE,
UNSET
};
};

#endif /* DLGTRACKINFO_H */
Loading