summaryrefslogblamecommitdiffstats
path: root/src/webview.h
blob: 79b4a644f787c8f8843da6164bf46f00e1f0b004 (plain) (tree)











































                                                                                       
#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);
        void reset(const QString baseUrl);

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

signals:
        void triggerReset(const QString &message);
        void startAuthentication(const QString &user, const QString &pass);

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

private:
	QStack<QUrl> _urls;
        QTimer *_timerAbortMessage;
	bool _abortedDownload;
        QString _token;
        QTimer *_timerReset;
};

#endif