Skip to content

Commit

Permalink
UI: Reorganize Preview/Source context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Warchamp7 committed Feb 6, 2025
1 parent c2b4823 commit 6b91888
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 117 deletions.
30 changes: 15 additions & 15 deletions frontend/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ Browse="Browse"
Mono="Mono"
Stereo="Stereo"
DroppedFrames="Dropped Frames %1 (%2%)"
StudioProgramProjector="Fullscreen Projector (Program)"
PreviewProjector="Fullscreen Projector (Preview)"
SceneProjector="Fullscreen Projector (Scene)"
SourceProjector="Fullscreen Projector (Source)"
StudioProgramWindow="Windowed Projector (Program)"
PreviewWindow="Windowed Projector (Preview)"
SceneWindow="Windowed Projector (Scene)"
SourceWindow="Windowed Projector (Source)"
MultiviewProjector="Multiview (Fullscreen)"
MultiviewWindowed="Multiview (Windowed)"
ResizeProjectorWindowToContent="Fit window to content"
Projector.Open.Program="Open Program Projector"
Projector.Open.Preview="Open Preview Projector"
Projector.Open.Scene="Open Scene Projector"
Projector.Open.Source="Open Source Projector"
Projector.Open.Multiview="Open Multiview"
Projector.Display="Display: %1"
Projector.Window="New window"
Projector.Title="Projector"
Projector.Title.Scene="Scene: %1"
Projector.Title.Source="Source: %1"
Projector.ResizeWindowToContent="Fit window to content"
Clear="Clear"
Revert="Revert"
Show="Show"
Expand Down Expand Up @@ -1132,10 +1132,10 @@ Basic.Settings.Output.SplitFile.Size="Split Size"
# Screenshot
Screenshot="Screenshot Output"
Screenshot.SourceHotkey="Screenshot Selected Source"
Screenshot.StudioProgram="Screenshot (Program)"
Screenshot.Preview="Screenshot (Preview)"
Screenshot.Scene="Screenshot (Scene)"
Screenshot.Source="Screenshot (Source)"
Screenshot.StudioProgram="Save Program Screenshot"
Screenshot.Preview="Save Preview Screenshot"
Screenshot.Scene="Save Scene Screenshot"
Screenshot.Source="Save Source Screenshot"

# basic mode 'output' settings - advanced section - recording subsection - completer
FilenameFormatting.completer="%CCYY-%MM-%DD %hh-%mm-%ss\n%YY-%MM-%DD %hh-%mm-%ss\n%Y-%m-%d %H-%M-%S\n%y-%m-%d %H-%M-%S\n%a %Y-%m-%d %H-%M-%S\n%A %Y-%m-%d %H-%M-%S\n%Y-%b-%d %H-%M-%S\n%Y-%B-%d %H-%M-%S\n%Y-%m-%d %I-%M-%S-%p\n%Y-%m-%d %H-%M-%S-%z\n%Y-%m-%d %H-%M-%S-%Z\n%FPS\n%CRES\n%ORES\n%VF"
Expand Down
8 changes: 1 addition & 7 deletions frontend/forms/OBSBasic.ui
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
</widget>
<widget class="QMenu" name="multiviewProjectorMenu">
<property name="title">
<string>MultiviewProjector</string>
<string>Projector.Open.Multiview</string>
</property>
</widget>
<action name="resetUI">
Expand Down Expand Up @@ -815,7 +815,6 @@
<addaction name="stats"/>
<addaction name="separator"/>
<addaction name="multiviewProjectorMenu"/>
<addaction name="multiviewProjectorWindowed"/>
<addaction name="separator"/>
<addaction name="actionAlwaysOnTop"/>
</widget>
Expand Down Expand Up @@ -2047,11 +2046,6 @@
<string>Basic.Stats</string>
</property>
</action>
<action name="multiviewProjectorWindowed">
<property name="text">
<string>MultiviewWindowed</string>
</property>
</action>
<action name="resetDocks">
<property name="text">
<string>Basic.MainMenu.Docks.ResetDocks</string>
Expand Down
181 changes: 109 additions & 72 deletions frontend/widgets/OBSBasic_SceneItems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void OBSBasic::RenameSources(OBSSource source, QString newName, QString prevName
{
RenameListValues(ui->scenes, newName, prevName);


if (vcamConfig.type == VCamOutputType::SourceOutput && prevName == QString::fromStdString(vcamConfig.source))
vcamConfig.source = newName.toStdString();
if (vcamConfig.type == VCamOutputType::SceneOutput && prevName == QString::fromStdString(vcamConfig.scene))
Expand Down Expand Up @@ -573,6 +574,32 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview)
delete colorSelect;
delete deinterlaceMenu;

OBSSceneItem sceneItem;
obs_source_t *source;
uint32_t flags;
bool isAsyncVideo = false;
bool hasAudio = false;
bool hasVideo = false;

bool sourceSelected = idx != -1;

if (sourceSelected) {
sceneItem = ui->sources->Get(idx);
source = obs_sceneitem_get_source(sceneItem);
flags = obs_source_get_output_flags(source);
isAsyncVideo = (flags & OBS_SOURCE_ASYNC_VIDEO) == OBS_SOURCE_ASYNC_VIDEO;
hasAudio = (flags & OBS_SOURCE_AUDIO) == OBS_SOURCE_AUDIO;
hasVideo = (flags & OBS_SOURCE_VIDEO) == OBS_SOURCE_VIDEO;
}

// Add new source
QPointer<QMenu> addSourceMenu = CreateAddSourcePopupMenu();
if (addSourceMenu) {
popup.addMenu(addSourceMenu);
popup.addSeparator();
}

// Preview menu entries
if (preview) {
QAction *action =
popup.addAction(QTStr("Basic.Main.PreviewConextMenu.Enable"), this, &OBSBasic::TogglePreview);
Expand All @@ -584,79 +611,76 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview)
popup.addAction(ui->actionLockPreview);
popup.addMenu(ui->scalingMenu);

previewProjectorSource = new QMenu(QTStr("PreviewProjector"));
popup.addSeparator();
}

