diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-07-17 04:35:17 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-07-17 04:35:17 (GMT) |
commit | a1e83cdc5c30495a6110e8c8f11ae28723e2b0d5 (patch) | |
tree | 4689ebf3e700737b366db0a8509c4c762e34d506 /src | |
parent | 4200dec4f01d8181a39704c149bc49c9a8882274 (diff) | |
parent | 43f131a0a5aaddf35b7b4b4c50468e2bb9db4965 (diff) | |
download | Qt-a1e83cdc5c30495a6110e8c8f11ae28723e2b0d5.zip Qt-a1e83cdc5c30495a6110e8c8f11ae28723e2b0d5.tar.gz Qt-a1e83cdc5c30495a6110e8c8f11ae28723e2b0d5.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts:
demos/declarative/samegame/content/BoomBlock.qml
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/extra/qfxparticles.cpp | 44 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.cpp | 38 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.h | 5 | ||||
-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 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 6 | ||||
-rw-r--r-- | src/declarative/util/qmltransitionmanager.cpp | 9 |
12 files changed, 71 insertions, 129 deletions
diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 3d59022..c31163c 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -410,7 +410,6 @@ public: }; -//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged) void QFxParticlesPrivate::tick(int time) { Q_Q(QFxParticles); @@ -465,12 +464,9 @@ void QFxParticlesPrivate::tick(int time) } lastAdvTime = time; - if (oldCount || particles.count()) { - if (q->itemParent()) - q->itemParent()->update(); - else - q->update(); - } else if (!count) { + paintItem->updateSize(); + paintItem->update(); + if (!(oldCount || particles.count()) && (!count || !emitting)) { lastAdvTime = 0; clock.stop(); } @@ -641,7 +637,8 @@ void QFxParticles::imageLoaded() { Q_D(QFxParticles); d->image = QFxPixmap(d->url); - update(); + d->paintItem->updateSize(); + d->paintItem->update(); } void QFxParticles::setSource(const QUrl &name) @@ -656,7 +653,8 @@ void QFxParticles::setSource(const QUrl &name) if (name.isEmpty()) { d->url = name; d->image = QPixmap(); - update(); + d->paintItem->updateSize(); + d->paintItem->update(); } else { d->url = name; Q_ASSERT(!name.isRelative()); @@ -687,10 +685,11 @@ void QFxParticles::setCount(int cnt) d->count = cnt; d->addParticleTime = 0; d->addParticleCount = d->particles.count(); - if (!oldCount && d->clock.state() != QAbstractAnimation::Running){ - d->clock.start(); // infinity?? + if (!oldCount && d->clock.state() != QAbstractAnimation::Running) { + d->clock.start(); } - update(); + d->paintItem->updateSize(); + d->paintItem->update(); } } @@ -1006,6 +1005,8 @@ void QFxParticles::setEmitting(bool r) { Q_D(QFxParticles); d->emitting = r; + if (d->count && r) + d->clock.start(); } /*! \qmlproperty ParticleMotion Particles::motion @@ -1046,17 +1047,10 @@ QString QFxParticles::propertyInfo() const return d->url.toString(); } -void QFxParticlesPainter::updateSize(){ - setX(-500); - setY(-500); - setWidth(1000); - setHeight(1000); - return ; +void QFxParticlesPainter::updateSize() +{ const int parentX = parentItem()->x(); const int parentY = parentItem()->y(); - //Have to use statistical approach to needed size as arbitrary particle - //motions make it impossible to calculate. - //max/min vars stored to give a never shrinking rect for (int i = 0; i < d->particles.count(); ++i) { const QFxParticle &particle = d->particles.at(i); if(particle.x > maxX) @@ -1090,7 +1084,6 @@ void QFxParticlesPainter::paintContents(QPainter &p) if (d->image.isNull()) return; - updateSize(); const int myX = x() + parentItem()->x(); const int myY = y() + parentItem()->y(); @@ -1099,15 +1092,16 @@ void QFxParticlesPainter::paintContents(QPainter &p) p.setOpacity(particle.opacity); p.drawPixmap(particle.x - myX, particle.y - myY, d->image); } - update();//Should I need this? (GV does) } void QFxParticles::componentComplete() { Q_D(QFxParticles); QFxItem::componentComplete(); - if (d->count) - d->clock.start(); // infinity?? + if (d->count) { + d->paintItem->updateSize(); + d->clock.start(); + } if (d->lifeSpanDev > d->lifeSpan) d->lifeSpanDev = d->lifeSpan; } diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 148c269..f57782c 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 925a520..378c20d 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -64,8 +64,8 @@ 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) + public: QFxImage(QFxItem *parent=0); ~QFxImage(); @@ -78,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 diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index b0bc6e8..220c464 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -940,9 +940,8 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj, if (compileState.ids.contains(idVal)) COMPILE_EXCEPTION(obj, "id is not unique"); - addId(idVal, obj); - obj->id = idVal; + addId(idVal, obj); } // Check the Component tree is well formed @@ -1343,10 +1342,9 @@ bool QmlCompiler::buildIdProperty(QmlParser::Property *prop, if (compileState.ids.contains(val)) COMPILE_EXCEPTION(prop, "id is not unique"); - obj->id = val; - prop->values.at(0)->type = Value::Id; + obj->id = val; addId(val, obj); return true; diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp index 5e86b73..ba4e160 100644 --- a/src/declarative/util/qmltransitionmanager.cpp +++ b/src/declarative/util/qmltransitionmanager.cpp @@ -109,13 +109,10 @@ void QmlTransitionManager::transition(const QList<Action> &list, QmlStateOperation::ActionList applyList = list; // Determine which actions are binding changes. foreach(const Action &action, applyList) { - if (action.toBinding) { + if (action.toBinding) d->bindingsList << action; - if (action.fromBinding) - action.property.setBinding(0); // Disable current binding - } else if (action.fromBinding) { + if (action.fromBinding) action.property.setBinding(0); // Disable current binding - } } // Animated transitions need both the start and the end value for @@ -156,7 +153,7 @@ void QmlTransitionManager::transition(const QList<Action> &list, continue; if (action.toBinding) - action.property.setBinding(0); + action.property.setBinding(0); // Make sure this is disabled during the transition action.property.write(action.fromValue); } |