Skip to content

frontend: Refactor main window menus#11171

Open
cg2121 wants to merge 1 commit into
obsproject:masterfrom
cg2121:menu-refactor
Open

frontend: Refactor main window menus#11171
cg2121 wants to merge 1 commit into
obsproject:masterfrom
cg2121:menu-refactor

Conversation

@cg2121

@cg2121 cg2121 commented Aug 22, 2024

Copy link
Copy Markdown
Contributor

Description

This makes it so we don't have to manually delete each menu each time they are shown, they are now created on demand, saving some memory. This also moves the menu code to a separate file.

Motivation and Context

The menu code has always bothered me

How Has This Been Tested?

Clicked through each menu to made sure they still worked

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@cg2121 cg2121 added the kind/cleanup Non-breaking change which makes code smaller or more readable label Aug 22, 2024
Comment thread UI/window-basic-main-menus.cpp Outdated
@cg2121

cg2121 commented Aug 25, 2024

Copy link
Copy Markdown
Contributor Author

I have updated the code to remove the sender methods from the menus.

@Warchamp7 Warchamp7 self-assigned this Oct 7, 2024
@cg2121

cg2121 commented May 3, 2025

Copy link
Copy Markdown
Contributor Author

Updated to adapt to the new frontend structure.

@cg2121 cg2121 changed the title UI: Refactor main window menus frontend: Refactor main window menus May 3, 2025
@cg2121 cg2121 force-pushed the menu-refactor branch 2 times, most recently from dcace05 to da14a24 Compare May 3, 2025 17:02
Comment thread frontend/forms/OBSBasic.ui
Comment thread frontend/widgets/OBSBasic.hpp Outdated
@RytoEX

RytoEX commented Dec 18, 2025

Copy link
Copy Markdown
Member

This PR has merge conflicts and unresolved feedback. cc @Warchamp7

@Warchamp7 Warchamp7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some quick testing and menus all seemed to behave correctly still.

Left a few comments, and just making a general note here to have any of the new/renamed functions be camelCase instead of PascalCase.

{
multiviewMenu.reset(CreateProjectorMenu(QTStr("Projector.Open.Multiview"), nullptr, ProjectorType::Multiview));

QAction *separatorAction = ui->viewMenu->actions().at(ui->viewMenu->actions().count() - 2);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cursed and we should find a better way to do it.

Should in theory be able to insert the new menu before the old one, then remove the old one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't work when OBS is first loaded because the menu is not created yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would work if there were a placeholder entry within the UI form still, no? Otherwise what you're saying wouldn't work now either.

Comment thread frontend/widgets/OBSBasic.hpp Outdated
Comment thread frontend/widgets/OBSBasic_SceneItems.cpp Outdated
Comment thread frontend/widgets/OBSBasic_SceneItems.cpp Outdated
@Warchamp7 Warchamp7 removed their assignment May 8, 2026
This makes it so we don't have to manually delete each menu each time
they are shown, they are now created on demand, saving some memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Non-breaking change which makes code smaller or more readable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants