diff --git a/obs/data/locale/en-US.ini b/obs/data/locale/en-US.ini
index 48e6bc44c..6d5b48380 100644
--- a/obs/data/locale/en-US.ini
+++ b/obs/data/locale/en-US.ini
@@ -102,6 +102,9 @@ Basic.AuxDevice4="Mic/Aux 4"
Basic.Scene="Scene"
Basic.DisplayCapture="Display Capture"
+# display context menu
+Basic.Main.PreviewConextMenu.Enable="Enable Preview"
+
# add scene dialog
Basic.Main.AddSceneDlg.Title="Add Scene"
Basic.Main.AddSceneDlg.Text="Please enter the name of the scene"
@@ -109,6 +112,9 @@ Basic.Main.AddSceneDlg.Text="Please enter the name of the scene"
# add scene suggested name
Basic.Main.DefaultSceneName.Text="Scene %1"
+# preview window disabled
+Basic.Main.PreviewDisabled="Preview is currently disabled"
+
# add source dialog
Basic.SourceSelect="Create/Select Source"
Basic.SourceSelect.CreateNew="Create new"
diff --git a/obs/forms/OBSBasic.ui b/obs/forms/OBSBasic.ui
index 52d520432..7c4f2ba55 100644
--- a/obs/forms/OBSBasic.ui
+++ b/obs/forms/OBSBasic.ui
@@ -52,9 +52,31 @@
Qt::ClickFocus
+
+ Qt::CustomContextMenu
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::CustomContextMenu
+
+
+ Basic.Main.PreviewDisabled
+
+
+ Qt::AlignCenter
+
+
+
-
diff --git a/obs/obs-app.cpp b/obs/obs-app.cpp
index d75aa3796..3378a3498 100644
--- a/obs/obs-app.cpp
+++ b/obs/obs-app.cpp
@@ -113,6 +113,8 @@ bool OBSApp::InitGlobalConfigDefaults()
config_set_default_string(globalConfig, "Video", "Renderer", "OpenGL");
#endif
+ config_set_default_bool(globalConfig, "BasicWindow", "PreviewEnabled",
+ true);
return true;
}
diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp
index 8d21769d7..02c08f903 100644
--- a/obs/window-basic-main.cpp
+++ b/obs/window-basic-main.cpp
@@ -83,6 +83,8 @@ OBSBasic::OBSBasic(QWidget *parent)
ui (new Ui::OBSBasic)
{
ui->setupUi(this);
+ ui->previewDisabledLabel->setVisible(false);
+
copyActionsDynamicProperties();
ui->sources->setItemDelegate(new VisibilityItemDelegate(ui->sources));
@@ -652,10 +654,18 @@ void OBSBasic::OBSInit()
saveTimer = new QTimer(this);
connect(saveTimer, SIGNAL(timeout()), this, SLOT(SaveProject()));
saveTimer->start(20000);
+
+ bool previewEnabled = config_get_bool(App()->GlobalConfig(),
+ "BasicWindow", "PreviewEnabled");
+ if (!previewEnabled)
+ QMetaObject::invokeMethod(this, "TogglePreview",
+ Qt::QueuedConnection);
}
OBSBasic::~OBSBasic()
{
+ bool previewEnabled = obs_preview_enabled();
+
/* XXX: any obs data must be released before calling obs_shutdown.
* currently, we can't automate this with C++ RAII because of the
* delicate nature of obs_shutdown needing to be freed before the UI
@@ -711,6 +721,8 @@ OBSBasic::~OBSBasic()
lastGeom.x());
config_set_int(App()->GlobalConfig(), "BasicWindow", "posy",
lastGeom.y());
+ config_set_bool(App()->GlobalConfig(), "BasicWindow", "PreviewEnabled",
+ previewEnabled);
config_save(App()->GlobalConfig());
}
@@ -1949,11 +1961,20 @@ void OBSBasic::EditSceneItemName()
item->setFlags(flags);
}
-void OBSBasic::on_sources_customContextMenuRequested(const QPoint &pos)
+void OBSBasic::CreateSourcePopupMenu(QListWidgetItem *item, bool preview)
{
- QListWidgetItem *item = ui->sources->itemAt(pos);
-
QMenu popup(this);
+
+ if (preview) {
+ QAction *action = popup.addAction(
+ QTStr("Basic.Main.PreviewConextMenu.Enable"),
+ this, SLOT(TogglePreview()));
+ action->setCheckable(true);
+ action->setChecked(obs_preview_enabled());
+
+ popup.addSeparator();
+ }
+
QPointer addSourceMenu = CreateAddSourcePopupMenu();
if (addSourceMenu)
popup.addMenu(addSourceMenu);
@@ -1991,6 +2012,11 @@ void OBSBasic::on_sources_customContextMenuRequested(const QPoint &pos)
popup.exec(QCursor::pos());
}
+void OBSBasic::on_sources_customContextMenuRequested(const QPoint &pos)
+{
+ CreateSourcePopupMenu(ui->sources->itemAt(pos), false);
+}
+
void OBSBasic::on_sources_itemDoubleClicked(QListWidgetItem *witem)
{
if (!witem)
@@ -2445,6 +2471,29 @@ void OBSBasic::on_settingsButton_clicked()
settings.exec();
}
+void OBSBasic::on_preview_customContextMenuRequested(const QPoint &pos)
+{
+ CreateSourcePopupMenu(ui->sources->currentItem(), true);
+
+ UNUSED_PARAMETER(pos);
+}
+
+void OBSBasic::on_previewDisabledLabel_customContextMenuRequested(
+ const QPoint &pos)
+{
+ QMenu popup(this);
+
+ QAction *action = popup.addAction(
+ QTStr("Basic.Main.PreviewConextMenu.Enable"),
+ this, SLOT(TogglePreview()));
+ action->setCheckable(true);
+ action->setChecked(obs_preview_enabled());
+
+ popup.exec(QCursor::pos());
+
+ UNUSED_PARAMETER(pos);
+}
+
void OBSBasic::GetFPSCommon(uint32_t &num, uint32_t &den) const
{
const char *val = config_get_string(basicConfig, "Video", "FPSCommon");
@@ -2743,3 +2792,11 @@ void OBSBasic::on_actionCenterToScreen_triggered()
obs_scene_enum_items(GetCurrentScene(), func, nullptr);
}
+
+void OBSBasic::TogglePreview()
+{
+ bool enabled = !obs_preview_enabled();
+ obs_preview_set_enabled(enabled);
+ ui->preview->setVisible(enabled);
+ ui->previewDisabledLabel->setVisible(!enabled);
+}
diff --git a/obs/window-basic-main.hpp b/obs/window-basic-main.hpp
index 539f4abf7..27c01ae66 100644
--- a/obs/window-basic-main.hpp
+++ b/obs/window-basic-main.hpp
@@ -225,6 +225,8 @@ public:
void ReorderSceneItem(obs_sceneitem_t *item, size_t idx);
+ void CreateSourcePopupMenu(QListWidgetItem *item, bool preview);
+
protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual void changeEvent(QEvent *event) override;
@@ -286,6 +288,10 @@ private slots:
void on_recordButton_clicked();
void on_settingsButton_clicked();
+ void on_preview_customContextMenuRequested(const QPoint &pos);
+ void on_previewDisabledLabel_customContextMenuRequested(
+ const QPoint &pos);
+
void logUploadFinished();
void updateFileFinished();
@@ -303,6 +309,8 @@ private slots:
void OpenSceneFilters();
void OpenFilters();
+ void TogglePreview();
+
public:
explicit OBSBasic(QWidget *parent = 0);
virtual ~OBSBasic();