Commit 288b21c1 authored by Clément Fauconnier's avatar Clément Fauconnier

improved behavior on font style changes

parent 88dee1f9
...@@ -353,9 +353,6 @@ void UBGraphicsTextItemDelegate::pickFont() ...@@ -353,9 +353,6 @@ void UBGraphicsTextItemDelegate::pickFont()
delegated()->setTextCursor(curCursor); delegated()->setTextCursor(curCursor);
if (curCursor.selectedText().length() == 0)
delegated()->setFont(selectedFont);
delegated()->setSelected(true); delegated()->setSelected(true);
delegated()->document()->adjustSize(); delegated()->document()->adjustSize();
delegated()->contentsChanged(); delegated()->contentsChanged();
...@@ -378,7 +375,7 @@ void UBGraphicsTextItemDelegate::pickColor() ...@@ -378,7 +375,7 @@ void UBGraphicsTextItemDelegate::pickColor()
if (colorDialog.exec()) if (colorDialog.exec())
{ {
QColor selectedColor = colorDialog.selectedColor(); QColor selectedColor = colorDialog.selectedColor();
delegated()->setDefaultTextColor(selectedColor);
QTextCursor curCursor = delegated()->textCursor(); QTextCursor curCursor = delegated()->textCursor();
QTextCharFormat format; QTextCharFormat format;
...@@ -386,8 +383,11 @@ void UBGraphicsTextItemDelegate::pickColor() ...@@ -386,8 +383,11 @@ void UBGraphicsTextItemDelegate::pickColor()
curCursor.mergeCharFormat(format); curCursor.mergeCharFormat(format);
delegated()->setTextCursor(curCursor); delegated()->setTextCursor(curCursor);
if (!curCursor.hasSelection()) if (!curCursor.hasSelection() || (curCursor.selectedText().length() == delegated()->toPlainText().length()))
{
delegated()->setDefaultTextColor(selectedColor);
UBGraphicsTextItem::lastUsedTextColor = selectedColor; UBGraphicsTextItem::lastUsedTextColor = selectedColor;
}
delegated()->setSelected(true); delegated()->setSelected(true);
delegated()->document()->adjustSize(); delegated()->document()->adjustSize();
...@@ -600,11 +600,9 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha ...@@ -600,11 +600,9 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha
int anchorPos = cursor.anchor(); int anchorPos = cursor.anchor();
int cursorPos = cursor.position(); int cursorPos = cursor.position();
if (0 == anchorPos-cursorPos) if (!cursor.hasSelection())
{ {
// If nothing is selected, then we select all the text cursor.select(QTextCursor::Document);
cursor.setPosition (0, QTextCursor::MoveAnchor);
cursor.setPosition (cursor.document()->characterCount()-1, QTextCursor::KeepAnchor);
} }
// Now we got the real start and stop positions // Now we got the real start and stop positions
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment