Skip to content

Commit

Permalink
UI: Fix source item widget color height
Browse files Browse the repository at this point in the history
The background color of the source tree item widgets wouldn't be
rendered properly.
  • Loading branch information
cg2121 authored and WizardCM committed Aug 27, 2022
1 parent a4f4865 commit adba393
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
8 changes: 7 additions & 1 deletion UI/data/themes/Acri.qss
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,17 @@ SourceTree {
padding: 3px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item {
padding: 6px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item,
SourceTree::item {
border-radius: 4px;
padding: 6px;
color: palette(text);
border: 0px solid transparent;
}
Expand Down
8 changes: 7 additions & 1 deletion UI/data/themes/Grey.qss
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,17 @@ SourceTree {
padding: 3px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item {
padding: 6px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item,
SourceTree::item {
border-radius: 4px;
padding: 6px;
color: palette(text);
border: 0px solid transparent;
}
Expand Down
8 changes: 7 additions & 1 deletion UI/data/themes/Light.qss
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,17 @@ SourceTree {
padding: 3px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item {
padding: 6px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item,
SourceTree::item {
border-radius: 4px;
padding: 6px;
color: palette(text);
border: 0px solid transparent;
}
Expand Down
8 changes: 7 additions & 1 deletion UI/data/themes/Rachni.qss
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,17 @@ SourceTree {
padding: 3px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item {
padding: 6px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item,
SourceTree::item {
border-radius: 4px;
padding: 6px;
color: palette(text);
border: 0px solid transparent;
}
Expand Down
8 changes: 7 additions & 1 deletion UI/data/themes/Yami.qss
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,17 @@ SourceTree {
padding: 3px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item {
padding: 6px;
}

SourceTreeItem,
QMenu::item,
SceneTree::item,
SourceTree::item {
border-radius: 4px;
padding: 6px;
color: palette(text);
border: 0px solid transparent;
}
Expand Down
16 changes: 16 additions & 0 deletions UI/source-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()));
}
12 changes: 11 additions & 1 deletion UI/source-tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QStaticText>
#include <QSvgRenderer>
#include <QAbstractListModel>
#include <QStyledItemDelegate>
#include <obs.hpp>
#include <obs-frontend-api.h>

Expand All @@ -25,7 +26,7 @@ class SourceTreeSubItemCheckBox : public QCheckBox {
Q_OBJECT
};

class SourceTreeItem : public QWidget {
class SourceTreeItem : public QFrame {
Q_OBJECT

friend class SourceTree;
Expand Down Expand Up @@ -218,3 +219,12 @@ public slots:
selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) override;
};

class SourceTreeDelegate : public QStyledItemDelegate {
Q_OBJECT

public:
SourceTreeDelegate(QObject *parent);
virtual QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
};

0 comments on commit adba393

Please sign in to comment.