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