UI: Add transition on double-click studio mode option

This adds the ability to switch to a scene by double-clicking it when in
studio mode.

(Edit by Jim: In case this change is undesired by the user, this has
been changed to be an option in general settings; disabled by default)

Closes jp9000/obs-studio#1029
master
cg2121 2017-09-21 15:37:01 -05:00 committed by jp9000
parent 79c0f0105c
commit 3a43a047d4
6 changed files with 96 additions and 25 deletions

View File

@ -555,6 +555,7 @@ Basic.Settings.General.SysTray="System Tray"
Basic.Settings.General.SysTrayWhenStarted="Minimize to system tray when started"
Basic.Settings.General.SystemTrayHideMinimize="Always minimize to system tray instead of task bar"
Basic.Settings.General.SaveProjectors="Save projectors on exit"
Basic.Settings.General.SwitchOnDoubleClick="Transition to scene when double-clicked"
# basic mode 'stream' settings
Basic.Settings.Stream="Stream"

View File

@ -145,8 +145,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>818</width>
<height>697</height>
<width>801</width>
<height>698</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
@ -540,6 +540,41 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Basic.TogglePreviewProgramMode</string>
</property>
<layout class="QFormLayout" name="formLayout_31">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="topMargin">
<number>2</number>
</property>
<item row="0" column="1">
<widget class="QCheckBox" name="doubleClickSwitch">
<property name="text">
<string>Basic.Settings.General.SwitchOnDoubleClick</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>170</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@ -675,8 +710,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>818</width>
<height>697</height>
<width>601</width>
<height>640</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -3314,8 +3349,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>69</height>
<width>80</width>
<height>16</height>
</rect>
</property>
</widget>
@ -3651,8 +3686,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>818</width>
<height>697</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QFormLayout" name="hotkeyLayout">
@ -3697,8 +3732,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-62</y>
<width>803</width>
<y>0</y>
<width>593</width>
<height>761</height>
</rect>
</property>

View File

