aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/addressbar/urllineedit.cpp1
-rw-r--r--src/mainwindow/widgets/loadingbar.cpp5
-rw-r--r--src/mainwindow/widgets/loadingbar.h2
-rw-r--r--src/mainwindow/widgets/navigationbar.cpp3
-rw-r--r--src/webengine/webview.cpp5
-rw-r--r--src/webengine/webview.h8
-rw-r--r--src/widgets/mainwindowtabbar.cpp1
7 files changed, 20 insertions, 5 deletions
diff --git a/src/addressbar/urllineedit.cpp b/src/addressbar/urllineedit.cpp
index d34fdcb..5b8e6c6 100644
--- a/src/addressbar/urllineedit.cpp
+++ b/src/addressbar/urllineedit.cpp
@@ -8,6 +8,7 @@
#include "urllineedit.h"
#include <QLabel>
+#include <QMenu>
#include <QTimer>
#include <QWidgetAction>
diff --git a/src/mainwindow/widgets/loadingbar.cpp b/src/mainwindow/widgets/loadingbar.cpp
index 2c12371..76eafc4 100644
--- a/src/mainwindow/widgets/loadingbar.cpp
+++ b/src/mainwindow/widgets/loadingbar.cpp
@@ -22,6 +22,7 @@ void LoadingBar::connectWebView(WebView *view)
disconnect(loadStartedConnection);
disconnect(loadProgressConnection);
+ disconnect(loadedConnection);
disconnect(loadFinishedConnection);
if(view->isLoaded()) {
@@ -33,6 +34,9 @@ void LoadingBar::connectWebView(WebView *view)
loadStartedConnection = connect(view, &QWebEngineView::loadStarted, this, &LoadingBar::loadStarted);
loadProgressConnection = connect(view, &QWebEngineView::loadProgress, this, &QProgressBar::setValue);
+ loadedConnection = connect(view, &WebView::loaded, this, [this]() {
+ QTimer::singleShot(2000, this, &LoadingBar::hide);
+ });
loadFinishedConnection = connect(view, &QWebEngineView::loadFinished, this, &LoadingBar::loadFinished);
}
@@ -46,5 +50,4 @@ void LoadingBar::loadStarted()
void LoadingBar::loadFinished(bool ok)
{
setFormat(QString("%p% %1").arg(ok ? tr("Finished") : tr("Failed")));
- QTimer::singleShot(2000, this, SLOT(hide()));
}
diff --git a/src/mainwindow/widgets/loadingbar.h b/src/mainwindow/widgets/loadingbar.h
index b03a25e..f75e72b 100644
--- a/src/mainwindow/widgets/loadingbar.h
+++ b/src/mainwindow/widgets/loadingbar.h
@@ -24,7 +24,7 @@ private slots:
void loadFinished(bool ok);
private:
- QMetaObject::Connection loadStartedConnection, loadProgressConnection, loadFinishedConnection;
+ QMetaObject::Connection loadStartedConnection, loadProgressConnection, loadedConnection, loadFinishedConnection;
};
#endif // LOADINGBAR_H
diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp
index 93711e1..e488d77 100644
--- a/src/mainwindow/widgets/navigationbar.cpp
+++ b/src/mainwindow/widgets/navigationbar.cpp
@@ -9,6 +9,7 @@
#include "navigationbar.h"
#include "mainwindow/mainwindow.h"
#include <QHBoxLayout>
+#include <QMenu>
#include <QShortcut>
#include <QStyle>
#include <QToolBar>
@@ -112,7 +113,7 @@ void NavigationBar::connectWebView(WebView *view)
}
loadStartedConnection = connect(view, &QWebEngineView::loadStarted, this, &NavigationBar::update_loadStarted);
- loadFinishedConnection = connect(view, &QWebEngineView::loadFinished, this, &NavigationBar::update_loadFinished);
+ loadFinishedConnection = connect(view, &WebView::loaded, this, &NavigationBar::update_loadFinished);
}
void NavigationBar::update_loadStarted()
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 263fb67..5f7fc35 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -7,6 +7,7 @@
*/
#include "webview.h"
+#include <QMenu>
// copy page URL
#include <QApplication>
@@ -47,6 +48,10 @@ WebView::WebView(MainWindow *parentMainWindow, QWidget *parent)
});
connect(this, &QWebEngineView::loadProgress, this, [this](int progress) {
m_loadProgress = progress;
+ if(m_loadProgress == 100) {
+ m_loaded = true;
+ emit loaded();
+ }
});
m_pageMenu = new QMenu();
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index 957d181..a274535 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -10,16 +10,16 @@
#define WEBVIEW_H
#include "webpage.h"
-#include <QMenu>
#include <QWebEngineView>
+class QMenu;
class MainWindow;
class WebView : public QWebEngineView
{
Q_OBJECT
public:
explicit WebView(MainWindow *parentMainWindow, QWidget *parent = nullptr);
- ~WebView();
+ ~WebView() override;
QMenu *pageMenu();
@@ -28,6 +28,10 @@ public:
int loadProgress() const;
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:
diff --git a/src/widgets/mainwindowtabbar.cpp b/src/widgets/mainwindowtabbar.cpp
index 213b2c2..007a2d1 100644
--- a/src/widgets/mainwindowtabbar.cpp
+++ b/src/widgets/mainwindowtabbar.cpp
@@ -11,6 +11,7 @@
#include "src/mainwindow/mainwindow.h"
#include <QContextMenuEvent>
#include <QShortcut>
+#include <QMenu>
MainWindowTabBar::MainWindowTabBar(const std::shared_ptr<Configuration> &config, MainWindow *parent)
: QTabBar(parent)