diff options
Diffstat (limited to 'src/webengine')
| -rw-r--r-- | src/webengine/webview.cpp | 23 | ||||
| -rw-r--r-- | src/webengine/webview.h | 7 | 
2 files changed, 28 insertions, 2 deletions
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index ea0ee26..c924144 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -26,7 +26,7 @@  #include <QPrinter>  #include <QPrinterInfo> -#include "mainwindow.h" +#include "src/mainwindow/mainwindow.h"  #include <QStatusBar>  // ssl errors @@ -38,6 +38,17 @@ WebView::WebView(MainWindow *parentMainWindow, QWidget *parent)      Q_CHECK_PTR(parentMainWindow);      m_parent = parentMainWindow; +    // load status and progress +    connect(this, &QWebEngineView::loadStarted, this, [this]() { +        m_loaded = false; +    }); +    connect(this, &QWebEngineView::loadFinished, this, [this]() { +        m_loaded = true; +    }); +    connect(this, &QWebEngineView::loadProgress, this, [this](int progress) { +        m_loadProgress = progress; +    }); +      m_pageMenu = new QMenu();      m_pageMenu->setMinimumWidth(240); @@ -137,6 +148,16 @@ void WebView::setPage(WebPage *page)      QWebEngineView::setPage(page);  } +bool WebView::isLoaded() const +{ +    return m_loaded; +} + +int WebView::loadProgress() const +{ +    return m_loadProgress; +} +  WebView *WebView::createWindow(QWebEnginePage::WebWindowType type)  {      WebView *view = new WebView(m_parent); diff --git a/src/webengine/webview.h b/src/webengine/webview.h index 18a1e02..78b85ce 100644 --- a/src/webengine/webview.h +++ b/src/webengine/webview.h @@ -24,12 +24,14 @@ public:      QMenu *pageMenu();      void setPage(WebPage *page); +    bool isLoaded() const; +    int loadProgress() const;  signals:      void newBookmark(const QString &title, const QUrl &url);  protected: -    WebView *createWindow(QWebEnginePage::WebWindowType type); +    WebView *createWindow(QWebEnginePage::WebWindowType type) override;  private slots:      void handleLinkHovered(const QString &url); @@ -38,6 +40,9 @@ private slots:  private:      MainWindow *m_parent = nullptr;      QMenu *m_pageMenu = nullptr; + +    bool m_loaded; +    int m_loadProgress;  };  #endif // WEBVIEW_H  | 
