summaryrefslogtreecommitdiffstats
path: root/src/webview.h
diff options
context:
space:
mode:
authorSimon Rettberg2017-07-07 15:21:28 +0200
committerSimon Rettberg2017-07-07 15:21:28 +0200
commitf5663edb4e1a53b6d80de909f2888ffd9ee1e170 (patch)
treef776b8e929bc356c215fafc46e6548ffe957e7f9 /src/webview.h
downloadslxbrowser-f5663edb4e1a53b6d80de909f2888ffd9ee1e170.tar.gz
slxbrowser-f5663edb4e1a53b6d80de909f2888ffd9ee1e170.tar.xz
slxbrowser-f5663edb4e1a53b6d80de909f2888ffd9ee1e170.zip
FIRST!!!1
Diffstat (limited to 'src/webview.h')
-rw-r--r--src/webview.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/webview.h b/src/webview.h
new file mode 100644
index 0000000..753c984
--- /dev/null
+++ b/src/webview.h
@@ -0,0 +1,28 @@
+#ifndef WEBVIEW_H_
+#define WEBVIEW_H_
+
+#include <QStack>
+#include <QWebView>
+
+/**
+ * Make sure pages that want to load in a new tab are actually loaded in the same page,
+ * and remember the previous URL in case the "new tab" requests to be closed.
+ */
+class WebView : public QWebView
+{
+ Q_OBJECT
+public:
+ WebView(QWidget* parent = NULL) : QWebView(parent) {
+ connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));
+ }
+protected:
+ QWebView *createWindow(QWebPage::WebWindowType);
+
+protected slots:
+ void windowCloseRequested();
+
+private:
+ QStack<QUrl> _urls;
+};
+
+#endif