// Projector menu entries
if (preview) {
previewProjectorSource = new QMenu(QTStr("Projector.Open.Preview"));
AddProjectorMenuMonitors(previewProjectorSource, this, &OBSBasic::OpenPreviewProjector);
previewProjectorSource->addSeparator();
previewProjectorSource->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenPreviewWindow);

popup.addMenu(previewProjectorSource);
}

QAction *previewWindow = popup.addAction(QTStr("PreviewWindow"), this, &OBSBasic::OpenPreviewWindow);

popup.addAction(previewWindow);

popup.addAction(QTStr("Screenshot.Preview"), this, &OBSBasic::ScreenshotScene);
if (hasVideo) {
sourceProjector = new QMenu(QTStr("Projector.Open.Source"));
AddProjectorMenuMonitors(sourceProjector, this, &OBSBasic::OpenSourceProjector);
sourceProjector->addSeparator();
sourceProjector->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenSourceWindow);

popup.addSeparator();
popup.addMenu(sourceProjector);
}

QPointer<QMenu> addSourceMenu = CreateAddSourcePopupMenu();
if (addSourceMenu)
popup.addMenu(addSourceMenu);

if (ui->sources->MultipleBaseSelected()) {
popup.addSeparator();
popup.addAction(QTStr("Basic.Main.GroupItems"), ui->sources, &SourceTree::GroupSelectedItems);
popup.addSeparator();

} else if (ui->sources->GroupsSelected()) {
popup.addSeparator();
popup.addAction(QTStr("Basic.Main.Ungroup"), ui->sources, &SourceTree::UngroupSelectedGroups);
// Screenshot menu entries
if (preview) {
popup.addAction(QTStr("Screenshot.Preview"), this, &OBSBasic::ScreenshotScene);
}

popup.addSeparator();
popup.addAction(ui->actionCopySource);
popup.addAction(ui->actionPasteRef);
popup.addAction(ui->actionPasteDup);
popup.addSeparator();
if (hasVideo) {
popup.addAction(QTStr("Screenshot.Source"), this, &OBSBasic::ScreenshotSelectedSource);
}

popup.addSeparator();
popup.addAction(ui->actionCopyFilters);
popup.addAction(ui->actionPasteFilters);
popup.addSeparator();

if (idx != -1) {
if (addSourceMenu)
if (sourceSelected) {
// Sources list menu entries
if (!preview) {
colorMenu = new QMenu(QTStr("ChangeBG"));
colorWidgetAction = new QWidgetAction(colorMenu);
colorSelect = new ColorSelect(colorMenu);
popup.addMenu(AddBackgroundColorMenu(colorMenu, colorWidgetAction, colorSelect, sceneItem));

if (hasAudio) {
QAction *actionHideMixer =
popup.addAction(QTStr("HideMixer"), this, &OBSBasic::ToggleHideMixer);
actionHideMixer->setCheckable(true);
actionHideMixer->setChecked(SourceMixerHidden(source));
}
popup.addSeparator();
}

OBSSceneItem sceneItem = ui->sources->Get(idx);
obs_source_t *source = obs_sceneitem_get_source(sceneItem);
uint32_t flags = obs_source_get_output_flags(source);
bool isAsyncVideo = (flags & OBS_SOURCE_ASYNC_VIDEO) == OBS_SOURCE_ASYNC_VIDEO;
bool hasAudio = (flags & OBS_SOURCE_AUDIO) == OBS_SOURCE_AUDIO;
bool hasVideo = (flags & OBS_SOURCE_VIDEO) == OBS_SOURCE_VIDEO;

colorMenu = new QMenu(QTStr("ChangeBG"));
colorWidgetAction = new QWidgetAction(colorMenu);
colorSelect = new ColorSelect(colorMenu);
popup.addMenu(AddBackgroundColorMenu(colorMenu, colorWidgetAction, colorSelect, sceneItem));
popup.addAction(renameSource);
popup.addAction(ui->actionRemoveSource);
popup.addSeparator();

popup.addMenu(ui->orderMenu);

if (hasVideo)
popup.addMenu(ui->transformMenu);
// Scene item menu entries
if (hasVideo && source) {
scaleFilteringMenu = new QMenu(QTStr("ScaleFiltering"));
popup.addMenu(AddScaleFilteringMenu(scaleFilteringMenu, sceneItem));
blendingModeMenu = new QMenu(QTStr("BlendingMode"));
popup.addMenu(AddBlendingModeMenu(blendingModeMenu, sceneItem));
blendingMethodMenu = new QMenu(QTStr("BlendingMethod"));
popup.addMenu(AddBlendingMethodMenu(blendingMethodMenu, sceneItem));
if (isAsyncVideo) {
deinterlaceMenu = new QMenu(QTStr("Deinterlacing"));
popup.addMenu(AddDeinterlacingMenu(deinterlaceMenu, source));
}

popup.addSeparator();
popup.addMenu(CreateVisibilityTransitionMenu(true));
popup.addMenu(CreateVisibilityTransitionMenu(false));

if (hasAudio) {
QAction *actionHideMixer =
popup.addAction(QTStr("HideMixer"), this, &OBSBasic::ToggleHideMixer);
actionHideMixer->setCheckable(true);
actionHideMixer->setChecked(SourceMixerHidden(source));
popup.addSeparator();
}

if (hasVideo) {
QAction *resizeOutput = popup.addAction(QTStr("ResizeOutputSizeOfSource"), this,
&OBSBasic::ResizeOutputSizeOfSource);

Expand All @@ -667,41 +691,54 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview)

if (width < 32 || height < 32)
resizeOutput->setEnabled(false);
}

scaleFilteringMenu = new QMenu(QTStr("ScaleFiltering"));
popup.addMenu(AddScaleFilteringMenu(scaleFilteringMenu, sceneItem));
blendingModeMenu = new QMenu(QTStr("BlendingMode"));
popup.addMenu(AddBlendingModeMenu(blendingModeMenu, sceneItem));
blendingMethodMenu = new QMenu(QTStr("BlendingMethod"));
popup.addMenu(AddBlendingMethodMenu(blendingMethodMenu, sceneItem));
if (isAsyncVideo) {
deinterlaceMenu = new QMenu(QTStr("Deinterlacing"));
popup.addMenu(AddDeinterlacingMenu(deinterlaceMenu, source));
}
popup.addSeparator();

popup.addMenu(ui->orderMenu);

if (hasVideo) {
popup.addMenu(ui->transformMenu);
}

popup.addSeparator();

// Source grouping
if (ui->sources->MultipleBaseSelected()) {
popup.addSeparator();
popup.addAction(QTStr("Basic.Main.GroupItems"), ui->sources, &SourceTree::GroupSelectedItems);

popup.addMenu(CreateVisibilityTransitionMenu(true));
popup.addMenu(CreateVisibilityTransitionMenu(false));
} else if (ui->sources->GroupsSelected()) {
popup.addSeparator();
popup.addAction(QTStr("Basic.Main.Ungroup"), ui->sources, &SourceTree::UngroupSelectedGroups);
}
popup.addSeparator();

sourceProjector = new QMenu(QTStr("SourceProjector"));
AddProjectorMenuMonitors(sourceProjector, this, &OBSBasic::OpenSourceProjector);
popup.addMenu(sourceProjector);
popup.addAction(QTStr("SourceWindow"), this, &OBSBasic::OpenSourceWindow);
popup.addAction(ui->actionCopySource);
popup.addAction(ui->actionPasteRef);
popup.addAction(ui->actionPasteDup);
popup.addSeparator();

popup.addAction(QTStr("Screenshot.Source"), this, &OBSBasic::ScreenshotSelectedSource);
if (hasVideo || hasAudio) {
popup.addAction(ui->actionCopyFilters);
popup.addAction(ui->actionPasteFilters);
popup.addSeparator();
}

popup.addAction(ui->actionRemoveSource);
popup.addAction(renameSource);
popup.addSeparator();

if (flags & OBS_SOURCE_INTERACTION)
if (flags && flags & OBS_SOURCE_INTERACTION)
popup.addAction(QTStr("Interact"), this, &OBSBasic::on_actionInteract_triggered);

popup.addAction(QTStr("Filters"), this, [&]() { OpenFilters(); });
QAction *action =
popup.addAction(QTStr("Properties"), this, &OBSBasic::on_actionSourceProperties_triggered);
action->setEnabled(obs_source_configurable(source));
} else {
popup.addAction(ui->actionPasteRef);
popup.addAction(ui->actionPasteDup);
}

popup.exec(QCursor::pos());
Expand Down
29 changes: 6 additions & 23 deletions frontend/widgets/OBSProjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
popup.addAction(QTStr("Windowed"), this, &OBSProjector::OpenWindowedProjector);

} else if (!this->isMaximized()) {
popup.addAction(QTStr("ResizeProjectorWindowToContent"), this, &OBSProjector::ResizeToContent);
popup.addAction(QTStr("Projector.ResizeWindowToContent"), this, &OBSProjector::ResizeToContent);
}

QAction *alwaysOnTopButton = new QAction(QTStr("Basic.MainMenu.View.AlwaysOnTop"), this);
Expand Down Expand Up @@ -319,39 +319,22 @@ void OBSProjector::UpdateMultiview()

void OBSProjector::UpdateProjectorTitle(QString name)
{
bool window = (GetMonitor() == -1);

QString title = nullptr;
switch (type) {
case ProjectorType::Scene:
if (!window)
title = QTStr("SceneProjector") + " - " + name;
else
title = QTStr("SceneWindow") + " - " + name;
title = QTStr("Projector.Title") + " - " + QTStr("Projector.Title.Scene").arg(name);
break;
case ProjectorType::Source:
if (!window)
title = QTStr("SourceProjector") + " - " + name;
else
title = QTStr("SourceWindow") + " - " + name;
title = QTStr("Projector.Title") + " - " + QTStr("Projector.Title.Source").arg(name);
break;
case ProjectorType::Preview:
if (!window)
title = QTStr("PreviewProjector");
else
title = QTStr("PreviewWindow");
title = QTStr("Projector.Title") + " - " + QTStr("StudioMode.Preview");
break;
case ProjectorType::StudioProgram:
if (!window)
title = QTStr("StudioProgramProjector");
else
title = QTStr("StudioProgramWindow");
title = QTStr("Projector.Title") + " - " + QTStr("StudioMode.Program");
break;
case ProjectorType::Multiview:
if (!window)
title = QTStr("MultiviewProjector");
else
title = QTStr("MultiviewWindowed");
title = QTStr("Projector.Title") + " - " + QTStr("Multiview");
break;
default:
title = name;
Expand Down

0 comments on commit 6b91888

Please sign in to comment.