Skip to content

Commit

Permalink
Merge remote-tracking branch 'mixxx/2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jan 20, 2024
2 parents 25c5d24 + 923abdf commit e12415a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/library/stardelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void StarDelegate::paintItem(
QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const {
// let the editor do the painting if this cell is currently being edited
// Let the editor do the painting if this cell is currently being edited.
// Note: if required, the focus border will be drawn by the editor.
if (index == m_currentEditedCellIndex) {
return;
}
Expand Down
15 changes: 8 additions & 7 deletions src/library/stareditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ void StarEditor::paintEvent(QPaintEvent*) {
// If the editor cell is selected set the respective flag so we can use the
// palette's 'HighlightedText' font color for the brush StarRating will use
// to fill the star/diamond polygons with.
// Else, unset it and we use the regular color.
QItemSelectionModel* selectionModel = m_pTableView->selectionModel();
if (selectionModel && selectionModel->isSelected(m_index)) {
m_styleOption.state |= QStyle::State_Selected;
} else {
m_styleOption.state &= ~QStyle::State_Selected;
}

QPainter painter(this);
Expand All @@ -62,13 +65,6 @@ void StarEditor::paintEvent(QPaintEvent*) {
style->drawControl(QStyle::CE_ItemViewItem, &m_styleOption, &painter, m_pTableView);
}

// Draw a border if the color cell has focus
if (m_styleOption.state & QStyle::State_Selected) {
// QPainterScope in drawBorder() and shift down?
TableItemDelegate::drawBorder(&painter, m_pFocusBorderColor, m_styleOption.rect);
}

// Starrating scales the painter so do this after painting the border.
// Set the palette appropriately based on whether the row is selected or
// not. We also have to check if it is inactive or not and use the
// appropriate ColorGroup.
Expand All @@ -86,6 +82,11 @@ void StarEditor::paintEvent(QPaintEvent*) {
}

m_starRating.paint(&painter, m_styleOption.rect);

// Draw a border if the color cell is selected
if (m_styleOption.state & QStyle::State_Selected) {
TableItemDelegate::drawBorder(&painter, m_pFocusBorderColor, m_styleOption.rect);
}
}

bool StarEditor::eventFilter(QObject* obj, QEvent* event) {
Expand Down
1 change: 1 addition & 0 deletions src/library/starrating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void StarRating::paint(QPainter* painter, const QRect& rect) const {
PainterScope painterScope(painter);
// Assume the painter is configured with the right brush.
painter->setRenderHint(QPainter::Antialiasing, true);
// Don't draw outlines, only fill the polygons
painter->setPen(Qt::NoPen);

// Center vertically inside the table cell, and also center horizontally
Expand Down
5 changes: 1 addition & 4 deletions src/widget/wstarrating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ void WStarRating::setup(const QDomNode& node, const SkinContext& context) {
}

QSize WStarRating::sizeHint() const {
QStyleOption option;
option.initFrom(this);

// Center rating horizontally
// Center rating horizontally and vertically
m_contentRect.setRect(
(size().width() - m_visualStarRating.sizeHint().width()) / 2,
(size().height() - m_visualStarRating.sizeHint().height()) / 2,
Expand Down

0 comments on commit e12415a

Please sign in to comment.