From e40da5484563f7de6b06180408205b597dfb485f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 17 Jul 2009 10:51:37 +1000 Subject: Must set id before call, since addId ASSERTs. --- src/declarative/qml/qmlcompiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index b0bc6e8..91ace10 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -940,9 +940,9 @@ 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 -- cgit v0.12 From 98468a7d49735b30697b8364a40338ed5838222f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 17 Jul 2009 11:09:10 +1000 Subject: Compile, tidy up code. --- examples/declarative/minehunt/Description.qml | 4 ---- examples/declarative/minehunt/main.cpp | 4 +--- examples/declarative/minehunt/minehunt.qml | 34 ++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml index 0241ae5..ea71d85 100644 --- a/examples/declarative/minehunt/Description.qml +++ b/examples/declarative/minehunt/Description.qml @@ -29,8 +29,4 @@ Item { wrap: true } } - filter: Shadow { - xOffset: 5 - yOffset: 5 - } } diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp index 7f10757..d8e60cc 100644 --- a/examples/declarative/minehunt/main.cpp +++ b/examples/declarative/minehunt/main.cpp @@ -62,7 +62,7 @@ public: MyWidget(int = 370, int = 480, QWidget *parent=0, Qt::WindowFlags flags=0); ~MyWidget(); - Q_PROPERTY(QList *tiles READ tiles); + Q_PROPERTY(QList *tiles READ tiles CONSTANT); QList *tiles() { return &_tiles; } Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged); @@ -134,9 +134,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags canvas->setQml(qml, fileName); QmlContext *ctxt = canvas->rootContext(); - ctxt->activate(); ctxt->addDefaultObject(this); - ctxt->deactivate(); canvas->execute(); } diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index 03fcc8d..286e485 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -46,7 +46,7 @@ Item { text: modelData.hint color: "white" font.bold: true - opacity: modelData.hasMine == false && modelData.hint > 0 + opacity: !modelData.hasMine && modelData.hint > 0 } Image { anchors.horizontalCenter: parent.horizontalCenter @@ -57,13 +57,13 @@ Item { Explosion { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - explode: modelData.hasMine==true && modelData.flipped==true + explode: modelData.hasMine && modelData.flipped } } states: [ State { name: "back" - when: modelData.flipped == true + when: modelData.flipped SetProperties { target: flipable; rotation: 180 } } ] @@ -71,7 +71,19 @@ Item { Transition { SequentialAnimation { PauseAnimation { - duration: {var ret = Math.abs(flipable.parent.x-field.clickx) + Math.abs(flipable.parent.y-field.clicky); if (ret > 0) {if(modelData.hasMine==true && modelData.flipped==true){ret*3;}else{ret;}} else {0}} + duration: { + var ret = Math.abs(flipable.parent.x-field.clickx) + + Math.abs(flipable.parent.y-field.clicky); + if (ret > 0) { + if (modelData.hasMine && modelData.flipped) { + ret*3 + } else { + ret + } + } else { + 0 + } + } } NumberAnimation { easing: "easeInOutQuad" @@ -82,7 +94,17 @@ Item { ] MouseRegion { anchors.fill: parent - onClicked: { field.clickx = flipable.parent.x; field.clicky = flipable.parent.y; row = Math.floor(index/9); col = index - (Math.floor(index/9) * 9); if(mouse.button==undefined || mouse.button==Qt.RightButton){flag(row,col);}else{flip(row,col);} } + onClicked: { + field.clickx = flipable.parent.x; + field.clicky = flipable.parent.y; + row = Math.floor(index/9); + col = index - (Math.floor(index/9) * 9); + if (mouse.button==undefined || mouse.button==Qt.RightButton) { + flag(row,col); + } else { + flip(row,col); + } + } } } } @@ -146,7 +168,7 @@ Item { Image { x: 280 y: 10 - source: if(isPlaying==true){'pics/face-smile.png'}else{if(hasWon==true){'pics/face-smile-big.png'}else{'pics/face-sad.png'}} + source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png' MouseRegion { anchors.fill: parent onClicked: { reset() } -- cgit v0.12 From eb9f53486a999aa6e56b115e6ea2ff8b7b107259 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 11:38:12 +1000 Subject: Minor cleanup. --- src/declarative/util/qmltransitionmanager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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 &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 &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); } -- cgit v0.12 From 1cea1e158e212f7182586c2963d7e28747d0140c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 11:48:14 +1000 Subject: Remove non-functioning opaque property. --- demos/declarative/flickr/flickr.qml | 2 +- demos/declarative/flickr/flickr2.qml | 2 +- examples/declarative/velocity/Day.qml | 1 - src/declarative/fx/qfximage.cpp | 38 ----------------------------------- src/declarative/fx/qfximage.h | 5 +---- src/declarative/fx/qfxitem.h | 3 +-- 6 files changed, 4 insertions(+), 47 deletions(-) diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index edf1095..7f45b1c 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -120,7 +120,7 @@ Item { anchors.fill: parent - Image { source: "content/pics/background.png"; opaque: true; anchors.fill: parent } + Image { source: "content/pics/background.png"; anchors.fill: parent } Loading { anchors.centeredIn: parent; visible: FeedModel.status != 0 } diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index d6d5c95..95bca38 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -180,7 +180,7 @@ Item { id: Background property var imageDetails: ImageDetails - Image { source: "content/pics/background.png"; opaque: true } + Image { source: "content/pics/background.png" } GridView { id: PhotoGridView; model: MyVisualModel.parts.gridView diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 8f78822..5154c91 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -11,7 +11,6 @@ Rect { x: 10 y: 10 source: "cork.jpg" - opaque: true } Text { x: 20 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.h b/src/declarative/fx/qfxitem.h index bfe8521..c125514 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 { -- cgit v0.12 From 00d841a494aff8d7158e355a5169d19c4f808573 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 11:58:16 +1000 Subject: LineEdit cleanup. --- src/declarative/fx/qfxlineedit.cpp | 28 +--------------------------- src/declarative/fx/qfxlineedit.h | 7 +------ src/declarative/fx/qfxlineedit_p.h | 6 ++---- 3 files changed, 4 insertions(+), 37 deletions(-) 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 //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 -- cgit v0.12 From 205363fadaa0251a5210e193b35e06a0470c28e2 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 17 Jul 2009 12:08:39 +1000 Subject: Stop the clock while no visible particles and not emitting. Fix size and update logic. Was using 100% CPU. --- src/declarative/extra/qfxparticles.cpp | 44 +++++++++++++++------------------- 1 file changed, 19 insertions(+), 25 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; } -- cgit v0.12 From 68cf34dbf4c5e240188a08f7dcca3a7343e2ef7f Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 17 Jul 2009 12:11:03 +1000 Subject: Be faster. Feel faster. --- demos/declarative/samegame/content/BoomBlock.qml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml index 0d05772..b7838dd 100644 --- a/demos/declarative/samegame/content/BoomBlock.qml +++ b/demos/declarative/samegame/content/BoomBlock.qml @@ -5,8 +5,9 @@ Item { id:block property int targetX: 0 property int targetY: 0 - x: Follow { source: targetX; spring: 1.2; damping: 0.1 } - y: Follow { source: targetY; spring: 1.2; damping: 0.1 } + x: Follow { source: targetX; spring: 2; damping: 0.2 } + y: Follow { source: targetY; spring: 2; damping: 0.2 } + Image { id: img source: { @@ -22,9 +23,10 @@ Item { id:block opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } anchors.fill: parent } + Particles { id: particles width:1; height:1; anchors.centeredIn: parent; opacity: 0 - lifeSpan: 1000000000; count:0; streamIn: false + lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false angle: 0; angleDeviation: 360; velocity: 100; velocityDeviation:30 source: { if(type == 0){ @@ -36,6 +38,7 @@ Item { id:block } } } + states: [ State{ name: "AliveState"; when: spawning == true && dying == false @@ -44,6 +47,7 @@ Item { id:block State{ name: "DeathState"; when: dying == true SetProperties { target: particles; count: 50 } SetProperties { target: particles; opacity: 1 } + SetProperties { target: particles; emitting: false } // i.e. emit only once SetProperties { target: img; opacity: 0 } } ] -- cgit v0.12 From c01d748e2afcf6cf31957d78c08f95bf9ec7da6e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 13:58:02 +1000 Subject: Basic inputMethodQuery support for KeyProxy. --- src/declarative/fx/qfxitem.cpp | 5 +++++ src/declarative/fx/qfxitem.h | 2 ++ src/declarative/fx/qfxkeyproxy.cpp | 46 +++++++++++++++++++++++++++----------- src/declarative/fx/qfxkeyproxy.h | 1 + 4 files changed, 41 insertions(+), 13 deletions(-) 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 c125514..67b60c1 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -273,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 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(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(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(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(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) -- cgit v0.12 From 603cfb5665f10e0cbef3d67df04e33d3e1e2b5f2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 14:25:03 +1000 Subject: WidgetContainer renamed to GraphicsObjectContainer. Also corrected handling of scene change. --- src/declarative/fx/fx.pri | 4 +- src/declarative/fx/qfxgraphicsobjectcontainer.cpp | 98 +++++++++++++++++++++++ src/declarative/fx/qfxgraphicsobjectcontainer.h | 82 +++++++++++++++++++ src/declarative/fx/qfxwidgetcontainer.cpp | 97 ---------------------- src/declarative/fx/qfxwidgetcontainer.h | 82 ------------------- 5 files changed, 182 insertions(+), 181 deletions(-) create mode 100644 src/declarative/fx/qfxgraphicsobjectcontainer.cpp create mode 100644 src/declarative/fx/qfxgraphicsobjectcontainer.h delete mode 100644 src/declarative/fx/qfxwidgetcontainer.cpp delete mode 100644 src/declarative/fx/qfxwidgetcontainer.h 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/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp new file mode 100644 index 0000000..479a21d --- /dev/null +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfxgraphicsobjectcontainer.h" +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmlclass GraphicsObjectContainer QFxGraphicsObjectContainer + \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements. +*/ + +/*! + \internal + \class QFxGraphicsObjectContainer + \brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications. +*/ + +QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer) + +QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent) +: QFxItem(parent), _graphicsObject(0) +{ +} + +QFxGraphicsObjectContainer::~QFxGraphicsObjectContainer() +{ +} + +QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const +{ + return _graphicsObject; +} + +/*! + \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject + The QGraphicsObject associated with this element. +*/ +void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object) +{ + if (object == _graphicsObject) + return; + + _graphicsObject = object; + + _graphicsObject->setParentItem(this); +} + +QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value) +{ + if (change == ItemSceneHasChanged) { + QGraphicsObject *o = _graphicsObject; + _graphicsObject = 0; + setGraphicsObject(o); + } + return QFxItem::itemChange(change, value); +} + +QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h new file mode 100644 index 0000000..e118555 --- /dev/null +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXGRAPHICSOBJECTCONTAINER_H +#define QFXGRAPHICSOBJECTCONTAINER_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QGraphicsObject; + +class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem +{ + Q_OBJECT + + Q_CLASSINFO("DefaultProperty", "graphicsObject") + Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject) + +public: + QFxGraphicsObjectContainer(QFxItem *parent = 0); + ~QFxGraphicsObjectContainer(); + + QGraphicsObject *graphicsObject() const; + void setGraphicsObject(QGraphicsObject *); + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + +private: + QGraphicsObject *_graphicsObject; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxGraphicsObjectContainer) + +QT_END_HEADER + +#endif // QFXGRAPHICSOBJECTCONTAINER_H diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxwidgetcontainer.cpp deleted file mode 100644 index ea702db..0000000 --- a/src/declarative/fx/qfxwidgetcontainer.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxwidgetcontainer.h" -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass WidgetContainer QFxWidgetContainer - \brief The WidgetContainer element allows you to add QGraphicsWidgets into Fluid UI elements. -*/ - -/*! - \internal - \class QFxWidgetContainer - \brief The QFxWidgetContainer class allows you to add QGraphicsWidgets into Fluid UI applications. -*/ - -QML_DEFINE_TYPE(QFxWidgetContainer, WidgetContainer) - -QFxWidgetContainer::QFxWidgetContainer(QFxItem *parent) -: QFxItem(parent), _graphicsWidget(0) -{ -} - -QFxWidgetContainer::~QFxWidgetContainer() -{ -} - -QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const -{ - return _graphicsWidget; -} - -/*! - \qmlproperty QGraphicsWidget QFxWidgetContainer::graphicsWidget - The QGraphicsWidget associated with this element. -*/ -void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget) -{ - if (widget == _graphicsWidget) - return; - - _graphicsWidget = widget; - - _graphicsWidget->setParentItem(this); -} - -void QFxWidgetContainer::canvasChanged() -{ - if (_graphicsWidget) { - QGraphicsWidget *w = _graphicsWidget; - _graphicsWidget = 0; - setGraphicsWidget(w); - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h deleted file mode 100644 index 862a280..0000000 --- a/src/declarative/fx/qfxwidgetcontainer.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXWIDGETCONTAINER_H -#define QFXWIDGETCONTAINER_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QGraphicsWidget; - -class Q_DECLARATIVE_EXPORT QFxWidgetContainer : public QFxItem -{ - Q_OBJECT - - Q_CLASSINFO("DefaultProperty", "graphicsWidget") - Q_PROPERTY(QGraphicsWidget *graphicsWidget READ graphicsWidget WRITE setGraphicsWidget) - -public: - QFxWidgetContainer(QFxItem *parent = 0); - ~QFxWidgetContainer(); - - QGraphicsWidget *graphicsWidget() const; - void setGraphicsWidget(QGraphicsWidget *); - -protected: - virtual void canvasChanged(); - -private: - QGraphicsWidget *_graphicsWidget; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxWidgetContainer) - -QT_END_HEADER - -#endif // QFXGRAPHICSWIDGET_H -- cgit v0.12 From 43a497cac00a93f015ec62339529f36ba3f19ece Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 17 Jul 2009 14:28:12 +1000 Subject: Update list of elements in doc. --- doc/src/declarative/elements.qdoc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index eda9079..e6e31f4 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -74,14 +74,12 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \l TextEdit \o \l Rect \o \l AnimatedImage -\o \l BlendedImage \endlist \o \list \o \l MouseRegion \o \l KeyActions -\o \l FocusPanel \o \l FocusRealm \o \l KeyProxy \endlist @@ -96,12 +94,8 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list \o \l Repeater -\o \l ContentWrapper - \list - \o \l Content - \endlist \o \l ComponentInstance -\o \l WidgetContainer +\o \l GraphicsObjectContainer \endlist \header @@ -147,10 +141,6 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list -\o \l Shadow -\o \l Reflection -\o \l Blur -\o \l Highlight \o \l Particles \list \o \l ParticleMotionLinear -- cgit v0.12