diff options
-rw-r--r-- | src/mainwindow/window.cpp | 18 | ||||
-rw-r--r-- | src/mainwindow/window.h | 2 | ||||
-rw-r--r-- | src/webengine/webview.cpp | 8 | ||||
-rw-r--r-- | src/webengine/webview.h | 1 |
4 files changed, 16 insertions, 13 deletions
diff --git a/src/mainwindow/window.cpp b/src/mainwindow/window.cpp index 3d7d037..273aa0a 100644 --- a/src/mainwindow/window.cpp +++ b/src/mainwindow/window.cpp @@ -103,10 +103,13 @@ Window::Window(const QHash<QString, QString> &config, QWidget *parent, Qt::Windo disconnect(titleConnection); disconnect(linkHoveredConnection); - connect(view, &WebView::titleChanged, this, &Window::setWindowTitle); - setWindowTitle(view->title()); + titleConnection = connect(view, &WebView::titleChanged, this, [this](const QString &title) { + auto *v = qobject_cast<WebView *>(sender()); + this->setWindowTitle(QString("%1 :%2").arg(title, v->profile()->name())); + }); + setWindowTitle(QString("%1 :%2").arg(view->title(), view->profile()->name())); - connect(view->page(), &WebPage::linkHovered, this, [this](const QString &url) { + linkHoveredConnection = connect(view->page(), &WebPage::linkHovered, this, [this](const QString &url) { if(!url.isEmpty()) emit showStatusMessage(url, 3000); }); @@ -121,11 +124,6 @@ Window::~Window() delete tabWidget; } -void Window::setWindowTitle(const QString &title) -{ - QMdiSubWindow::setWindowTitle(QString("%1 :%2").arg(title, profile->name())); -} - WebView *Window::currentView() { return qobject_cast<WebView *>(tabWidget->currentWidget()); @@ -142,9 +140,7 @@ void Window::setProfile(WebProfile *profile) this->profile = profile; for(int i = 0; i < tabWidget->count(); ++i) { auto *view = qobject_cast<WebView *>(tabWidget->widget(i)); - const auto url = view->url(); - view->setPage(new WebPage(profile, view)); - view->load(url); + view->setProfile(profile); } } diff --git a/src/mainwindow/window.h b/src/mainwindow/window.h index 4d15e8d..6431466 100644 --- a/src/mainwindow/window.h +++ b/src/mainwindow/window.h @@ -24,8 +24,6 @@ public: explicit Window(const QHash<QString, QString> &config, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~Window() override; - void setWindowTitle(const QString &title); - WebView *currentView(); WebView *view(int index) const; diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 686a689..d5f88d0 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -50,6 +50,14 @@ WebView::~WebView() delete m_pageMenu; } +void WebView::setProfile(WebProfile *profile) +{ + m_profile = profile; + const auto url = this->url(); + setPage(new WebPage(profile, this)); + this->load(url); +} + bool WebView::isLoaded() const { return m_loaded; diff --git a/src/webengine/webview.h b/src/webengine/webview.h index 78ea80d..378296e 100644 --- a/src/webengine/webview.h +++ b/src/webengine/webview.h @@ -41,6 +41,7 @@ public: WebProfile *profile() { return m_profile; } + void setProfile(WebProfile *profile); bool isLoaded() const; |