diff options
author | Ning Chi <ext-chi.ning@nokia.com> | 2010-12-20 22:21:13 +0200 |
---|---|---|
committer | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2011-01-11 18:37:45 +0200 |
commit | ce229adcefd2e9b5f28ba48a016cfc74989e3457 (patch) | |
tree | 39f0d84999475cebcc3af90d2e7ab9b4c1deb6c4 | |
parent | b6b01e4ebd4820d0d268341fa81e5935ef9004f0 (diff) |
Fixes: NB#213911 - VKB Bold, Italic, Underline settings are not working properly
RevBy: Pekka Vuorela
Details: also fix richtextedit can not show correct style when cursor is
inside preedit.
-rw-r--r-- | src/corelib/widgets/mrichtextedit.cpp | 18 | ||||
-rwxr-xr-x | src/corelib/widgets/mtextedit.cpp | 15 | ||||
-rwxr-xr-x | src/corelib/widgets/mtextedit_p.h | 1 |
3 files changed, 31 insertions, 3 deletions
diff --git a/src/corelib/widgets/mrichtextedit.cpp b/src/corelib/widgets/mrichtextedit.cpp index 4c3b9abd..a95c9b3a 100644 --- a/src/corelib/widgets/mrichtextedit.cpp +++ b/src/corelib/widgets/mrichtextedit.cpp @@ -121,7 +121,12 @@ void MRichTextEditPrivate::_q_updateStyle() Q_Q(MRichTextEdit); QTextCursor cursor = q->textCursor(); - QTextCharFormat format = cursor.charFormat(); + QTextCharFormat format; + if (isPreediting()) { + format = currentPreeditCharFormat(); + } else { + format = cursor.charFormat(); + } MInputMethodState::instance()->setToolbarItemAttribute(q->attachedToolbarId(), "Bold", @@ -483,9 +488,16 @@ void MRichTextEdit::setFontBold(bool bold) QFont MRichTextEdit::currentFont() { - QTextCursor textcursor = textCursor(); + Q_D(MRichTextEdit); - return textcursor.charFormat().font(); + QFont font; + if (d->isPreediting() == true) { + font = d->currentPreeditCharFormat().font(); + } else { + QTextCursor textcursor = textCursor(); + font = textcursor.charFormat().font(); + } + return font; } diff --git a/src/corelib/widgets/mtextedit.cpp b/src/corelib/widgets/mtextedit.cpp index 3fdf6d37..62dea38c 100755 --- a/src/corelib/widgets/mtextedit.cpp +++ b/src/corelib/widgets/mtextedit.cpp @@ -1164,6 +1164,21 @@ void MTextEditPrivate::addStyleToPreeditStyling(StyleType currentStyleType, bool } } +/*! + * \brief returns the cursor's current character format in the stored preedit styling + */ +QTextCharFormat MTextEditPrivate::currentPreeditCharFormat() const +{ + QTextCharFormat format; + const QString preedit = cursor()->selectedText(); + int currentStyleLastCharIndex = 0; + int currentStyleIndex = currentPreeditStylingIndex(currentStyleLastCharIndex); + if (currentStyleIndex >= 0) { + format = preeditStyling.at(currentStyleIndex).charFormat; + } + return format; + +} /*! * \brief clears the unused styling from stored preedit styling information diff --git a/src/corelib/widgets/mtextedit_p.h b/src/corelib/widgets/mtextedit_p.h index 91765886..11d63e5f 100755 --- a/src/corelib/widgets/mtextedit_p.h +++ b/src/corelib/widgets/mtextedit_p.h @@ -100,6 +100,7 @@ public: void storePreeditTextStyling(int start, int end); void addStyleToPreeditStyling(StyleType currentStyleType, bool setValue); + QTextCharFormat currentPreeditCharFormat() const; void insertTextWithPreeditStyling(const QString &text, int ¤tListIndex, int ¤tCount); void clearUnusedPreeditStyling(int currentListIndex, int currentCount); int currentPreeditStylingIndex(int ¤tStyleLastCharIndex) const; |