From 6b1220bf4bc16ddf331ce76c72b52274988902ea Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 15 Sep 2009 11:04:32 +1000 Subject: Fix double-deletion bug with QFxTextEdit's cursor delegate QFxTextEdit autotests now pass --- src/declarative/fx/qfxtextedit.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 72f12cc..c106ee0 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -455,7 +455,6 @@ void QFxTextEdit::setCursorDelegate(QmlComponent* c) { Q_D(QFxTextEdit); if(d->cursorComponent){ - delete d->cursorComponent; if(d->cursor){ disconnect(d->control, SIGNAL(cursorPositionChanged()), this, SLOT(moveCursorDelegate())); -- cgit v0.12 From 6b9a5070b3806e80a937d940c959302769061826 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 15 Sep 2009 14:07:40 +1000 Subject: Implement some of the TODOs in QFxTextInput -delegate loading error messages -selectedText/selection color This is an intermediate commit, it relies on a patch to QLineControl which hasn't been committed yet. --- src/declarative/fx/qfxtextinput.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index d9da308..b5960fd 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -171,7 +171,9 @@ void QFxTextInput::setSelectionColor(const QColor &color) return; d->selectionColor = color; - //TODO: implement + QPalette p = d->control->palette(); + p.setColor(QPalette::Highlight, d->selectionColor); + d->control->setPalette(p); } /*! @@ -192,7 +194,9 @@ void QFxTextInput::setSelectedTextColor(const QColor &color) return; d->selectedTextColor = color; - //TODO: implement + QPalette p = d->control->palette(); + p.setColor(QPalette::HighlightedText, d->selectedTextColor); + d->control->setPalette(p); } /*! @@ -485,8 +489,6 @@ QmlComponent* QFxTextInput::cursorDelegate() const void QFxTextInput::setCursorDelegate(QmlComponent* c) { Q_D(QFxTextInput); - if(d->cursorComponent) - delete d->cursorComponent; d->cursorComponent = c; d->startCreatingCursor(); } @@ -507,14 +509,20 @@ void QFxTextInputPrivate::startCreatingCursor() q->connect(cursorComponent, SIGNAL(statusChanged(int)), q, SLOT(createCursor())); }else{//isError - qWarning() << "You could really use the error checking for QFxTextInput. We'll implement it soon.";//TODO:better error handling + qmlInfo(this) << "Could not load cursor delegate"; + qWarning() << cursorComponent->errors(); } } void QFxTextInput::createCursor() { Q_D(QFxTextInput); - //Handle isError too + if(d->cursorComponent->isError()){ + qmlInfo(this) << "Could not load cursor delegate"; + qWarning() << cursorComponent->errors(); + return; + } + if(!d->cursorComponent->isReady()) return; @@ -522,7 +530,8 @@ void QFxTextInput::createCursor() delete d->cursorItem; d->cursorItem = qobject_cast(d->cursorComponent->create()); if(!d->cursorItem){ - qWarning() << "You could really use the error reporting for QFxTextInput. We'll implement it soon.";//TODO:better error handling + qmlInfo(this) << "Could not instantiate cursor delegate"; + //The failed instantiation should print its own error messages return; } @@ -610,8 +619,9 @@ void QFxTextInput::drawContents(QPainter *p, const QRect &r) int flags = QLineControl::DrawText; if(!isReadOnly() && d->cursorVisible && !d->cursorItem) flags |= QLineControl::DrawCursor; - if (d->control->hasSelectedText()) + if (d->control->hasSelectedText()){ flags |= QLineControl::DrawSelections; + } d->control->draw(p, QPoint(0,0), r, flags); -- cgit v0.12 From d0742b84e085fb1f38cd127c43da07275f5553ac Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 16 Sep 2009 08:55:41 +1000 Subject: Remove unnecessary definitions in GL pixmap filter code. The code does not use QGLShader directly any more. Reviewed-by: trustme --- src/opengl/qglpixmapfilter.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 7876661..e4df69e 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -75,9 +75,6 @@ public: protected: bool processGL(QPainter *painter, const QPointF &pos, const QPixmap &pixmap, const QRectF &srcRect) const; - -private: - mutable QGLShader *m_shader; }; class QGLPixmapConvolutionFilter: public QGLPixmapFilter @@ -111,8 +108,6 @@ protected: private: static QByteArray generateBlurShader(int radius, bool gaussianBlur); - mutable QGLShader *m_shader; - mutable QSize m_textureSize; mutable bool m_horizontalBlur; -- cgit v0.12 From dcd4b15595a63864ee59a19d80f1ba33b4821aa3 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 16 Sep 2009 09:31:01 +1000 Subject: Only regenerate pixmap filter source if the parameters have changed. Reviewed-by: trustme --- src/opengl/qglpixmapfilter.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index e4df69e..43f1990 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -71,6 +71,8 @@ void QGLPixmapFilterBase::drawImpl(QPainter *painter, const QPointF &pos, const class QGLPixmapColorizeFilter: public QGLCustomShaderStage, public QGLPixmapFilter { public: + QGLPixmapColorizeFilter(); + void setUniforms(QGLShaderProgram *program); protected: @@ -100,6 +102,8 @@ private: class QGLPixmapBlurFilter : public QGLCustomShaderStage, public QGLPixmapFilter { public: + QGLPixmapBlurFilter(); + void setUniforms(QGLShaderProgram *program); protected: @@ -111,6 +115,10 @@ private: mutable QSize m_textureSize; mutable bool m_horizontalBlur; + + mutable bool m_haveCached; + mutable int m_cachedRadius; + mutable Qt::TransformationMode m_cachedQuality; }; extern QGLWidget *qt_gl_share_widget(); @@ -182,10 +190,14 @@ static const char *qt_gl_colorize_filter = " return vec4(mix(srcPixel.rgb, colorized * srcPixel.a, colorizeStrength), srcPixel.a);" "}"; +QGLPixmapColorizeFilter::QGLPixmapColorizeFilter() +{ + setSource(qt_gl_colorize_filter); +} + bool QGLPixmapColorizeFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapColorizeFilter *filter = const_cast(this); - filter->setSource(qt_gl_colorize_filter); filter->setOnPainter(painter); painter->drawPixmap(pos, src); @@ -292,10 +304,27 @@ bool QGLPixmapConvolutionFilter::processGL(QPainter *, const QPointF &pos, const return true; } +QGLPixmapBlurFilter::QGLPixmapBlurFilter() + : m_haveCached(false), m_cachedRadius(5), + m_cachedQuality(Qt::FastTransformation) +{ +} + bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const QPixmap &src, const QRectF &) const { QGLPixmapBlurFilter *filter = const_cast(this); - filter->setSource(generateBlurShader(radius(), quality() == Qt::SmoothTransformation)); + + int radius = this->radius(); + Qt::TransformationMode quality = this->quality(); + + if (!m_haveCached || radius != m_cachedRadius || + quality != m_cachedQuality) { + // Only regenerate the shader from source if parameters have changed. + m_haveCached = true; + m_cachedRadius = radius; + m_cachedQuality = quality; + filter->setSource(generateBlurShader(radius, quality == Qt::SmoothTransformation)); + } QGLFramebufferObjectFormat format; format.setInternalTextureFormat(GLenum(src.hasAlphaChannel() ? GL_RGBA : GL_RGB)); -- cgit v0.12 From adfb5c6160b37a917f20b301366567c208ae52a0 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Sep 2009 09:43:45 +1000 Subject: Fix QLineEdit::setPalette QLineControl has a separate palette that wasn't getting updated. Task-number: 261239 Reviewed-by: mbm --- src/gui/widgets/qlinecontrol_p.h | 13 +++++++++++++ src/gui/widgets/qlineedit.cpp | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 8ad0452..68898b6 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -220,6 +220,9 @@ public: QString cancelText() const; void setCancelText(const QString &text); + const QPalette &palette() const; + void setPalette(const QPalette &); + enum DrawFlags { DrawText = 0x01, DrawSelections = 0x02, @@ -741,6 +744,16 @@ inline void QLineControl::setCancelText(const QString &text) m_cancelText = text; } +inline const QPalette & QLineControl::palette() const +{ + return m_palette; +} + +inline void QLineControl::setPalette(const QPalette &p) +{ + m_palette = p; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index a55ca8e..b4cea1b 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1851,8 +1851,12 @@ void QLineEdit::paintEvent(QPaintEvent *) #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled() || hasEditFocus()) #endif - if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())) + if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ flags |= QLineControl::DrawSelections; + // Palette only used for selections/mask and may not be in sync + if(d->control->palette() != pal) + d->control->setPalette(pal); + } // Asian users see an IM selection text as cursor on candidate // selection phase of input method, so the ordinary cursor should be -- cgit v0.12 From c878fde1d0ddd54c8dff485e7c7146b3d8962fb9 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Sep 2009 09:52:04 +1000 Subject: Fix QLineEdit drag'n'drop QLineEdit shouldn't have been moving the text cursor while dragging. Task-number: 260457 Reviewed-by: mbm --- src/gui/widgets/qlineedit.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index e536928..629e839 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1434,7 +1434,6 @@ void QLineEdit::mousePressEvent(QMouseEvent* e) #ifndef QT_NO_DRAGANDDROP if (!mark && d->dragEnabled && d->control->echoMode() == Normal && e->button() == Qt::LeftButton && d->control->inSelection(e->pos().x())) { - d->control->moveCursor(cursor); d->dndPos = e->pos(); if (!d->dndTimer.isActive()) d->dndTimer.start(QApplication::startDragTime(), this); -- cgit v0.12 From cacf0e4f1411c844f2e866f07af5f28f0f53c7ec Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 16 Sep 2009 10:43:58 +1000 Subject: Compile fix --- src/declarative/fx/qfxtextinput.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index b5960fd..8a09ebc 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -41,6 +41,7 @@ #include "qfxtextinput.h" #include "qfxtextinput_p.h" +#include "qmlinfo.h" #include #include #include @@ -509,7 +510,7 @@ void QFxTextInputPrivate::startCreatingCursor() q->connect(cursorComponent, SIGNAL(statusChanged(int)), q, SLOT(createCursor())); }else{//isError - qmlInfo(this) << "Could not load cursor delegate"; + qmlInfo(q) << "Could not load cursor delegate"; qWarning() << cursorComponent->errors(); } } @@ -519,7 +520,7 @@ void QFxTextInput::createCursor() Q_D(QFxTextInput); if(d->cursorComponent->isError()){ qmlInfo(this) << "Could not load cursor delegate"; - qWarning() << cursorComponent->errors(); + qWarning() << d->cursorComponent->errors(); return; } -- cgit v0.12 From 9f629961ad9f569eb1d31b5698a0779f104e65aa Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 16 Sep 2009 15:30:23 +1000 Subject: Make flicking a bit more resistant to spurrious input. --- src/declarative/fx/qfxflickable.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 1e6ad5a..c4d593c 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -587,8 +587,8 @@ void QFxFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) stealMouse = false; pressed = true; timeline.clear(); - velocityX = -1; - velocityY = -1; + velocityX = 0; + velocityY = 0; lastPos = QPoint(); lastPosTime.start(); pressPos = event->pos(); @@ -654,12 +654,16 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) elapsed = 1; if (q->yflick()) { qreal diff = event->pos().y() - lastPos.y(); - velocityY = diff / elapsed; + // average to reduce the effect of spurious moves + velocityY += diff / elapsed; + velocityY /= 2; } if (q->xflick()) { qreal diff = event->pos().x() - lastPos.x(); - velocityX = diff / elapsed; + // average to reduce the effect of spurious moves + velocityX += diff / elapsed; + velocityX /= 2; } } @@ -681,6 +685,12 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *even if (lastPosTime.isNull()) return; + if (lastPosTime.elapsed() > 100) { + // if we drag then pause before release we should not cause a flick. + velocityX = 0.0; + velocityY = 0.0; + } + vTime = timeline.time(); if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) flickY(velocityY); -- cgit v0.12 From 1713d5794cd578fbe1d083737647285ba7edac60 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 16 Sep 2009 15:31:02 +1000 Subject: Small tweaks. --- src/declarative/fx/qfxlistview.cpp | 10 ++-------- src/declarative/fx/qfxlistview.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 168e4c4..015eacf 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -570,13 +570,7 @@ void QFxListViewPrivate::layout() return; q->refill(); updateHighlight(); - if (orient == Qt::Vertical) { - fixupY(); - q->setViewportHeight(endPosition() - startPosition()); - } else { - fixupX(); - q->setViewportWidth(endPosition() - startPosition()); - } + fixupPosition(); updateUnrequestedPositions(); } @@ -1131,7 +1125,7 @@ void QFxListView::setStrictlyEnforceHighlightRange(bool strict) } /*! - \qmlproperty int ListView::spacing + \qmlproperty real ListView::spacing This property holds the spacing to leave between items. */ diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index e5c3138..cc3d910 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -62,7 +62,6 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_OBJECT Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxListView) - Q_ENUMS(CurrentItemPositioning) Q_PROPERTY(QVariant model READ model WRITE setModel) Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) -- cgit v0.12