From 7665ed207b67eeebde62d243c96f12054e884a4d Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 28 May 2018 12:32:34 +0200 Subject: Show view profile instead of window profile in title --- src/mainwindow/window.cpp | 18 +++++++----------- src/mainwindow/window.h | 2 -- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'src/mainwindow') 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 &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(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(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(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 &config, QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); ~Window() override; - void setWindowTitle(const QString &title); - WebView *currentView(); WebView *view(int index) const; -- cgit v1.2.1