From 1814a0005dbeb6ca54ff69c9020c713e2f1e628d Mon Sep 17 00:00:00 2001 From: Murugappan Nataraj Date: Thu, 9 Sep 2010 13:01:25 +0530 Subject: 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. --- src/corelib/widgets/mrichtextedit.cpp | 8 ++++---- src/corelib/widgets/mtextedit.cpp | 7 ++++--- src/corelib/widgets/mtextedit_p.h | 0 3 files changed, 8 insertions(+), 7 deletions(-) mode change 100644 => 100755 src/corelib/widgets/mrichtextedit.cpp mode change 100644 => 100755 src/corelib/widgets/mtextedit.cpp mode change 100644 => 100755 src/corelib/widgets/mtextedit_p.h (limited to 'src') diff --git a/src/corelib/widgets/mrichtextedit.cpp b/src/corelib/widgets/mrichtextedit.cpp old mode 100644 new mode 100755 index 6afb13a0..97012b6e --- 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(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 old mode 100644 new mode 100755 index 5f61b6bb..1d8e688d --- 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(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 old mode 100644 new mode 100755 -- cgit v1.2.3