diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-02-08 16:16:41 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-02-08 16:16:41 +0100 |
commit | bb0eccac8d006e03e29f7b5a849994bf819405ed (patch) | |
tree | 3a0630a2f636f9ba89cc0849f00d479ecdd7b422 | |
parent | Fixed address bar auto-complete (diff) | |
download | smolbote-bb0eccac8d006e03e29f7b5a849994bf819405ed.tar.xz |
Connected WebView::newBookmark signal
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 13 | ||||
-rw-r--r-- | src/mainwindow/mainwindow.h | 3 | ||||
-rw-r--r-- | src/webengine/webview.cpp | 4 |
3 files changed, 17 insertions, 3 deletions
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 <bookmarks/bookmarkswidget.h> #include <downloads/downloadswidget.h> #include <src/addressbar/urllineedit.h> +#include <lib/bookmarks/bookmarksview.h> //#include <settings/settingsdialog.h> MainWindow::MainWindow(std::shared_ptr<Configuration> 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); diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h index f9e0515..84b408b 100644 --- a/src/mainwindow/mainwindow.h +++ b/src/mainwindow/mainwindow.h @@ -92,6 +92,9 @@ private: std::shared_ptr<Configuration> m_config; std::shared_ptr<BookmarksWidget> m_bookmarksWidget; std::shared_ptr<DownloadsWidget> m_downloadsWidget; + + QMetaObject::Connection titleChangedConnection; + QMetaObject::Connection newBookmarkConnection; }; #endif // MAINWINDOW_H diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 5f7fc35..9cf0157 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -62,7 +62,7 @@ WebView::WebView(MainWindow *parentMainWindow, QWidget *parent) qApp->clipboard()->setText(this->url().toString()); }); - QAction *bookmarkAction = m_pageMenu->addAction(tr("TODO: Bookmark page")); + QAction *bookmarkAction = m_pageMenu->addAction(tr("Bookmark page")); connect(bookmarkAction, &QAction::triggered, this, [this]() { emit newBookmark(this->title(), this->url()); }); @@ -105,7 +105,7 @@ WebView::WebView(MainWindow *parentMainWindow, QWidget *parent) m_pageMenu->addSeparator(); - QAction *savePageAction = m_pageMenu->addAction(tr("TODO: Save Page")); + QAction *savePageAction = m_pageMenu->addAction(tr("Save Page")); connect(savePageAction, &QAction::triggered, this, [this]() { this->triggerPageAction(QWebEnginePage::SavePage); }); |