diff options
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicseffects.cpp | 27 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicspainteditem.cpp | 4 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextedit.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview.cpp | 52 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview_p.h | 3 | ||||
-rw-r--r-- | src/declarative/util/qmlpropertychanges.cpp | 37 | ||||
-rw-r--r-- | src/declarative/util/qmltimer.cpp | 25 |
7 files changed, 104 insertions, 46 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp index 2f0aae7..0523fd5 100644 --- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp +++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp @@ -51,10 +51,10 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) \qmlclass Blur QGraphicsBlurEffect \brief The Blur object provides a blur effect. - A blur effect blurs the source item. This effect is useful for reducing details, - such as when the source loses focus and you want to draw attention to other - elements. The level of detail can be modified using the blurRadius property. - Use blurHint to choose the quality or performance blur hints. + A blur effect blurs the source item. This effect is useful for reducing details; + for example, when the a source loses focus and attention should be drawn to other + elements. Use blurRadius to control the level of detail and blurHint to control + the quality of the blur. By default, the blur radius is 5 pixels. @@ -64,21 +64,22 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) /*! \qmlproperty real Blur::blurRadius - blurRadius controls how blurry an item will appear. - Using a smaller radius results in a sharper appearance, whereas a bigger - radius results in a more blurred appearance. + This controls how blurry an item will appear. - By default, the blur radius is 5 pixels. + A smaller radius produces a sharper appearance, and a larger radius produces + a more blurred appearance. + + The default radius is 5 pixels. */ /*! \qmlproperty enumeration Blur::blurHint - Use the Qt.PerformanceHint hint to say that you want a faster blur, - and the Qt.QualityHint hint to say that you prefer a higher quality blur. - - When animating the blur radius it's recommended to use Qt.PerformanceHint. + Use Qt.PerformanceHint to specify a faster blur or Qt.QualityHint hint + to specify a higher quality blur. + + If the blur radius is animated, it is recommended you use Qt.PerformanceHint. - By default, the blur hint is Qt.PerformanceHint. + The default hint is Qt.PerformanceHint. */ QML_DECLARE_TYPE(QGraphicsColorizeEffect) diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp index 2f467e7..948f69a 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp @@ -289,7 +289,7 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * } cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); uncached += d->imagecache[oldest]->area; - d->imagecache.removeAt(oldest); + delete d->imagecache.takeAt(oldest); } const QRegion bigger = QRegion(biggerrect) & uncached; const QVector<QRect> rects = bigger.rects(); @@ -366,7 +366,7 @@ void QmlGraphicsPaintedItem::setPixelCacheSize(int pixels) } } cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); - d->imagecache.removeAt(oldest); + delete d->imagecache.takeAt(oldest); } } d->max_imagecache_size = pixels; diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index 2588f7d..bec2ff8 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -563,7 +563,7 @@ QString QmlGraphicsTextEdit::selectedText() const \qmlproperty bool TextEdit::focusOnPress Whether the TextEdit should gain focus on a mouse press. By default this is - set to false; + set to false. */ bool QmlGraphicsTextEdit::focusOnPress() const { diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index aedf787..e21bda3 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -79,6 +79,7 @@ public: : QmlGraphicsPaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0), progress(1.0), status(QmlGraphicsWebView::Null), pending(PendingNone), newWindowComponent(0), newWindowParent(0), + pressTime(400), windowObjects(this), rendering(true) { @@ -99,6 +100,11 @@ public: QmlComponent *newWindowComponent; QmlGraphicsItem *newWindowParent; + QBasicTimer pressTimer; + QPoint pressPoint; + int pressTime; // milliseconds before it's a "hold" XXX not currently settable + static const int pressDragLength = 15; // XXX #pixels before it's no longer a "hold"; device-specific + void updateWindowObjects(); class WindowObjectList : public QmlConcreteList<QObject *> { @@ -613,8 +619,15 @@ bool QmlGraphicsWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { + Q_D(QmlGraphicsWebView); + setFocus (true); QMouseEvent *me = sceneMouseEventToMouseEvent(event); + + d->pressPoint = me->pos(); + d->pressTimer.start(d->pressTime,this); + setKeepMouseGrab(false); + page()->event(me); event->setAccepted( /* @@ -636,8 +649,11 @@ void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) void QmlGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { + Q_D(QmlGraphicsWebView); + QMouseEvent *me = sceneMouseEventToMouseEvent(event); page()->event(me); + d->pressTimer.stop(); event->setAccepted( /* It is not correct to send the press event upwards, if it is not accepted by WebKit @@ -653,24 +669,45 @@ void QmlGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (!event->isAccepted()) { QmlGraphicsPaintedItem::mouseReleaseEvent(event); } + setKeepMouseGrab(false); + ungrabMouse(); +} + +void QmlGraphicsWebView::timerEvent(QTimerEvent *event) +{ + Q_D(QmlGraphicsWebView); + if (event->timerId() == d->pressTimer.timerId()) { + d->pressTimer.stop(); + grabMouse(); + setKeepMouseGrab(true); + } } void QmlGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { + Q_D(QmlGraphicsWebView); + QMouseEvent *me = sceneMouseEventToMouseEvent(event); - page()->event(me); - event->setAccepted( + if (d->pressTimer.isActive()) { + if ((me->pos() - d->pressPoint).manhattanLength() > d->pressDragLength) { + d->pressTimer.stop(); + } + } + if (keepMouseGrab()) { + page()->event(me); + 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 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 - true + true #else - me->isAccepted() + me->isAccepted() #endif - ); + ); + } delete me; if (!event->isAccepted()) QmlGraphicsPaintedItem::mouseMoveEvent(event); @@ -722,7 +759,6 @@ bool QmlGraphicsWebView::sceneEvent(QEvent *event) } - /*! \qmlproperty action WebView::back This property holds the action for causing the previous URL in the history to be displayed. @@ -1161,6 +1197,8 @@ void QmlGraphicsWebPage::javaScriptConsoleMessage(const QString& message, int li QString QmlGraphicsWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile) { // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(oldFile) return oldFile; } @@ -1172,6 +1210,8 @@ void QmlGraphicsWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QStr bool QmlGraphicsWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg) { // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) return false; } diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 17546c1..7ff51f3 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -89,7 +89,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem { Q_OBJECT - Q_ENUMS(Status) + Q_ENUMS(Status SelectionMode) Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) @@ -220,6 +220,7 @@ protected: void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void timerEvent(QTimerEvent *event); void hoverMoveEvent (QGraphicsSceneHoverEvent * event); void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 6a393ee..9ca6db8 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -56,19 +56,32 @@ QT_BEGIN_NAMESPACE \qmlclass PropertyChanges QmlPropertyChanges \brief The PropertyChanges element describes new property values for a state. - PropertyChanges changes the properties of an item. It allows you to specify the property - names and values for a state similar to how you normally would specify them for the - actual item: + PropertyChanges provides a state change that modifies the properties of an item. - \code - PropertyChanges { - target: myRect - x: 52 - y: 300 - width: 48 - } - \endcode + Here is a property change that modifies the text and color of a Text element + when it is clicked: + + \qml + Text { + id: myText + width: 100; height: 100 + text: "Hello" + color: "blue" + + states: State { + name: "myState" + + PropertyChanges { + target: myText + text: "Goodbye" + color: "red" + } + } + MouseRegion { anchors.fill: parent; onClicked: myText.state = 'myState' } + } + \endqml + State-specific script for signal handlers can also be specified: \qml @@ -92,7 +105,7 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty Object PropertyChanges::target - This property holds the object that the properties to change belong to + This property holds the object which contains the properties to be changed. */ class QmlReplaceSignalHandler : public ActionEvent diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index d2198f2..0a2448a 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -73,6 +73,9 @@ public: A timer can be used to trigger an action either once, or repeatedly at a given interval. + Here is a timer that shows the current date and time, and updates + the text every 500 milliseconds: + \qml Timer { interval: 500; running: true; repeat: true @@ -107,7 +110,7 @@ QmlTimer::QmlTimer(QObject *parent) /*! \qmlproperty int Timer::interval - Sets the \a interval in milliseconds between triggering. + Sets the \a interval between triggers, in milliseconds. The default interval is 1000 milliseconds. */ @@ -130,7 +133,7 @@ int QmlTimer::interval() const \qmlproperty bool Timer::running If set to true, starts the timer; otherwise stops the timer. - For a non-repeating timer, \a running will be set to false after the + For a non-repeating timer, \a running is set to false after the timer has been triggered. \a running defaults to false. @@ -157,7 +160,7 @@ void QmlTimer::setRunning(bool running) /*! \qmlproperty bool Timer::repeat - If \a repeat is true the timer will be triggered repeatedly at the + If \a repeat is true the timer is triggered repeatedly at the specified interval; otherwise, the timer will trigger once at the specified interval and then stop (i.e. running will be set to false). @@ -183,15 +186,15 @@ void QmlTimer::setRepeating(bool repeating) /*! \qmlproperty bool Timer::triggeredOnStart - When the Timer is started the first trigger is normally after the specified - interval has elapsed. It is sometimes desireable to trigger immediately - when the timer is started, for example to establish an initial + When a timer is started, the first trigger is usually after the specified + interval has elapsed. It is sometimes desirable to trigger immediately + when the timer is started; for example, to establish an initial state. - If \a triggeredOnStart is true, the timer will be triggered immediately - when started, and subsequently at the specified interval. Note that for - a Timer with \e repeat set to false, this will result in the timer being - triggered twice; once on start, and again at the interval. + If \a triggeredOnStart is true, the timer is triggered immediately + when started, and subsequently at the specified interval. Note that if + \e repeat is set to false, the timer is triggered twice; once on start, + and again at the interval. \a triggeredOnStart defaults to false. @@ -226,7 +229,7 @@ void QmlTimer::start() /*! \qmlmethod Timer::stop() - \brief stops the timer. + \brief Stops the timer. If the timer is not running, calling this method has no effect. The \c running property will be false following a call to \c stop(). |