diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-10-05 06:32:26 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-10-05 06:32:26 (GMT) |
commit | 231745acfc4b106d889b139d208563df190db264 (patch) | |
tree | 3677db18f7b2adea9d86168f7a5c8eb047b92b66 | |
parent | 0251974200e4f931c534f120834ab89fe3836405 (diff) | |
parent | 9c80d8284449e8cfc421aa047598020dc4c58772 (diff) | |
download | Qt-231745acfc4b106d889b139d208563df190db264.zip Qt-231745acfc4b106d889b139d208563df190db264.tar.gz Qt-231745acfc4b106d889b139d208563df190db264.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
27 files changed, 197 insertions, 95 deletions
diff --git a/demos/declarative/flickr/common/pics/button-pressed.sci b/demos/declarative/flickr/common/pics/button-pressed.sci index d3b16e2..b8db272 100644 --- a/demos/declarative/flickr/common/pics/button-pressed.sci +++ b/demos/declarative/flickr/common/pics/button-pressed.sci @@ -1,5 +1,5 @@ -gridLeft: 8 -gridTop: 4 -gridBottom: 4 -gridRight: 8 -imageFile: button.png +border.left: 8 +border.top: 4 +border.bottom: 4 +border.right: 8 +source: button.png diff --git a/demos/declarative/flickr/common/pics/button.sci b/demos/declarative/flickr/common/pics/button.sci index d3b16e2..b8db272 100644 --- a/demos/declarative/flickr/common/pics/button.sci +++ b/demos/declarative/flickr/common/pics/button.sci @@ -1,5 +1,5 @@ -gridLeft: 8 -gridTop: 4 -gridBottom: 4 -gridRight: 8 -imageFile: button.png +border.left: 8 +border.top: 4 +border.bottom: 4 +border.right: 8 +source: button.png diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml index 6a4efd9..f8cf048 100644 --- a/demos/declarative/flickr/flickr-desktop.qml +++ b/demos/declarative/flickr/flickr-desktop.qml @@ -70,8 +70,8 @@ Item { PropertyChanges { target: ItemRotation; angle: 0 } PropertyChanges { target: Shadows; opacity: 0 } PropertyChanges { target: ImageDetails; y: 20 } - PropertyChanges { target: PhotoGridView; y: "-480" } - PropertyChanges { target: PhotoPathView; y: "-480" } + PropertyChanges { target: PhotoGridView; y: -480 } + PropertyChanges { target: PhotoPathView; y: -480 } PropertyChanges { target: ViewModeButton; opacity: 0 } PropertyChanges { target: TagsEdit; opacity: 0 } PropertyChanges { target: FetchButton; opacity: 0 } @@ -82,8 +82,10 @@ Item { transitions: [ Transition { from: "*"; to: "Details" - ParentAction { } - NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + SequentialAnimation { + ParentAction { } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + } }, Transition { from: "Details"; to: "*" diff --git a/demos/declarative/flickr/mobile/images/lineedit.sci b/demos/declarative/flickr/mobile/images/lineedit.sci index 7c5ec6c..054bff7 100644 --- a/demos/declarative/flickr/mobile/images/lineedit.sci +++ b/demos/declarative/flickr/mobile/images/lineedit.sci @@ -1,5 +1,5 @@ -gridLeft: 10 -gridTop: 10 -gridBottom: 10 -gridRight: 10 -imageFile: lineedit.png +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/demos/declarative/flickr/mobile/images/titlebar.sci b/demos/declarative/flickr/mobile/images/titlebar.sci index 50444e1..0418d94 100644 --- a/demos/declarative/flickr/mobile/images/titlebar.sci +++ b/demos/declarative/flickr/mobile/images/titlebar.sci @@ -1,5 +1,5 @@ -gridLeft: 10 -gridTop: 12 -gridBottom: 12 -gridRight: 10 -imageFile: titlebar.png +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/demos/declarative/flickr/mobile/images/toolbutton.sci b/demos/declarative/flickr/mobile/images/toolbutton.sci index a0a885f..9e4f965 100644 --- a/demos/declarative/flickr/mobile/images/toolbutton.sci +++ b/demos/declarative/flickr/mobile/images/toolbutton.sci @@ -1,5 +1,5 @@ -gridLeft: 15 -gridTop: 4 -gridBottom: 4 -gridRight: 15 -imageFile: toolbutton.png +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci index 464dbf5..96c5efb 100644 --- a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci +++ b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci @@ -1,6 +1,6 @@ -gridLeft: 7 -gridTop: 7 -gridBottom: 7 -gridRight: 7 -imageFile: addressbar-filled.png +border.left: 7 +border.top: 7 +border.bottom: 7 +border.right: 7 +source: addressbar-filled.png diff --git a/demos/declarative/webbrowser/content/pics/addressbar.sci b/demos/declarative/webbrowser/content/pics/addressbar.sci index 23a2a19..8f1cd18 100644 --- a/demos/declarative/webbrowser/content/pics/addressbar.sci +++ b/demos/declarative/webbrowser/content/pics/addressbar.sci @@ -1,6 +1,6 @@ -gridLeft: 7 -gridTop: 7 -gridBottom: 7 -gridRight: 7 -imageFile: addressbar.png +border.left: 7 +border.top: 7 +border.bottom: 7 +border.right: 7 +source: addressbar.png diff --git a/demos/declarative/webbrowser/content/pics/footer.sci b/demos/declarative/webbrowser/content/pics/footer.sci index be1d086..7be58f1 100644 --- a/demos/declarative/webbrowser/content/pics/footer.sci +++ b/demos/declarative/webbrowser/content/pics/footer.sci @@ -1,6 +1,6 @@ -gridLeft: 5 -gridTop: 0 -gridBottom: 0 -gridRight: 5 -imageFile: footer.png +border.left: 5 +border.top: 0 +border.bottom: 0 +border.right: 5 +source: footer.png diff --git a/demos/declarative/webbrowser/content/pics/softshadow-left.sci b/demos/declarative/webbrowser/content/pics/softshadow-left.sci index 82e38f8..45c88d5 100644 --- a/demos/declarative/webbrowser/content/pics/softshadow-left.sci +++ b/demos/declarative/webbrowser/content/pics/softshadow-left.sci @@ -1,5 +1,5 @@ -gridLeft: 0 -gridTop: 16 -gridBottom: 16 -gridRight: 0 -imageFile: softshadow-left.png +border.left: 0 +border.top: 16 +border.bottom: 16 +border.right: 0 +source: softshadow-left.png diff --git a/demos/declarative/webbrowser/content/pics/softshadow-right.sci b/demos/declarative/webbrowser/content/pics/softshadow-right.sci index e9494ed..4d459c0 100644 --- a/demos/declarative/webbrowser/content/pics/softshadow-right.sci +++ b/demos/declarative/webbrowser/content/pics/softshadow-right.sci @@ -1,5 +1,5 @@ -gridLeft: 0 -gridTop: 16 -gridBottom: 16 -gridRight: 0 -imageFile: softshadow-right.png +border.left: 0 +border.top: 16 +border.bottom: 16 +border.right: 0 +source: softshadow-right.png diff --git a/examples/declarative/border-image/colors-round.sci b/examples/declarative/border-image/colors-round.sci index 3784e10..506f6f5 100644 --- a/examples/declarative/border-image/colors-round.sci +++ b/examples/declarative/border-image/colors-round.sci @@ -1,7 +1,7 @@ -gridLeft:30 -gridTop:30 -gridRight:30 -gridBottom:30 +border.left:30 +border.top:30 +border.right:30 +border.bottom:30 horizontalTileRule:Round verticalTileRule:Round -imageFile:colors.png +source:colors.png diff --git a/examples/declarative/border-image/colors-stretch.sci b/examples/declarative/border-image/colors-stretch.sci index c693599..e4989a7 100644 --- a/examples/declarative/border-image/colors-stretch.sci +++ b/examples/declarative/border-image/colors-stretch.sci @@ -1,5 +1,5 @@ -gridLeft:30 -gridTop:30 -gridRight:30 -gridBottom:30 -imageFile:colors.png +border.left:30 +border.top:30 +border.right:30 +border.bottom:30 +source:colors.png diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/Removebutton.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/RemoveButton.qml index a8ac7fe..a8ac7fe 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/Removebutton.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1/RemoveButton.qml diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml index 162452f..9508018 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1/ContactField.qml @@ -21,7 +21,7 @@ Item { anchors.verticalCenter: parent.verticalCenter font.bold: true color: "black" - text: 123123 + text: "123123" } Image { source: "../../shared/pics/phone.png" diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml index cf50fb0..e50dcc5 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1a/ContactField.qml @@ -24,7 +24,7 @@ Item { anchors.verticalCenter: parent.verticalCenter font.bold: true color: "black" - text: 123123 + text: "123123" } Image { source: "../../shared/pics/phone.png" diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml index 2e1a488..ce6a289 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2/ContactField.qml @@ -23,7 +23,7 @@ Item { anchors.verticalCenter: parent.verticalCenter font.bold: true color: "black" - text: 123123 + text: "123123" } Image { source: "../../shared/pics/phone.png" diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml index 3516cee..f253763 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml @@ -16,9 +16,10 @@ Item { Column { id: layout - anchors.fill: parent + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right spacing: 5 - margin: 5 ContactField { id: labelField anchors.left: layout.left diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml index 83988ab..db85d2a 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml @@ -19,9 +19,10 @@ Item { Column { id: layout - anchors.fill: parent + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right spacing: 5 - margin: 5 ContactField { id: labelField anchors.left: layout.left diff --git a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml index a7764ed..cd14a08 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml @@ -5,7 +5,7 @@ Rectangle { width: layout.width height: layout.height color: "white" - Bind { + Binding { id: currentItem value: true } diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml index d00bf05..58a542b 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml @@ -17,7 +17,6 @@ Item { id: layout anchors.fill: parent spacing: 5 - margin: 5 ContactField { id: labelField anchors.left: layout.left diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index 3bc76da..6616912 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -124,19 +124,16 @@ QFxBorderImage::~QFxBorderImage() BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies - \list - \i the grid lines describing a \l {BorderImage::border.left}{scale grid}. - \i an image file. - \endlist - - The following .sci file sets grid line offsets of 10 on each side for the image \c picture.png: - \code - gridLeft: 10 - gridTop: 10 - gridBottom: 10 - gridRight: 10 - imageFile: picture.png - \endcode + the borders, the image file and the tile rules. + + The following .sci file sets the borders to 10 on each side for the image \c picture.png: + \qml + border.left: 10 + border.top: 10 + border.bottom: 10 + border.right: 10 + source: picture.png + \endqml The URL may be absolute, or relative to the URL of the component. */ diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp index 08120fc..c0cac6c 100644 --- a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp @@ -41,6 +41,8 @@ #include "qfxgraphicsobjectcontainer.h" #include <QGraphicsObject> +#include <QGraphicsWidget> +#include <QGraphicsSceneResizeEvent> QT_BEGIN_NAMESPACE @@ -59,7 +61,7 @@ QML_DEFINE_NOCREATE_TYPE(QGraphicsObject) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GraphicsObjectContainer,QFxGraphicsObjectContainer) QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent) -: QFxItem(parent), _graphicsObject(0) +: QFxItem(parent), _graphicsObject(0), _syncedResize(false) { } @@ -81,9 +83,20 @@ void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object) if (object == _graphicsObject) return; + //### what should we do with previously set object? + _graphicsObject = object; - _graphicsObject->setParentItem(this); + if (_graphicsObject) { + _graphicsObject->setParentItem(this); + + if (_syncedResize && _graphicsObject->isWidget()) { + _graphicsObject->installEventFilter(this); + QSizeF newSize = static_cast<QGraphicsWidget*>(_graphicsObject)->size(); //### use sizeHint? + setImplicitWidth(newSize.width()); + setImplicitHeight(newSize.height()); + } + } } QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value) @@ -96,4 +109,83 @@ QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const return QFxItem::itemChange(change, value); } +bool QFxGraphicsObjectContainer::eventFilter(QObject *watched, QEvent *e) +{ + if (watched == _graphicsObject && e->type() == QEvent::GraphicsSceneResize) { + if (_graphicsObject && _graphicsObject->isWidget() && _syncedResize) { + QSizeF newSize = static_cast<QGraphicsWidget*>(_graphicsObject)->size(); + setImplicitWidth(newSize.width()); + setImplicitHeight(newSize.height()); + } + } + return QFxItem::eventFilter(watched, e); +} + +/*! + \qmlproperty bool GraphicsObjectContainer::synchronizedResizing + + This property determines whether or not the container and graphics object will synchronize their + sizes. + + \note This property only applies when wrapping a QGraphicsWidget. + + If synchronizedResizing is enabled, the container and widget will + synchronize their sizes as follows. + \list + \o If a size has been set on the container, the widget will be resized to the container. + Any changes in the container's size will be reflected in the widget. + + \o \e Otherwise, the container will initially be sized to the preferred size of the widget. + Any changes to the container's size will be reflected in the widget, and any changes to the + widget's size will be reflected in the container. + \endlist +*/ +bool QFxGraphicsObjectContainer::synchronizedResizing() const +{ + return _syncedResize; +} + +void QFxGraphicsObjectContainer::setSynchronizedResizing(bool on) +{ + if (on == _syncedResize) + return; + + if (_graphicsObject && _graphicsObject->isWidget()) { + if (!on) { + _graphicsObject->removeEventFilter(this); + disconnect(this, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); + disconnect(this, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); + } + } + + _syncedResize = on; + + if (_graphicsObject && _graphicsObject->isWidget()) { + if (on) { + _graphicsObject->installEventFilter(this); + connect(this, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); + connect(this, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); + } + } +} + +void QFxGraphicsObjectContainer::_q_updateSize() +{ + if (!_graphicsObject || !_graphicsObject->isWidget() || !_syncedResize) + return; + + QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(_graphicsObject); + const QSizeF newSize(width(), height()); + gw->resize(newSize); + + //### will respecting the widgets min/max ever get us in trouble? (all other items always + // size to exactly what you tell them) + /*QSizeF constrainedSize = newSize.expandedTo(gw->minimumSize()).boundedTo(gw->maximumSize()); + gw->resize(constrainedSize); + if (constrainedSize != newSize) { + setImplicitWidth(constrainedSize.width()); + setImplicitHeight(constrainedSize.height()); + }*/ +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h index 165bc48..a8b7c8c 100644 --- a/src/declarative/fx/qfxgraphicsobjectcontainer.h +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h @@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem Q_CLASSINFO("DefaultProperty", "graphicsObject") Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject) + Q_PROPERTY(bool synchronizedResizing READ synchronizedResizing WRITE setSynchronizedResizing) public: QFxGraphicsObjectContainer(QFxItem *parent = 0); @@ -66,11 +67,19 @@ public: QGraphicsObject *graphicsObject() const; void setGraphicsObject(QGraphicsObject *); + bool synchronizedResizing() const; + void setSynchronizedResizing(bool on); + protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value); + bool eventFilter(QObject *watched, QEvent *e); + +private Q_SLOTS: + void _q_updateSize(); private: QGraphicsObject *_graphicsObject; + bool _syncedResize; }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index eb8103c..0648ac4 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -459,7 +459,7 @@ void QFxRect::drawRect(QPainter &p) QMargins margins(xOffset, yOffset, xOffset, yOffset); QTileRules rules(Qt::StretchTile, Qt::StretchTile); - qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, d->rectImage.width()/2 + xOffset*2, d->rectImage.height()/2 + yOffset*2), margins, d->rectImage, d->rectImage.rect(), margins, rules); + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules); if (d->smooth) { p.setRenderHint(QPainter::Antialiasing, oldAA); diff --git a/src/declarative/fx/qfxscalegrid.cpp b/src/declarative/fx/qfxscalegrid.cpp index f0c5758..4c6a522 100644 --- a/src/declarative/fx/qfxscalegrid.cpp +++ b/src/declarative/fx/qfxscalegrid.cpp @@ -142,15 +142,15 @@ QFxGridScaledImage::QFxGridScaledImage(QIODevice *data) list[0] = list[0].trimmed(); list[1] = list[1].trimmed(); - if (list[0] == QLatin1String("gridLeft")) + if (list[0] == QLatin1String("border.left")) l = list[1].toInt(); - else if (list[0] == QLatin1String("gridRight")) + else if (list[0] == QLatin1String("border.right")) r = list[1].toInt(); - else if (list[0] == QLatin1String("gridTop")) + else if (list[0] == QLatin1String("border.top")) t = list[1].toInt(); - else if (list[0] == QLatin1String("gridBottom")) + else if (list[0] == QLatin1String("border.bottom")) b = list[1].toInt(); - else if (list[0] == QLatin1String("imageFile")) + else if (list[0] == QLatin1String("source")) imgFile = list[1]; else if (list[0] == QLatin1String("horizontalTileRule")) _h = stringToRule(list[1]); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index b2884dd..e185536 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -302,7 +302,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) setLayout(layout); if (mb) layout->addWidget(mb); - layout->addWidget(canvas); + layout->addWidget(canvas, 0, Qt::AlignLeft); setupProxy(); canvas->engine()->networkAccessManager()->setCookieJar(new PersistentCookieJar(this)); @@ -651,6 +651,7 @@ void QmlViewer::openQml(const QString& fileName) if (!skin) { canvas->updateGeometry(); canvas->resize(canvas->sizeHint()); + canvas->updateGeometry(); resize(sizeHint()); } else { if (scaleSkin) |