Skip to content

Commit

Permalink
Execute expensive setStleSheet only, if textcolor of BPM checkbox(pad…
Browse files Browse the repository at this point in the history
…lock) changed
  • Loading branch information
JoergAtGithub committed Jun 10, 2024
1 parent 6d12418 commit 623a704
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/library/tabledelegates/bpmdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ BPMDelegate::BPMDelegate(QTableView* pTableView)
#else
m_pFactory->registerEditor(QVariant::Double, new BpmEditorCreator());
#endif
m_cachedTextColor = QColor();
setItemEditorFactory(m_pFactory);
}

Expand Down Expand Up @@ -108,7 +109,9 @@ void BPMDelegate::paintItem(QPainter* painter,const QStyleOptionViewItem &option
textColor = option.palette.color(QPalette::Normal, QPalette::Text);
}
}
if (textColor.isValid()) {

if (textColor.isValid() && textColor != m_cachedTextColor) {
m_cachedTextColor = textColor;
m_pCheckBox->setStyleSheet(QStringLiteral(
"#LibraryBPMButton::item { color: %1; }")
.arg(textColor.name(QColor::HexRgb)));
Expand Down
1 change: 1 addition & 0 deletions src/library/tabledelegates/bpmdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ class BPMDelegate : public TableItemDelegate {
private:
QCheckBox* m_pCheckBox;
QItemEditorFactory* m_pFactory;
mutable QColor m_cachedTextColor;
};

0 comments on commit 623a704

Please sign in to comment.