From: Marcus Eggenberger Date: Sat, 27 Sep 2008 11:47:14 +0000 (+0200) Subject: making webkit optional X-Git-Tag: 0.3.1~234 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=e65e46d007d7f5f59274590dec3bc1d8e5f94e91 making webkit optional --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8462db8a..dd3355b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ option(WANT_MONO "Build the monolithic (all-in-one) binary" OFF) option(WITH_OPENSSL "Enable OpenSSL support if present on the system" ON) option(WITH_DBUS "Enable D-Bus support if present on the system" ON) +option(WITH_WEBKIT "Enable WebKit support if present on the system" ON) option(STATIC "Enable static building (might not be portable)" OFF) option(DEPLOY "Mac OS X only! Adds required libs to bundle resources and create a dmg. Note: requires Qt to be built with 10.4u SDK" OFF) @@ -133,6 +134,22 @@ else(WITH_DBUS) message(STATUS "Disabling D-Bus support") endif(WITH_DBUS) +# Setup QtWebKit support +if(WITH_WEBKIT) + if(QT_QTWEBKIT_FOUND) + message(STATUS "Found QtWebKit, enabling WebKit support") + add_definitions(-DHAVE_WEBKIT) + set(LINK_WEBKIT WEBKIT) + set(HAVE_WEBKIT true) + set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_WEBKIT) + else(QT_QTWEBKIT_FOUND) + message(STATUS "QtWebKit not found, disabling D-Bus support") + endif(QT_QTWEBKIT_FOUND) +else(WITH_WEBKIT) + message(STATUS "Disabling WebKit support") +endif(WITH_WEBKIT) + + # Set global buildflags # This is very much non-portable, so don't use -DSTATIC until you know what # you do. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c4f652af..7b2ca4aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,7 @@ if(WANT_CORE) endif(WANT_CORE) if(WANT_QTCLIENT) - setup_qt4_variables(${LINK_DBUS} GUI NETWORK WEBKIT) + setup_qt4_variables(${LINK_DBUS} GUI NETWORK ${LINK_WEBKIT}) add_executable(quasselclient WIN32 common/main.cpp ${COMMON_DEPS} ${CLIENT_DEPS}) add_dependencies(quasselclient icons) set_target_properties(quasselclient PROPERTIES @@ -50,7 +50,7 @@ if(WANT_QTCLIENT) endif(WANT_QTCLIENT) if(WANT_MONO) - setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL WEBKIT) + setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL ${LINK_WEBKIT}) add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS}) add_dependencies(quassel icons) set_target_properties(quassel PROPERTIES diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 2ee0aa47..399d0de4 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -47,7 +47,6 @@ set(MOC_HDRS aboutdlg.h bufferwidget.h channellistdlg.h - chatitem.h chatlinemodel.h chatmonitorfilter.h chatmonitorview.h @@ -75,6 +74,10 @@ set(MOC_HDRS topicwidget.h verticaldock.h) +if(HAVE_WEBKIT) + set(MOC_HDRS ${MOC_HDRS} chatitem.h) +endif(HAVE_WEBKIT) + set(HEADERS chatline.h chatlinemodelitem.h @@ -82,6 +85,10 @@ set(HEADERS qtuisettings.h qtuistyle.h) +if(NOT HAVE_WEBKIT) + set(HEADERS ${HEADERS} chatitem.h) +endif(NOT HAVE_WEBKIT) + set(FORMS aboutdlg.ui bufferviewwidget.ui diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 758de8d0..7e26f000 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -26,7 +26,9 @@ #include #include #include +#ifdef HAVE_WEBKIT #include +#endif #include #include "chatitem.h" @@ -381,7 +383,9 @@ void ContentsChatItem::endHoverMode() { if(hasLayout() && privateData()->currentClickable.isValid()) { setCursor(Qt::ArrowCursor); privateData()->currentClickable = Clickable(); +#ifdef HAVE_WEBKIT privateData()->clearPreview(); +#endif update(); } } @@ -441,6 +445,7 @@ void ContentsChatItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { if(!hasLayout()) updateLayout(); +#ifdef HAVE_WEBKIT QTextLine line = layout()->lineForTextPosition(click.start); qreal x = line.cursorToX(click.start); qreal width = line.cursorToX(click.start + click.length) - x; @@ -451,6 +456,7 @@ void ContentsChatItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { if(!url.contains("://")) url = "http://" + url; privateData()->loadWebPreview(url, urlRect); +#endif } else if(click.type == Clickable::Channel) { // TODO: don't make clickable if it's our own name //onClickable = true; //FIXME disabled for now @@ -471,9 +477,12 @@ void ContentsChatItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { // ContentsChatItemPrivate // **************************************** ContentsChatItemPrivate::~ContentsChatItemPrivate() { +#ifdef HAVE_WEBKIT clearPreview(); +#endif } +#ifdef HAVE_WEBKIT void ContentsChatItemPrivate::loadWebPreview(const QString &url, const QRectF &urlRect) { if(!controller) controller = new PreviewController(contentsItem); @@ -549,6 +558,7 @@ void ContentsChatItemPrivate::PreviewItem::paint(QPainter *painter, const QStyle QString text = QString::number(zValue()); painter->drawText(_boundingRect.center(), text); } +#endif // #ifdef HAVE_WEBKIT /*************************************************************************************************/ diff --git a/src/qtui/chatitem.h b/src/qtui/chatitem.h index b6e8a9cf..f572bb44 100644 --- a/src/qtui/chatitem.h +++ b/src/qtui/chatitem.h @@ -202,9 +202,14 @@ struct ContentsChatItemPrivate : ChatItemPrivate { ContentsChatItem::Clickable currentClickable; bool hasDragged; +#ifdef HAVE_WEBKIT ContentsChatItemPrivate(QTextLayout *l, const QList &c, ContentsChatItem *parent) : ChatItemPrivate(l), contentsItem(parent), clickables(c), hasDragged(false), controller(0) {} +#else + ContentsChatItemPrivate(QTextLayout *l, const QList &c, ContentsChatItem *parent) : ChatItemPrivate(l), contentsItem(parent), clickables(c), hasDragged(false) {} +#endif ~ContentsChatItemPrivate(); +#ifdef HAVE_WEBKIT void loadWebPreview(const QString &url, const QRectF &urlRect); void clearPreview(); @@ -212,8 +217,10 @@ private: class PreviewController; class PreviewItem; PreviewController *controller; +#endif //#ifdef HAVE_WEBKIT }; +#ifdef HAVE_WEBKIT class ContentsChatItemPrivate::PreviewController : public QObject { Q_OBJECT public: @@ -242,6 +249,7 @@ public: private: QRectF _boundingRect; }; +#endif //#ifdef HAVE_WEBKIT //inlines regarding ContentsChatItemPrivate ContentsChatItemPrivate *ContentsChatItem::privateData() const { return (ContentsChatItemPrivate *)ChatItem::privateData(); }