UI: Add source icons

This commit is contained in:
Clayton Groeneveld
2019-11-24 20:50:42 -08:00
committed by jp9000
parent 226f704e90
commit 82ffcdc827
66 changed files with 551 additions and 9 deletions
+30 -3
View File
@@ -57,6 +57,24 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_)
obs_data_release(privData);
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
const char *id = obs_source_get_id(source);
QIcon icon;
if (strcmp(id, "scene") == 0)
icon = main->GetSceneIcon();
else if (strcmp(id, "group") == 0)
icon = main->GetGroupIcon();
else
icon = main->GetSourceIcon(id);
QPixmap pixmap = icon.pixmap(QSize(16, 16));
QLabel *iconLabel = new QLabel();
iconLabel->setPixmap(pixmap);
iconLabel->setFixedSize(16, 16);
iconLabel->setStyleSheet("background: none");
vis = new VisibilityCheckBox();
vis->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
vis->setFixedSize(16, 16);
@@ -80,11 +98,13 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_)
#endif
boxLayout = new QHBoxLayout();
boxLayout->setContentsMargins(1, 1, 1, 1);
boxLayout->setSpacing(1);
boxLayout->setContentsMargins(0, 0, 0, 0);
boxLayout->addWidget(iconLabel);
boxLayout->addSpacing(2);
boxLayout->addWidget(label);
boxLayout->addWidget(vis);
boxLayout->setSpacing(2);
boxLayout->addSpacing(1);
boxLayout->addWidget(lock);
#ifdef __APPLE__
/* Hack: Fixes a bug where scrollbars would be above the lock icon */
@@ -943,6 +963,13 @@ SourceTree::SourceTree(QWidget *parent_) : QListView(parent_)
UpdateNoSourcesMessage();
connect(App(), &OBSApp::StyleChanged, this,
&SourceTree::UpdateNoSourcesMessage);
connect(App(), &OBSApp::StyleChanged, this, &SourceTree::UpdateIcons);
}
void SourceTree::UpdateIcons()
{
SourceTreeModel *stm = GetStm();
stm->SceneChanged();
}
void SourceTree::ResetWidgets()