A simple Qt based browser with no bullshit that supports PKCS#11 tokens (such as the SuisseID).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

80 lines
2.4 KiB

/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
#ifndef WEBVIEW_HXX
#define WEBVIEW_HXX
#include <qbrowserlib/webpage.hxx>
#include <QtWebKit>
#include <QWebView>
#include <memory>
//! @addtogroup qbrowserlib
//! @{
namespace qbrowserlib {
//! QWebViev class with additional features.
/*! This QWebView class contains a @ref WebPage and adds a new
signal @refs newView that sends the view whenever the a new view
(new window, new tab) must be opened.
\copydetails WebView::newView(WebView*)
*/
class WebView: public QWebView {
Q_OBJECT;
Q_SIGNALS:
//! Signals that a new window (or tab) must be opened
/*! @note You @b must connect to @ref newView and assign the new
@ref WebView instance to a partent widget or at least
delete it, otherwise you'll have a memory leak! */
void newView(qbrowserlib::WebView*);
public:
//! Default construction, creates new @ref WebView
WebView(QWidget *parent=0,
QNetworkAccessManager* net=0): QWebView(parent) {
if (!net) net = (_fallbackNetworkAccessManager =
std::auto_ptr<QNetworkAccessManager>
(new QNetworkAccessManager)).get();
//! @bugfix, gcc does not yet support constructor calling
x(new WebPage(net, this));
}
//! Construction with externally allocated @ref WebPage
/*! WebView takes ownership of WebPage. */
WebView(WebPage* webpage) {
//! @bugfix, gcc does not yet support constructor calling
x(webpage);
}
private:
//! @bugfix, gcc does not yet support constructor calling
/*! @see http://en.wikipedia.org/wiki/C++11#Object_construction_improvement
*/
void x(WebPage* webpage) {
webpage->setParent(this);
setPage(webpage);
// create a new WebView when a new WebPage has been created
assert(connect(page(), SIGNAL(newPage(WebPage*)),
SLOT(newPage(WebPage*))));
}
private Q_SLOTS:
void newPage(WebPage* p) {
// memory will be lost if signal is not handled and WebView
// is not assigned
newView(new WebView(p));
}
private:
std::auto_ptr<QNetworkAccessManager> _fallbackNetworkAccessManager;
};
}
//! @}
#endif