Fix queued item painting
This commit is contained in:
@@ -98,17 +98,13 @@ void QueuedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||||||
opacity /= kQueueOpacitySteps;
|
opacity /= kQueueOpacitySteps;
|
||||||
opacity *= float(1.0) - float(kQueueOpacityLowerBound);
|
opacity *= float(1.0) - float(kQueueOpacityLowerBound);
|
||||||
opacity += kQueueOpacityLowerBound;
|
opacity += kQueueOpacityLowerBound;
|
||||||
painter->setOpacity(opacity);
|
DrawBox(painter, option.rect, option.font, QString::number(queue_pos + 1), kQueueBoxLength, opacity);
|
||||||
|
|
||||||
DrawBox(painter, option.rect, option.font, QString::number(queue_pos + 1), kQueueBoxLength);
|
|
||||||
|
|
||||||
painter->setOpacity(1.0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
QFont smaller = font;
|
||||||
smaller.setPointSize(smaller.pointSize() - 1);
|
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(0.0, kQueueBoxGradientColor1);
|
||||||
gradient.setColorAt(1.0, kQueueBoxGradientColor2);
|
gradient.setColorAt(1.0, kQueueBoxGradientColor2);
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->setOpacity(opacity);
|
||||||
|
|
||||||
// Turn on antialiasing
|
// Turn on antialiasing
|
||||||
painter->setRenderHint(QPainter::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->drawText(rect, Qt::AlignCenter, text);
|
||||||
painter->translate(-0.5, -0.5);
|
painter->translate(-0.5, -0.5);
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int QueuedItemDelegate::queue_indicator_size(const QModelIndex &idx) const {
|
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);
|
explicit QueuedItemDelegate(QObject *parent, int indicator_column = Playlist::Column_Title);
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
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;
|
int queue_indicator_size(const QModelIndex &idx) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user