Skip to content

Commit

Permalink
Remove the remaining dependencies onto QtWidgets
Browse files Browse the repository at this point in the history
Change-Id: I49efc4d0af4c19c24515ecfaa5c549e36f442cc8
Reviewed-on: http://codereview.qt.nokia.com/3992
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
  • Loading branch information
Lars Knoll committed Sep 1, 2011
1 parent e4ba808 commit 1259c57
Show file tree
Hide file tree
Showing 38 changed files with 84 additions and 99 deletions.
2 changes: 1 addition & 1 deletion modules/qt_declarative.pri
Expand Up @@ -11,7 +11,7 @@ QT.declarative.sources = $$QT_MODULE_BASE/src/declarative
QT.declarative.libs = $$QT_MODULE_LIB_BASE
QT.declarative.plugins = $$QT_MODULE_PLUGIN_BASE
QT.declarative.imports = $$QT_MODULE_IMPORT_BASE
QT.declarative.depends = gui network opengl xmlpatterns
QT.declarative.depends = gui network xmlpatterns
QT.declarative.DEFINES = QT_DECLARATIVE_LIB

QT_CONFIG += declarative
4 changes: 2 additions & 2 deletions src/declarative/debugger/qdeclarativedebugserver.cpp
Expand Up @@ -49,7 +49,7 @@
#include <QtCore/QStringList>

#include <private/qobject_p.h>
#include <private/qapplication_p.h>
#include <private/qguiapplication_p.h>

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -167,7 +167,7 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
if (!commandLineTested) {
commandLineTested = true;

QApplicationPrivate *appD = static_cast<QApplicationPrivate*>(QObjectPrivate::get(qApp));
QGuiApplicationPrivate *appD = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(qApp));
#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
// ### remove port definition when protocol is changed
int port = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/declarative/declarative.pro
Expand Up @@ -6,7 +6,7 @@ QPRO_PWD = $$PWD
CONFIG += module
MODULE_PRI += ../../modules/qt_declarative.pri

QT = core-private gui gui-private network widgets-private sql v8-private
QT = core-private gui gui-private network sql v8-private

DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000
Expand Down
11 changes: 4 additions & 7 deletions src/declarative/items/context2d/qsgcontext2d.cpp
Expand Up @@ -47,9 +47,7 @@
#include <QtCore/qdebug.h>
#include "private/qsgcontext_p.h"

#include <QtWidgets/qgraphicsitem.h>
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qgraphicseffect.h>
#include <QtGui/qguiapplication.h>
#include <qdeclarativeinfo.h>
#include <QtCore/qmath.h>
#include "qdeclarativepixmapcache_p.h"
Expand Down Expand Up @@ -78,10 +76,6 @@ void copy_vector(QVector<T>* dst, const QVector<T>& src)
}
}

// Note, this is exported but in a private header as qtopengl depends on it.
// But it really should be considered private API
void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0);
void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0);
static bool parsePathDataFast(const QString &dataStr, QPainterPath &path);
#define DEGREES(t) ((t) * 180.0 / Q_PI)
#define qClamp(val, min, max) qMin(qMax(val, min), max)
Expand Down Expand Up @@ -1322,6 +1316,8 @@ QImage QSGContext2DPrivate::makeShadowImage(const QPixmap& pix)
tmpPainter.drawPixmap(shadowX, shadowY, pix);
tmpPainter.end();

#if 0
// ### refactor
// blur the alpha channel
if (state.shadowBlur > 0) {
QImage blurred(shadowImg.size(), QImage::Format_ARGB32);
Expand All @@ -1331,6 +1327,7 @@ QImage QSGContext2DPrivate::makeShadowImage(const QPixmap& pix)
blurPainter.end();
shadowImg = blurred;
}
#endif

// blacken the image with shadow color...
tmpPainter.begin(&shadowImg);
Expand Down
1 change: 1 addition & 0 deletions src/declarative/items/qsganimation.cpp
Expand Up @@ -47,6 +47,7 @@
#include <QtCore/qmath.h>
#include <QtCore/qsequentialanimationgroup.h>
#include <QtCore/qparallelanimationgroup.h>
#include <QtGui/qtransform.h>

QT_BEGIN_NAMESPACE

Expand Down
8 changes: 4 additions & 4 deletions src/declarative/items/qsgcanvas.cpp
Expand Up @@ -115,7 +115,7 @@ class QSGCanvasPlainRenderLoop : public QObject, public QSGCanvasRenderLoop

