summaryrefslogtreecommitdiffstats
path: root/src/webview.h
blob: 753c9840f8e721b3f1975d9b387ef8d865484ccf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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