Scroll the album cover manager view more sensibly

This commit is contained in:
David Sansome 2010-02-28 19:56:18 +00:00
parent 605e3a87cc
commit 16d991b76a
3 changed files with 33 additions and 6 deletions

View File

@ -10,11 +10,14 @@
#include <QListWidget>
#include <QCryptographicHash>
#include <QDir>
#include <QEvent>
#include <QScrollBar>
const char* AlbumCoverManager::kSettingsGroup = "CoverManager";
AlbumCoverManager::AlbumCoverManager(QWidget *parent)
: QDialog(parent),
constructed_(false),
cover_loader_(new BackgroundThread<AlbumCoverLoader>(this)),
cover_fetcher_(new AlbumCoverFetcher(this)),
artist_icon_(":/artist.png"),
@ -70,6 +73,7 @@ AlbumCoverManager::AlbumCoverManager(QWidget *parent)
}
cover_loader_->start();
constructed_ = true;
}
AlbumCoverManager::~AlbumCoverManager() {
@ -237,3 +241,18 @@ void AlbumCoverManager::AlbumCoverFetched(quint64 id, const QImage &image) {
if (cover_fetching_tasks_.isEmpty())
ui_.fetch->setEnabled(true);
}
bool AlbumCoverManager::event(QEvent* e) {
if (constructed_) {
// I think KDE styles override these, and ScrollPerItem really confusing
// when you have huge items.
// We seem to have to reset them to sensible values each time the contents
// of ui_.albums changes.
ui_.albums->setVerticalScrollMode(QListWidget::ScrollPerPixel);
//ui_.albums->verticalScrollBar()->setPageStep(10);
ui_.albums->verticalScrollBar()->setSingleStep(20);
}
QDialog::event(e);
return false;
}

View File

@ -29,6 +29,7 @@ class AlbumCoverManager : public QDialog {
protected:
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *);
bool event(QEvent *);
private slots:
void ArtistChanged(QListWidgetItem* current);
@ -52,6 +53,8 @@ class AlbumCoverManager : public QDialog {
void CancelRequests();
private:
bool constructed_;
Ui::CoverManager ui_;
boost::shared_ptr<LibraryBackend> backend_;

View File

@ -37,7 +37,7 @@
<item>
<widget class="QToolButton" name="clear">
<property name="icon">
<iconset resource="../data/data.qrc">
<iconset>
<normaloff>:/clear.png</normaloff>:/clear.png</iconset>
</property>
<property name="autoRaise">
@ -58,7 +58,7 @@
<string>View</string>
</property>
<property name="icon">
<iconset resource="../data/data.qrc">
<iconset>
<normaloff>:/view-choose.png</normaloff>:/view-choose.png</iconset>
</property>
<property name="popupMode">
@ -78,7 +78,7 @@
<string>Fetch Missing Covers</string>
</property>
<property name="icon">
<iconset resource="../data/data.qrc">
<iconset>
<normaloff>:/download.png</normaloff>:/download.png</iconset>
</property>
</widget>
@ -96,9 +96,6 @@
<height>120</height>
</size>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="flow">
<enum>QListView::LeftToRight</enum>
</property>
@ -135,6 +132,14 @@
<header>lineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>artists</tabstop>
<tabstop>clear</tabstop>
<tabstop>filter</tabstop>
<tabstop>view</tabstop>
<tabstop>fetch</tabstop>
<tabstop>albums</tabstop>
</tabstops>
<resources>
<include location="../data/data.qrc"/>
</resources>