From a490b9f584887c2569a751fde063e883b7bf79ab Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 29 Jul 2009 11:49:56 +1000 Subject: Implement the font property for QFxLineEdit --- src/declarative/fx/qfxlineedit.cpp | 17 +++++++++++++++++ src/declarative/fx/qfxlineedit.h | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp index c88f1d0..4ff3504 100644 --- a/src/declarative/fx/qfxlineedit.cpp +++ b/src/declarative/fx/qfxlineedit.cpp @@ -108,6 +108,22 @@ QmlFont *QFxLineEdit::font() } /*! +This signal is emitted when the font of the item changes. +*/ +void QFxLineEdit::fontChanged() +{ + Q_D(QFxLineEdit); + d->control->setFont(d->font->font()); + if(d->cursorItem){ + d->cursorItem->setHeight(QFontMetrics(d->font->font()).height()); + moveCursor(); + } + //updateSize(); + updateAll();//TODO: Only necessary updates + emit update(); +} + +/*! \qmlproperty color LineEdit::color The text color. @@ -478,6 +494,7 @@ void QFxLineEditPrivate::init() q, SLOT(updateAll())); if(!font) font = new QmlFont(); + q->connect(font, SIGNAL(updated()), q, SLOT(fontChanged())); q->updateSize(); oldValidity = control->hasAcceptableInput(); lastSelectionStart = 0; diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h index 2c22d4b..0f56818 100644 --- a/src/declarative/fx/qfxlineedit.h +++ b/src/declarative/fx/qfxlineedit.h @@ -147,8 +147,9 @@ protected: void focusChanged(bool hasFocus); -private slots: +private Q_SLOTS: void updateSize(); + void fontChanged(); void q_textChanged(); void selectionChanged(); void updateAll(); -- cgit v0.12