Add a config item to configure album-view to load all covers immediately.

BUG: 312
This commit is contained in:
craig.p.drummond
2013-10-06 18:37:58 +00:00
parent 042f8f9f79
commit fdb24f8e2d
8 changed files with 80 additions and 1 deletions

View File

@@ -59,6 +59,9 @@
29. Move media-keys setting into shortcuts page.
30. Add a config item to disable all network access. Needs to be set manually,
see README for details.
31. Add a config item to configure album-view to load all covers immediately,
rather than waiting for then to be displayed. Again, no UI for this, and
see README for details.
1.1.3
-----

6
README
View File

@@ -302,6 +302,11 @@ networkAccessEnabled=<Bool - true/false>
Configure whether Cantata should be allowed to make networks requests - for
accessing covers, etc. By default this is set to true.
albumViewLoadAll=<bool - true/false>
If set to true, then when th ealbum view is shown it will request all covers
covers immediately - rather than waiting for the cover to be displayed.
Default is false.
e.g.
[General]
iconTheme=oxygen
@@ -309,6 +314,7 @@ maxCoverFindPerIteration=5
maxCoverUpdatePerIteration=5
cueFileCodecs=GBK, big5-0
networkAccessEnabled=false
albumViewLoadAll=true
7. CUE Files

View File

@@ -34,6 +34,7 @@
AlbumsPage::AlbumsPage(QWidget *p)
: QWidget(p)
, coverLoad(Settings::self()->albumViewLoadAll() ? CL_LoadAll : CL_LoadAsRequired)
{
setupUi(this);
addToPlayQueue->setDefaultAction(StdActions::self()->addToPlayQueueAction);
@@ -67,6 +68,7 @@ AlbumsPage::AlbumsPage(QWidget *p)
view->setModel(&proxy);
connect(MusicLibraryModel::self(), SIGNAL(updateGenres(const QSet<QString> &)), genreCombo, SLOT(update(const QSet<QString> &)));
connect(AlbumsModel::self(), SIGNAL(updated()), this, SLOT(albumsUpdated()));
connect(this, SIGNAL(add(const QStringList &, bool, quint8)), MPDConnection::self(), SLOT(add(const QStringList &, bool, quint8)));
connect(this, SIGNAL(addSongsToPlaylist(const QString &, const QStringList &)), MPDConnection::self(), SLOT(addToPlaylist(const QString &, const QStringList &)));
connect(genreCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(searchItems()));
@@ -87,6 +89,15 @@ void AlbumsPage::setView(int v)
view->setMode((ItemView::Mode)v);
}
void AlbumsPage::showEvent(QShowEvent *e)
{
if (CL_LoadAll==coverLoad) {
AlbumsModel::self()->loadAllCovers();
coverLoad=CL_Loaded;
}
QWidget::showEvent(e);
}
void AlbumsPage::clear()
{
AlbumsModel::self()->clear();
@@ -107,6 +118,20 @@ void AlbumsPage::setItemSize(int v)
}
}
void AlbumsPage::albumsUpdated()
{
if (CL_LoadAsRequired==coverLoad) {
return;
}
if (isVisible()) {
AlbumsModel::self()->loadAllCovers();
coverLoad=CL_Loaded;
} else {
coverLoad=CL_LoadAll;
}
}
QStringList AlbumsPage::selectedFiles(bool allowPlaylists) const
{
QModelIndexList selected = view->selectedIndexes();

View File

@@ -34,6 +34,14 @@ class MusicLibraryItemRoot;
class AlbumsPage : public QWidget, public Ui::AlbumsPage
{
Q_OBJECT
enum CoverLoad
{
CL_LoadAsRequired,
CL_LoadAll,
CL_Loaded
};
public:
AlbumsPage(QWidget *p);
virtual ~AlbumsPage();
@@ -52,6 +60,7 @@ public:
void focusSearch() { view->focusSearch(); }
void goBack() { view->backActivated(); }
void goTop() { view->setLevel(0); }
void showEvent(QShowEvent *e);
private:
void setItemSize(int v);
@@ -69,8 +78,10 @@ public Q_SLOTS:
void controlActions();
void searchItems();
void updateGenres(const QModelIndex &);
void albumsUpdated();
private:
CoverLoad coverLoad;
AlbumsProxyModel proxy;
};

View File

@@ -753,6 +753,11 @@ bool Settings::networkAccessEnabled()
return GET_BOOL("networkAccessEnabled", true);
}
bool Settings::albumViewLoadAll()
{
return GET_BOOL("albumViewLoadAll", false);
}
void Settings::removeConnectionDetails(const QString &v)
{
if (v==currentConnection()) {

View File

@@ -188,6 +188,7 @@ public:
int maxCoverUpdatePerIteration();
QStringList cueFileCodecs();
bool networkAccessEnabled();
bool albumViewLoadAll();
void removeConnectionDetails(const QString &v);
void saveConnectionDetails(const MPDConnectionDetails &v);

View File

@@ -373,6 +373,7 @@ void AlbumsModel::update(const MusicLibraryItemRoot *root)
return;
}
bool changesMade=false;
bool resettingModel=items.isEmpty() || 0==root->childCount();
if (resettingModel) {
beginResetModel();
@@ -422,6 +423,7 @@ void AlbumsModel::update(const MusicLibraryItemRoot *root)
}
if (!found) {
changesMade=true;
AlbumItem *a=new AlbumItem(artist, album, albumItem->year());
a->setSongs(albumItem);
a->genres=albumItem->genres();
@@ -452,6 +454,10 @@ void AlbumsModel::update(const MusicLibraryItemRoot *root)
}
}
}
if (changesMade) {
emit updated();
}
}
void AlbumsModel::setCover(const Song &song, const QImage &img, const QString &file, bool update)
@@ -532,6 +538,25 @@ void AlbumsModel::setAlbumSort(int s)
}
}
void AlbumsModel::loadAllCovers()
{
if (items.isEmpty()) {
return;
}
int iSize=iconSize();
if (!iSize) {
return;
}
foreach (AlbumItem *al, items) {
if (!al->coverRequested && Song::SingleTracks!=al->type) {
al->getCover();
if (!al->cover) {
al->coverRequested=true;
}
}
}
}
AlbumsModel::AlbumItem::AlbumItem(const QString &ar, const QString &al, quint16 y)
: artist(ar)
, album(al)

View File

@@ -124,7 +124,10 @@ public:
void setEnabled(bool e);
int albumSort() const;
void setAlbumSort(int s);
// void getCovers();
void loadAllCovers();
Q_SIGNALS:
void updated();
public Q_SLOTS:
void setCover(const Song &song, const QImage &img, const QString &file, bool update=false);