From 349d37aff07ac86c5b70f7ed76c2241b4c4f3637 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 1 May 2009 11:59:54 +1000 Subject: More format changes --- doc/src/snippets/declarative/drag.qml | 16 +++++++++++++ doc/src/snippets/declarative/mouseregion.qml | 23 ++++++++++++++++++ src/declarative/fx/qfxkeyactions.cpp | 10 ++++---- src/declarative/fx/qfxmouseregion.cpp | 32 +++++++------------------ src/declarative/fx/qfxrect.cpp | 36 ++++++++++++++-------------- 5 files changed, 70 insertions(+), 47 deletions(-) create mode 100644 doc/src/snippets/declarative/drag.qml create mode 100644 doc/src/snippets/declarative/mouseregion.qml diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml new file mode 100644 index 0000000..3a573ad --- /dev/null +++ b/doc/src/snippets/declarative/drag.qml @@ -0,0 +1,16 @@ +//! [0] +Rect { + id: blurtest; width: 600; height: 200; color: "white" + Image { + id: pic; source: "qtlogo-64.png"; anchors.verticalCenter: parent.verticalCenter + opacity: (600.0-pic.x) / 600; + MouseRegion { + anchors.fill: parent + drag.target: pic + drag.axis: "x" + drag.xmin: 0 + drag.xmax: blurtest.width-pic.width + } + } +} +//! [0] diff --git a/doc/src/snippets/declarative/mouseregion.qml b/doc/src/snippets/declarative/mouseregion.qml new file mode 100644 index 0000000..5c1afe6 --- /dev/null +++ b/doc/src/snippets/declarative/mouseregion.qml @@ -0,0 +1,23 @@ +Rect { width: 200; height: 100 +HorizontalLayout { +//! [0] +Rect { width: 100; height: 100; color: "green" + MouseRegion { anchors.fill: parent; onClicked: { parent.color = 'red' } } +} +//! [0] +//! [1] +Rect { + width: 100; height: 100; color: "green" + MouseRegion { + anchors.fill: parent + onClicked: { + if (mouse.button == Qt.RightButton) + parent.color = 'blue'; + else + parent.color = 'red'; + } + } +} +//! [1] +} +} diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp index d2739ea..52a013a 100644 --- a/src/declarative/fx/qfxkeyactions.cpp +++ b/src/declarative/fx/qfxkeyactions.cpp @@ -245,7 +245,7 @@ void QFxKeyActions::setEnabled(bool e) The following example sets actions for the 'c' and 'x' keys. \code - + KeyActions { keyC: "print('c is for cookie')"; keyX: "print('I like cookies')" } \endcode */ QString QFxKeyActions::key_A() const @@ -519,7 +519,7 @@ void QFxKeyActions::setKey_Z(const QString &s) The following example sets actions for the left and right arrow keys. \code - + KeyActions { leftArrow: "print('You pressed left')"; rightArrow: "print('You pressed right')" } \endcode */ @@ -570,7 +570,7 @@ void QFxKeyActions::setKey_Down(const QString &s) The following example sets actions for the '5' and '6' keys. \code - + KeyActions { digit5: "print('5 is a prime number')"; digit6: "print('6 is a composite number')"; focus: true } \endcode */ @@ -745,7 +745,7 @@ void QFxKeyActions::setKey_Space(const QString &s) The following example sets an action for the space key. \code - + KeyActions { space: "print('Space pressed')" } \endcode */ @@ -766,7 +766,7 @@ void QFxKeyActions::setKey_Space(const QString &s) The following example sets an action for the hangup key. \code - + KeyActions { hangup: "print('Go away now')" } \endcode */ diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp index d197c9a..3b318e3 100644 --- a/src/declarative/fx/qfxmouseregion.cpp +++ b/src/declarative/fx/qfxmouseregion.cpp @@ -148,12 +148,11 @@ void QFxDrag::setYmax(int m) \brief The MouseRegion element enables simple mouse handling. \inherits Item - A MouseRegion is typically used in conjunction with a visible element, where the MouseRegion effectively 'proxies' mouse handling for that element. For example, we can put a MouseRegion in a Rect that changes the Rect color to red when clicked: - \code - - - - \endcode + A MouseRegion is typically used in conjunction with a visible element, + where the MouseRegion effectively 'proxies' mouse handling for that + element. For example, we can put a MouseRegion in a Rect that changes + the Rect color to red when clicked: + \snippet doc/src/snippets/declarative/mouseregion.qml 0 Many MouseRegion signals pass a \l {MouseEvent}{mouse} parameter that contains additional information about the mouse event, such as the position, button, @@ -161,11 +160,7 @@ void QFxDrag::setYmax(int m) Below we have the previous example extended so as to give a different color when you right click. - \code - - - - \endcode + \snippet doc/src/snippets/declarative/mouseregion.qml 1 For basic key handling, see \l KeyActions. @@ -578,19 +573,8 @@ QFxDrag *QFxMouseRegion::drag() \i the min and max properties limit how far the target can be dragged along the corresponding axes. \endlist - The following example uses drag to blur an image as it moves to the right: - \code - - - - - - - \endcode + The following example uses drag to reduce the opacity of an image as it moves to the right: + \snippet doc/src/snippets/declarative/drag.qml 0 */ QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 2bfc149..8aaddba 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -54,7 +54,7 @@ QML_DEFINE_TYPE(QFxPen,Pen); Example: \code - + Rect { pen.width: 2; pen.color: "red" ... } \endcode */ @@ -73,11 +73,11 @@ QML_DEFINE_TYPE(QFxPen,Pen); or as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword name} (as defined by the World Wide Web Consortium). For example: \code - - + // rect with green border using hexidecimal notation + Rect { pen.color: "#00FF00" } - - + // rect with steelblue border using SVG color name + Rect { pen.color: "steelblue" } \endcode For the full set of ways to specify color, see Qt's QColor::setNamedColor documentation. @@ -102,7 +102,7 @@ QML_DEFINE_TYPE(QFxRect,Rect); A Rect is painted having a solid fill (color) and an optional border (pen). You can also create rounded rectangles using the radius property. \code - + Rect { width: 100; height: 100; color: "red"; pen.color: "black"; pen.width: 5; radius: 10 } \endcode \image declarative-rect.png @@ -116,7 +116,7 @@ QML_DEFINE_TYPE(QFxRect,Rect); A Rect is painted having a solid fill (color) and an optional border (pen). You can also create rounded rectangles using the radius property. \code - + Rect { width: 100; height: 100; color: "red"; pen.color: "black"; pen.width: 5; radius: 10 } \endcode \image declarative-rect.png @@ -217,11 +217,11 @@ void QFxRect::dump(int depth) This property holds the color used to fill the rect. \code - - + // green rect using hexidecimal notation + Rect { color: "#00FF00" } - - + // steelblue rect using SVG color name + Rect { color: "steelblue" } \endcode */ @@ -260,8 +260,8 @@ void QFxRect::setColor(const QColor &c) This color will be drawn over the rect's color when the rect is painted. The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red tint by having the tint color be pure red which is only 1/16th opaque. \code - - + Rect { x: 0; width: 80; height: 80; color: "lightsteelblue" } + Rect { x: 100; width: 80; height: 80; color: "lightsteelblue"; tintColor: "#10FF0000" } \endcode \image declarative-rect_tint.png @@ -321,11 +321,11 @@ QColor QFxRectPrivate::getColor() This property allows for the easy construction of simple horizontal gradients. Other gradients may by formed by adding rotation to the rect. The gradient will blend linearly from the rect's main color to the color specified for gradient color. \code - - - - + Rect { y: 0; width: 80; height: 80; color: "lightsteelblue" } + Rect { y: 100; width: 80; height: 80; color: "lightsteelblue"; gradientColor="blue" } + Rect { rotation: 90; x: 80; y: 200; width: 80; height: 80; color="lightsteelblue" + gradientColor: "blue" } + // The x offset is needed because the rotation is from the top left corner \endcode \image declarative-rect_gradient.png */ -- cgit v0.12