Enforce a minimum row size in the playlist, and stop the current track highlight bar from becoming really pale when on an "alternate" row.

This commit is contained in:
David Sansome 2010-04-12 18:07:07 +00:00
parent 00b19ae83e
commit d54c8cf2f9
3 changed files with 15 additions and 2 deletions

View File

@ -21,6 +21,8 @@
#include <QLineEdit>
#include <QPainter>
const int PlaylistDelegateBase::kMinHeight = 19;
PlaylistDelegateBase::PlaylistDelegateBase(QTreeView* view)
: QStyledItemDelegate(view),
view_(view)
@ -48,6 +50,13 @@ QString PlaylistDelegateBase::displayText(const QVariant& value, const QLocale&)
}
}
QSize PlaylistDelegateBase::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
QSize size = QStyledItemDelegate::sizeHint(option, index);
if (size.height() < kMinHeight)
size.setHeight(kMinHeight);
return size;
}
void PlaylistDelegateBase::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
QStyledItemDelegate::paint(painter, Adjusted(option, index), index);

View File

@ -31,9 +31,12 @@ class PlaylistDelegateBase : public QStyledItemDelegate {
PlaylistDelegateBase(QTreeView* view);
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
QString displayText(const QVariant& value, const QLocale& locale) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
QStyleOptionViewItemV4 Adjusted(const QStyleOptionViewItem& option, const QModelIndex& index) const;
static const int kMinHeight;
protected:
QTreeView* view_;
};

View File

@ -123,8 +123,8 @@ QList<QPixmap> PlaylistView::LoadBarPixmap(const QString& filename) {
// Colour the bar with the palette colour
QPainter p(&image);
p.setCompositionMode(QPainter::CompositionMode_SourceAtop);
p.setOpacity(0.4);
p.fillRect(image.rect(), palette().color(QPalette::Highlight).lighter(125));
p.setOpacity(0.7);
p.fillRect(image.rect(), palette().color(QPalette::Highlight));
p.end();
// Animation steps
@ -186,6 +186,7 @@ void PlaylistView::drawRow(QPainter* painter, const QStyleOptionViewItem& option
opt.palette.setColor(QPalette::Text, Qt::white);
opt.palette.setColor(QPalette::HighlightedText, Qt::white);
opt.palette.setColor(QPalette::Highlight, Qt::transparent);
opt.palette.setColor(QPalette::AlternateBase, Qt::transparent);
opt.font.setItalic(true);
opt.decorationSize = QSize(20,20);
}