summaryrefslogblamecommitdiffstats
path: root/src/webview.h
blob: 9d7e28d77d0dab18c6a64f30bb7bc303db792bb0 (plain) (tree)
1
2
3
4
5
6
7
8
9




                   



                          






                                                                                       
        
       




                                          
         
 




                                                        


                                                


                           

                              


      
#ifndef WEBVIEW_H_
#define WEBVIEW_H_

#include <QStack>
#include <QWebView>
#include <QNetworkRequest>

class QNetworkReply;
class QTimer;

/**
 * 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);
	bool wasAbortedDownload() {
		bool r = _abortedDownload;
		_abortedDownload = false;
		return r;
	}

protected:
	QWebView *createWindow(QWebPage::WebWindowType);

protected slots:
	void windowCloseRequested();
	void unsupportedContent(QNetworkReply*);
	void downloadRequest(QNetworkRequest);
	void downloadDeniedMessage();

private:
	QStack<QUrl> _urls;
	QTimer *_timer;
	bool _abortedDownload;
};

#endif