From 6bda60d69b416af871c72a34cb1c7ce32c6b3ef6 Mon Sep 17 00:00:00 2001 From: Warchamp7 Date: Mon, 4 Nov 2024 12:33:14 -0500 Subject: [PATCH] UI: Reorganize Preview/Source context menu --- UI/data/locale/en-US.ini | 30 +++--- UI/forms/OBSBasic.ui | 8 +- UI/window-basic-main.cpp | 212 +++++++++++++++++++++++---------------- UI/window-basic-main.hpp | 4 +- UI/window-projector.cpp | 29 ++---- 5 files changed, 150 insertions(+), 133 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 572b15f15117fb..657483539d5e5c 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -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" @@ -1130,10 +1130,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" diff --git a/UI/forms/OBSBasic.ui b/UI/forms/OBSBasic.ui index 53e457ad30313b..a34745c4ef5f69 100644 --- a/UI/forms/OBSBasic.ui +++ b/UI/forms/OBSBasic.ui @@ -787,7 +787,7 @@ - MultiviewProjector + Projector.Open.Multiview @@ -815,7 +815,6 @@ - @@ -2047,11 +2046,6 @@ Basic.Stats - - - MultiviewWindowed - - Basic.MainMenu.Docks.ResetDocks diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index bbc3e6cb3dda67..f72ea3f0ed3d24 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -2566,6 +2566,8 @@ void OBSBasic::UpdateMultiviewProjectorMenu() { ui->multiviewProjectorMenu->clear(); AddProjectorMenuMonitors(ui->multiviewProjectorMenu, this, &OBSBasic::OpenMultiviewProjector); + ui->multiviewProjectorMenu->addSeparator(); + ui->multiviewProjectorMenu->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenMultiviewWindow); } void OBSBasic::InitHotkeys() @@ -5181,13 +5183,14 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos) popup.addSeparator(); delete sceneProjectorMenu; - sceneProjectorMenu = new QMenu(QTStr("SceneProjector")); + sceneProjectorMenu = new QMenu(QTStr("Projector.Open.Scene")); AddProjectorMenuMonitors(sceneProjectorMenu, this, &OBSBasic::OpenSceneProjector); - popup.addMenu(sceneProjectorMenu); + sceneProjectorMenu->addSeparator(); + sceneProjectorMenu->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenSceneWindow); - QAction *sceneWindow = popup.addAction(QTStr("SceneWindow"), this, &OBSBasic::OpenSceneWindow); + popup.addMenu(sceneProjectorMenu); - popup.addAction(sceneWindow); + popup.addSeparator(); popup.addAction(QTStr("Screenshot.Scene"), this, &OBSBasic::ScreenshotScene); popup.addSeparator(); popup.addAction(QTStr("Filters"), this, &OBSBasic::OpenSceneFilters); @@ -5577,6 +5580,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 addSourceMenu = CreateAddSourcePopupMenu(); + if (addSourceMenu) { + popup.addMenu(addSourceMenu); + popup.addSeparator(); + } + + // Display Preview-specific menu entries if (preview) { QAction *action = popup.addAction(QTStr("Basic.Main.PreviewConextMenu.Enable"), this, &OBSBasic::TogglePreview); @@ -5588,90 +5617,79 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview) popup.addAction(ui->actionLockPreview); popup.addMenu(ui->scalingMenu); - previewProjectorSource = new QMenu(QTStr("PreviewProjector")); + popup.addSeparator(); + } + + // Projector 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 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 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) - 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); + if (preview || sourceSelected) { + popup.addAction(ui->actionPasteRef); + popup.addAction(ui->actionPasteDup); popup.addSeparator(); + } + if (sourceSelected) { popup.addMenu(ui->orderMenu); - if (hasVideo) + if (hasVideo) { popup.addMenu(ui->transformMenu); + } - popup.addSeparator(); - - if (hasAudio) { - QAction *actionHideMixer = - popup.addAction(QTStr("HideMixer"), this, &OBSBasic::ToggleHideMixer); - actionHideMixer->setCheckable(true); - actionHideMixer->setChecked(SourceMixerHidden(source)); + if (!preview) { popup.addSeparator(); + 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)); + } } - if (hasVideo) { - QAction *resizeOutput = popup.addAction(QTStr("ResizeOutputSizeOfSource"), this, - &OBSBasic::ResizeOutputSizeOfSource); - - int width = obs_source_get_width(source); - int height = obs_source_get_height(source); - - resizeOutput->setEnabled(!obs_video_active()); + popup.addSeparator(); - if (width < 32 || height < 32) - resizeOutput->setEnabled(false); + if (hasVideo) { + popup.addAction(ui->actionCopyFilters); + popup.addAction(ui->actionPasteFilters); + popup.addSeparator(); + } + if (hasVideo && source) { scaleFilteringMenu = new QMenu(QTStr("ScaleFiltering")); popup.addMenu(AddScaleFilteringMenu(scaleFilteringMenu, sceneItem)); blendingModeMenu = new QMenu(QTStr("BlendingMode")); @@ -5683,23 +5701,44 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview) popup.addMenu(AddDeinterlacingMenu(deinterlaceMenu, source)); } - popup.addSeparator(); - popup.addMenu(CreateVisibilityTransitionMenu(true)); popup.addMenu(CreateVisibilityTransitionMenu(false)); + popup.addSeparator(); - sourceProjector = new QMenu(QTStr("SourceProjector")); - AddProjectorMenuMonitors(sourceProjector, this, &OBSBasic::OpenSourceProjector); - popup.addMenu(sourceProjector); - popup.addAction(QTStr("SourceWindow"), this, &OBSBasic::OpenSourceWindow); + QAction *resizeOutput = popup.addAction(QTStr("ResizeOutputSizeOfSource"), this, + &OBSBasic::ResizeOutputSizeOfSource); + + int width = obs_source_get_width(source); + int height = obs_source_get_height(source); + + resizeOutput->setEnabled(!obs_video_active()); - popup.addAction(QTStr("Screenshot.Source"), this, &OBSBasic::ScreenshotSelectedSource); + if (width < 32 || height < 32) + resizeOutput->setEnabled(false); } popup.addSeparator(); - if (flags & OBS_SOURCE_INTERACTION) + // Source grouping + if (ui->sources->MultipleBaseSelected()) { + popup.addSeparator(); + popup.addAction(QTStr("Basic.Main.GroupItems"), ui->sources, &SourceTree::GroupSelectedItems); + + } else if (ui->sources->GroupsSelected()) { + popup.addSeparator(); + popup.addAction(QTStr("Basic.Main.Ungroup"), ui->sources, &SourceTree::UngroupSelectedGroups); + } + popup.addAction(renameSource); + popup.addAction(ui->actionRemoveSource); + popup.addSeparator(); + + popup.addAction(ui->actionCopySource); + popup.addAction(ui->actionPasteRef); + popup.addAction(ui->actionPasteDup); + popup.addSeparator(); + + if (flags && flags & OBS_SOURCE_INTERACTION) popup.addAction(QTStr("Interact"), this, &OBSBasic::on_actionInteract_triggered); popup.addAction(QTStr("Filters"), this, [&]() { OpenFilters(); }); @@ -5768,7 +5807,7 @@ QMenu *OBSBasic::CreateAddSourcePopupMenu() bool foundDeprecated = false; size_t idx = 0; - QMenu *popup = new QMenu(QTStr("Add"), this); + QMenu *popup = new QMenu(QTStr("AddSource"), this); QMenu *deprecated = new QMenu(QTStr("Deprecated"), popup); auto getActionAfter = [](QMenu *menu, const QString &name) { @@ -7654,11 +7693,13 @@ void OBSBasic::ProgramViewContextMenuRequested() QMenu popup(this); QPointer studioProgramProjector; - studioProgramProjector = new QMenu(QTStr("StudioProgramProjector")); + studioProgramProjector = new QMenu(QTStr("Projector.Open.Program")); AddProjectorMenuMonitors(studioProgramProjector, this, &OBSBasic::OpenStudioProgramProjector); + studioProgramProjector->addSeparator(); + studioProgramProjector->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenStudioProgramWindow); popup.addMenu(studioProgramProjector); - popup.addAction(QTStr("StudioProgramWindow"), this, &OBSBasic::OpenStudioProgramWindow); + popup.addSeparator(); popup.addAction(QTStr("Screenshot.StudioProgram"), this, &OBSBasic::ScreenshotProgram); popup.exec(QCursor::pos()); @@ -7673,13 +7714,12 @@ void OBSBasic::on_previewDisabledWidget_customContextMenuRequested() action->setCheckable(true); action->setChecked(obs_display_enabled(ui->preview->GetDisplay())); - previewProjectorMain = new QMenu(QTStr("PreviewProjector")); + previewProjectorMain = new QMenu(QTStr("Projector.Open.Preview")); AddProjectorMenuMonitors(previewProjectorMain, this, &OBSBasic::OpenPreviewProjector); - - QAction *previewWindow = popup.addAction(QTStr("PreviewWindow"), this, &OBSBasic::OpenPreviewWindow); + previewProjectorMain->addSeparator(); + previewProjectorMain->addAction(QTStr("Projector.Window"), this, &OBSBasic::OpenPreviewWindow); popup.addMenu(previewProjectorMain); - popup.addAction(previewWindow); popup.exec(QCursor::pos()); } @@ -8575,6 +8615,11 @@ void OBSBasic::OpenSourceWindow() OpenProjector(obs_sceneitem_get_source(item), -1, ProjectorType::Source); } +void OBSBasic::OpenMultiviewWindow() +{ + OpenProjector(nullptr, -1, ProjectorType::Multiview); +} + void OBSBasic::OpenSceneWindow() { OBSScene scene = GetCurrentScene(); @@ -8831,11 +8876,6 @@ void OBSBasic::on_resetUI_triggered() config_set_bool(App()->GetUserConfig(), "BasicWindow", "gridMode", false); } -void OBSBasic::on_multiviewProjectorWindowed_triggered() -{ - OpenProjector(nullptr, -1, ProjectorType::Multiview); -} - void OBSBasic::on_toggleListboxToolbars_toggled(bool visible) { ui->sourcesToolbar->setVisible(visible); @@ -9035,8 +9075,8 @@ void OBSBasic::SystemTrayInit() exit = new QAction(QTStr("Exit"), trayIcon.data()); trayMenu = new QMenu; - previewProjector = new QMenu(QTStr("PreviewProjector")); - studioProgramProjector = new QMenu(QTStr("StudioProgramProjector")); + previewProjector = new QMenu(QTStr("Projector.Open.Preview")); + studioProgramProjector = new QMenu(QTStr("Projector.Open.Program")); AddProjectorMenuMonitors(previewProjector, this, &OBSBasic::OpenPreviewProjector); AddProjectorMenuMonitors(studioProgramProjector, this, &OBSBasic::OpenStudioProgramProjector); trayMenu->addAction(showHide); diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 81bb7b4780fbbc..39a9c2c6db9bfc 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -988,7 +988,7 @@ private slots: auto projectors = GetProjectorMenuMonitorsFormatted(); for (int i = 0; i < projectors.size(); i++) { QString str = projectors[i]; - QAction *action = parent->addAction(str, target, slot); + QAction *action = parent->addAction(QTStr("Projector.Display").arg(str), target, slot); action->setProperty("monitor", i); } } @@ -1137,7 +1137,6 @@ private slots: void on_resetUI_triggered(); void on_resetDocks_triggered(bool force = false); void on_lockDocks_toggled(bool lock); - void on_multiviewProjectorWindowed_triggered(); void on_sideDocks_toggled(bool side); void logUploadFinished(const QString &text, const QString &error); @@ -1172,6 +1171,7 @@ private slots: void OpenStudioProgramWindow(); void OpenPreviewWindow(); void OpenSourceWindow(); + void OpenMultiviewWindow(); void OpenSceneWindow(); void StackedMixerAreaContextMenuRequested(); diff --git a/UI/window-projector.cpp b/UI/window-projector.cpp index 60f873bc93b7d1..6b12805edec22f 100644 --- a/UI/window-projector.cpp +++ b/UI/window-projector.cpp @@ -264,7 +264,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); @@ -320,39 +320,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;