diff options
author | Murugappan Nataraj <murugappan.nataraj@nokia.com> | 2010-09-09 13:01:25 +0530 |
---|---|---|
committer | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2010-09-10 15:41:36 +0300 |
commit | 1814a0005dbeb6ca54ff69c9020c713e2f1e628d (patch) | |
tree | 48ed4c2157233f7db2d348493d380fe7951d2eee /src | |
parent | ed88217311e890c58c2b9bfb00b9bd424712de27 (diff) |
Fixes: NB#188672 - Not able to get default Normal text once switched to Bold text
RevBy: Pekka Vuorela, Michael Hasselmann
Details: Toggling between normal text and bold text happens with help of default fontweight specified with the current theme.
Diffstat (limited to 'src')
-rwxr-xr-x[-rw-r--r--] | src/corelib/widgets/mrichtextedit.cpp | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | src/corelib/widgets/mtextedit.cpp | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | src/corelib/widgets/mtextedit_p.h | 0 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/corelib/widgets/mrichtextedit.cpp b/src/corelib/widgets/mrichtextedit.cpp index 6afb13a0..97012b6e 100644..100755 --- a/src/corelib/widgets/mrichtextedit.cpp +++ b/src/corelib/widgets/mrichtextedit.cpp @@ -124,7 +124,7 @@ void MRichTextEditPrivate::_q_updateStyle() MInputMethodState::instance()->setToolbarItemAttribute(q->attachedToolbarId(), "Bold", "pressed", - QVariant((QFont::Bold == format.fontWeight()) ? "true" : "false")); + QVariant((format.fontWeight() > QFont::Normal) ? "true" : "false")); MInputMethodState::instance()->setToolbarItemAttribute(q->attachedToolbarId(), "Underline", "pressed", @@ -245,9 +245,9 @@ void MRichTextEdit::setFontBold(bool bold) } else { QTextCursor textcursor = textCursor(); - QFont::Weight wt = QFont::Normal; - if (bold) - wt = QFont::Bold; + QFont font = document()->defaultFont(); + QFont::Weight defaultWeight = static_cast<QFont::Weight>(font.weight()); + QFont::Weight wt = (bold ? QFont::Bold : defaultWeight); QTextCharFormat format; format.setFontWeight(wt); diff --git a/src/corelib/widgets/mtextedit.cpp b/src/corelib/widgets/mtextedit.cpp index 5f61b6bb..1d8e688d 100644..100755 --- a/src/corelib/widgets/mtextedit.cpp +++ b/src/corelib/widgets/mtextedit.cpp @@ -1131,6 +1131,7 @@ void MTextEditPrivate::insertTextWithPreeditStyling(const QString &text, int &cu */ void MTextEditPrivate::addStyleToPreeditStyling(StyleType currentStyleType, bool setValue) { + Q_Q(MTextEdit); QTextCharFormat format; int preeditStyleSize = preeditStyling.size(); @@ -1143,9 +1144,9 @@ void MTextEditPrivate::addStyleToPreeditStyling(StyleType currentStyleType, bool } else if (currentStyleType == Italic) { format.setFontItalic(setValue); } else { // bold - QFont::Weight wt = QFont::Normal; - if (setValue) - wt = QFont::Bold; + QFont font = q->document()->defaultFont(); + QFont::Weight defaultWeight = static_cast<QFont::Weight>(font.weight()); + QFont::Weight wt = (setValue ? QFont::Bold : defaultWeight); format.setFontWeight(wt); } diff --git a/src/corelib/widgets/mtextedit_p.h b/src/corelib/widgets/mtextedit_p.h index 00ad99b8..00ad99b8 100644..100755 --- a/src/corelib/widgets/mtextedit_p.h +++ b/src/corelib/widgets/mtextedit_p.h |