UI: Store dock titles in BrowserDock instead of relying on Qt

Attempting to set the window title of a BrowserDock that is closed, then
opening the BrowserDock, would show that BrowserDock with an incorrect
title. We can handle this by overriding the showEvent of BrowserDock and
manually setting the window title after the showEvent is called,
hopefully ensuring that we are only setting the window title on a window
that exists.
This commit is contained in:
Ryan Foster 2023-08-11 16:47:29 -04:00
parent 25b97df6eb
commit f049d04af4
5 changed files with 21 additions and 1 deletions

View file

@ -18,3 +18,9 @@ void BrowserDock::closeEvent(QCloseEvent *event)
cefWidget->closeBrowser();
}
}
void BrowserDock::showEvent(QShowEvent *event)
{
OBSDock::showEvent(event);
setWindowTitle(title);
}

View file

@ -8,10 +8,14 @@ extern QCef *cef;
extern QCefCookieManager *panel_cookies;
class BrowserDock : public OBSDock {
private:
QString title;
public:
inline BrowserDock() : OBSDock() { setAttribute(Qt::WA_NativeWindow); }
inline BrowserDock(const QString &title) : OBSDock(title)
inline BrowserDock(const QString &title_) : OBSDock(title_)
{
title = title_;
setAttribute(Qt::WA_NativeWindow);
}
@ -23,5 +27,8 @@ public:
cefWidget.reset(widget_);
}
inline void setTitle(const QString &title_) { title = title_; }
void closeEvent(QCloseEvent *event) override;
void showEvent(QShowEvent *event) override;
};

View file

@ -34,3 +34,8 @@ void OBSDock::closeEvent(QCloseEvent *event)
QDockWidget::closeEvent(event);
}
void OBSDock::showEvent(QShowEvent *event)
{
QDockWidget::showEvent(event);
}

View file

@ -13,4 +13,5 @@ public:
}
virtual void closeEvent(QCloseEvent *event);
virtual void showEvent(QShowEvent *event);
};

View file

@ -181,6 +181,7 @@ void ExtraBrowsersModel::UpdateItem(Item &item)
if (main->extraBrowserDockNames[idx] != item.title) {
main->extraBrowserDockNames[idx] = item.title;
dock->toggleViewAction()->setText(item.title);
dock->setTitle(item.title);
}
if (main->extraBrowserDockTargets[idx] != item.url) {