1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Added new macros for checking QTWEBKIT version.

QTWEBKIT_FROM_2_2 - >= 2.2.0
QTWEBKIT_TO_2_2   - < 2.2.0
QTWEBKIT_FROM_2_3 - >= 2.3.0
QTWEBKIT_TO_2_3   - < 2.2.0

It also check whether Qt5 is used and if so, it will
compile all features just like the QtWebKit version
was 2.3.0
This commit is contained in:
nowrep 2013-01-20 12:10:28 +01:00
parent 489b5bcc2f
commit 14ca6e2f0d
13 changed files with 31 additions and 19 deletions

View File

@ -377,7 +377,7 @@ void MainApplication::loadSettings()
m_websettings->setMaximumPagesInCache(settings.value("maximumCachedPages", 3).toInt()); m_websettings->setMaximumPagesInCache(settings.value("maximumCachedPages", 3).toInt());
m_websettings->setDefaultTextEncoding(settings.value("DefaultEncoding", m_websettings->defaultTextEncoding()).toString()); m_websettings->setDefaultTextEncoding(settings.value("DefaultEncoding", m_websettings->defaultTextEncoding()).toString());
#if QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_FROM_2_3
m_websettings->setAttribute(QWebSettings::CaretBrowsingEnabled, settings.value("CaretBrowsing", false).toBool()); m_websettings->setAttribute(QWebSettings::CaretBrowsingEnabled, settings.value("CaretBrowsing", false).toBool());
m_websettings->setAttribute(QWebSettings::ScrollAnimatorEnabled, settings.value("AnimateScrolling", true).toBool()); m_websettings->setAttribute(QWebSettings::ScrollAnimatorEnabled, settings.value("AnimateScrolling", true).toBool());
#endif #endif
@ -387,7 +387,7 @@ void MainApplication::loadSettings()
m_websettings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true); m_websettings->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);
#endif #endif
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
m_websettings->setAttribute(QWebSettings::HyperlinkAuditingEnabled, true); m_websettings->setAttribute(QWebSettings::HyperlinkAuditingEnabled, true);
m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value("allowJavaScriptCloseWindow", false).toBool()); m_websettings->setAttribute(QWebSettings::JavascriptCanCloseWindows, settings.value("allowJavaScriptCloseWindow", false).toBool());
#endif #endif

View File

@ -407,7 +407,7 @@ void QupZilla::setupMenu()
m_actionCaretBrowsing->setShortcut(QKeySequence("F7")); m_actionCaretBrowsing->setShortcut(QKeySequence("F7"));
connect(m_actionCaretBrowsing, SIGNAL(triggered()), this, SLOT(triggerCaretBrowsing())); connect(m_actionCaretBrowsing, SIGNAL(triggered()), this, SLOT(triggerCaretBrowsing()));
#if QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_FROM_2_3
m_actionCaretBrowsing->setVisible(true); m_actionCaretBrowsing->setVisible(true);
#endif #endif
@ -1093,7 +1093,7 @@ void QupZilla::changeEncoding()
void QupZilla::triggerCaretBrowsing() void QupZilla::triggerCaretBrowsing()
{ {
#if QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_FROM_2_3
bool enable = !mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled); bool enable = !mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled);
Settings settings; Settings settings;

View File

@ -126,4 +126,16 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
#define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG true #define DEFAULT_DOWNLOAD_USE_NATIVE_DIALOG true
#endif #endif
#define QTWEBKIT_FROM_2_2 \
(QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)))
#define QTWEBKIT_TO_2_2 \
(QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 2, 0)))
#define QTWEBKIT_FROM_2_3 \
(QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 3, 0)))
#define QTWEBKIT_TO_2_3 \
(QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 3, 0)))
#endif // QZ_NAMESPACE_H #endif // QZ_NAMESPACE_H

View File

@ -88,7 +88,7 @@ void BookmarksTree::refreshTree()
} }
addTopLevelItem(newItem); addTopLevelItem(newItem);
QTreeWidgetItem* bookmarksToolbar; QTreeWidgetItem* bookmarksToolbar = 0;
if (m_viewType != SideBarView) { if (m_viewType != SideBarView) {
bookmarksToolbar = new QTreeWidgetItem(rootItem); bookmarksToolbar = new QTreeWidgetItem(rootItem);
bookmarksToolbar->setText(0, _bookmarksToolbar); bookmarksToolbar->setText(0, _bookmarksToolbar);

View File

@ -98,7 +98,7 @@ void CookieJar::loadSettings()
m_blacklist = settings.value("blacklist", QStringList()).toStringList(); m_blacklist = settings.value("blacklist", QStringList()).toStringList();
settings.endGroup(); settings.endGroup();
#if QT_VERSION >= 0x050000 || (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_FROM_2_3
mApp->webSettings()->setThirdPartyCookiePolicy(m_blockThirdParty ? mApp->webSettings()->setThirdPartyCookiePolicy(m_blockThirdParty ?
QWebSettings::AlwaysBlockThirdPartyCookies : QWebSettings::AlwaysBlockThirdPartyCookies :
QWebSettings::AlwaysAllowThirdPartyCookies); QWebSettings::AlwaysAllowThirdPartyCookies);
@ -137,7 +137,7 @@ bool CookieJar::rejectCookie(const QString &domain, const QNetworkCookie &cookie
} }
// This feature is now natively in QtWebKit in Qt 5 // This feature is now natively in QtWebKit in Qt 5
#if QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_TO_2_3
if (m_blockThirdParty) { if (m_blockThirdParty) {
bool result = blockThirdParty(cookieDomain, domain); bool result = blockThirdParty(cookieDomain, domain);
if (result) { if (result) {

View File

@ -63,7 +63,7 @@ QString UserAgentManager::userAgentForUrl(const QUrl &url) const
} }
} }
#if QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_TO_2_3
if (host.contains(QLatin1String("google"))) { if (host.contains(QLatin1String("google"))) {
return m_fakeUserAgent; return m_fakeUserAgent;
} }

View File

@ -41,7 +41,7 @@ JsOptions::JsOptions(QWidget* parent)
ui->jscanAccessClipboard->setChecked(settings.value("allowJavaScriptAccessClipboard", false).toBool()); ui->jscanAccessClipboard->setChecked(settings.value("allowJavaScriptAccessClipboard", false).toBool());
settings.endGroup(); settings.endGroup();
#if (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 2, 0)) && QT_VERSION < 0x050000 #if QTWEBKIT_TO_2_2
ui->jscanCloseWindow->setHidden(true); ui->jscanCloseWindow->setHidden(true);
#endif #endif
} }

View File

@ -461,7 +461,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->version->setText(" QupZilla v" + QupZilla::VERSION); ui->version->setText(" QupZilla v" + QupZilla::VERSION);
ui->listWidget->setCurrentRow(currentSettingsPage); ui->listWidget->setCurrentRow(currentSettingsPage);
#if QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_TO_2_3
ui->caretBrowsing->setHidden(true); ui->caretBrowsing->setHidden(true);
ui->animateScrolling->setHidden(true); ui->animateScrolling->setHidden(true);
#endif #endif

View File

