diff options
Diffstat (limited to 'src/declarative/fx')
-rw-r--r-- | src/declarative/fx/fx.pri | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxgraphicsobjectcontainer.cpp (renamed from src/declarative/fx/qfxwidgetcontainer.cpp) | 47 | ||||
-rw-r--r-- | src/declarative/fx/qfxgraphicsobjectcontainer.h (renamed from src/declarative/fx/qfxwidgetcontainer.h) | 28 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 38 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxitem.h | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxkeyproxy.cpp | 46 | ||||
-rw-r--r-- | src/declarative/fx/qfxkeyproxy.h | 1 | ||||
-rw-r--r-- | src/declarative/fx/qfxlineedit.cpp | 28 | ||||
-rw-r--r-- | src/declarative/fx/qfxlineedit.h | 7 | ||||
-rw-r--r-- | src/declarative/fx/qfxlineedit_p.h | 6 |
12 files changed, 86 insertions, 133 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 413b8db..24c5536 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -40,7 +40,7 @@ HEADERS += \ fx/qfxpixmap.cpp \ fx/qfxvisualitemmodel.h \ fx/qfxlistview.h \ - fx/qfxwidgetcontainer.h \ + fx/qfxgraphicsobjectcontainer.h \ SOURCES += \ fx/qfxanchors.cpp \ @@ -69,7 +69,7 @@ SOURCES += \ fx/qfxpixmap.cpp \ fx/qfxvisualitemmodel.cpp \ fx/qfxlistview.cpp \ - fx/qfxwidgetcontainer.cpp \ + fx/qfxgraphicsobjectcontainer.cpp \ contains(QT_CONFIG, webkit) { QT+=webkit diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp index ea702db..479a21d 100644 --- a/src/declarative/fx/qfxwidgetcontainer.cpp +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp @@ -39,59 +39,60 @@ ** ****************************************************************************/ -#include "qfxwidgetcontainer.h" -#include <qgraphicswidget.h> +#include "qfxgraphicsobjectcontainer.h" +#include <QGraphicsObject> QT_BEGIN_NAMESPACE /*! - \qmlclass WidgetContainer QFxWidgetContainer - \brief The WidgetContainer element allows you to add QGraphicsWidgets into Fluid UI elements. + \qmlclass GraphicsObjectContainer QFxGraphicsObjectContainer + \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements. */ /*! \internal - \class QFxWidgetContainer - \brief The QFxWidgetContainer class allows you to add QGraphicsWidgets into Fluid UI applications. + \class QFxGraphicsObjectContainer + \brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications. */ -QML_DEFINE_TYPE(QFxWidgetContainer, WidgetContainer) +QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer) -QFxWidgetContainer::QFxWidgetContainer(QFxItem *parent) -: QFxItem(parent), _graphicsWidget(0) +QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent) +: QFxItem(parent), _graphicsObject(0) { } -QFxWidgetContainer::~QFxWidgetContainer() +QFxGraphicsObjectContainer::~QFxGraphicsObjectContainer() { } -QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const +QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const { - return _graphicsWidget; + return _graphicsObject; } /*! - \qmlproperty QGraphicsWidget QFxWidgetContainer::graphicsWidget - The QGraphicsWidget associated with this element. + \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject + The QGraphicsObject associated with this element. */ -void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget) +void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object) { - if (widget == _graphicsWidget) + if (object == _graphicsObject) return; - _graphicsWidget = widget; + _graphicsObject = object; - _graphicsWidget->setParentItem(this); + _graphicsObject->setParentItem(this); } -void QFxWidgetContainer::canvasChanged() +QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value) { - if (_graphicsWidget) { - QGraphicsWidget *w = _graphicsWidget; - _graphicsWidget = 0; - setGraphicsWidget(w); + if (change == ItemSceneHasChanged) { + QGraphicsObject *o = _graphicsObject; + _graphicsObject = 0; + setGraphicsObject(o); } + return QFxItem::itemChange(change, value); } QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h index 862a280..e118555 100644 --- a/src/declarative/fx/qfxwidgetcontainer.h +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QFXWIDGETCONTAINER_H -#define QFXWIDGETCONTAINER_H +#ifndef QFXGRAPHICSOBJECTCONTAINER_H +#define QFXGRAPHICSOBJECTCONTAINER_H #include <QtDeclarative/qfxitem.h> @@ -50,33 +50,33 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QGraphicsWidget; +class QGraphicsObject; -class Q_DECLARATIVE_EXPORT QFxWidgetContainer : public QFxItem +class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem { Q_OBJECT - Q_CLASSINFO("DefaultProperty", "graphicsWidget") - Q_PROPERTY(QGraphicsWidget *graphicsWidget READ graphicsWidget WRITE setGraphicsWidget) + Q_CLASSINFO("DefaultProperty", "graphicsObject") + Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject) public: - QFxWidgetContainer(QFxItem *parent = 0); - ~QFxWidgetContainer(); + QFxGraphicsObjectContainer(QFxItem *parent = 0); + ~QFxGraphicsObjectContainer(); - QGraphicsWidget *graphicsWidget() const; - void setGraphicsWidget(QGraphicsWidget *); + QGraphicsObject *graphicsObject() const; + void setGraphicsObject(QGraphicsObject *); protected: - virtual void canvasChanged(); + QVariant itemChange(GraphicsItemChange change, const QVariant &value); private: - QGraphicsWidget *_graphicsWidget; + QGraphicsObject *_graphicsObject; }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QFxWidgetContainer) +QML_DECLARE_TYPE(QFxGraphicsObjectContainer) QT_END_HEADER -#endif // QFXGRAPHICSWIDGET_H +#endif // QFXGRAPHICSOBJECTCONTAINER_H diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 34ff157..d19d620 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -219,44 +219,6 @@ void QFxImage::setTiled(bool tile) d->tiled = tile; } -/*! - \qmlproperty bool Image::opaque - - Set this property if you know that the image is opaque to give your - application a significant performance boost. - - \note - This is a performance hint to Qt Declarative. Unfortunately whether or not an image - is opaque is not automatically detected. Setting this property to true when - the image is not opaque will lead to drawing artifacts. However, leaving it as - false will always work correctly - although possibly not at maximum performance. - */ - -/*! - \property QFxImage::opaque - \brief whether the image is opaque (non-transparent). - - This property is provided purely for the purpose of optimization. An opaque - image can be optimized more than a non-opaque one. -*/ -bool QFxImage::isOpaque() const -{ - Q_D(const QFxImage); - return d->opaque; -} - -void QFxImage::setOpaque(bool o) -{ - Q_D(QFxImage); - if (o == d->opaque) - return; - d->opaque = o; - - setOptions(IsOpaque, o); - - update(); -} - void QFxImage::componentComplete() { QFxItem::componentComplete(); diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index bc63d7a..7b3445c 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -64,7 +64,6 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid) Q_PROPERTY(bool tile READ isTiled WRITE setTiled) Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false) - Q_PROPERTY(bool opaque READ isOpaque WRITE setOpaque) Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) Q_PROPERTY(bool preserveAspect READ preserveAspect WRITE setPreserveAspect); public: @@ -79,9 +78,6 @@ public: QPixmap pixmap() const; void setPixmap(const QPixmap &); - bool isOpaque() const; - void setOpaque(bool); - bool smoothTransform() const; void setSmoothTransform(bool); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 3386faf..481733b 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2556,4 +2556,9 @@ QPixmap QFxItem::string(const QString &str, const QColor &c, const QFont &f) return img; } +QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const +{ + return QGraphicsItem::inputMethodQuery(query); +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index bfe8521..67b60c1 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -149,8 +149,7 @@ public: SimpleItem = 0x00000020, IsFocusPanel = 0x00000040, IsFocusRealm = 0x00000080, - AcceptsInputMethods = 0x00000100, - IsOpaque = 0x00000200 }; + AcceptsInputMethods = 0x00000100 }; Q_DECLARE_FLAGS(Options, Option) enum TransformOrigin { @@ -274,6 +273,8 @@ public: static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont()); + QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy + public Q_SLOTS: void newChild(const QString &url); diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp index f234a0f..e4b4269 100644 --- a/src/declarative/fx/qfxkeyproxy.cpp +++ b/src/declarative/fx/qfxkeyproxy.cpp @@ -82,13 +82,15 @@ QML_DEFINE_TYPE(QFxKeyProxy,KeyProxy) class QFxKeyProxyPrivate { public: - QFxKeyProxyPrivate() : inPress(false), inRelease(false), inIM(false) {} + QFxKeyProxyPrivate() : inPress(false), inRelease(false), inIM(false), imeItem(0) {} QList<QFxItem *> targets; //loop detection bool inPress:1; bool inRelease:1; bool inIM:1; + + QFxItem *imeItem; }; QFxKeyProxy::QFxKeyProxy(QFxItem *parent) @@ -124,11 +126,12 @@ void QFxKeyProxy::keyPressEvent(QKeyEvent *e) d->inPress = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii))); - if (i) + if (i) { scene()->sendEvent(i, e); - if (e->isAccepted()) { - d->inPress = false; - return; + if (e->isAccepted()) { + d->inPress = false; + return; + } } } d->inPress = false; @@ -143,11 +146,12 @@ void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e) d->inRelease = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii))); - if (i) + if (i) { scene()->sendEvent(i, e); - if (e->isAccepted()) { - d->inRelease = false; - return; + if (e->isAccepted()) { + d->inRelease = false; + return; + } } } d->inRelease = false; @@ -162,15 +166,31 @@ void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e) d->inIM = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii))); - if (i) + if (i && (i->options() & AcceptsInputMethods)) { scene()->sendEvent(i, e); - if (e->isAccepted()) { - d->inIM = false; - return; + if (e->isAccepted()) { + d->imeItem = i; + d->inIM = false; + return; + } } } d->inIM = false; } } +QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const +{ + for (int ii = 0; ii < d->targets.count(); ++ii) { + QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii))); + if (i && (i->options() & AcceptsInputMethods) && i == d->imeItem) { //### how robust is i == d->imeItem check? + QVariant v = i->inputMethodQuery(query); + if (v.type() == QVariant::RectF) + v = mapRectFromItem(i, v.toRectF()); //### cost? + return v; + } + } + return QFxItem::inputMethodQuery(query); +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h index 8bcdc26..e77ffac 100644 --- a/src/declarative/fx/qfxkeyproxy.h +++ b/src/declarative/fx/qfxkeyproxy.h @@ -65,6 +65,7 @@ protected: virtual void keyPressEvent(QKeyEvent *); virtual void keyReleaseEvent(QKeyEvent *); virtual void inputMethodEvent(QInputMethodEvent *); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; private: Q_DISABLE_COPY(QFxKeyProxy) diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index d23c325..24cf3fc 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -207,23 +207,6 @@ QString QFxLineEdit::selectedText() const return d->control->selectedText(); } -bool QFxLineEdit::isAwesome() const -{ - Q_D(const QFxLineEdit); - return d->awesome; -} - -#include <QTimer> //Can be removed along wit the property -void QFxLineEdit::setAwesome(bool a) -{ - Q_D(QFxLineEdit); - d->awesome = a; - if(a){ - setColor(QColor(0,0,255)); - rainbowRedraw(); - } -} - QObject* QFxLineEdit::validator() const { Q_D(const QFxLineEdit); @@ -462,7 +445,7 @@ void QFxLineEditPrivate::init() { Q_Q(QFxLineEdit); control->setCursorWidth(1); - control->setPasswordCharacter('*'); + control->setPasswordCharacter(QLatin1Char('*')); control->setLayoutDirection(Qt::LeftToRight); control->setSelection(0,0); q->setSmooth(true); @@ -530,14 +513,5 @@ void QFxLineEdit::updateSize() setContentsSize(QSize(width(), height())); } -void QFxLineEdit::rainbowRedraw() -{ - Q_D(QFxLineEdit); - if(!d->awesome) - return; - setColor(QColor::fromHsv((d->color.hue() + 5)%360, d->color.saturation(), d->color.value())); - updateAll(); - QTimer::singleShot(50, this, SLOT(rainbowRedraw())); -} QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h index 5abb418..e053c54 100644 --- a/src/declarative/fx/qfxlineedit.h +++ b/src/declarative/fx/qfxlineedit.h @@ -84,8 +84,7 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem /* Q_PROPERTY(int scrollDuration READ scrollDuration SET setScrollDuration NOTIFY scrollDurationChanged); */ - //### Requested by Aaron K.(Remove before release?) - Q_PROPERTY(bool awesome READ isAwesome WRITE setAwesome); + public: QFxLineEdit(QFxItem* parent=0); ~QFxLineEdit(); @@ -148,9 +147,6 @@ public: bool hasAcceptableInput() const; - bool isAwesome() const; - void setAwesome(bool a); - void drawContents(QPainter *p,const QRect &r); Q_SIGNALS: void textChanged(); @@ -178,7 +174,6 @@ private slots: void updateAll(); void createCursor(); void moveCursor(); - void rainbowRedraw(); private: Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxLineEdit); diff --git a/src/declarative/fx/qfxlineedit_p.h b/src/declarative/fx/qfxlineedit_p.h index 8ee5cca..a0ab19c 100644 --- a/src/declarative/fx/qfxlineedit_p.h +++ b/src/declarative/fx/qfxlineedit_p.h @@ -65,9 +65,9 @@ class QFxLineEditPrivate : public QFxPaintedItemPrivate public: QFxLineEditPrivate() : control(new QLineControl(QString())), font(0), color((QRgb)0), style(QFxText::Normal), + styleColor((QRgb)0), hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), - styleColor((QRgb)0), oldScroll(0), hscroll(0), - focused(false), awesome(false) + hscroll(0), oldScroll(0), focused(false) { } @@ -96,8 +96,6 @@ public: int hscroll; int oldScroll; bool focused; - bool awesome; - }; QT_END_NAMESPACE |