virtual void maybeUpdate() {
if (!updatePending) {
QApplication::postEvent(this, new QEvent(QEvent::User));
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
updatePending = true;
}
}
Expand Down Expand Up @@ -839,7 +839,7 @@ bool QSGCanvasPrivate::clearHover()

bool accepted = false;
foreach (QSGItem* item, hoverItems)
accepted = sendHoverEvent(QEvent::HoverLeave, item, pos, pos, QApplication::keyboardModifiers(), true) || accepted;
accepted = sendHoverEvent(QEvent::HoverLeave, item, pos, pos, QGuiApplication::keyboardModifiers(), true) || accepted;
hoverItems.clear();
return accepted;
}
Expand Down Expand Up @@ -1888,7 +1888,7 @@ void QSGCanvasRenderThread::run()
#ifdef THREAD_DEBUG
printf(" RenderThread: aquired sync lock...\n");
#endif
QApplication::postEvent(this, new QEvent(QEvent::User));
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
#ifdef THREAD_DEBUG
printf(" RenderThread: going to sleep...\n");
#endif
Expand Down Expand Up @@ -2251,7 +2251,7 @@ QImage QSGCanvasRenderThread::grab()

void QSGCanvasRenderThread::maybeUpdate()
{
Q_ASSERT_X(QThread::currentThread() == QApplication::instance()->thread() || inSync,
Q_ASSERT_X(QThread::currentThread() == QCoreApplication::instance()->thread() || inSync,
"QSGCanvas::update",
"Function can only be called from GUI thread or during QSGItem::updatePaintNode()");

Expand Down
2 changes: 1 addition & 1 deletion src/declarative/items/qsgcanvas.h
Expand Up @@ -44,7 +44,7 @@

#include <QtCore/qmetatype.h>
#include <QtGui/qopengl.h>
#include <QtWidgets/qwidget.h>
#include <QtGui/qwindow.h>

QT_BEGIN_HEADER

Expand Down
2 changes: 1 addition & 1 deletion src/declarative/items/qsgcanvas_p.h
Expand Up @@ -63,11 +63,11 @@
#include <QtCore/qthread.h>
#include <QtCore/qmutex.h>
#include <QtCore/qwaitcondition.h>
#include <private/qwidget_p.h>
#include <private/qwindow_p.h>
#include <private/qopengl_p.h>
#include <qopenglcontext.h>
#include <QtGui/qopenglframebufferobject.h>
#include <QtGui/qevent.h>

QT_BEGIN_NAMESPACE

Expand Down
11 changes: 6 additions & 5 deletions src/declarative/items/qsgflickable.cpp
Expand Up @@ -46,7 +46,8 @@

#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtGui/qevent.h>
#include <QtWidgets/qapplication.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qstylehints.h>
#include "qplatformdefs.h"

QT_BEGIN_NAMESPACE
Expand Down Expand Up @@ -821,7 +822,7 @@ void QSGFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)

if (q->yflick()) {
int dy = int(event->localPos().y() - pressPos.y());
if (qAbs(dy) > QApplication::startDragDistance() || QSGItemPrivate::elapsed(pressTime) > 200) {
if (qAbs(dy) > qApp->styleHints()->startDragDistance() || QSGItemPrivate::elapsed(pressTime) > 200) {
if (!vMoved)
vData.dragStartOffset = dy;
qreal newY = dy + vData.pressPos - vData.dragStartOffset;
Expand All @@ -846,14 +847,14 @@ void QSGFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
vData.move.setValue(qRound(newY));
vMoved = true;
}
if (qAbs(dy) > QApplication::startDragDistance())
if (qAbs(dy) > qApp->styleHints()->startDragDistance())
stealY = true;
}
}

if (q->xflick()) {
int dx = int(event->localPos().x() - pressPos.x());
if (qAbs(dx) > QApplication::startDragDistance() || QSGItemPrivate::elapsed(pressTime) > 200) {
if (qAbs(dx) > qApp->styleHints()->startDragDistance() || QSGItemPrivate::elapsed(pressTime) > 200) {
if (!hMoved)
hData.dragStartOffset = dx;
qreal newX = dx + hData.pressPos - hData.dragStartOffset;
Expand All @@ -879,7 +880,7 @@ void QSGFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
hMoved = true;
}

if (qAbs(dx) > QApplication::startDragDistance())
if (qAbs(dx) > qApp->styleHints()->startDragDistance())
stealX = true;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/declarative/items/qsgitem.cpp
Expand Up @@ -51,8 +51,8 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtWidgets/qgraphicstransform.h>
#include <QtGui/qpen.h>
#include <QtGui/qcursor.h>
#include <QtCore/qdebug.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qnumeric.h>
Expand Down Expand Up @@ -2240,15 +2240,16 @@ void QSGItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObjec
// This test is measurably (albeit only slightly) faster than qobject_cast<>()
const QMetaObject *mo = o->metaObject();
while (mo && mo != &QSGItem::staticMetaObject) {
if (mo == &QGraphicsObject::staticMetaObject)
qWarning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className());
mo = mo->d.superdata;
}

if (mo) {
QSGItem *item = static_cast<QSGItem *>(o);
item->setParentItem(that);
} else {
if (o->inherits("QGraphicsItem"))
qWarning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className());

// XXX todo - do we really want this behavior?
o->setParent(that);
}
Expand Down
1 change: 0 additions & 1 deletion src/declarative/items/qsgitem.h
Expand Up @@ -50,7 +50,6 @@
#include <QtCore/QList>
#include <QtGui/qevent.h>
#include <QtGui/qfont.h>
#include <QtWidgets/qaction.h>

QT_BEGIN_HEADER

Expand Down
3 changes: 0 additions & 3 deletions src/declarative/items/qsgitemsmodule.cpp
Expand Up @@ -157,9 +157,6 @@ static void qt_sgitems_defineModule(const char *uri, int major, int minor)
qmlRegisterType<QValidator>();
#endif
qmlRegisterType<QSGVisualModel>();
#ifndef QT_NO_ACTION
qmlRegisterType<QAction>();
#endif
qmlRegisterType<QSGPen>();
qmlRegisterType<QSGFlickableVisibleArea>();
qRegisterMetaType<QSGAnchorLine>("QSGAnchorLine");
Expand Down
3 changes: 2 additions & 1 deletion src/declarative/items/qsgmousearea.cpp
Expand Up @@ -47,6 +47,7 @@

#include <QtGui/qevent.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qstylehints.h>

#include <float.h>

Expand Down Expand Up @@ -760,7 +761,7 @@ void QSGMouseArea::mouseMoveEvent(QMouseEvent *event)
curLocalPos = event->windowPos();
}

