mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-30 00:55:33 +01:00
Fix queued item painting
This commit is contained in:
parent
460d045cbe
commit
7323fe0000
@ -98,17 +98,13 @@ void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
opacity /= kQueueOpacitySteps;
|
||||
opacity *= float(1.0) - float(kQueueOpacityLowerBound);
|
||||
opacity += kQueueOpacityLowerBound;
|
||||
painter->setOpacity(opacity);
|
||||
|
||||
DrawBox(painter, option.rect, option.font, QString::number(queue_pos + 1), kQueueBoxLength);
|
||||
|
||||
painter->setOpacity(1.0);
|
||||
DrawBox(painter, option.rect, option.font, QString::number(queue_pos + 1), kQueueBoxLength, opacity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &text, int width) const {
|
||||
void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &text, int width, const float opacity) const {
|
||||
|
||||
QFont smaller = font;
|
||||
smaller.setPointSize(smaller.pointSize() - 1);
|
||||
@ -135,6 +131,10 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, cons
|
||||
gradient.setColorAt(0.0, kQueueBoxGradientColor1);
|
||||
gradient.setColorAt(1.0, kQueueBoxGradientColor2);
|
||||
|
||||
painter->save();
|
||||
|
||||
painter->setOpacity(opacity);
|
||||
|
||||
// Turn on antialiasing
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
@ -149,6 +149,8 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect &line_rect, cons
|
||||
painter->drawText(rect, Qt::AlignCenter, text);
|
||||
painter->translate(-0.5, -0.5);
|
||||
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
int QueuedItemDelegate::queue_indicator_size(const QModelIndex &idx) const {
|
||||
|
@ -60,7 +60,7 @@ class QueuedItemDelegate : public QStyledItemDelegate {
|
||||
explicit QueuedItemDelegate(QObject *parent, int indicator_column = Playlist::Column_Title);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &idx, int width = -1) const;
|
||||
void DrawBox(QPainter *painter, const QRect &line_rect, const QFont &font, const QString &idx, int width = -1, const float opacity = 1.0) const;
|
||||
|
||||
int queue_indicator_size(const QModelIndex &idx) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user