Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI,docs: Send a custom event to the dock widget when closing #10516

Merged

Conversation

tytan652
Copy link
Collaborator

@tytan652 tytan652 commented Apr 11, 2024

Description

Send a custom event to the OBSDock widget when the dock (from obs_frontend_add_dock_by_id) is closed, which allow plugin authors to potentially save resources while the dock is closed.

A QShowEvent is already sent to the widget when the dock is (re-)opened.

Motivation and Context

Motivation related to:

Enabling a way closing browser from a plugin dock when the said dock is closed, since OBS Studio completely owns the access to the dock object.

So in a scenario like separating service integration, beside randomly guessing we can't know when close browsers to save resources.

How Has This Been Tested?

Disabled the closeBrowser() call in BrowserDock closeEvent() impl and added the following to QCefWidgetInternal for testing purpose:

bool QCefWidgetInternal::event(QEvent *event)
{
	if (event->type() == (QEvent::User + QEvent::Close))
	{
		closeBrowser();
		return true;
	}

	return QCefWidget::event(event);
}

The browser is closed when the dock is closed thanks to the event as expected.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Tweak (non-breaking change to improve existing functionality)

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.

@tytan652 tytan652 added the Enhancement Improvement to existing functionality label Apr 11, 2024
docs/sphinx/reference-frontend-api.rst Outdated Show resolved Hide resolved
docs/sphinx/reference-frontend-api.rst Outdated Show resolved Hide resolved
@tytan652 tytan652 force-pushed the custom_close_event_for_dock_widget branch from 9264dde to c106167 Compare April 14, 2024 07:40
@RytoEX RytoEX requested review from RytoEX and removed request for RytoEX April 14, 2024 07:47
@tytan652 tytan652 force-pushed the custom_close_event_for_dock_widget branch from c106167 to ece2e71 Compare May 8, 2024 21:27
@tytan652 tytan652 force-pushed the custom_close_event_for_dock_widget branch from ece2e71 to f5242c0 Compare May 16, 2024 12:52
@tytan652 tytan652 added this to the OBS Studio 31 milestone Jul 2, 2024
@tytan652 tytan652 force-pushed the custom_close_event_for_dock_widget branch from f5242c0 to 828735f Compare July 30, 2024 05:39
@WizardCM WizardCM merged commit 3b266fe into obsproject:master Aug 4, 2024
15 checks passed
@tytan652 tytan652 deleted the custom_close_event_for_dock_widget branch August 4, 2024 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants