rename webpage and webview to swisswebpage and swissswebview to be more specific; refs #115
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
#include <errorlog.hxx>
|
#include <errorlog.hxx>
|
||||||
#include <downloadmanager.hxx>
|
#include <downloadmanager.hxx>
|
||||||
#include <authentication.hxx>
|
#include <authentication.hxx>
|
||||||
#include <qbrowserlib/webview.hxx>
|
#include <qbrowserlib/swisswebview.hxx>
|
||||||
#include <settings.hxx>
|
#include <settings.hxx>
|
||||||
#include <editbookmarks.hxx>
|
#include <editbookmarks.hxx>
|
||||||
#include <temporaryfile.hxx>
|
#include <temporaryfile.hxx>
|
||||||
@@ -222,8 +222,8 @@ class Browser: public QMainWindow, protected Ui::Browser {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebView* newTab() {
|
SwissWebView* newTab() {
|
||||||
WebView* browser(new WebView);
|
SwissWebView* browser(new SwissWebView);
|
||||||
newTab(browser);
|
newTab(browser);
|
||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
@@ -277,14 +277,14 @@ class Browser: public QMainWindow, protected Ui::Browser {
|
|||||||
view->load(page);
|
view->load(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
void newTab(WebView* browser) {
|
void newTab(SwissWebView* browser) {
|
||||||
browser->page()->setNetworkAccessManager(&_networkManager);
|
browser->page()->setNetworkAccessManager(&_networkManager);
|
||||||
assert(connect(&_networkManager, SIGNAL(finished(QNetworkReply*)),
|
assert(connect(&_networkManager, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(finished(QNetworkReply*))));
|
SLOT(finished(QNetworkReply*))));
|
||||||
_url->setFocus();
|
_url->setFocus();
|
||||||
// WebView
|
// SwissWebView
|
||||||
assert(connect(browser, SIGNAL(newView(WebView*)),
|
assert(connect(browser, SIGNAL(newView(SwissWebView*)),
|
||||||
SLOT(newTab(WebView*))));
|
SLOT(newTab(SwissWebView*))));
|
||||||
// QWebView
|
// QWebView
|
||||||
assert(connect(browser, SIGNAL(urlChanged(const QUrl&)),
|
assert(connect(browser, SIGNAL(urlChanged(const QUrl&)),
|
||||||
SLOT(urlChanged(const QUrl&))));
|
SLOT(urlChanged(const QUrl&))));
|
||||||
|
@@ -7,4 +7,4 @@
|
|||||||
|
|
||||||
#include <webviewwidgetifc.hxx>
|
#include <webviewwidgetifc.hxx>
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(webviewwidgetplugin, WebViewWidgetIfc);
|
Q_EXPORT_PLUGIN2(swisswebviewwidgetplugin, SwissWebViewWidgetIfc);
|
||||||
|
@@ -8,13 +8,14 @@
|
|||||||
#ifndef __WEBVIEWWIDGETIFC_HXX
|
#ifndef __WEBVIEWWIDGETIFC_HXX
|
||||||
#define __WEBVIEWWIDGETIFC_HXX
|
#define __WEBVIEWWIDGETIFC_HXX
|
||||||
|
|
||||||
#include <qbrowserlib/webview.hxx>
|
#include <qbrowserlib/swisswebview.hxx>
|
||||||
#include <QtDesigner>
|
#include <QtDesigner>
|
||||||
|
|
||||||
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
||||||
|
|
||||||
//! WebView widget for Qt Designer
|
//! WebView widget for Qt Designer
|
||||||
class WebViewWidgetIfc: public QObject, public QDesignerCustomWidgetInterface {
|
class SwissWebViewWidgetIfc: public QObject,
|
||||||
|
public QDesignerCustomWidgetInterface {
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
Q_INTERFACES(QDesignerCustomWidgetInterface);
|
Q_INTERFACES(QDesignerCustomWidgetInterface);
|
||||||
public:
|
public:
|
||||||
@@ -51,7 +52,7 @@ class WebViewWidgetIfc: public QObject, public QDesignerCustomWidgetInterface {
|
|||||||
}
|
}
|
||||||
QString name() const {
|
QString name() const {
|
||||||
LOG;
|
LOG;
|
||||||
return "WebView";
|
return "SwissWebView";
|
||||||
}
|
}
|
||||||
QString toolTip() const {
|
QString toolTip() const {
|
||||||
LOG;
|
LOG;
|
||||||
@@ -63,7 +64,7 @@ class WebViewWidgetIfc: public QObject, public QDesignerCustomWidgetInterface {
|
|||||||
}
|
}
|
||||||
QWidget *createWidget(QWidget *parent) {
|
QWidget *createWidget(QWidget *parent) {
|
||||||
LOG;
|
LOG;
|
||||||
return new WebView(parent);
|
return new SwissWebView(parent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ TRANSLATIONS = @srcdir@/qbrowserlib_en.ts \
|
|||||||
|
|
||||||
SOURCES =
|
SOURCES =
|
||||||
|
|
||||||
HEADERS = @srcdir@/webview.hxx @srcdir@/webpage.hxx \
|
HEADERS = @srcdir@/swisswebview.hxx @srcdir@/swisswebpage.hxx \
|
||||||
@srcdir@/pluginfactory.hxx @srcdir@/saveorrun.hxx
|
@srcdir@/pluginfactory.hxx @srcdir@/saveorrun.hxx
|
||||||
|
|
||||||
FORMS = @srcdir@/saveorrun.ui
|
FORMS = @srcdir@/saveorrun.ui
|
||||||
|
@@ -5,8 +5,10 @@
|
|||||||
// 1 2 3 4 5 6 7 8
|
// 1 2 3 4 5 6 7 8
|
||||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
#ifndef __WEBPAGE_HXX__
|
#ifndef __SWISSWEBPAGE_HXX__
|
||||||
#define __WEBPAGE_HXX__
|
#define __SWISSWEBPAGE_HXX__
|
||||||
|
|
||||||
|
#include <qbrowserlib/pluginfactory.hxx>
|
||||||
|
|
||||||
#include <QtWebKit/QWebPage>
|
#include <QtWebKit/QWebPage>
|
||||||
#include <QtCore/QProcessEnvironment>
|
#include <QtCore/QProcessEnvironment>
|
||||||
@@ -16,18 +18,31 @@
|
|||||||
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
#define LOG qDebug()<<__PRETTY_FUNCTION__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class WebPage: public QWebPage {
|
//! QWebPage with additional features and better default behaviour.
|
||||||
|
/*! SwissWebPage is designed to be used by SwissWebView.
|
||||||
|
|
||||||
|
This QWebPage supports the folloing additional features:
|
||||||
|
- Handling of plugins through PluginFactory
|
||||||
|
- Processing of unsupportedContent
|
||||||
|
- Delegation of all links
|
||||||
|
- Signals @ref newPage if a new window should be created
|
||||||
|
- Set useragent from environment variable @c SWISS_USERAGENT */
|
||||||
|
class SwissWebPage: public QWebPage {
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
signals:
|
signals:
|
||||||
void newPage(WebPage*);
|
void newPage(SwissWebPage*);
|
||||||
public:
|
public:
|
||||||
WebPage(QObject *parent = 0): QWebPage(parent) {}
|
SwissWebPage(QObject *parent = 0): QWebPage(parent) {
|
||||||
|
setPluginFactory(new PluginFactory);
|
||||||
|
setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
||||||
|
setForwardUnsupportedContent(true);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual QWebPage* createWindow(WebWindowType type) {
|
virtual QWebPage* createWindow(WebWindowType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QWebPage::WebBrowserWindow:
|
case QWebPage::WebBrowserWindow:
|
||||||
case QWebPage::WebModalDialog: {
|
case QWebPage::WebModalDialog: {
|
||||||
WebPage *page(new WebPage);
|
SwissWebPage *page(new SwissWebPage);
|
||||||
newPage(page);
|
newPage(page);
|
||||||
return page;
|
return page;
|
||||||
} break;
|
} break;
|
||||||
@@ -36,7 +51,7 @@ class WebPage: public QWebPage {
|
|||||||
}
|
}
|
||||||
virtual QString userAgentForUrl(const QUrl& url) const {
|
virtual QString userAgentForUrl(const QUrl& url) const {
|
||||||
QString add(QProcessEnvironment::systemEnvironment()
|
QString add(QProcessEnvironment::systemEnvironment()
|
||||||
.value("SWISSSURFER_USERAGENT"));
|
.value("SWISS_USERAGENT"));
|
||||||
return QWebPage::userAgentForUrl(url)+(add.size()?" "+add:QString());
|
return QWebPage::userAgentForUrl(url)+(add.size()?" "+add:QString());
|
||||||
}
|
}
|
||||||
QObject* createPlugin(const QString& classid, const QUrl& url,
|
QObject* createPlugin(const QString& classid, const QUrl& url,
|
64
src/qbrowserlib/swisswebview.hxx
Normal file
64
src/qbrowserlib/swisswebview.hxx
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*! @file
|
||||||
|
|
||||||
|
@id $Id$
|
||||||
|
*/
|
||||||
|
// 1 2 3 4 5 6 7 8
|
||||||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||||
|
|
||||||
|
#ifndef SWISSWEBVIEW_HXX
|
||||||
|
#define SWISSWEBVIEW_HXX
|
||||||
|
|
||||||
|
#include <qbrowserlib/swisswebpage.hxx>
|
||||||
|
|
||||||
|
#include <QtWebKit>
|
||||||
|
#include <QtDesigner/QDesignerExportWidget>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
//! QWebViev class with additional features.
|
||||||
|
/*! This QWebView class contains a @ref SwissWebPage and adds a new
|
||||||
|
signal @refs newView that sends the view whenever the a new view
|
||||||
|
(new window, new tab) must be opened.
|
||||||
|
|
||||||
|
\copydetails SwissWebView::newView(SwissWebView*)
|
||||||
|
*/
|
||||||
|
class QDESIGNER_WIDGET_EXPORT SwissWebView: public QWebView {
|
||||||
|
Q_OBJECT;
|
||||||
|
signals:
|
||||||
|
//! Signals that a new window (or tab) must be opened
|
||||||
|
/*! @note You @b must connect to @ref newView and assign the new
|
||||||
|
@ref SwissWebView instance to a partent widget or at least
|
||||||
|
delete it, otherwise you'll have a memory leak! */
|
||||||
|
void newView(SwissWebView*);
|
||||||
|
public:
|
||||||
|
//! Default construction, creates new @ref SwissWebView
|
||||||
|
SwissWebView(QWidget *parent=0): QWebView(parent) {
|
||||||
|
//! @bugfix, gcc does not yet support constructor calling
|
||||||
|
x(new SwissWebPage);
|
||||||
|
}
|
||||||
|
//! Construction with externally allocated @ref SwissWebPage
|
||||||
|
/*! SwissWebView takes ownership of SwissWebPage. */
|
||||||
|
SwissWebView(SwissWebPage* 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(SwissWebPage* webpage) {
|
||||||
|
webpage->setParent(this);
|
||||||
|
setPage(webpage);
|
||||||
|
// create a new SwissWebView when a new SwissWebPage has been created
|
||||||
|
assert(connect(page(), SIGNAL(newPage(SwissWebPage*)),
|
||||||
|
SLOT(newPage(SwissWebPage*))));
|
||||||
|
}
|
||||||
|
private slots:
|
||||||
|
void newPage(SwissWebPage* p) {
|
||||||
|
// memory will be lost if signal is not handled and SwissWebView
|
||||||
|
// is not assigned
|
||||||
|
newView(new SwissWebView(p));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@@ -1,49 +0,0 @@
|
|||||||
/*! @file
|
|
||||||
|
|
||||||
@id $Id$
|
|
||||||
*/
|
|
||||||
// 1 2 3 4 5 6 7 8
|
|
||||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
|
||||||
|
|
||||||
#ifndef WEBVIEW_HXX
|
|
||||||
#define WEBVIEW_HXX
|
|
||||||
|
|
||||||
#include <qbrowserlib/webpage.hxx>
|
|
||||||
#include <qbrowserlib/pluginfactory.hxx>
|
|
||||||
|
|
||||||
#include <QtWebKit>
|
|
||||||
#include <QtDesigner/QDesignerExportWidget>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class QDESIGNER_WIDGET_EXPORT WebView: public QWebView {
|
|
||||||
Q_OBJECT;
|
|
||||||
signals:
|
|
||||||
void newView(WebView*);
|
|
||||||
public:
|
|
||||||
WebView(WebPage* webpage) {
|
|
||||||
x(webpage); //! @bugfix, gcc does not yet support constructor calling
|
|
||||||
}
|
|
||||||
WebView(QWidget *parent=0): QWebView(parent) {
|
|
||||||
x(new WebPage); //! @bugfix, gcc does not yet support constructor calling
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
page()->setPluginFactory(new PluginFactory);
|
|
||||||
page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
|
|
||||||
page()->setForwardUnsupportedContent(true);
|
|
||||||
assert(connect(page(), SIGNAL(newPage(WebPage*)),
|
|
||||||
SLOT(newPage(WebPage*))));
|
|
||||||
}
|
|
||||||
private slots:
|
|
||||||
void newPage(WebPage* p) {
|
|
||||||
newView(new WebView(p));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Reference in New Issue
Block a user