From c0ea7090a6db60c315dae3534fcaf05d1b2591e1 Mon Sep 17 00:00:00 2001 From: Tapani Mikola Date: Thu, 13 Aug 2009 22:20:13 +0300 Subject: Fix to QFxWebView to show cursor in focused text input. Correction textedit and lineedit so that they emit focuschanged signals. Clean ups to webbrowser.qml. --- .../declarative/webbrowser/fieldtext/FieldText.qml | 28 ++++++---------------- demos/declarative/webbrowser/webbrowser.qml | 1 - src/declarative/fx/qfxlineedit.cpp | 1 + src/declarative/fx/qfxtextedit.cpp | 1 + src/declarative/fx/qfxwebview.cpp | 17 ++++++++++++- src/declarative/fx/qfxwebview.h | 1 + 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/demos/declarative/webbrowser/fieldtext/FieldText.qml b/demos/declarative/webbrowser/fieldtext/FieldText.qml index d822d65..3a9abdf 100644 --- a/demos/declarative/webbrowser/fieldtext/FieldText.qml +++ b/demos/declarative/webbrowser/fieldtext/FieldText.qml @@ -17,7 +17,6 @@ Item { if (!mouseGrabbed) { fieldText.startEdit(); fieldText.state='editing'; - textEdit.selectAll(); mouseGrabbed=true; } } @@ -61,7 +60,7 @@ Item { opacity: 0 } - TextEdit { + LineEdit { id: textEdit text: fieldText.text focus: false @@ -73,7 +72,9 @@ Item { color: "black" font.bold: true readOnly: true - wrap: false + Keys.onEnterPressed: confirm() + Keys.onReturnPressed: confirm() + Keys.onEscapePressed: reset() } Text { @@ -95,20 +96,6 @@ Item { } } - KeyProxy { - id: proxy - focus: false - anchors.fill: parent - targets: [keyActions,textEdit] - } - - Item { - id: keyActions - Keys.onEnterPressed: confirm() - Keys.onReturnPressed: confirm() - Keys.onEscapePressed: reset() - } - MouseRegion { anchors.fill: cancelIcon onClicked: { reset() } @@ -140,6 +127,9 @@ Item { target: textEdit color: "black" readOnly: false + focus: true + selectionStart: 0 + selectionEnd: -1 } SetProperties { target: editRegion @@ -153,10 +143,6 @@ Item { target: textEdit.anchors rightMargin: 34 } - SetProperties { - target: proxy - focus: true - } } ] diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index efa8532..73fedae 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -80,7 +80,6 @@ Item { id: HeaderText text: MyWebView.title!='' || MyWebView.progress == 1.0 ? MyWebView.title : 'Loading...' - //text: MyWebView.url elide: "ElideRight" color: "white" diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index e1d9f14..ccb0637 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -467,6 +467,7 @@ void QFxLineEdit::focusChanged(bool hasFocus) Q_D(QFxLineEdit); d->focused = hasFocus; setCursorVisible(hasFocus); + emit QFxItem::focusChanged(); } void QFxLineEdit::keyPressEvent(QKeyEvent* ev) diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 3013ac2..379e12f 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -885,6 +885,7 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event) void QFxTextEdit::focusChanged(bool hasFocus) { setCursorVisible(hasFocus); + emit QFxItem::focusChanged(); } /*! diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 797e6cb..6645a0f 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -440,6 +440,20 @@ QVariant QFxWebView::evaluateJavaScript(const QString &scriptSource) return this->page()->mainFrame()->evaluateJavaScript(scriptSource); } +void QFxWebView::focusChanged(bool flag) +{ + QFocusEvent *e; + if (flag) { + e = new QFocusEvent (QEvent::FocusIn); + } + else { + e = new QFocusEvent (QEvent::FocusOut); + } + page()->event(e); + delete e; + emit QFxItem::focusChanged(); +} + void QFxWebView::expandToWebPage() { Q_D(QFxWebView); @@ -702,6 +716,7 @@ void QFxWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QFxWebView); if (d->interactive) { + setFocus (true); QMouseEvent *me = sceneMouseEventToMouseEvent(event); if (d->lastPress) delete d->lastPress; d->lastPress = me; @@ -709,7 +724,7 @@ void QFxWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) event->setAccepted( /* It is not correct to send the press event upwards, if it is not accepted by WebKit - e.g. push button does not work, if done so as QGraohucsScene will not send the release event at all to WebKit + e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit Might be a bug in WebKit, though */ #if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835 diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index 9003377..498cf2e 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -211,6 +211,7 @@ protected: void timerEvent(QTimerEvent *event); virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + virtual void focusChanged(bool); private: void init(); -- cgit v0.12 From 1416c6ec1819ff4bd50e7ec964591ca67239e6e0 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 14 Aug 2009 10:54:45 +1000 Subject: Make calling base class focusChanged a protocol. --- src/declarative/fx/qfxitem.cpp | 6 ++++-- src/declarative/fx/qfxlineedit.cpp | 2 +- src/declarative/fx/qfxtextedit.cpp | 2 +- src/declarative/fx/qfxwebview.cpp | 15 ++++----------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index aba6bf1..aab371b 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1822,8 +1822,10 @@ void QFxItem::activeFocusChanged(bool flag) /*! This function emits the \e focusChanged signal. - \a flag is not used. - */ + + Subclasses overriding this function should call up + to their base class. +*/ void QFxItem::focusChanged(bool flag) { Q_UNUSED(flag); diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index ccb0637..6f2f079 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -467,7 +467,7 @@ void QFxLineEdit::focusChanged(bool hasFocus) Q_D(QFxLineEdit); d->focused = hasFocus; setCursorVisible(hasFocus); - emit QFxItem::focusChanged(); + QFxItem::focusChanged(hasFocus); } void QFxLineEdit::keyPressEvent(QKeyEvent* ev) diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 379e12f..1391490 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -885,7 +885,7 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event) void QFxTextEdit::focusChanged(bool hasFocus) { setCursorVisible(hasFocus); - emit QFxItem::focusChanged(); + QFxItem::focusChanged(hasFocus); } /*! diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 6645a0f..eb84097 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -440,18 +440,11 @@ QVariant QFxWebView::evaluateJavaScript(const QString &scriptSource) return this->page()->mainFrame()->evaluateJavaScript(scriptSource); } -void QFxWebView::focusChanged(bool flag) +void QFxWebView::focusChanged(bool hasFocus) { - QFocusEvent *e; - if (flag) { - e = new QFocusEvent (QEvent::FocusIn); - } - else { - e = new QFocusEvent (QEvent::FocusOut); - } - page()->event(e); - delete e; - emit QFxItem::focusChanged(); + QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut); + page()->event(&e); + QFxItem::focusChanged(hasFocus); } void QFxWebView::expandToWebPage() -- cgit v0.12 From 27bf0d224bb44e2b4ade4dee24fd781b3220bb21 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 14 Aug 2009 11:56:18 +1000 Subject: New Qt URL. --- demos/declarative/webbrowser/webbrowser.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 73fedae..c4f7c8a 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -6,7 +6,7 @@ import "fieldtext" Item { id: WebBrowser - property string urlString : "http://www.qtsoftware.com/" + property string urlString : "http://qt.nokia.com/" state: "Normal" -- cgit v0.12 From 48dc284007cbbc1dbf5c7aeee250d5ad4006dbed Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 12:11:21 +1000 Subject: Remove unused function. --- src/declarative/fx/qfxitem.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index f005d89..30d9f1e 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -235,8 +235,6 @@ private: void setKeyHandler(QFxKeysAttached *); - // ### move to d-pointer - void init(QFxItem *parent); friend class QmlStatePrivate; friend class QFxAnchors; friend class QFxKeysAttached; -- cgit v0.12 From da56f50eb640823e2d48c1308c09626a428a50f5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 12:49:22 +1000 Subject: Improve error message. --- src/declarative/qml/qmlcompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 75ed94b..5c12d9c 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -1490,7 +1490,7 @@ bool QmlCompiler::buildValueTypeProperty(QObject *type, foreach (Property *prop, obj->properties) { int idx = type->metaObject()->indexOfProperty(prop->name.constData()); if (idx == -1) - COMPILE_EXCEPTION(prop, "Cannot assign to non-existant property"); + COMPILE_EXCEPTION(prop, "Cannot assign to non-existant property" << prop->name); QMetaProperty p = type->metaObject()->property(idx); prop->index = idx; prop->type = p.userType(); -- cgit v0.12 From c7aef9c3a3a9c4b2fcebb9f55ae11fc0b590a9ed Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 12:56:13 +1000 Subject: Get rid of QmlFont and use the QFont value type instead. --- demos/declarative/calculator/calculator.qml | 4 +- demos/declarative/flickr/content/ImageDetails.qml | 2 +- demos/declarative/flickr/flickr.qml | 2 +- demos/declarative/flickr/flickr2.qml | 2 +- demos/declarative/samegame/SameGame.qml | 2 +- demos/declarative/samegame/content/Button.qml | 2 +- demos/declarative/webbrowser/webbrowser.qml | 4 +- doc/src/declarative/basictypes.qdoc | 4 +- doc/src/declarative/qmlforcpp.qdoc | 2 +- doc/src/declarative/tutorial1.qdoc | 6 +- doc/src/declarative/tutorial2.qdoc | 2 +- doc/src/declarative/tutorial3.qdoc | 2 +- examples/declarative/fillmode/fillmode.qml | 2 +- examples/declarative/fonts/fonts.qml | 10 +- examples/declarative/listview/recipes.qml | 6 +- examples/declarative/loader/Browser.qml | 2 +- examples/declarative/loader/Button.qml | 2 +- examples/declarative/minehunt/minehunt.qml | 2 +- .../tutorials/helloworld/t1/tutorial1.qml | 2 +- .../tutorials/helloworld/t2/tutorial2.qml | 2 +- .../tutorials/helloworld/t3/tutorial3.qml | 2 +- examples/declarative/velocity/Day.qml | 4 +- examples/declarative/xmldata/yahoonews.qml | 2 +- src/declarative/fx/qfxlineedit.cpp | 22 ++- src/declarative/fx/qfxlineedit.h | 6 +- src/declarative/fx/qfxlineedit_p.h | 4 +- src/declarative/fx/qfxtext.cpp | 38 +++--- src/declarative/fx/qfxtext.h | 11 +- src/declarative/fx/qfxtext_p.h | 23 +--- src/declarative/fx/qfxtextedit.cpp | 43 +++--- src/declarative/fx/qfxtextedit.h | 9 +- src/declarative/fx/qfxtextedit_p.h | 4 +- src/declarative/util/qmlfont.cpp | 148 --------------------- src/declarative/util/qmlfont.h | 93 ------------- src/declarative/util/util.pri | 2 - 35 files changed, 96 insertions(+), 377 deletions(-) delete mode 100644 src/declarative/util/qmlfont.cpp delete mode 100644 src/declarative/util/qmlfont.h diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index 42e1422..f766a30 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -17,7 +17,7 @@ Rect { Text { id: CurNum - font.bold: true; font.size: 16 + font.bold: true; font.pointSize: 16 color: Palette.text anchors.right: Container.right anchors.rightMargin: 5 @@ -27,7 +27,7 @@ Rect { Text { id: CurrentOperation color: Palette.text - font.bold: true; font.size: 16 + font.bold: true; font.pointSize: 16 anchors.left: Container.left anchors.leftMargin: 5 anchors.verticalCenter: Container.verticalCenter diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml index 0182d48..09d8f03 100644 --- a/demos/declarative/flickr/content/ImageDetails.qml +++ b/demos/declarative/flickr/content/ImageDetails.qml @@ -44,7 +44,7 @@ Flipable { } Text { id: TitleText; style: "Raised"; styleColor: "black"; color: "white"; elide: "ElideRight" - x: 220; y: 30; width: parent.width - 240; text: Container.photoTitle; font.size: 22 } + x: 220; y: 30; width: parent.width - 240; text: Container.photoTitle; font.pointSize: 22 } LikeOMeter { x: 40; y: 250; rating: Container.rating } diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml index 8e1e3e8..a8d18fb 100644 --- a/demos/declarative/flickr/flickr.qml +++ b/demos/declarative/flickr/flickr.qml @@ -206,6 +206,6 @@ Item { id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15; text: "Flickr - " + (FeedModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + FeedModel.tags) - font.size: 20; font.bold: true; color: "white"; style: "Raised"; styleColor: "black" + font.pointSize: 20; font.bold: true; color: "white"; style: "Raised"; styleColor: "black" } } diff --git a/demos/declarative/flickr/flickr2.qml b/demos/declarative/flickr/flickr2.qml index f3b4244..5350a36 100644 --- a/demos/declarative/flickr/flickr2.qml +++ b/demos/declarative/flickr/flickr2.qml @@ -256,6 +256,6 @@ Item { id: CategoryText; anchors.horizontalCenter: parent.horizontalCenter; y: 15; text: "Flickr - " + (FeedModel.tags=="" ? "Uploads from everyone" : "Recent Uploads tagged " + FeedModel.tags) - font.size: 16; font.bold: true; color: "white"; style: "Raised"; styleColor: "black" + font.pointSize: 16; font.bold: true; color: "white"; style: "Raised"; styleColor: "black" } } diff --git a/demos/declarative/samegame/SameGame.qml b/demos/declarative/samegame/SameGame.qml index e74646d..42c313c 100644 --- a/demos/declarative/samegame/SameGame.qml +++ b/demos/declarative/samegame/SameGame.qml @@ -28,7 +28,7 @@ Rect { anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.left: gameCanvas.left; } Text { - text: "Score: " + gameCanvas.score; width:100; font.size:14 + text: "Score: " + gameCanvas.score; width:100; font.pointSize:14 anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.right: gameCanvas.right; } } diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/content/Button.qml index c7a49f1..e3d0d30 100644 --- a/demos/declarative/samegame/content/Button.qml +++ b/demos/declarative/samegame/content/Button.qml @@ -13,6 +13,6 @@ Rect { MouseRegion { id:mr; anchors.fill: parent; onClicked: page.clicked() } Text { id: txtItem; text: page.text; anchors.centerIn: page; color: activePalette.buttonText - font.size: 14; + font.pointSize: 14; } } diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 73fedae..f57b7be 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -87,7 +87,7 @@ Item { style: "Raised" font.family: "Helvetica" - font.size: 10 + font.pointSize: 10 font.bold: true anchors.left: Header.left @@ -136,7 +136,7 @@ Item { /*<<<<<<< HEAD:demos/declarative/webbrowser/webbrowser.qml text: MyWebView.url == '' ? ' ' : MyWebView.url wrap: false - font.size: 11 + font.pointSize: 11 color: "#555555" focusOnPress: true =======*/ diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index a22af0f..684fd0d 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -214,12 +214,12 @@ \o string font.family \o bool font.bold \o bool font.italic - \o real font.size + \o real font.pointSize \endlist Setting a font looks like this: \code - Text { font.family: "Helvetica"; font.size: 13; font.bold: true } + Text { font.family: "Helvetica"; font.pointSize: 13; font.bold: true } \endcode \target basicqmlaction diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc index 74357bb..53af252 100644 --- a/doc/src/declarative/qmlforcpp.qdoc +++ b/doc/src/declarative/qmlforcpp.qdoc @@ -161,7 +161,7 @@ \code Text { font.family: "helvetica" - font.size: 12 + font.pointSize: 12 font { bold: true italic: true diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index 5c11326..d38dc54 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -18,7 +18,7 @@ Rect { Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter @@ -49,7 +49,7 @@ The \l Rect element contains many other properties (such as \c x and \c y), but Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter @@ -60,7 +60,7 @@ We add a text element as a child of our root element to display the text 'Hello The \c y property is used to position the text vertically at 30 pixels from the top of its parent. -The \c font.size and \c font.bold properties are related to fonts and use the \e 'dot' notation. +The \c font.pointSize and \c font.bold properties are related to fonts and use the \e 'dot' notation. The \c anchors.horizontalCenter property refers to the horizontal center of an element. In this case, we specify that our text element should be horizontally centered in the \e Page element. diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc index c22a01a..4be0702 100644 --- a/doc/src/declarative/tutorial2.qdoc +++ b/doc/src/declarative/tutorial2.qdoc @@ -41,7 +41,7 @@ Rect { Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc index 9ae56c1..0f9dac2 100644 --- a/doc/src/declarative/tutorial3.qdoc +++ b/doc/src/declarative/tutorial3.qdoc @@ -20,7 +20,7 @@ Rect { Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml index f2a87c8..9e22885 100644 --- a/examples/declarative/fillmode/fillmode.qml +++ b/examples/declarative/fillmode/fillmode.qml @@ -28,7 +28,7 @@ Image { } Text { id: Label - font.size: 24 + font.pointSize: 24 color: "blue" style: "Outline" styleColor: "white" diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index 9fd409a..578cffa 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -24,21 +24,21 @@ Rect { color: Palette.windowText width: parent.width; elide: "ElideRight" font.family: "Times" - font.size: 32 + font.pointSize: 32 } Text { text: myText color: Palette.windowText width: parent.width; elide: "ElideRight" font.family: FixedFont.name - font.size: 32 + font.pointSize: 32 } Text { text: myText color: Palette.windowText width: parent.width; elide: "ElideRight" font.family: LocalFont.name - font.size: 32 + font.pointSize: 32 } Text { text: { @@ -49,7 +49,7 @@ Rect { color: Palette.windowText width: parent.width; elide: "ElideRight" font.family: WebFont.name - font.size: 32 + font.pointSize: 32 } Text { text: { @@ -60,7 +60,7 @@ Rect { color: Palette.windowText width: parent.width; elide: "ElideRight" font.family: WebFont2.name - font.size: 32 + font.pointSize: 32 } } } diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index 7abadd0..b2c17af 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -48,9 +48,9 @@ Rect { VerticalPositioner { height: recipePic.height; width: background.width-recipePic.width-20 spacing: 5 - Text { id: name; text: title; font.bold: true; font.size: 16 } + Text { id: name; text: title; font.bold: true; font.pointSize: 16 } Text { - text: "Ingredients"; font.size: 12; font.bold: true + text: "Ingredients"; font.pointSize: 12; font.bold: true opacity: wrapper.detailsOpacity } Text { @@ -67,7 +67,7 @@ Rect { opacity: wrapper.detailsOpacity Text { id: methodTitle - text: "Method"; font.size: 12; font.bold: true + text: "Method"; font.pointSize: 12; font.bold: true anchors.top: parent.top } Flickable { diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml index 96c2a76..1c849b8 100644 --- a/examples/declarative/loader/Browser.qml +++ b/examples/declarative/loader/Browser.qml @@ -36,7 +36,7 @@ Rect { id: NameText anchors.fill: parent; vAlign: "AlignVCenter" text: fileName; anchors.leftMargin: 32 - font.size: 10 + font.pointSize: 10 color: activePalette.windowText } MouseRegion { diff --git a/examples/declarative/loader/Button.qml b/examples/declarative/loader/Button.qml index 999e180..391a800 100644 --- a/examples/declarative/loader/Button.qml +++ b/examples/declarative/loader/Button.qml @@ -12,5 +12,5 @@ Rect { radius: 4 color: "grey" MouseRegion { anchors.fill: parent; onClicked: Container.clicked() } - Text { id: Text; anchors.centerIn:parent; font.size: 10; text: parent.text } + Text { id: Text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text } } diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml index 55cf3c2..b3bcaf3 100644 --- a/examples/declarative/minehunt/minehunt.qml +++ b/examples/declarative/minehunt/minehunt.qml @@ -148,7 +148,7 @@ Item { y: 380 Text { color: "white" - font.size: 18 + font.pointSize: 18 x: 20 y: 20 } diff --git a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml index f067695..156655a 100644 --- a/examples/declarative/tutorials/helloworld/t1/tutorial1.qml +++ b/examples/declarative/tutorials/helloworld/t1/tutorial1.qml @@ -8,7 +8,7 @@ Rect { Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml index efbdbf1..5619d04 100644 --- a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml +++ b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml @@ -8,7 +8,7 @@ Rect { Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index 3e93632..ca32709 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -8,7 +8,7 @@ Rect { Text { id: HelloText text: "Hello world!" - font.size: 24 + font.pointSize: 24 font.bold: true y: 30 anchors.horizontalCenter: Page.horizontalCenter diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index f7a5a47..59a31af 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -18,7 +18,7 @@ Rect { x: 20 y: 20 height: 40 - font.size: 14 + font.pointSize: 14 font.bold: true width: 370 text: day @@ -50,7 +50,7 @@ Rect { TextEdit { id: MyText smooth: true - font.size: 28 + font.pointSize: 28 readOnly: false x: -104 y: 36 diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index c7f0b08..156eb31 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -49,7 +49,7 @@ Rect { text: '' + title + '' font.bold: true font.family: "Helvetica" - font.size: 14 + font.pointSize: 14 onLinkActivated: { print('link clicked: ' + link) } } Text { diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index 6f2f079..de850f8 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -101,26 +101,25 @@ void QFxLineEdit::setText(const QString &s) Set the LineEdit's font attributes. \c font.size sets the font's point size. */ -QmlFont *QFxLineEdit::font() +QFont QFxLineEdit::font() const { - Q_D(QFxLineEdit); + Q_D(const QFxLineEdit); return d->font; } -/*! -This signal is emitted when the font of the item changes. -*/ -void QFxLineEdit::fontChanged() +void QFxLineEdit::setFont(const QFont &font) { Q_D(QFxLineEdit); - d->control->setFont(d->font->font()); + d->font = font; + + d->control->setFont(d->font); if(d->cursorItem){ - d->cursorItem->setHeight(QFontMetrics(d->font->font()).height()); + d->cursorItem->setHeight(QFontMetrics(d->font).height()); moveCursor(); } //updateSize(); updateAll();//TODO: Only necessary updates - emit update(); + update(); } /*! @@ -564,9 +563,6 @@ void QFxLineEditPrivate::init() q, SLOT(updateAll())); q->connect(control, SIGNAL(selectionChanged()), q, SLOT(updateAll())); - if(!font) - font = new QmlFont(); - q->connect(font, SIGNAL(updated()), q, SLOT(fontChanged())); q->updateSize(); oldValidity = control->hasAcceptableInput(); lastSelectionStart = 0; @@ -633,7 +629,7 @@ void QFxLineEdit::updateSize() Q_D(QFxLineEdit); setImplicitHeight(d->control->height()); //d->control->width() is max width, not current width - QFontMetrics fm = QFontMetrics(d->font->font()); + QFontMetrics fm = QFontMetrics(d->font); setImplicitWidth(fm.boundingRect(d->control->text()).width()+1); setContentsSize(QSize(width(), height())); } diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h index f78dbfc..0218fb0 100644 --- a/src/declarative/fx/qfxlineedit.h +++ b/src/declarative/fx/qfxlineedit.h @@ -64,7 +64,7 @@ class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) - Q_PROPERTY(QmlFont *font READ font CONSTANT) + Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) @@ -98,7 +98,8 @@ public: QString text() const; void setText(const QString &); - QmlFont *font(); + QFont font() const; + void setFont(const QFont &font); QColor color() const; void setColor(const QColor &c); @@ -169,7 +170,6 @@ protected: private Q_SLOTS: void updateSize(); - void fontChanged(); void q_textChanged(); void selectionChanged(); void updateAll(); diff --git a/src/declarative/fx/qfxlineedit_p.h b/src/declarative/fx/qfxlineedit_p.h index a087a32..369669f 100644 --- a/src/declarative/fx/qfxlineedit_p.h +++ b/src/declarative/fx/qfxlineedit_p.h @@ -64,7 +64,7 @@ class QFxLineEditPrivate : public QFxPaintedItemPrivate Q_DECLARE_PUBLIC(QFxLineEdit); public: QFxLineEditPrivate() : control(new QLineControl(QString())), - font(0), color((QRgb)0), style(QFxText::Normal), + color((QRgb)0), style(QFxText::Normal), styleColor((QRgb)0), hAlign(QFxLineEdit::AlignLeft), hscroll(0), oldScroll(0), focused(false), cursorVisible(false) { @@ -79,7 +79,7 @@ public: QLineControl* control; - QmlFont *font; + QFont font; QColor color; QColor highlightColor; QColor highlightedTextColor; diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 0315a75..11fef69 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -108,7 +108,6 @@ QFxText::QFxText(QFxItem *parent) : QFxItem(*(new QFxTextPrivate), parent) { Q_D(QFxText); - d->init(); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, false); } @@ -117,7 +116,6 @@ QFxText::QFxText(QFxTextPrivate &dd, QFxItem *parent) : QFxItem(dd, parent) { Q_D(QFxText); - d->init(); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, false); } @@ -142,10 +140,20 @@ QFxText::~QFxText() \brief the font used to display the text. */ -QmlFont *QFxText::font() +QFont QFxText::font() const +{ + Q_D(const QFxText); + return d->font; +} + +void QFxText::setFont(const QFont &font) { Q_D(QFxText); - return d->font(); + d->font = font; + + d->imgDirty = true; + d->updateSize(); + update(); } void QFxText::setText(const QString &n) @@ -492,15 +500,6 @@ void QFxText::geometryChanged(const QRectF &newGeometry, QFxItem::geometryChanged(newGeometry, oldGeometry); } - -void QFxText::fontChanged() -{ - Q_D(QFxText); - d->imgDirty = true; - d->updateSize(); - emit update(); -} - void QFxTextPrivate::updateSize() { Q_Q(QFxText); @@ -508,8 +507,7 @@ void QFxTextPrivate::updateSize() if (text.isEmpty()) { return; } - QFont f; if (_font) f = _font->font(); - QFontMetrics fm(f); + QFontMetrics fm(font); int dy = q->height(); QString tmp; @@ -524,14 +522,14 @@ void QFxTextPrivate::updateSize() if (singleline && elideMode != Qt::ElideNone && q->widthValid()) tmp = fm.elidedText(tmp,elideMode,q->width()); // XXX still worth layout...? layout.clearLayout(); - layout.setFont(f); + layout.setFont(font); layout.setText(tmp); size = setupTextLayout(&layout); cachedLayoutSize = size; } if (richText) { singleline = false; // richtext can't elide or be optimized for single-line case - doc->setDefaultFont(f); + doc->setDefaultFont(font); QTextOption option((Qt::Alignment)int(hAlign | vAlign)); if (wrap) option.setWrapMode(QTextOption::WordWrap); @@ -622,8 +620,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout) Q_Q(QFxText); layout->setCacheEnabled(true); - QFont f; if (_font) f = _font->font(); - QFontMetrics fm = QFontMetrics(f); + QFontMetrics fm = QFontMetrics(font); int height = 0; qreal widthUsed = 0; @@ -657,7 +654,6 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout) QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle) { //do layout - QFont f; if (_font) f = _font->font(); QSize size = cachedLayoutSize; int x = 0; @@ -682,7 +678,7 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle) } else p.setPen(color); - p.setFont(f); + p.setFont(font); layout.draw(&p, QPointF(0, 0)); return img; } diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index 3665ac6..edf6031 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -43,8 +43,6 @@ #define QFXTEXT_H #include -#include - QT_BEGIN_HEADER @@ -61,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_ENUMS(TextFormat) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QmlFont *font READ font CONSTANT) + Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(TextStyle style READ style WRITE setStyle) Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor) @@ -93,7 +91,8 @@ public: QString text() const; void setText(const QString &); - QmlFont *font(); + QFont font() const; + void setFont(const QFont &font); QColor color() const; void setColor(const QColor &c); @@ -129,10 +128,6 @@ Q_SIGNALS: void textChanged(const QString &text); void linkActivated(const QString &link); -private Q_SLOTS: - //### should be in QFxTextPrivate? - void fontChanged(); - protected: QFxText(QFxTextPrivate &dd, QFxItem *parent); void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h index bbb54a3..95b566c 100644 --- a/src/declarative/fx/qfxtext_p.h +++ b/src/declarative/fx/qfxtext_p.h @@ -69,22 +69,13 @@ class QFxTextPrivate : public QFxItemPrivate Q_DECLARE_PUBLIC(QFxText) public: QFxTextPrivate() - : _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true), + : color((QRgb)0), style(QFxText::Normal), imgDirty(true), hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone), dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0), format(QFxText::AutoText) { } - ~QFxTextPrivate() - { - delete _font; - } - - void init() - { - } - void updateSize(); void checkImgCache(); @@ -96,17 +87,7 @@ public: QSize setupTextLayout(QTextLayout *layout); QString text; - QmlFont *font() - { - if (!_font) { - Q_Q(QFxText); - _font = new QmlFont; - QObject::connect(_font, SIGNAL(updated()), q, SLOT(fontChanged())); - } - return _font; - } - - QmlFont *_font; + QFont font; QColor color; QFxText::TextStyle style; QColor styleColor; diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 1391490..628d49b 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -242,10 +242,25 @@ void QFxTextEdit::setTextFormat(TextFormat format) \brief the text edit's default font */ -QmlFont *QFxTextEdit::font() +QFont QFxTextEdit::font() const +{ + Q_D(const QFxTextEdit); + return d->font; +} + +void QFxTextEdit::setFont(const QFont &font) { Q_D(QFxTextEdit); - return &(d->font); + d->font = font; + + clearCache(); + d->document->setDefaultFont(d->font); + if(d->cursor){ + d->cursor->setHeight(QFontMetrics(d->font).height()); + moveCursorDelegate(); + } + updateSize(); + update(); } /*! @@ -532,7 +547,7 @@ void QFxTextEdit::loadCursorDelegate() d->control->setCursorWidth(0); dirtyCache(cursorRect()); d->cursor->setParentItem(this); - d->cursor->setHeight(QFontMetrics(d->font.font()).height()); + d->cursor->setHeight(QFontMetrics(d->font).height()); moveCursorDelegate(); }else{ qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName(); @@ -980,22 +995,6 @@ void QFxTextEdit::drawContents(QPainter *painter, const QRect &bounds) d->control->drawContents(painter, bounds); } -/*! -This signal is emitted when the font of the item changes. -*/ -void QFxTextEdit::fontChanged() -{ - Q_D(QFxTextEdit); - clearCache(); - d->document->setDefaultFont(d->font.font()); - if(d->cursor){ - d->cursor->setHeight(QFontMetrics(d->font.font()).height()); - moveCursorDelegate(); - } - updateSize(); - emit update(); -} - void QFxTextEdit::updateImgCache(const QRectF &r) { dirtyCache(r.toRect()); @@ -1024,8 +1023,6 @@ void QFxTextEditPrivate::init() q->setFlag(QGraphicsItem::ItemHasNoContents, false); q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); - QObject::connect(&font, SIGNAL(updated()), q, SLOT(fontChanged())); - control = new QTextControl(q); QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF))); @@ -1037,7 +1034,7 @@ void QFxTextEditPrivate::init() QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged())); document = control->document(); - document->setDefaultFont(font.font()); + document->setDefaultFont(font); document->setDocumentMargin(textMargin); document->setUndoRedoEnabled(false); // flush undo buffer. document->setUndoRedoEnabled(true); @@ -1102,7 +1099,7 @@ void QFxTextEdit::updateSize() { Q_D(QFxTextEdit); if (isComponentComplete()) { - QFontMetrics fm = QFontMetrics(d->font.font()); + QFontMetrics fm = QFontMetrics(d->font); int dy = height(); // ### assumes that if the width is set, the text will fill to edges // ### (unless wrap is false, then clipping will occur) diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index 132b474..f2f163b 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -71,7 +71,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) - Q_PROPERTY(QmlFont * font READ font) + Q_PROPERTY(QFont font READ font WRITE setFont) Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) Q_PROPERTY(bool wrap READ wrap WRITE setWrap) @@ -114,8 +114,8 @@ public: TextFormat textFormat() const; void setTextFormat(TextFormat format); - // leave in, have affect the default text - QmlFont *font(); + QFont font() const; + void setFont(const QFont &font); QColor color() const; void setColor(const QColor &c); @@ -192,7 +192,6 @@ public Q_SLOTS: void selectAll(); private Q_SLOTS: - void fontChanged(); void updateImgCache(const QRectF &rect); void q_textChanged(); void updateSelectionMarkers(); @@ -223,8 +222,6 @@ protected: void drawContents(QPainter *, const QRect &); private: - - friend class QmlFont; Q_DISABLE_COPY(QFxTextEdit) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxTextEdit) }; diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h index 45a8a60..fb757de 100644 --- a/src/declarative/fx/qfxtextedit_p.h +++ b/src/declarative/fx/qfxtextedit_p.h @@ -68,7 +68,7 @@ class QFxTextEditPrivate : public QFxPaintedItemPrivate public: QFxTextEditPrivate() - : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), + : color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false), preserveSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QFxTextEdit::AutoText), document(0) @@ -82,7 +82,7 @@ public: void updateSelection(); QString text; - QmlFont font; + QFont font; QColor color; QColor highlightColor; QColor highlightedTextColor; diff --git a/src/declarative/util/qmlfont.cpp b/src/declarative/util/qmlfont.cpp deleted file mode 100644 index 06e8769..0000000 --- a/src/declarative/util/qmlfont.cpp +++ /dev/null @@ -1,148 +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 "private/qobject_p.h" -#include "qfont.h" -#include "qmlfont.h" - -QT_BEGIN_NAMESPACE - -class QmlFontPrivate : public QObjectPrivate -{ -public: - QFont font; -}; - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Font,QmlFont) - -/*! - \internal - \class QmlFont - \ingroup group_utility - \brief The QmlFont class provides a font used for drawing text on a QFxView. -*/ -QmlFont::QmlFont(QObject *parent) - : QObject(*(new QmlFontPrivate), parent) -{ -} - -QmlFont::~QmlFont() -{ -} - -/*! - \property QmlFont::family - \brief the family of the font. -*/ -QString QmlFont::family() const -{ - Q_D(const QmlFont); - return d->font.family(); -} - -void QmlFont::setFamily(const QString &family) -{ - Q_D(QmlFont); - d->font.setFamily(family); - emit updated(); -} - -/*! - \property QmlFont::bold - \brief whether the font should be bold. -*/ -bool QmlFont::bold() const -{ - Q_D(const QmlFont); - return d->font.bold(); -} - -void QmlFont::setBold(bool b) -{ - Q_D(QmlFont); - d->font.setBold(b); - emit updated(); -} - -/*! - \property QmlFont::italic - \brief whether the font should be italic. -*/ -bool QmlFont::italic() const -{ - Q_D(const QmlFont); - return d->font.italic(); -} - -void QmlFont::setItalic(bool b) -{ - Q_D(QmlFont); - d->font.setItalic(b); - emit updated(); -} - -/*! - \property QmlFont::size - \brief the size of the font in points. -*/ -qreal QmlFont::size() const -{ - Q_D(const QmlFont); - return d->font.pointSizeF(); -} - -void QmlFont::setSize(qreal size) -{ - Q_D(QmlFont); - d->font.setPointSizeF(size); - emit updated(); -} - -/*! - \brief Returns a QFont representation of the font. -*/ -QFont QmlFont::font() const -{ - Q_D(const QmlFont); - return d->font; -} - -QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfont.h b/src/declarative/util/qmlfont.h deleted file mode 100644 index e85b8d3..0000000 --- a/src/declarative/util/qmlfont.h +++ /dev/null @@ -1,93 +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 QMLFONT_H -#define QMLFONT_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlFontPrivate; -class Q_DECLARATIVE_EXPORT QmlFont : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlFont) - - Q_PROPERTY(QString family READ family WRITE setFamily) - Q_PROPERTY(bool bold READ bold WRITE setBold) - Q_PROPERTY(bool italic READ italic WRITE setItalic) - Q_PROPERTY(qreal size READ size WRITE setSize) - -public: - QmlFont(QObject *parent=0); - ~QmlFont(); - - QString family() const; - void setFamily(const QString &); - - bool bold() const; - void setBold(bool b); - - bool italic() const; - void setItalic(bool b); - - qreal size() const; - void setSize(qreal size); - - QFont font() const; - -Q_SIGNALS: - void updated(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlFont) - -QT_END_HEADER - -#endif // QMLFONT_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 59e3695..9374f00 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -6,7 +6,6 @@ SOURCES += \ util/qmlpackage.cpp \ util/qmlscript.cpp \ util/qmlanimation.cpp \ - util/qmlfont.cpp \ util/qmlpalette.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ @@ -32,7 +31,6 @@ HEADERS += \ util/qmlscript.h \ util/qmlanimation.h \ util/qmlanimation_p.h \ - util/qmlfont.h \ util/qmlpalette.h \ util/qmlfollow.h \ util/qmlstate.h\ -- cgit v0.12 From 76653ee26b5884b9510e6d73b348573491d39711 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 13:02:02 +1000 Subject: Remove unused function. --- src/declarative/fx/qfxitem.cpp | 7 ------- src/declarative/fx/qfxitem.h | 3 --- 2 files changed, 10 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index aab371b..f10977f 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -876,13 +876,6 @@ QFxItem::QFxItem(QFxItemPrivate &dd, QFxItem *parent) d->init(parent); } -/*! \internal -*/ -void QFxItem::doUpdate() -{ - update(); -} - /*! Destroys the QFxItem. */ diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 30d9f1e..35a757e 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -217,9 +217,6 @@ protected: virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); -private Q_SLOTS: - void doUpdate(); - protected: QFxItem(QFxItemPrivate &dd, QFxItem *parent = 0); -- cgit v0.12 From 84756f93be62b5f901825f81484a733912d8f37c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 13:43:12 +1000 Subject: Remove unused include. --- src/declarative/fx/qfxitem.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 35a757e..d8fb983 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -43,7 +43,6 @@ #define QFXITEM_H #include -#include #include #include #include -- cgit v0.12 From e84c2895ff108b43515a5200a646610efea6d8da Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 13:43:27 +1000 Subject: Make sure URLs specified in a state change are resolved. --- src/declarative/util/qmlsetproperties.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 482405c..a08f4ba 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -48,6 +48,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -314,6 +315,11 @@ QmlSetProperties::ActionList QmlSetProperties::actions() if (a.property.isValid()) { a.restore = restoreEntryValues(); + + if (a.property.propertyType() == QVariant::Url && + (a.toValue.type() == QVariant::String || a.toValue.type() == QVariant::ByteArray) && !a.toValue.isNull()) + a.toValue.setValue(qmlContext(this)->resolvedUrl(QUrl(a.toValue.toString()))); //### d->object's context? + list << a; } } -- cgit v0.12 From 56693f7d247ee8da6b730b157d1871a1dceab5a8 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 13:56:05 +1000 Subject: QFxPixmap -> QFxPixmapCache --- src/declarative/extra/qfxparticles.cpp | 10 +- src/declarative/fx/fx.pri | 4 +- src/declarative/fx/qfxborderimage.cpp | 14 +- src/declarative/fx/qfximagebase.cpp | 10 +- src/declarative/fx/qfxpixmap.cpp | 233 --------------------------------- src/declarative/fx/qfxpixmap.h | 70 ---------- src/declarative/fx/qfxpixmapcache.cpp | 231 ++++++++++++++++++++++++++++++++ src/declarative/fx/qfxpixmapcache.h | 70 ++++++++++ src/declarative/fx/qfxscalegrid_p.h | 2 +- 9 files changed, 321 insertions(+), 323 deletions(-) delete mode 100644 src/declarative/fx/qfxpixmap.cpp delete mode 100644 src/declarative/fx/qfxpixmap.h create mode 100644 src/declarative/fx/qfxpixmapcache.cpp create mode 100644 src/declarative/fx/qfxpixmapcache.h diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index f05f233..0e94ea6 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -50,7 +50,7 @@ #ifndef INT_MAX #define INT_MAX 2147483647 #endif -#include +#include #include #include #include @@ -617,7 +617,7 @@ QFxParticles::~QFxParticles() { Q_D(QFxParticles); if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); + QFxPixmapCache::cancelGet(d->url, this); } /*! @@ -638,7 +638,7 @@ QUrl QFxParticles::source() const void QFxParticles::imageLoaded() { Q_D(QFxParticles); - QFxPixmap::find(d->url, &d->image); + QFxPixmapCache::find(d->url, &d->image); d->paintItem->updateSize(); d->paintItem->update(); } @@ -651,7 +651,7 @@ void QFxParticles::setSource(const QUrl &name) return; if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); + QFxPixmapCache::cancelGet(d->url, this); if (name.isEmpty()) { d->url = name; d->image = QPixmap(); @@ -660,7 +660,7 @@ void QFxParticles::setSource(const QUrl &name) } else { d->url = name; Q_ASSERT(!name.isRelative()); - d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->image); + d->reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->image); if (d->reply) connect(d->reply, SIGNAL(finished()), this, SLOT(imageLoaded())); else { diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 5f574cd..48af58e 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -41,7 +41,7 @@ HEADERS += \ fx/qfxtextedit_p.h \ fx/qfxtext.h \ fx/qfxtext_p.h \ - fx/qfxpixmap.cpp \ + fx/qfxpixmapcache.h \ fx/qfxvisualitemmodel.h \ fx/qfxlistview.h \ fx/qfxgraphicsobjectcontainer.h \ @@ -72,7 +72,7 @@ SOURCES += \ fx/qfxlineedit.cpp \ fx/qfxtext.cpp \ fx/qfxtextedit.cpp \ - fx/qfxpixmap.cpp \ + fx/qfxpixmapcache.cpp \ fx/qfxvisualitemmodel.cpp \ fx/qfxlistview.cpp \ fx/qfxgraphicsobjectcontainer.cpp \ diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index adb70a3..4920bf6 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -92,7 +92,7 @@ QFxBorderImage::~QFxBorderImage() if (d->sciReply) d->sciReply->deleteLater(); if (!d->sciurl.isEmpty()) - QFxPixmap::cancelGet(d->sciurl, this); + QFxPixmapCache::cancelGet(d->sciurl, this); } /*! \qmlproperty enum BorderImage::status @@ -166,9 +166,9 @@ void QFxBorderImage::setSource(const QUrl &url) } if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); + QFxPixmapCache::cancelGet(d->url, this); if (!d->sciurl.isEmpty()) - QFxPixmap::cancelGet(d->sciurl, this); + QFxPixmapCache::cancelGet(d->sciurl, this); d->url = url; d->sciurl = QUrl(); @@ -205,7 +205,7 @@ void QFxBorderImage::setSource(const QUrl &url) this, SLOT(sciRequestFinished())); } } else { - d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->pix); + d->reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix); if (d->reply) { connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), @@ -315,7 +315,7 @@ void QFxBorderImage::setGridScaledImage(const QFxGridScaledImage& sci) d->verticalTileMode = sci.verticalTileRule(); d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - d->reply = QFxPixmap::get(qmlEngine(this), d->sciurl, &d->pix); + d->reply = QFxPixmapCache::get(qmlEngine(this), d->sciurl, &d->pix); if (d->reply) { connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), @@ -340,7 +340,7 @@ void QFxBorderImage::requestFinished() { Q_D(QFxBorderImage); if (d->url.path().endsWith(QLatin1String(".sci"))) { - QFxPixmap::find(d->sciurl, &d->pix); + QFxPixmapCache::find(d->sciurl, &d->pix); } else { if (d->reply) { //###disconnect really needed? @@ -349,7 +349,7 @@ void QFxBorderImage::requestFinished() if (d->reply->error() != QNetworkReply::NoError) d->status = Error; } - QFxPixmap::find(d->url, &d->pix); + QFxPixmapCache::find(d->url, &d->pix); } setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); diff --git a/src/declarative/fx/qfximagebase.cpp b/src/declarative/fx/qfximagebase.cpp index f96ff6f..66685c2 100644 --- a/src/declarative/fx/qfximagebase.cpp +++ b/src/declarative/fx/qfximagebase.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -65,7 +65,7 @@ QFxImageBase::~QFxImageBase() { Q_D(QFxImageBase); if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); + QFxPixmapCache::cancelGet(d->url, this); } QFxImageBase::Status QFxImageBase::status() const @@ -103,7 +103,7 @@ void QFxImageBase::setSource(const QUrl &url) return; if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); + QFxPixmapCache::cancelGet(d->url, this); d->url = url; if (d->progress != 0.0) { @@ -123,7 +123,7 @@ void QFxImageBase::setSource(const QUrl &url) update(); } else { d->status = Loading; - d->reply = QFxPixmap::get(qmlEngine(this), d->url, &d->pix); + d->reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix); if (d->reply) { connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), @@ -156,7 +156,7 @@ void QFxImageBase::requestFinished() if (d->reply->error() != QNetworkReply::NoError) d->status = Error; } - QFxPixmap::find(d->url, &d->pix); + QFxPixmapCache::find(d->url, &d->pix); setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp deleted file mode 100644 index 43e94e5..0000000 --- a/src/declarative/fx/qfxpixmap.cpp +++ /dev/null @@ -1,233 +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 "qfxpixmap.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QSharedNetworkReply; -typedef QHash QFxSharedNetworkReplyHash; -static QFxSharedNetworkReplyHash qfxActiveNetworkReplies; - -class QSharedNetworkReply -{ -public: - QSharedNetworkReply(QNetworkReply *r) : reply(r), refCount(1) {} - ~QSharedNetworkReply() - { - reply->deleteLater(); - } - QNetworkReply *reply; - - int refCount; - void addRef() - { - ++refCount; - } - void release() - { - Q_ASSERT(refCount > 0); - --refCount; - if (refCount == 0) { - QString key = reply->url().toString(); - qfxActiveNetworkReplies.remove(key); - delete this; - } - } -}; - -static bool readImage(QIODevice *dev, QPixmap *pixmap) - { - QImageReader imgio(dev); - -//#define QT_TEST_SCALED_SIZE -#ifdef QT_TEST_SCALED_SIZE - /* - Some mechanism is needed for loading images at a limited size, especially - for remote images. Loading only thumbnails of remote progressive JPEG - images can be efficient. (Qt jpeg handler does not do so currently) - */ - - QSize limit(60,60); - QSize sz = imgio.size(); - if (sz.width() > limit.width() || sz.height() > limit.height()) { - sz.scale(limit,Qt::KeepAspectRatio); - imgio.setScaledSize(sz); - } -#endif - - QImage img; - if (imgio.read(&img)) { -#ifdef QT_TEST_SCALED_SIZE - if (!sz.isValid()) - img = img.scaled(limit,Qt::KeepAspectRatio); -#endif - *pixmap = QPixmap::fromImage(img); - return true; - } else { - return false; - } - } - -/*! - \internal - \class QFxPixmap - \ingroup group_utility - \brief Enacapsultes a pixmap for QFx items. - - This class is NOT reentrant. - The pixmap cache will grow indefinately. - */ - - -bool QFxPixmap::find(const QUrl& url, QPixmap *pixmap) -{ -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer perf; -#endif - - QString key = url.toString(); - if (!QPixmapCache::find(key,pixmap)) { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - if (url.scheme()==QLatin1String("file")) { - QFile f(url.toLocalFile()); - if (f.open(QIODevice::ReadOnly)) { - if (!readImage(&f, pixmap)) { - qWarning() << "Format error loading" << url; - *pixmap = QPixmap(); - } - } else - *pixmap = QPixmap(); - } else -#endif - { - QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); - if (iter == qfxActiveNetworkReplies.end()) { - // API usage error - qWarning() << "QFxPixmap: URL not loaded" << url; - } else { - if ((*iter)->reply->error()) { - qWarning() << "Network error loading" << url << (*iter)->reply->errorString(); - *pixmap = QPixmap(); - } else - if (!readImage((*iter)->reply, pixmap)) { - qWarning() << "Format error loading" << url; - *pixmap = QPixmap(); - } - (*iter)->release(); - } - } - QPixmapCache::insert(key, *pixmap); - } - return true; -} - -/*! - Starts a network request to load \a url. When the URL is loaded, - the given slot is invoked. Note that if the image is already cached, - the slot may be invoked immediately. - - Returns a QNetworkReply if the image is not immediately available, otherwise - returns 0. The QNetworkReply must not be stored - it may be destroyed at any time. -*/ -QNetworkReply *QFxPixmap::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap) -{ -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - if (url.scheme()==QLatin1String("file")) { - QString key = url.toString(); - if (!QPixmapCache::find(key,pixmap)) { - QFile f(url.toLocalFile()); - if (f.open(QIODevice::ReadOnly)) { - if (!readImage(&f, pixmap)) { - qWarning() << "Format error loading" << url; - *pixmap = QPixmap(); - } - } else - *pixmap = QPixmap(); - QPixmapCache::insert(key, *pixmap); - } - return 0; - } -#endif - - QString key = url.toString(); - if (QPixmapCache::find(key,pixmap)) { - return 0; - } - - QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); - if (iter == qfxActiveNetworkReplies.end()) { - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); - QSharedNetworkReply *item = new QSharedNetworkReply(engine->networkAccessManager()->get(req)); - iter = qfxActiveNetworkReplies.insert(key, item); - } else { - (*iter)->addRef(); - } - - return (*iter)->reply; -} - -/*! - Stops the given slot being invoked if the given url finishes loading. - May also cancel loading (eg. if no other pending request). - - Any connections to the QNetworkReply returned by get() will be - disconnected. -*/ -void QFxPixmap::cancelGet(const QUrl& url, QObject* obj) -{ - QString key = url.toString(); - QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); - if (iter == qfxActiveNetworkReplies.end()) - return; - QObject::disconnect((*iter)->reply, 0, obj, 0); - (*iter)->release(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpixmap.h b/src/declarative/fx/qfxpixmap.h deleted file mode 100644 index ec8d2be..0000000 --- a/src/declarative/fx/qfxpixmap.h +++ /dev/null @@ -1,70 +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 QFXPIXMAP_H -#define QFXPIXMAP_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QmlEngine; -class QNetworkReply; -class Q_DECLARATIVE_EXPORT QFxPixmap //### rename QFxPixmapCache -{ -public: - static QNetworkReply *get(QmlEngine *, const QUrl& url, QPixmap *pixmap); - static void cancelGet(const QUrl& url, QObject* obj); - - static bool find(const QUrl& url, QPixmap *pixmap); // url must have been passed to QFxPixmap::get, and finished. Or must be a local file. -}; - - -QT_END_NAMESPACE - -QT_END_HEADER -#endif // QFXPIXMAP_H diff --git a/src/declarative/fx/qfxpixmapcache.cpp b/src/declarative/fx/qfxpixmapcache.cpp new file mode 100644 index 0000000..5220d15 --- /dev/null +++ b/src/declarative/fx/qfxpixmapcache.cpp @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** 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 "qfxpixmapcache.h" +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QSharedNetworkReply; +typedef QHash QFxSharedNetworkReplyHash; +static QFxSharedNetworkReplyHash qfxActiveNetworkReplies; + +class QSharedNetworkReply +{ +public: + QSharedNetworkReply(QNetworkReply *r) : reply(r), refCount(1) {} + ~QSharedNetworkReply() + { + reply->deleteLater(); + } + QNetworkReply *reply; + + int refCount; + void addRef() + { + ++refCount; + } + void release() + { + Q_ASSERT(refCount > 0); + --refCount; + if (refCount == 0) { + QString key = reply->url().toString(); + qfxActiveNetworkReplies.remove(key); + delete this; + } + } +}; + +static bool readImage(QIODevice *dev, QPixmap *pixmap) + { + QImageReader imgio(dev); + +//#define QT_TEST_SCALED_SIZE +#ifdef QT_TEST_SCALED_SIZE + /* + Some mechanism is needed for loading images at a limited size, especially + for remote images. Loading only thumbnails of remote progressive JPEG + images can be efficient. (Qt jpeg handler does not do so currently) + */ + + QSize limit(60,60); + QSize sz = imgio.size(); + if (sz.width() > limit.width() || sz.height() > limit.height()) { + sz.scale(limit,Qt::KeepAspectRatio); + imgio.setScaledSize(sz); + } +#endif + + QImage img; + if (imgio.read(&img)) { +#ifdef QT_TEST_SCALED_SIZE + if (!sz.isValid()) + img = img.scaled(limit,Qt::KeepAspectRatio); +#endif + *pixmap = QPixmap::fromImage(img); + return true; + } else { + return false; + } + } + +/*! + \internal + \class QFxPixmapCache + \brief Enacapsultes a pixmap for QFx items. + + This class is NOT reentrant. + */ + + +bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap) +{ +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer perf; +#endif + + QString key = url.toString(); + if (!QPixmapCache::find(key,pixmap)) { +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML + if (url.scheme()==QLatin1String("file")) { + QFile f(url.toLocalFile()); + if (f.open(QIODevice::ReadOnly)) { + if (!readImage(&f, pixmap)) { + qWarning() << "Format error loading" << url; + *pixmap = QPixmap(); + } + } else + *pixmap = QPixmap(); + } else +#endif + { + QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); + if (iter == qfxActiveNetworkReplies.end()) { + // API usage error + qWarning() << "QFxPixmapCache: URL not loaded" << url; + } else { + if ((*iter)->reply->error()) { + qWarning() << "Network error loading" << url << (*iter)->reply->errorString(); + *pixmap = QPixmap(); + } else + if (!readImage((*iter)->reply, pixmap)) { + qWarning() << "Format error loading" << url; + *pixmap = QPixmap(); + } + (*iter)->release(); + } + } + QPixmapCache::insert(key, *pixmap); + } + return true; +} + +/*! + Starts a network request to load \a url. When the URL is loaded, + the given slot is invoked. Note that if the image is already cached, + the slot may be invoked immediately. + + Returns a QNetworkReply if the image is not immediately available, otherwise + returns 0. The QNetworkReply must not be stored - it may be destroyed at any time. +*/ +QNetworkReply *QFxPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap) +{ +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML + if (url.scheme()==QLatin1String("file")) { + QString key = url.toString(); + if (!QPixmapCache::find(key,pixmap)) { + QFile f(url.toLocalFile()); + if (f.open(QIODevice::ReadOnly)) { + if (!readImage(&f, pixmap)) { + qWarning() << "Format error loading" << url; + *pixmap = QPixmap(); + } + } else + *pixmap = QPixmap(); + QPixmapCache::insert(key, *pixmap); + } + return 0; + } +#endif + + QString key = url.toString(); + if (QPixmapCache::find(key,pixmap)) { + return 0; + } + + QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); + if (iter == qfxActiveNetworkReplies.end()) { + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); + QSharedNetworkReply *item = new QSharedNetworkReply(engine->networkAccessManager()->get(req)); + iter = qfxActiveNetworkReplies.insert(key, item); + } else { + (*iter)->addRef(); + } + + return (*iter)->reply; +} + +/*! + Stops the given slot being invoked if the given url finishes loading. + May also cancel loading (eg. if no other pending request). + + Any connections to the QNetworkReply returned by get() will be + disconnected. +*/ +void QFxPixmapCache::cancelGet(const QUrl& url, QObject* obj) +{ + QString key = url.toString(); + QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); + if (iter == qfxActiveNetworkReplies.end()) + return; + QObject::disconnect((*iter)->reply, 0, obj, 0); + (*iter)->release(); +} + +QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpixmapcache.h b/src/declarative/fx/qfxpixmapcache.h new file mode 100644 index 0000000..ca5d47b --- /dev/null +++ b/src/declarative/fx/qfxpixmapcache.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 QFXPIXMAPCACHE_H +#define QFXPIXMAPCACHE_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QmlEngine; +class QNetworkReply; +class Q_DECLARATIVE_EXPORT QFxPixmapCache +{ +public: + static QNetworkReply *get(QmlEngine *, const QUrl& url, QPixmap *pixmap); + static void cancelGet(const QUrl& url, QObject* obj); + + static bool find(const QUrl& url, QPixmap *pixmap); // url must have been passed to QFxPixmapCache::get, and finished. Or must be a local file. +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QFXPIXMAPCACHE_H diff --git a/src/declarative/fx/qfxscalegrid_p.h b/src/declarative/fx/qfxscalegrid_p.h index 7df90f1..bae1436 100644 --- a/src/declarative/fx/qfxscalegrid_p.h +++ b/src/declarative/fx/qfxscalegrid_p.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include "qfxborderimage.h" -- cgit v0.12 From 5a40eb79637bda111b83a12892b80f90ea21fd78 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 15:53:14 +1000 Subject: Make sure we get a complete when reversing a transition. This fixes task 258702. --- src/declarative/util/qmlstate.h | 2 -- src/declarative/util/qmltransition.cpp | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 46659c6..1b35295 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -118,7 +118,6 @@ protected: typedef QmlStateOperation::ActionList QmlStateActions; class QmlTransition; -class QmlTransitionPrivate; class QmlStatePrivate; class Q_DECLARATIVE_EXPORT QmlState : public QObject { @@ -161,7 +160,6 @@ Q_SIGNALS: private: Q_DECLARE_PRIVATE(QmlState) Q_DISABLE_COPY(QmlState) - friend class QmlTransitionPrivate; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index eb8bf53..a9b8cb3 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -128,7 +128,9 @@ void ParallelAnimationWrapper::updateState(QAbstractAnimation::State oldState, Q { QParallelAnimationGroup::updateState(oldState, newState); //XXX not 100% guaranteed to be at end (if there are many zero duration animations at the end)? - if (newState == Stopped && currentTime() == duration()) + if (newState == Stopped && + ((direction() == QAbstractAnimation::Forward && currentTime() == duration()) || + (direction() == QAbstractAnimation::Backward && currentTime() == 0))) { trans->complete(); } -- cgit v0.12 From fe59969d239231ae1bfb33e702f58d124554db95 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 14 Aug 2009 16:04:35 +1000 Subject: Tidy up usage of QNetworkReply returned by QFxPixmapCache::get, update documentation. --- src/declarative/extra/qfxanimatedimageitem_p.h | 4 ++- src/declarative/extra/qfxparticles.cpp | 7 ++-- src/declarative/fx/qfxborderimage.cpp | 26 ++++++-------- src/declarative/fx/qfximagebase.cpp | 46 +++++++++++-------------- src/declarative/fx/qfximagebase_p.h | 1 - src/declarative/fx/qfxpixmapcache.cpp | 47 ++++++++++++++++++-------- 6 files changed, 69 insertions(+), 62 deletions(-) diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h index 859f869..56252ca 100644 --- a/src/declarative/extra/qfxanimatedimageitem_p.h +++ b/src/declarative/extra/qfxanimatedimageitem_p.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE class QMovie; +class QNetworkReply; class QFxAnimatedImageItemPrivate : public QFxImagePrivate { @@ -65,13 +66,14 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate public: QFxAnimatedImageItemPrivate() - : playing(true), paused(false), _movie(0) + : playing(true), paused(false), _movie(0), reply(0) { } bool playing; bool paused; QMovie *_movie; + QNetworkReply *reply; }; QT_END_NAMESPACE diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 0e94ea6..2380655 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -405,7 +405,6 @@ public: bool emitting; QFxParticleMotion *motion; QFxParticlesPainter *paintItem; - QPointer reply; QList particles; QTickAnimationProxy clock; @@ -660,9 +659,9 @@ void QFxParticles::setSource(const QUrl &name) } else { d->url = name; Q_ASSERT(!name.isRelative()); - d->reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->image); - if (d->reply) - connect(d->reply, SIGNAL(finished()), this, SLOT(imageLoaded())); + QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->image); + if (reply) + connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded())); else { //### unify with imageLoaded d->paintItem->updateSize(); diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index 4920bf6..f8c79a6 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -205,10 +205,10 @@ void QFxBorderImage::setSource(const QUrl &url) this, SLOT(sciRequestFinished())); } } else { - d->reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix); - if (d->reply) { - connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); - connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), + QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix); + if (reply) { + connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); } else { //### should be unified with requestFinished @@ -315,10 +315,10 @@ void QFxBorderImage::setGridScaledImage(const QFxGridScaledImage& sci) d->verticalTileMode = sci.verticalTileRule(); d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - d->reply = QFxPixmapCache::get(qmlEngine(this), d->sciurl, &d->pix); - if (d->reply) { - connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); - connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), + QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->sciurl, &d->pix); + if (reply) { + connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(requestProgress(qint64,qint64))); } else { //### should be unified with requestFinished @@ -342,14 +342,8 @@ void QFxBorderImage::requestFinished() if (d->url.path().endsWith(QLatin1String(".sci"))) { QFxPixmapCache::find(d->sciurl, &d->pix); } else { - if (d->reply) { - //###disconnect really needed? - disconnect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(requestProgress(qint64,qint64))); - if (d->reply->error() != QNetworkReply::NoError) - d->status = Error; - } - QFxPixmapCache::find(d->url, &d->pix); + if (!QFxPixmapCache::find(d->url, &d->pix)) + d->status = Error; } setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); diff --git a/src/declarative/fx/qfximagebase.cpp b/src/declarative/fx/qfximagebase.cpp index 66685c2..e3760f3 100644 --- a/src/declarative/fx/qfximagebase.cpp +++ b/src/declarative/fx/qfximagebase.cpp @@ -123,25 +123,25 @@ void QFxImageBase::setSource(const QUrl &url) update(); } else { d->status = Loading; - d->reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix); - if (d->reply) { - connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); - connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(requestProgress(qint64,qint64))); - } else { - //### should be unified with requestFinished - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); - - if (d->status == Loading) - d->status = Ready; - d->progress = 1.0; - emit statusChanged(d->status); - emit sourceChanged(d->url); - emit progressChanged(1.0); - update(); - } + QNetworkReply *reply = QFxPixmapCache::get(qmlEngine(this), d->url, &d->pix); + if (reply) { + connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(requestProgress(qint64,qint64))); + } else { + //### should be unified with requestFinished + setImplicitWidth(d->pix.width()); + setImplicitHeight(d->pix.height()); + + if (d->status == Loading) + d->status = Ready; + d->progress = 1.0; + emit statusChanged(d->status); + emit sourceChanged(d->url); + emit progressChanged(1.0); + update(); } + } emit statusChanged(d->status); } @@ -149,14 +149,8 @@ void QFxImageBase::setSource(const QUrl &url) void QFxImageBase::requestFinished() { Q_D(QFxImageBase); - if (d->reply) { - //###disconnect really needed? - disconnect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(requestProgress(qint64,qint64))); - if (d->reply->error() != QNetworkReply::NoError) - d->status = Error; - } - QFxPixmapCache::find(d->url, &d->pix); + if (!QFxPixmapCache::find(d->url, &d->pix)) + d->status = Error; setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); diff --git a/src/declarative/fx/qfximagebase_p.h b/src/declarative/fx/qfximagebase_p.h index b468b90..3f43f38 100644 --- a/src/declarative/fx/qfximagebase_p.h +++ b/src/declarative/fx/qfximagebase_p.h @@ -73,7 +73,6 @@ public: QPixmap pix; QFxImageBase::Status status; QUrl url; - QPointer reply; qreal progress; }; diff --git a/src/declarative/fx/qfxpixmapcache.cpp b/src/declarative/fx/qfxpixmapcache.cpp index 5220d15..0ca77c3 100644 --- a/src/declarative/fx/qfxpixmapcache.cpp +++ b/src/declarative/fx/qfxpixmapcache.cpp @@ -122,7 +122,14 @@ static bool readImage(QIODevice *dev, QPixmap *pixmap) This class is NOT reentrant. */ +/*! + Finds the cached pixmap corresponding to \a url. + A previous call to get() must have requested the URL, + and the QNetworkReply must have finished before calling + this function. + Returns true if the image was loaded without error. +*/ bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap) { #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -130,6 +137,7 @@ bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap) #endif QString key = url.toString(); + bool ok = true; if (!QPixmapCache::find(key,pixmap)) { #ifndef QT_NO_LOCALFILE_OPTIMIZED_QML if (url.scheme()==QLatin1String("file")) { @@ -138,9 +146,12 @@ bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap) if (!readImage(&f, pixmap)) { qWarning() << "Format error loading" << url; *pixmap = QPixmap(); + ok = false; } - } else + } else { *pixmap = QPixmap(); + ok = false; + } } else #endif { @@ -148,30 +159,36 @@ bool QFxPixmapCache::find(const QUrl& url, QPixmap *pixmap) if (iter == qfxActiveNetworkReplies.end()) { // API usage error qWarning() << "QFxPixmapCache: URL not loaded" << url; + ok = false; } else { if ((*iter)->reply->error()) { qWarning() << "Network error loading" << url << (*iter)->reply->errorString(); *pixmap = QPixmap(); - } else - if (!readImage((*iter)->reply, pixmap)) { - qWarning() << "Format error loading" << url; - *pixmap = QPixmap(); - } + ok = false; + } else if (!readImage((*iter)->reply, pixmap)) { + qWarning() << "Format error loading" << url; + *pixmap = QPixmap(); + ok = false; + } (*iter)->release(); } } QPixmapCache::insert(key, *pixmap); + } else { + ok = !pixmap->isNull(); } - return true; + return ok; } /*! - Starts a network request to load \a url. When the URL is loaded, - the given slot is invoked. Note that if the image is already cached, - the slot may be invoked immediately. + Starts a network request to load \a url. Returns a QNetworkReply if the image is not immediately available, otherwise - returns 0. The QNetworkReply must not be stored - it may be destroyed at any time. + returns 0. Caller should connect to QNetworkReply::finished() to then call + find() when the image is available. + + The returned QNetworkReply will be deleted when all get() calls are + matched by a corresponding find() call. */ QNetworkReply *QFxPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap *pixmap) { @@ -212,10 +229,11 @@ QNetworkReply *QFxPixmapCache::get(QmlEngine *engine, const QUrl& url, QPixmap * } /*! - Stops the given slot being invoked if the given url finishes loading. + Cancels a previous call to get(). + May also cancel loading (eg. if no other pending request). - Any connections to the QNetworkReply returned by get() will be + Any connections from the QNetworkReply returned by get() to \a obj will be disconnected. */ void QFxPixmapCache::cancelGet(const QUrl& url, QObject* obj) @@ -224,7 +242,8 @@ void QFxPixmapCache::cancelGet(const QUrl& url, QObject* obj) QFxSharedNetworkReplyHash::Iterator iter = qfxActiveNetworkReplies.find(key); if (iter == qfxActiveNetworkReplies.end()) return; - QObject::disconnect((*iter)->reply, 0, obj, 0); + if (obj) + QObject::disconnect((*iter)->reply, 0, obj, 0); (*iter)->release(); } -- cgit v0.12 From 03223716c1eda9b548fc130c6655c55483651e4d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 14 Aug 2009 16:12:41 +1000 Subject: Improve error message. --- 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 5c12d9c..caf78e8 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -194,7 +194,7 @@ bool QmlCompiler::testLiteralAssignment(const QMetaProperty &prop, QString string = v->value.asScript(); if (!prop.isWritable()) - COMPILE_EXCEPTION(v, "Invalid property assignment: read-only property"); + COMPILE_EXCEPTION(v, "Invalid property assignment:" << QLatin1String(prop.name()) << "is a read-only property"); if (prop.isEnumType()) { int value; @@ -2042,7 +2042,7 @@ bool QmlCompiler::buildBinding(QmlParser::Value *value, QMetaProperty mp = prop->parent->metaObject()->property(prop->index); if (!mp.isWritable() && !QmlMetaType::isList(prop->type)) - COMPILE_EXCEPTION(prop, "Invalid property assignment: read-only property"); + COMPILE_EXCEPTION(prop, "Invalid property assignment:" << QString::fromLatin1(prop->name) << "is a read-only property"); BindingReference reference; reference.expression = value->value; -- cgit v0.12 From 5adb8478ffc55db35f2fc20e24ff77755030dca7 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 Aug 2009 12:22:22 +0200 Subject: Fix load error in qmldebugger/engines.qml Commit 019ae3a99e renamed HorizontalLayout to HorizontalPositioner --- tools/qmldebugger/engines.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml index eedba08..ad12aa6 100644 --- a/tools/qmldebugger/engines.qml +++ b/tools/qmldebugger/engines.qml @@ -6,7 +6,7 @@ Item { signal engineClicked(int id) signal refreshEngines() - HorizontalLayout { + HorizontalPositioner { anchors.fill: parent Repeater { dataSource: engines -- cgit v0.12 From a64acdd50452678f368688d19631ef2c1fd31ec8 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 Aug 2009 12:30:46 +0200 Subject: Fix qmldebugger not finding engines.qml Load engines.qml from resources --- tools/qmldebugger/qmldebugger.qrc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tools/qmldebugger/qmldebugger.qrc diff --git a/tools/qmldebugger/qmldebugger.qrc b/tools/qmldebugger/qmldebugger.qrc new file mode 100644 index 0000000..5820558 --- /dev/null +++ b/tools/qmldebugger/qmldebugger.qrc @@ -0,0 +1,5 @@ + + + engines.qml + + -- cgit v0.12 From 3e9d47531aa0d521b0724646642a95ffca780907 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 Aug 2009 13:08:27 +0200 Subject: Fix qmldebugger not finding engines.qml 2 Also load images from resources --- tools/qmldebugger/engine.cpp | 7 ++++++- tools/qmldebugger/engines.qml | 6 +++--- tools/qmldebugger/qmldebugger.pro | 3 +++ tools/qmldebugger/qmldebugger.qrc | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 229cd3f..16d7f02 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -38,10 +39,14 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent) setLayout(layout); + QFile enginesFile(":/engines.qml"); + enginesFile.open(QFile::ReadOnly); + Q_ASSERT(enginesFile.isOpen()); + m_engineView = new QFxView(this); m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); m_engineView->setContentResizable(true); - m_engineView->setUrl(QUrl::fromLocalFile("engines.qml")); + m_engineView->setQml(enginesFile.readAll()); m_engineView->execute(); m_engineView->setFixedHeight(100); QObject::connect(m_engineView->root(), SIGNAL(engineClicked(int)), diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml index ad12aa6..9a96c4b 100644 --- a/tools/qmldebugger/engines.qml +++ b/tools/qmldebugger/engines.qml @@ -11,10 +11,10 @@ Item { Repeater { dataSource: engines Item { - width: 100; height: 100; + width: 100; height: 100; Image { id: Image; - source: "engine.png" + source: "qrc:/engine.png" anchors.horizontalCenter: parent.horizontalCenter } Text { @@ -33,7 +33,7 @@ Item { Image { y: 15 - source: "refresh.png"; + source: "qrc:/refresh.png"; width: 75; height: 63; smooth: true diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro index 532fd2a..3935351 100644 --- a/tools/qmldebugger/qmldebugger.pro +++ b/tools/qmldebugger/qmldebugger.pro @@ -5,6 +5,9 @@ contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl # Input HEADERS += canvasframerate.h engine.h SOURCES += main.cpp canvasframerate.cpp engine.cpp +RESOURCES += qmldebugger.qrc + +OTHER_FILES += engines.qml target.path=$$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/qmldebugger/qmldebugger.qrc b/tools/qmldebugger/qmldebugger.qrc index 5820558..cb53ad5 100644 --- a/tools/qmldebugger/qmldebugger.qrc +++ b/tools/qmldebugger/qmldebugger.qrc @@ -1,5 +1,7 @@ engines.qml + engine.png + refresh.png -- cgit v0.12 From 5f13d479e4b9080f7a0d8bca05b020b3019aa272 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 14 Aug 2009 14:56:12 +0200 Subject: Show full object tree in qml debugger Clicking on an engine now automatically shows the object tree --- tools/qmldebugger/engine.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 16d7f02..1f4bcc2 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -141,6 +141,8 @@ void EnginePane::queryContext(int id) void EnginePane::contextChanged() { dump(m_context->rootContext(), 0); + foreach (const QmlDebugObjectReference &object, m_context->rootContext().objects()) + fetchObject(object.debugId()); delete m_context; m_context = 0; } @@ -171,12 +173,19 @@ void EnginePane::dump(const QmlDebugObjectReference &obj, int ind) void EnginePane::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) { + if (!parent) + m_objTree->clear(); + m_objTree->expandAll(); + QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(m_objTree); item->setText(0, obj.className()); item->setData(0, Qt::UserRole, obj.debugId()); for (int ii = 0; ii < obj.children().count(); ++ii) buildTree(obj.children().at(ii), item); + + if (!parent) + m_objTree->expandAll(); } void EnginePane::queryEngines() -- cgit v0.12 From 36a87c0a6cbc858dc5ae443cb16ded0f92c7725a Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 14 Aug 2009 16:58:43 +0200 Subject: proper deployment for Windows CE Reviewed-by: Joerg --- tools/qmlviewer/qmlviewer.pro | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 8b9a768..bcf361e 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -18,3 +18,11 @@ FORMS = recopts.ui \ include($$QT_SOURCE_TREE/tools/shared/deviceskin/deviceskin.pri) target.path = $$[QT_INSTALL_BINS] INSTALLS += target + +wince* { +QT += scripttools \ + xml \ + xmlpatterns \ + webkit \ + phonon +} -- cgit v0.12 From 02e5239002786a55d68f04a512baa7d4c5f40e66 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 14 Aug 2009 21:30:28 +0200 Subject: readd and fix the qml documentation for Rotation and Scale This got forgotten during the move to QGraphicsTransform. The docs also required a few adjustments as Rotation3D is now gone and some properties in Scale and Rotation have changed. --- doc/src/declarative/effects.qdoc | 2 +- doc/src/declarative/elements.qdoc | 2 - doc/src/snippets/declarative/rotation.qml | 8 +-- src/declarative/fx/qfxitem.cpp | 86 +++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 7 deletions(-) diff --git a/doc/src/declarative/effects.qdoc b/doc/src/declarative/effects.qdoc index 8350dc4..7879260 100644 --- a/doc/src/declarative/effects.qdoc +++ b/doc/src/declarative/effects.qdoc @@ -8,7 +8,7 @@ \list \o Scaling (\l Item \bold scale property) \o Opacity (\l Item \bold opacity property) -\o Rotation (\l Item \bold rotation property, and Rotation3D) +\o Rotation (\l Item \bold rotation property) \o Affine Transforms (\l Squish) \endlist diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index b5dd2bb..3f74ff5 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -137,8 +137,6 @@ The following table lists the Qml elements provided by the Qt Declarative module \list \o \l Scale \o \l Rotation -\o \l Squish -\o \l Rotation3D \endlist \o diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml index c7e184f..ab7d4ca 100644 --- a/doc/src/snippets/declarative/rotation.qml +++ b/doc/src/snippets/declarative/rotation.qml @@ -10,19 +10,19 @@ Rect { Image { source: "pics/qt.png" } Image { source: "pics/qt.png" - transform: Rotation3D { axis.startX: 30; axis.endX: 30; axis.endY: 60; angle: 18 } + transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0 angle: 18 } } Image { source: "pics/qt.png" - transform: Rotation3D { axis.startX: 30; axis.endX: 30; axis.endY: 60; angle: 36 } + transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0 angle: 36 } } Image { source: "pics/qt.png" - transform: Rotation3D { axis.startX: 30; axis.endX: 30; axis.endY: 60; angle: 54 } + transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0; angle: 54 } } Image { source: "pics/qt.png" - transform: Rotation3D { axis.startX: 30; axis.endX: 30; axis.endY: 60; angle: 72 } + transform: Rotation { origin.x: 30; axis.y: 60; axis.z: 0; angle: 72 } } } //! [0] diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index f10977f..0b86a54 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -77,6 +77,92 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QGraphicsScale) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) /*! + \qmlclass Transform + \brief A transformation. +*/ + +/*! + \qmlclass Scale + \brief A Scale object provides a way to scale an Item. + + The scale object gives more control over scaling than using Item's scale property. Specifically, + it allows a different scale for the x and y axes, and allows the scale to be relative to an + arbitrary point. + + The following example scales the X axis of the Rect, relative to its interior point 25, 25: + \qml + Rect { + width: 100; height: 100 + color: "blue" + transform: Scale { origin.x: 25; origin.y: 25; xScale: 3} + } + \endqml +*/ + +/*! + \qmlproperty real Scale::origin.x + \qmlproperty real Scale::origin.y + + The origin point for the scale. The scale will be relative to this point. +*/ + +/*! + \qmlproperty real Scale::xScale + + The scaling factor for the X axis. +*/ + +/*! + \qmlproperty real Scale::yScale + + The scaling factor for the Y axis. +*/ + +/*! + \qmlclass Rotation + \brief A Rotation object provides a way to rotate an Item around a point using an axis in 3D space. + + The following example rotates a Rect around its interior point 25, 25: + \qml + Rect { + width: 100; height: 100 + color: "blue" + transform: Rotation { origin.x: 25; origin.y: 25; angle: 45} + } + \endqml + + Here is an example of various rotations applied to an \l Image. + \snippet doc/src/snippets/declarative/rotation.qml 0 + + \image axisrotation.png +*/ + +/*! + \qmlproperty real Rotation::origin.x + \qmlproperty real Rotation::origin.y + + The point to rotate around. +*/ + +/*! + \qmlproperty real Rotation::axis.x + \qmlproperty real Rotation::axis.y + \qmlproperty real Rotation::axis.z + + A rotation axis is specified by a vector in 3D space By default the vector defines a rotation around the z-Axis. + + \image 3d-rotation-axis.png + +*/ + +/*! + \qmlproperty real Rotation::angle + + The angle, in degrees, to rotate. +*/ + + +/*! \group group_animation \title Animation */ -- cgit v0.12