const int dragThreshold = 20; // ### refactor: QGuiApplication::startDragDistance();
const int dragThreshold = qApp->styleHints()->startDragDistance();
qreal dx = qAbs(curLocalPos.x() - startLocalPos.x());
qreal dy = qAbs(curLocalPos.y() - startLocalPos.y());

Expand Down
2 changes: 2 additions & 0 deletions src/declarative/items/qsgmousearea_p.h
Expand Up @@ -45,6 +45,8 @@

#include "qsgitem.h"

#include <QtCore/qstringlist.h>

QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE
Expand Down
1 change: 1 addition & 0 deletions src/declarative/items/qsgpainteditem.h
Expand Up @@ -43,6 +43,7 @@
#define QSGPAINTEDITEM_P_H

#include <qsgitem.h>
#include <QtGui/qcolor.h>

QT_BEGIN_HEADER

Expand Down
1 change: 1 addition & 0 deletions src/declarative/items/qsgpainteditem_p.h
Expand Up @@ -44,6 +44,7 @@
#define QSGPAINTEDITEM_P_P_H

#include "qsgitem_p.h"
#include <QtGui/qcolor.h>

QT_BEGIN_NAMESPACE

Expand Down
5 changes: 3 additions & 2 deletions src/declarative/items/qsgpathview.cpp
Expand Up @@ -49,7 +49,8 @@

#include <QtGui/qevent.h>
#include <QtGui/qevent.h>
#include <QtWidgets/qapplication.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qstylehints.h>
#include <QtCore/qmath.h>
#include <math.h>

Expand Down Expand Up @@ -1163,7 +1164,7 @@ void QSGPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event)
QPointF pathPoint = pointNear(event->localPos(), &newPc);
if (!stealMouse) {
QPointF delta = pathPoint - startPoint;
if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) {
if (qAbs(delta.x()) > qApp->styleHints()->startDragDistance() || qAbs(delta.y()) > qApp->styleHints()->startDragDistance()) {
stealMouse = true;
startPc = newPc;
}
Expand Down
5 changes: 3 additions & 2 deletions src/declarative/items/qsgpincharea.cpp
Expand Up @@ -43,7 +43,8 @@
#include "qsgcanvas.h"

#include <QtGui/qevent.h>
#include <QtWidgets/qapplication.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qstylehints.h>

#include <float.h>
#include <math.h>
Expand Down Expand Up @@ -341,7 +342,7 @@ void QSGPinchArea::updatePinch()
d->initPinch = true;
}
if (d->pinchActivated && !d->pinchRejected){
const int dragThreshold = QApplication::startDragDistance();
const int dragThreshold = qApp->styleHints()->startDragDistance();
QPointF p1 = touchPoint1.scenePos();
QPointF p2 = touchPoint2.scenePos();
qreal dx = p1.x() - p2.x();
Expand Down
4 changes: 2 additions & 2 deletions src/declarative/items/qsgtext.cpp
Expand Up @@ -56,7 +56,7 @@
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextobject.h>
#include <QtGui/qtextcursor.h>
#include <QtWidgets/qapplication.h>
#include <QtGui/qguiapplication.h>

#include <private/qdeclarativestyledtext_p.h>
#include <private/qdeclarativepixmapcache_p.h>
Expand Down Expand Up @@ -1166,7 +1166,7 @@ bool QSGTextPrivate::determineHorizontalAlignment()
{
Q_Q(QSGText);
if (hAlignImplicit && q->isComponentComplete()) {
bool alignToRight = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText;
bool alignToRight = text.isEmpty() ? QGuiApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText;
return setHAlign(alignToRight ? QSGText::AlignRight : QSGText::AlignLeft);
}
return false;
Expand Down
12 changes: 5 additions & 7 deletions src/declarative/items/qsgtextedit.cpp
Expand Up @@ -47,7 +47,7 @@
#include "qsgsimplerectnode.h"

#include <QtDeclarative/qdeclarativeinfo.h>
#include <QtWidgets/qapplication.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qevent.h>
#include <QtGui/qpainter.h>
#include <QtGui/qtextobject.h>
Expand All @@ -56,7 +56,6 @@
#include <private/qdeclarativeglobal_p.h>
#include <private/qtextcontrol_p.h>
#include <private/qtextengine_p.h>
#include <private/qwidget_p.h>
#include <private/qsgdistancefieldglyphcache_p.h>
#include <private/qsgtexture_p.h>
#include <private/qsgadaptationlayer_p.h>
Expand All @@ -65,7 +64,6 @@ QT_BEGIN_NAMESPACE

DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)

Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);
/*!
\qmlclass TextEdit QSGTextEdit
\inqmlmodule QtQuick 2
Expand Down Expand Up @@ -551,7 +549,7 @@ bool QSGTextEditPrivate::determineHorizontalAlignment()
{
Q_Q(QSGTextEdit);
if (hAlignImplicit && q->isComponentComplete()) {
bool alignToRight = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText;
bool alignToRight = text.isEmpty() ? QGuiApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText;
return setHAlign(alignToRight ? QSGTextEdit::AlignRight : QSGTextEdit::AlignLeft);
}
return false;
Expand Down Expand Up @@ -1636,7 +1634,7 @@ void QSGTextEditPrivate::init()
QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
#ifndef QT_NO_CLIPBOARD
QObject::connect(q, SIGNAL(readOnlyChanged(bool)), q, SLOT(q_canPasteChanged()));
QObject::connect(QApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
QObject::connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged()));
canPaste = control->canPaste();
#endif

Expand Down Expand Up @@ -1910,7 +1908,7 @@ void QSGTextEdit::openSoftwareInputPanel()
if (qApp) {
if (canvas()) {
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(canvas(), &event);
QGuiApplication::sendEvent(canvas(), &event);
}
}
}
Expand Down Expand Up @@ -1959,7 +1957,7 @@ void QSGTextEdit::closeSoftwareInputPanel()
if (qApp) {
if (canvas()) {
QEvent event(QEvent::CloseSoftwareInputPanel);
QApplication::sendEvent(canvas(), &event);
QGuiApplication::sendEvent(canvas(), &event);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/declarative/items/qsgtextedit_p_p.h
Expand Up @@ -58,6 +58,7 @@
#include "qsgimplicitsizeitem_p_p.h"

#include <QtDeclarative/qdeclarative.h>
#include <QtGui/qpixmap.h>

QT_BEGIN_NAMESPACE
class QTextLayout;
Expand Down

0 comments on commit 1259c57

Please sign in to comment.