mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-15 07:44:10 +00:00
UI: Add context menu to preview
Includes the ability to disable the preview and general source context menu options (add/remove/filters/properties/etc)
This commit is contained in:
parent
1cfe72664a
commit
167df61d03
|
@ -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"
|
||||
|
|
|
@ -52,9 +52,31 @@
|
|||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<addaction name="actionRemoveSource"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="previewDisabledLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Basic.Main.PreviewDisabled</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
||||
<widget class="QWidget" name="controlsContainer" native="true">
|
||||
<property name="sizePolicy">
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<QMenu> 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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue