summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2014-11-28 10:18:38 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2014-12-09 12:07:19 +0100
commit008926f193ceb29da6ca94fae6a7efb3ca0e0f09 (patch)
treea1f33bf5af43a6d1a7552e413d22e1ac86542a8b
parentdd45163e883d9db55ce0361db81b96a0c0f97bd7 (diff)
Assistant: Introduce DEFINES per browser type.
This makes it easier to add additional browser types and switch between browsers. Task-number: QTBUG-41130 Change-Id: I88e2890bfe9e815ed7deb9d867060f244b7e2a45 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: Alejandro Exojo Piqueras <suy@badopi.org>
-rw-r--r--src/assistant/assistant/assistant.pro11
-rw-r--r--src/assistant/assistant/centralwidget.cpp6
-rw-r--r--src/assistant/assistant/findwidget.cpp8
-rw-r--r--src/assistant/assistant/globalactions.cpp10
-rw-r--r--src/assistant/assistant/globalactions.h4
-rw-r--r--src/assistant/assistant/helpviewer.h18
-rw-r--r--src/assistant/assistant/helpviewer_p.h24
-rw-r--r--src/assistant/assistant/main.cpp6
-rw-r--r--src/assistant/assistant/mainwindow.cpp12
-rw-r--r--src/assistant/shared/collectionconfiguration.cpp2
10 files changed, 57 insertions, 44 deletions
diff --git a/src/assistant/assistant/assistant.pro b/src/assistant/assistant/assistant.pro
index a310302fc..48f710351 100644
--- a/src/assistant/assistant/assistant.pro
+++ b/src/assistant/assistant/assistant.pro
@@ -1,8 +1,9 @@
qtHaveModule(webkitwidgets):!contains(QT_CONFIG, static) {
- QT += webkitwidgets
+ BROWSER = qtwebkit
} else {
- DEFINES += QT_NO_WEBKIT
+ BROWSER = qtextbrowser
}
+
QT += widgets network help sql help
qtHaveModule(printsupport): QT += printsupport
PROJECTNAME = Assistant
@@ -74,9 +75,13 @@ SOURCES += aboutdialog.cpp \
openpageswidget.cpp \
openpagesmanager.cpp \
openpagesswitcher.cpp
-qtHaveModule(webkitwidgets):!contains(QT_CONFIG, static) {
+
+equals(BROWSER, "qtwebkit") {
+ DEFINES += BROWSER_QTWEBKIT
+ QT += webkitwidgets
SOURCES += helpviewer_qwv.cpp
} else {
+ DEFINES += BROWSER_QTEXTBROWSER
SOURCES += helpviewer_qtb.cpp
}
diff --git a/src/assistant/assistant/centralwidget.cpp b/src/assistant/assistant/centralwidget.cpp
index 50b59bd96..6b2592e63 100644
--- a/src/assistant/assistant/centralwidget.cpp
+++ b/src/assistant/assistant/centralwidget.cpp
@@ -607,7 +607,7 @@ void CentralWidget::initPrinter()
void CentralWidget::connectSignals(HelpViewer *page)
{
TRACE_OBJ
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
connect(page, SIGNAL(printRequested()), this, SLOT(print()));
#endif
connect(page, SIGNAL(copyAvailable(bool)), this,
@@ -631,10 +631,10 @@ bool CentralWidget::eventFilter(QObject *object, QEvent *e)
QKeyEvent *keyEvent = static_cast<QKeyEvent*> (e);
if (viewer == object && keyEvent->key() == Qt::Key_Backspace) {
if (viewer->isBackwardAvailable()) {
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
// this helps in case there is an html <input> field
if (!viewer->hasFocus())
-#endif
+#endif // BROWSER_QTWEBKIT
viewer->backward();
}
}
diff --git a/src/assistant/assistant/findwidget.cpp b/src/assistant/assistant/findwidget.cpp
index 082bb9134..036ce993b 100644
--- a/src/assistant/assistant/findwidget.cpp
+++ b/src/assistant/assistant/findwidget.cpp
@@ -157,11 +157,11 @@ void FindWidget::setTextWrappedVisible(bool visible)
void FindWidget::hideEvent(QHideEvent* event)
{
TRACE_OBJ
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
// TODO: remove this once webkit supports setting the palette
if (!event->spontaneous())
qApp->setPalette(appPalette);
-#else
+#else // BROWSER_QTWEBKIT
Q_UNUSED(event);
#endif
}
@@ -169,7 +169,7 @@ void FindWidget::hideEvent(QHideEvent* event)
void FindWidget::showEvent(QShowEvent* event)
{
TRACE_OBJ
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
// TODO: remove this once webkit supports setting the palette
if (!event->spontaneous()) {
QPalette p = appPalette;
@@ -179,7 +179,7 @@ void FindWidget::showEvent(QShowEvent* event)
p.color(QPalette::Active, QPalette::HighlightedText));
qApp->setPalette(p);
}
-#else
+#else // BROWSER_QTWEBKIT
Q_UNUSED(event);
#endif
}
diff --git a/src/assistant/assistant/globalactions.cpp b/src/assistant/assistant/globalactions.cpp
index b683392ab..4b33fa419 100644
--- a/src/assistant/assistant/globalactions.cpp
+++ b/src/assistant/assistant/globalactions.cpp
@@ -40,8 +40,8 @@
#include <QtWidgets/QAction>
#include <QtWidgets/QMenu>
-#if !defined(QT_NO_WEBKIT)
-#include <QWebHistory>
+#if defined(BROWSER_QTWEBKIT)
+# include <QWebHistory>
#endif
GlobalActions *GlobalActions::instance(QObject *parent)
@@ -160,7 +160,7 @@ void GlobalActions::setCopyAvailable(bool available)
m_copyAction->setEnabled(available);
}
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
void GlobalActions::slotAboutToShowBackMenu()
{
@@ -209,12 +209,12 @@ void GlobalActions::slotOpenActionUrl(QAction *action)
}
}
-#endif
+#endif // BROWSER_QTWEBKIT
void GlobalActions::setupNavigationMenus(QAction *back, QAction *next,
QWidget *parent)
{
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
m_backMenu = new QMenu(parent);
connect(m_backMenu, SIGNAL(aboutToShow()), this,
SLOT(slotAboutToShowBackMenu()));
diff --git a/src/assistant/assistant/globalactions.h b/src/assistant/assistant/globalactions.h
index 772d7caa2..b7f13379e 100644
--- a/src/assistant/assistant/globalactions.h
+++ b/src/assistant/assistant/globalactions.h
@@ -62,12 +62,12 @@ public:
Q_SLOT void updateActions();
Q_SLOT void setCopyAvailable(bool available);
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
private slots:
void slotAboutToShowBackMenu();
void slotAboutToShowNextMenu();
void slotOpenActionUrl(QAction *action);
-#endif
+#endif // BROWSER_QTWEBKIT
private:
void setupNavigationMenus(QAction *back, QAction *next, QWidget *parent);
diff --git a/src/assistant/assistant/helpviewer.h b/src/assistant/assistant/helpviewer.h
index 9e268b0a0..e9deaf389 100644
--- a/src/assistant/assistant/helpviewer.h
+++ b/src/assistant/assistant/helpviewer.h
@@ -42,19 +42,19 @@
#include <QtWidgets/QAction>
#include <QtGui/QFont>
-#if defined(QT_NO_WEBKIT)
-#include <QtWidgets/QTextBrowser>
-#else
-#include <QWebView>
+#if defined(BROWSER_QTWEBKIT)
+# include <QWebView>
+#elif defined(BROWSER_QTEXTBROWSER)
+# include <QtWidgets/QTextBrowser>
#endif
QT_BEGIN_NAMESPACE
class HelpEngineWrapper;
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
class HelpViewer : public QWebView
-#else
+#elif defined(BROWSER_QTEXTBROWSER)
class HelpViewer : public QTextBrowser
#endif
{
@@ -114,14 +114,16 @@ public slots:
signals:
void titleChanged();
-#if !defined(QT_NO_WEBKIT)
+#if !defined(BROWSER_QTEXTBROWSER)
+ // Provide signals present in QTextBrowser, QTextEdit for browsers that do not inherit QTextBrowser
void copyAvailable(bool yes);
void sourceChanged(const QUrl &url);
void forwardAvailable(bool enabled);
void backwardAvailable(bool enabled);
void highlighted(const QString &link);
void printRequested();
-#else
+#elif !defined(BROWSER_QTWEBKIT)
+ // Provide signals present in QWebView for browsers that do not inherit QWebView
void loadStarted();
void loadFinished(bool finished);
#endif
diff --git a/src/assistant/assistant/helpviewer_p.h b/src/assistant/assistant/helpviewer_p.h
index b9a8b0187..79992de71 100644
--- a/src/assistant/assistant/helpviewer_p.h
+++ b/src/assistant/assistant/helpviewer_p.h
@@ -39,12 +39,12 @@
#include "openpagesmanager.h"
#include <QtCore/QObject>
-#ifdef QT_NO_WEBKIT
-#include <QtWidgets/QTextBrowser>
-#else
-#include <QtGui/QGuiApplication>
-#include <QtGui/QScreen>
-#endif
+#if defined(BROWSER_QTEXTBROWSER)
+# include <QtWidgets/QTextBrowser>
+#elif defined(BROWSER_QTWEBKIT)
+# include <QtGui/QGuiApplication>
+# include <QtGui/QScreen>
+#endif // BROWSER_QTWEBKIT
QT_BEGIN_NAMESPACE
@@ -53,14 +53,14 @@ class HelpViewer::HelpViewerPrivate : public QObject
Q_OBJECT
public:
-#ifdef QT_NO_WEBKIT
+#if defined(BROWSER_QTEXTBROWSER)
HelpViewerPrivate(int zoom)
: zoomCount(zoom)
, forceFont(false)
, lastAnchor(QString())
, m_loadFinished(false)
{ }
-#else
+#elif defined(BROWSER_QTWEBKIT)
HelpViewerPrivate()
: m_loadFinished(false)
{
@@ -73,9 +73,9 @@ public:
if (webDpiRatio < 1.25)
webDpiRatio = 1.0;
}
-#endif
+#endif // BROWSER_QTWEBKIT
-#ifdef QT_NO_WEBKIT
+#if defined(BROWSER_QTEXTBROWSER)
bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos)
{
lastAnchor = browser->anchorAt(pos);
@@ -117,9 +117,9 @@ public:
int zoomCount;
bool forceFont;
QString lastAnchor;
-#else
+#elif defined(BROWSER_QTWEBKIT)
qreal webDpiRatio;
-#endif // QT_NO_WEBKIT
+#endif // BROWSER_QTWEBKIT
public:
bool m_loadFinished;
diff --git a/src/assistant/assistant/main.cpp b/src/assistant/assistant/main.cpp
index e4d5a4f38..0957f618a 100644
--- a/src/assistant/assistant/main.cpp
+++ b/src/assistant/assistant/main.cpp
@@ -51,7 +51,7 @@
#include <QtSql/QSqlDatabase>
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
#include <QtGui/QFont>
#include <QWebSettings>
#endif
@@ -308,13 +308,13 @@ int main(int argc, char *argv[])
a->addLibraryPath(a->applicationDirPath() + QLatin1String("/plugins"));
setupTranslations();
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
if (qobject_cast<QApplication *>(a.data())) {
QFont f;
f.setStyleHint(QFont::SansSerif);
QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, f.defaultFamily());
}
-#endif
+#endif // BROWSER_QTWEBKIT
// Parse arguments.
CmdLineParser cmd(a->arguments());
diff --git a/src/assistant/assistant/mainwindow.cpp b/src/assistant/assistant/mainwindow.cpp
index 8b7afc746..3b7cfe802 100644
--- a/src/assistant/assistant/mainwindow.cpp
+++ b/src/assistant/assistant/mainwindow.cpp
@@ -891,11 +891,17 @@ void MainWindow::showAboutDialog()
aboutDia.setWindowTitle(aboutDia.documentTitle());
} else {
QByteArray resources;
+#if defined(BROWSER_QTWEBKIT)
+ const QString browser = QStringLiteral("Qt WebKit");
+#else
+ const QString browser = QStringLiteral("QTextBrowser");
+#endif
aboutDia.setText(tr("<center>"
"<h3>%1</h3>"
- "<p>Version %2</p></center>"
- "<p>Copyright (C) %3 Digia Plc and/or its subsidiary(-ies).</p>")
- .arg(tr("Qt Assistant"), QLatin1String(QT_VERSION_STR), QStringLiteral("2014")),
+ "<p>Version %2</p>"
+ "<p>Browser: %3</p></center>"
+ "<p>Copyright (C) %4 Digia Plc and/or its subsidiary(-ies).</p>")
+ .arg(tr("Qt Assistant"), QLatin1String(QT_VERSION_STR), browser, QStringLiteral("2014")),
resources);
QLatin1String path(":/qt-project.org/assistant/images/assistant-128.png");
aboutDia.setPixmap(QString(path));
diff --git a/src/assistant/shared/collectionconfiguration.cpp b/src/assistant/shared/collectionconfiguration.cpp
index e15f5077d..0effe2ddf 100644
--- a/src/assistant/shared/collectionconfiguration.cpp
+++ b/src/assistant/shared/collectionconfiguration.cpp
@@ -56,7 +56,7 @@ namespace {
const QString LastRegisterTime(QLatin1String("LastRegisterTime"));
const QString LastShownPagesKey(QLatin1String("LastShownPages"));
const QString LastZoomFactorsKey(QLatin1String(
-#if !defined(QT_NO_WEBKIT)
+#if defined(BROWSER_QTWEBKIT)
"LastPagesZoomWebView"
#else
"LastPagesZoomTextBrowser"