Improve application of text formats from buttons.
- If the bar is empty they are now applied as normal - If there is a selection or the cursor is next to a word it is applied to it. - If there is no selected text and no word it is applied properly to the next char
This commit is contained in:
@@ -481,7 +481,15 @@ void ChatTextItemHelper::mergeTextFormatOnCursor(RichFormat::Format format, QTex
|
||||
if (!cursor.hasSelection()) {
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
}
|
||||
cursor.mergeCharFormat(charFormat);
|
||||
|
||||
if (!cursor.hasSelection() && isEmpty()) {
|
||||
cursor.mergeBlockCharFormat(charFormat);
|
||||
} else if (!cursor.hasSelection()) {
|
||||
cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor);
|
||||
cursor.mergeCharFormat(charFormat);
|
||||
} else {
|
||||
cursor.mergeCharFormat(charFormat);
|
||||
}
|
||||
Q_EMIT charFormatChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user