@ -12,7 +12,7 @@ HTML5PermissionsManager::HTML5PermissionsManager(QObject *parent)
loadSettings(); loadSettings();
} }
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebFrame *frame, const QWebPage::Feature &feature) void HTML5PermissionsManager::requestPermissions(WebPage* page, QWebFrame *frame, const QWebPage::Feature &feature)
{ {
if (!frame || !page) { if (!frame || !page) {

View File

@ -15,7 +15,7 @@ class QT_QUPZILLA_EXPORT HTML5PermissionsManager : public QObject
public: public:
explicit HTML5PermissionsManager(QObject* parent); explicit HTML5PermissionsManager(QObject* parent);
#ifdef USE_QTWEBKIT_2_2 #if QTWEBKIT_FROM_2_2
void requestPermissions(WebPage* page, QWebFrame* frame, const QWebPage::Feature &feature); void requestPermissions(WebPage* page, QWebFrame* frame, const QWebPage::Feature &feature);
void rememberPermissions(const QString &host, const QWebPage::Feature &feature, void rememberPermissions(const QString &host, const QWebPage::Feature &feature,
const QWebPage::PermissionPolicy &policy); const QWebPage::PermissionPolicy &policy);

View File

@ -6,7 +6,7 @@
#include <QWebFrame> #include <QWebFrame>
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
HTML5PermissionsNotification::HTML5PermissionsNotification(const QString &host, QWebFrame *frame, const QWebPage::Feature &feature) HTML5PermissionsNotification::HTML5PermissionsNotification(const QString &host, QWebFrame *frame, const QWebPage::Feature &feature)
: AnimatedWidget(AnimatedWidget::Down, 300, 0) : AnimatedWidget(AnimatedWidget::Down, 300, 0)
, ui(new Ui::HTML5PermissionsNotification) , ui(new Ui::HTML5PermissionsNotification)
@ -75,4 +75,4 @@ HTML5PermissionsNotification::~HTML5PermissionsNotification()
{ {
delete ui; delete ui;
} }
#endif // (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #endif // QTWEBKIT_FROM_2_2

View File

@ -94,7 +94,7 @@ WebPage::WebPage(QupZilla* mainClass)
connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject())); connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptObject()));
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(featurePermissionRequested(QWebFrame*, QWebPage::Feature))); connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(featurePermissionRequested(QWebFrame*, QWebPage::Feature)));
#endif #endif
@ -392,7 +392,7 @@ void WebPage::windowCloseRequested()
webView->closeView(); webView->closeView();
} }
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
void WebPage::featurePermissionRequested(QWebFrame* frame, const QWebPage::Feature &feature) void WebPage::featurePermissionRequested(QWebFrame* frame, const QWebPage::Feature &feature)
{ {
mApp->html5permissions()->requestPermissions(this, frame, feature); mApp->html5permissions()->requestPermissions(this, frame, feature);

View File

@ -540,7 +540,7 @@ void WebView::bookmarkLink()
void WebView::showSourceOfSelection() void WebView::showSourceOfSelection()
{ {
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
showSource(page()->mainFrame(), selectedHtml()); showSource(page()->mainFrame(), selectedHtml());
#endif #endif
} }
@ -778,7 +778,7 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
mApp->plugins()->populateWebViewMenu(menu, this, hitTest); mApp->plugins()->populateWebViewMenu(menu, this, hitTest);
#if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 2, 0)) #if QTWEBKIT_FROM_2_2
// still bugged? in 4.8 RC (it shows selection of webkit's internal source, not html from page) // still bugged? in 4.8 RC (it shows selection of webkit's internal source, not html from page)
// it may or may not be bug, but this implementation is useless for us // it may or may not be bug, but this implementation is useless for us
// //
@ -1158,7 +1158,7 @@ void WebView::setZoom(int zoom)
bool WebView::eventFilter(QObject* obj, QEvent* event) bool WebView::eventFilter(QObject* obj, QEvent* event)
{ {
// This hack is no longer needed with QtWebKit 2.3 (bundled in Qt 5) // This hack is no longer needed with QtWebKit 2.3 (bundled in Qt 5)
#if QT_VERSION < 0x050000 && (QTWEBKIT_VERSION < QTWEBKIT_VERSION_CHECK(2, 3, 0)) #if QTWEBKIT_TO_2_3
if (obj != this || m_disableTouchMocking) { if (obj != this || m_disableTouchMocking) {
return false; return false;
} }