diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-02 23:34:24 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-02 23:34:24 +0200 |
commit | 9282e3c987bdc123622ae93041bec37b0d6e9234 (patch) | |
tree | 7caa8b89846048ce01fb03202e2c4b08ca360d59 /src | |
parent | Don't open additional tabs when creating subwindows (diff) | |
download | smolbote-9282e3c987bdc123622ae93041bec37b0d6e9234.tar.xz |
Clean up WebView
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow/widgets/navigationbar.cpp | 2 | ||||
-rw-r--r-- | src/webengine/webview.cpp | 26 | ||||
-rw-r--r-- | src/webengine/webview.h | 14 |
3 files changed, 7 insertions, 35 deletions
diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp index 98a7932..98fe0fa 100644 --- a/src/mainwindow/widgets/navigationbar.cpp +++ b/src/mainwindow/widgets/navigationbar.cpp @@ -102,7 +102,7 @@ void NavigationBar::connectWebView(WebView *view) } loadStartedConnection = connect(view, &QWebEngineView::loadStarted, this, &NavigationBar::update_loadStarted); - loadFinishedConnection = connect(view, &WebView::loaded, this, &NavigationBar::update_loadFinished); + loadFinishedConnection = connect(view, &QWebEngineView::loadFinished, this, &NavigationBar::update_loadFinished); stopReloadAction->setEnabled(true); homeAction->setEnabled(true); } diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 3c4e19e..b9dfaa7 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -32,13 +32,6 @@ WebView::WebView(WebProfile *profile, QWidget *parent) connect(this, &QWebEngineView::loadFinished, this, [this]() { m_loaded = true; }); - connect(this, &QWebEngineView::loadProgress, this, [this](int progress) { - m_loadProgress = progress; - if(m_loadProgress == 100) { - m_loaded = true; - emit loaded(); - } - }); m_pageMenu = new PageMenu(this); m_toolsMenu = new PageToolsMenu(this); @@ -49,30 +42,11 @@ WebView::~WebView() delete m_pageMenu; } -QMenu *WebView::pageMenu() -{ - Q_CHECK_PTR(m_pageMenu); - return m_pageMenu; -} - -void WebView::setPage(QWebEnginePage *page) -{ - Q_CHECK_PTR(page); - // make sure the page gets cleaned up if we replace it by taking ownership - page->setParent(this); - QWebEngineView::setPage(page); -} - bool WebView::isLoaded() const { return m_loaded; } -int WebView::loadProgress() const -{ - return m_loadProgress; -} - void WebView::search(const QString &term) { const QString searchUrl = m_profile->search().arg(QString(QUrl::toPercentEncoding(term))); diff --git a/src/webengine/webview.h b/src/webengine/webview.h index 2a99fdd..78ea80d 100644 --- a/src/webengine/webview.h +++ b/src/webengine/webview.h @@ -27,7 +27,11 @@ public: explicit WebView(WebProfile *profile = nullptr, QWidget *parent = nullptr); ~WebView() override; - QMenu *pageMenu(); + QMenu *pageMenu() + { + Q_CHECK_PTR(m_pageMenu); + return m_pageMenu; + } QMenu *toolsMenu() { Q_CHECK_PTR(m_toolsMenu); @@ -37,9 +41,8 @@ public: WebProfile *profile() { return m_profile; } - void setPage(QWebEnginePage *page); + bool isLoaded() const; - int loadProgress() const; void triggerViewAction(ViewAction action); @@ -47,10 +50,6 @@ public slots: void search(const QString &term); signals: - // loadStarted is always emitted, be it page load or in-page request, - // but loadFinished is only emitted when it's a page load - // so emit loaded when a load is emitted (progress == 100) - void loaded(); void newBookmark(const QString &title, const QUrl &url); protected: @@ -64,7 +63,6 @@ private: QMenu *m_toolsMenu = nullptr; bool m_loaded; - int m_loadProgress; }; #endif // SMOLBOTE_WEBVIEW_H |