UI: Fix source item widget color height

The background color of the source tree item widgets wouldn't be
rendered properly.
This commit is contained in:
cg2121 2022-08-24 12:37:54 -05:00 • committed by Matt Gajownik
commit adba393ca8
7 changed files with 62 additions and 6 deletions

View file

@ -1088,6 +1088,8 @@ SourceTree::SourceTree(QWidget *parent_) : QListView(parent_)
connect(App(), &OBSApp::StyleChanged, this,
&SourceTree::UpdateNoSourcesMessage);
connect(App(), &OBSApp::StyleChanged, this, &SourceTree::UpdateIcons);
setItemDelegate(new SourceTreeDelegate(this));
}
void SourceTree::UpdateIcons()
@ -1743,3 +1745,17 @@ void SourceTree::paintEvent(QPaintEvent *event)
QListView::paintEvent(event);
}
}
SourceTreeDelegate::SourceTreeDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{
}
QSize SourceTreeDelegate::sizeHint(const QStyleOptionViewItem &,
const QModelIndex &index) const
{
SourceTree *tree = qobject_cast<SourceTree *>(parent());
QWidget *item = tree->indexWidget(index);
return (QSize(item->width(), item->height()));
}