UI: Add visibility checkbox to main sources list

Adds a visibility checkbox to the main sources list so that users can
temporarily disable/re-enable sources.  Only applies to scene items, not
the sources themselves.
master
jp9000 2015-03-22 20:51:21 -07:00
parent 86ed7f12f3
commit 3c5cc5cd54
1 changed files with 18 additions and 3 deletions

View File

@ -33,6 +33,7 @@
#include "obs-app.hpp" #include "obs-app.hpp"
#include "platform.hpp" #include "platform.hpp"
#include "visibility-item-widget.hpp"
#include "window-basic-settings.hpp" #include "window-basic-settings.hpp"
#include "window-namedialog.hpp" #include "window-namedialog.hpp"
#include "window-basic-source-select.hpp" #include "window-basic-source-select.hpp"
@ -84,6 +85,8 @@ OBSBasic::OBSBasic(QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
copyActionsDynamicProperties(); copyActionsDynamicProperties();
ui->sources->setItemDelegate(new VisibilityItemDelegate(ui->sources));
int width = config_get_int(App()->GlobalConfig(), "MainWindow", "cx"); int width = config_get_int(App()->GlobalConfig(), "MainWindow", "cx");
// Check if no values are saved (new installation). // Check if no values are saved (new installation).
@ -763,15 +766,16 @@ void OBSBasic::UpdateSources(OBSScene scene)
void OBSBasic::InsertSceneItem(obs_sceneitem_t *item) void OBSBasic::InsertSceneItem(obs_sceneitem_t *item)
{ {
obs_source_t *source = obs_sceneitem_get_source(item); obs_source_t *source = obs_sceneitem_get_source(item);
const char *name = obs_source_get_name(source);
QListWidgetItem *listItem = new QListWidgetItem(QT_UTF8(name)); QListWidgetItem *listItem = new QListWidgetItem();
listItem->setData(Qt::UserRole, listItem->setData(Qt::UserRole,
QVariant::fromValue(OBSSceneItem(item))); QVariant::fromValue(OBSSceneItem(item)));
ui->sources->insertItem(0, listItem); ui->sources->insertItem(0, listItem);
ui->sources->setCurrentRow(0); ui->sources->setCurrentRow(0);
SetupVisibilityItem(ui->sources, listItem, item);
/* if the source was just created, open properties dialog */ /* if the source was just created, open properties dialog */
if (sourceSceneRefs[source] == 0 && loaded) if (sourceSceneRefs[source] == 0 && loaded)
CreatePropertiesWindow(source); CreatePropertiesWindow(source);
@ -919,7 +923,6 @@ static void RenameListValues(QListWidget *listWidget, const QString &newName,
void OBSBasic::RenameSources(QString newName, QString prevName) void OBSBasic::RenameSources(QString newName, QString prevName)
{ {
RenameListValues(ui->scenes, newName, prevName); RenameListValues(ui->scenes, newName, prevName);
RenameListValues(ui->sources, newName, prevName);
for (size_t i = 0; i < volumes.size(); i++) { for (size_t i = 0; i < volumes.size(); i++) {
if (volumes[i]->GetName().compare(prevName) == 0) if (volumes[i]->GetName().compare(prevName) == 0)
@ -1185,6 +1188,9 @@ void OBSBasic::ReorderSceneItem(obs_sceneitem_t *item, size_t idx)
if (listItem) { if (listItem) {
ui->sources->insertItem(idx_inv, ui->sources->insertItem(idx_inv,
listItem); listItem);
SetupVisibilityItem(ui->sources,
listItem, item);
if (sel) if (sel)
ui->sources->setCurrentRow( ui->sources->setCurrentRow(
idx_inv); idx_inv);
@ -1934,8 +1940,13 @@ void OBSBasic::EditSceneItemName()
{ {
QListWidgetItem *item = ui->sources->currentItem(); QListWidgetItem *item = ui->sources->currentItem();
Qt::ItemFlags flags = item->flags(); Qt::ItemFlags flags = item->flags();
OBSSceneItem sceneItem= item->data(Qt::UserRole).value<OBSSceneItem>();
obs_source_t *source = obs_sceneitem_get_source(sceneItem);
const char *name = obs_source_get_name(source);
item->setText(QT_UTF8(name));
item->setFlags(flags | Qt::ItemIsEditable); item->setFlags(flags | Qt::ItemIsEditable);
ui->sources->removeItemWidget(item);
ui->sources->editItem(item); ui->sources->editItem(item);
item->setFlags(flags); item->setFlags(flags);
} }
@ -2320,6 +2331,10 @@ void OBSBasic::SceneItemNameEdited(QWidget *editor,
obs_source_t *source = obs_sceneitem_get_source(item); obs_source_t *source = obs_sceneitem_get_source(item);
RenameListItem(this, ui->sources, source, text); RenameListItem(this, ui->sources, source, text);
QListWidgetItem *listItem = ui->sources->currentItem();
listItem->setText(QString());
SetupVisibilityItem(ui->sources, listItem, item);
UNUSED_PARAMETER(endHint); UNUSED_PARAMETER(endHint);
} }