aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/webview.cpp40
-rw-r--r--src/webengine/webview.h8
2 files changed, 44 insertions, 4 deletions
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 5463610..ff2780c 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -28,9 +28,15 @@
#include <QPrinterInfo>
#include <QPrintDialog>
-WebView::WebView(QWidget *parent) :
+#include "mainwindow.h"
+#include <QStatusBar>
+
+WebView::WebView(MainWindow *parentMainWindow, QWidget *parent) :
QWebEngineView(parent)
{
+ Q_CHECK_PTR(parentMainWindow);
+ m_parent = parentMainWindow;
+
m_pageMenu = new QMenu();
m_pageMenu->setMinimumWidth(240);
@@ -125,7 +131,37 @@ void WebView::setPage(QWebEnginePage *page)
QWebEngineView::setPage(page);
}
+WebView *WebView::createWindow(QWebEnginePage::WebWindowType type)
+{
+ WebView *view = new WebView(m_parent);
+ switch (type) {
+ case QWebEnginePage::WebBrowserWindow:
+ // a complete web browser window
+ m_parent->newWindow()->tabBar->addTab(view);
+ break;
+
+ case QWebEnginePage::WebBrowserTab:
+ // a web browser tab
+ m_parent->tabBar->setCurrentIndex(m_parent->tabBar->addTab(view));
+ break;
+
+ case QWebEnginePage::WebDialog:
+ // a window without decorations
+ m_parent->newWindow()->tabBar->addTab(view);
+ break;
+
+ case QWebEnginePage::WebBrowserBackgroundTab:
+ // a web browser tab, but don't swap to it
+ m_parent->tabBar->addTab(view);
+ break;
+ }
+
+ return view;
+}
+
void WebView::handleLinkHovered(const QString &url)
{
- emit linkHovered(url);
+ if(isVisible()) {
+ m_parent->statusBar()->showMessage(url);
+ }
}
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index 10654fa..d30a1fd 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -12,11 +12,12 @@
#include <QWebEngineView>
#include <QMenu>
+class MainWindow;
class WebView : public QWebEngineView
{
Q_OBJECT
public:
- explicit WebView(QWidget *parent = nullptr);
+ explicit WebView(MainWindow *parentMainWindow, QWidget *parent = nullptr);
~WebView();
QMenu *pageMenu();
@@ -24,13 +25,16 @@ public:
void setPage(QWebEnginePage *page);
signals:
- void linkHovered(const QString &url);
void newBookmark(const QString &title, const QUrl &url);
+protected:
+ WebView *createWindow(QWebEnginePage::WebWindowType type);
+
private slots:
void handleLinkHovered(const QString &url);
private:
+ MainWindow *m_parent = nullptr;
QMenu *m_pageMenu = nullptr;
};