UI,docs: Send a custom event to the dock widget when closing
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:
- https://github.com/obsproject/obs-browser/pull/431
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:
- [x] My code has been run through clang-format.
- [x] I have read the contributing document.
- [x] My code is not on the master branch.
- [x] The code has been tested.
- [x] All commit messages are properly formatted and commits squashed where appropriate.
- [x] I have included updates to all appropriate documentation.