@ -220,10 +220,10 @@ obs_source_t *OBSBasic::FindTransition(const char *name)
return nullptr;
}
void OBSBasic::TransitionToScene(OBSScene scene, bool force)
void OBSBasic::TransitionToScene(OBSScene scene, bool force, bool direct)
{
obs_source_t *source = obs_scene_get_source(scene);
TransitionToScene(source, force);
TransitionToScene(source, force, direct);
}
void OBSBasic::TransitionStopped()
@ -242,7 +242,7 @@ void OBSBasic::TransitionStopped()
swapScene = nullptr;
}
void OBSBasic::TransitionToScene(OBSSource source, bool force)
void OBSBasic::TransitionToScene(OBSSource source, bool force, bool direct)
{
obs_scene_t *scene = obs_scene_from_source(source);
bool usingPreviewProgram = IsPreviewProgramMode();
@ -251,7 +251,7 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force)
OBSWeakSource lastProgramScene;
if (usingPreviewProgram) {
if (usingPreviewProgram && !direct) {
lastProgramScene = programScene;
programScene = OBSGetWeakRef(source);
@ -266,7 +266,7 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force)
}
}
if (usingPreviewProgram && sceneDuplicationMode) {
if (usingPreviewProgram && sceneDuplicationMode && !direct) {
scene = obs_scene_duplicate(scene, NULL,
editPropertiesMode ?
OBS_SCENE_DUP_PRIVATE_COPY :
@ -285,7 +285,7 @@ void OBSBasic::TransitionToScene(OBSSource source, bool force)
ui->transitionDuration->value(), source);
}
if (usingPreviewProgram && sceneDuplicationMode)
if (usingPreviewProgram && sceneDuplicationMode && !direct)
obs_scene_release(scene);
obs_source_release(transition);
@ -544,10 +544,10 @@ int OBSBasic::GetQuickTransitionIdx(int id)
return -1;
}
void OBSBasic::SetCurrentScene(obs_scene_t *scene, bool force)
void OBSBasic::SetCurrentScene(obs_scene_t *scene, bool force, bool direct)
{
obs_source_t *source = obs_scene_get_source(scene);
SetCurrentScene(source, force);
SetCurrentScene(source, force, direct);
}
template <typename T>
@ -556,10 +556,13 @@ static T GetOBSRef(QListWidgetItem *item)
return item->data(static_cast<int>(QtDataRole::OBSRef)).value<T>();
}
void OBSBasic::SetCurrentScene(OBSSource scene, bool force)
void OBSBasic::SetCurrentScene(OBSSource scene, bool force, bool direct)
{
if (!IsPreviewProgramMode()) {
TransitionToScene(scene, force);
if (!IsPreviewProgramMode() && !direct) {
TransitionToScene(scene, force, false);
} else if (IsPreviewProgramMode() && direct) {
TransitionToScene(scene, force, true);
} else {
OBSSource actualLastScene = OBSGetStrongRef(lastScene);

View File

@ -3794,6 +3794,24 @@ void OBSBasic::on_sources_itemDoubleClicked(QListWidgetItem *witem)
CreatePropertiesWindow(source);
}
void OBSBasic::on_scenes_itemDoubleClicked(QListWidgetItem *witem)
{
if (!witem)
return;
if (IsPreviewProgramMode()) {
bool doubleClickSwitch = config_get_bool(App()->GlobalConfig(),
"BasicWindow", "TransitionOnDoubleClick");
if (doubleClickSwitch) {
OBSScene scene = GetCurrentScene();
if (scene)
SetCurrentScene(scene, false, true);
}
}
}
void OBSBasic::AddSource(const char *id)
{
if (id && *id) {

View File

@ -299,7 +299,8 @@ private:
void SetPreviewProgramMode(bool enabled);
void ResizeProgram(uint32_t cx, uint32_t cy);
void SetCurrentScene(obs_scene_t *scene, bool force = false);
void SetCurrentScene(obs_scene_t *scene, bool force = false,
bool direct = false);
static void RenderProgram(void *data, uint32_t cx, uint32_t cy);
std::vector<QuickTransition> quickTransitions;
@ -388,9 +389,12 @@ public slots:
void SaveProject();
void SetTransition(OBSSource transition);
void TransitionToScene(OBSScene scene, bool force = false);
void TransitionToScene(OBSSource scene, bool force = false);
void SetCurrentScene(OBSSource scene, bool force = false);
void TransitionToScene(OBSScene scene, bool force = false,
bool direct = false);
void TransitionToScene(OBSSource scene, bool force = false,
bool direct = false);
void SetCurrentScene(OBSSource scene, bool force = false,
bool direct = false);
private slots:
void AddSceneItem(OBSSceneItem item);
@ -578,6 +582,7 @@ private slots:
void on_sources_itemSelectionChanged();
void on_sources_customContextMenuRequested(const QPoint &pos);
void on_sources_itemDoubleClicked(QListWidgetItem *item);
void on_scenes_itemDoubleClicked(QListWidgetItem *item);
void on_actionAddSource_triggered();
void on_actionRemoveSource_triggered();
void on_actionInteract_triggered();

View File

@ -315,6 +315,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->centerSnapping, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->sourceSnapping, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->snapDistance, DSCROLL_CHANGED,GENERAL_CHANGED);
HookWidget(ui->doubleClickSwitch, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->outputMode, COMBO_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->streamType, COMBO_CHANGED, STREAM1_CHANGED);
HookWidget(ui->simpleOutputPath, EDIT_CHANGED, OUTPUTS_CHANGED);
@ -1077,6 +1078,10 @@ void OBSBasicSettings::LoadGeneralSettings()
"BasicWindow", "ProjectorAlwaysOnTop");
ui->projectorAlwaysOnTop->setChecked(projectorAlwaysOnTop);
bool doubleClickSwitch = config_get_bool(GetGlobalConfig(),
"BasicWindow", "TransitionOnDoubleClick");
ui->doubleClickSwitch->setChecked(doubleClickSwitch);
loading = false;
}
@ -2582,6 +2587,10 @@ void OBSBasicSettings::SaveGeneralSettings()
config_set_double(GetGlobalConfig(), "BasicWindow",
"SnapDistance",
ui->snapDistance->value());
if (WidgetChanged(ui->doubleClickSwitch))
config_set_bool(GetGlobalConfig(), "BasicWindow",
"TransitionOnDoubleClick",
ui->doubleClickSwitch->isChecked());
config_set_bool(GetGlobalConfig(), "BasicWindow",
"WarnBeforeStartingStream",