From bb0eccac8d006e03e29f7b5a849994bf819405ed Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Thu, 8 Feb 2018 16:16:41 +0100 Subject: Connected WebView::newBookmark signal --- src/mainwindow/mainwindow.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/mainwindow/mainwindow.cpp') diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index 5ee0a78..2d7ba09 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -16,6 +16,7 @@ #include #include #include +#include //#include MainWindow::MainWindow(std::shared_ptr config, QWidget *parent) @@ -247,6 +248,9 @@ void MainWindow::handleTabChanged(WebView *view) { Q_CHECK_PTR(view); + disconnect(titleChangedConnection); + disconnect(newBookmarkConnection); + m_currentView = view; // centralWidget can be a nullptr @@ -266,7 +270,14 @@ void MainWindow::handleTabChanged(WebView *view) m_addressBar->connectWebView(view); - connect(view, &WebView::titleChanged, this, &MainWindow::handleTitleUpdated); + titleChangedConnection = connect(view, &WebView::titleChanged, this, &MainWindow::handleTitleUpdated); + newBookmarkConnection = connect(view, &WebView::newBookmark, this, [this](const QString &title, const QUrl &url) { + if(m_bookmarksWidget) { + auto *bookmark = m_bookmarksWidget->model()->createBookmark(nullptr); + bookmark->setText(0, title); + bookmark->setText(1, url.toString()); + } + }); m_progressBar->connectWebView(view); -- cgit v1.2.1