download only large covers from google

add cover size tooltip (see issue #1704)
cover search window is now a grid and not a long list with vertical scrollbar
This commit is contained in:
Paweł Bara 2011-04-06 15:24:56 +00:00
parent 41ef30151a
commit 2b22dfaaee
3 changed files with 16 additions and 8 deletions

View File

@ -13,9 +13,11 @@ class GoogleImagesCoversScript(clementine.CoverProvider):
self.api_url = 'https://ajax.googleapis.com/ajax/services/search/images?{0}' self.api_url = 'https://ajax.googleapis.com/ajax/services/search/images?{0}'
self.api_args = { self.api_args = {
'v' : '1.0', 'v' : '1.0',
# at most five results # at most five results
'rsz' : '5' 'rsz' : '5',
# only larger sizes
'imgsz' : 'large|xlarge'
} }
self.network = clementine.NetworkAccessManager(self) self.network = clementine.NetworkAccessManager(self)
self.queries = {} self.queries = {}

View File

@ -81,6 +81,9 @@ void AlbumCoverSearcher::Search() {
ui_->query->setEnabled(false); ui_->query->setEnabled(false);
ui_->covers->setEnabled(false); ui_->covers->setEnabled(false);
ui_->covers->clear();
cover_loading_tasks_.clear();
id_ = fetcher_->SearchForCovers(ui_->query->text()); id_ = fetcher_->SearchForCovers(ui_->query->text());
} }
@ -93,8 +96,6 @@ void AlbumCoverSearcher::SearchFinished(quint64 id, const CoverSearchResults& re
ui_->covers->setEnabled(true); ui_->covers->setEnabled(true);
id_ = 0; id_ = 0;
ui_->covers->clear();
cover_loading_tasks_.clear();
foreach (const CoverSearchResult& result, results) { foreach (const CoverSearchResult& result, results) {
if (result.image_url.isEmpty()) if (result.image_url.isEmpty())
continue; continue;
@ -127,6 +128,8 @@ void AlbumCoverSearcher::ImageLoaded(quint64 id, const QImage& image) {
QListWidgetItem* item = cover_loading_tasks_.take(id); QListWidgetItem* item = cover_loading_tasks_.take(id);
item->setIcon(icon); item->setIcon(icon);
item->setToolTip(item->text() + " (" + QString::number(image.width()) + "x" +
QString::number(image.height()) + ")");
if (cover_loading_tasks_.isEmpty()) if (cover_loading_tasks_.isEmpty())
ui_->busy->hide(); ui_->busy->hide();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>624</width> <width>556</width>
<height>330</height> <height>354</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -47,10 +47,10 @@
</size> </size>
</property> </property>
<property name="movement"> <property name="movement">
<enum>QListView::Static</enum> <enum>QListView::Free</enum>
</property> </property>
<property name="flow"> <property name="flow">
<enum>QListView::TopToBottom</enum> <enum>QListView::LeftToRight</enum>
</property> </property>
<property name="resizeMode"> <property name="resizeMode">
<enum>QListView::Adjust</enum> <enum>QListView::Adjust</enum>
@ -61,6 +61,9 @@
<property name="viewMode"> <property name="viewMode">
<enum>QListView::IconMode</enum> <enum>QListView::IconMode</enum>
</property> </property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>