Fix alert when installing an extension

Before this, the alert's parent window was the main window instead of
the options window.
This commit is contained in:
Martín Capello 2021-03-30 14:39:45 -03:00 committed by David Capello
parent 5e172d81ee
commit fdbb3aec59
3 changed files with 25 additions and 5 deletions

View File

@ -1644,12 +1644,20 @@ void OptionsCommand::onExecute(Context* context)
static int curSection = 0;
OptionsWindow window(context, curSection);
window.openWindow();
if (!m_installExtensionFilename.empty()) {
if (!window.showDialogToInstallExtension(m_installExtensionFilename))
return;
}
// As showDialogToInstallExtension() will show an ui::Alert, we need
// to call this function after window.openWindowInForeground(), so
// the parent window of the alert will be our OptionsWindow (and not
// the main window).
window.Open.connect(
[&]() {
if (!m_installExtensionFilename.empty()) {
if (!window.showDialogToInstallExtension(this->m_installExtensionFilename)) {
window.closeWindow(&window);
return;
}
}
});
window.openWindowInForeground();
if (window.ok())

View File

@ -284,6 +284,12 @@ void Window::onHitTest(HitTestEvent& ev)
ev.setHit(ht);
}
void Window::onOpen(Event& ev)
{
// Fire Open signal
Open(ev);
}
void Window::onWindowResize()
{
// Do nothing
@ -366,6 +372,10 @@ void Window::openWindow()
{
if (!parent()) {
Manager::getDefault()->_openWindow(this, m_isAutoRemap);
// Open event
Event ev(this);
onOpen(ev);
}
}

View File

@ -75,6 +75,7 @@ namespace ui {
void loadNativeFrame(const gfx::Rect& frame) { m_lastFrame = frame; }
// Signals
obs::signal<void (Event&)> Open;
obs::signal<void (CloseEvent&)> Close;
protected:
@ -87,6 +88,7 @@ namespace ui {
virtual void onSetText() override;
// New events
virtual void onOpen(Event& ev);
virtual void onClose(CloseEvent& ev);
virtual void onHitTest(HitTestEvent& ev);
virtual void onWindowResize();