SANKORE-466. Mechanism of text resizing improvement.

preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 484968fea2
commit 0d2565c25d
  1. 51
      src/domain/UBGraphicsTextItemDelegate.cpp

@ -301,27 +301,52 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(int delta)
int startPos = qMin(cursor.anchor(), cursor.position()); int startPos = qMin(cursor.anchor(), cursor.position());
int endPos = qMax(cursor.anchor(), cursor.position()); int endPos = qMax(cursor.anchor(), cursor.position());
for (int i = startPos; i < endPos ; i++) QFont curFont;
{ bool bEndofTheSameBlock;
// selecting single symbol int iBlockLen;
cursor.setPosition (i, QTextCursor::MoveAnchor); int iPointSize;
cursor.setPosition (i+1, QTextCursor::KeepAnchor); int inewPointSize;
int iCursorPos = startPos;
//setting new parameners // we search continuous blocks of the text with the same PointSize and allpy new settings for them.
QFont curFont = cursor.charFormat().font(); while(iCursorPos < endPos)
{
bEndofTheSameBlock = false;
iBlockLen = 0;
cursor.setPosition (iCursorPos+1, QTextCursor::KeepAnchor);
iPointSize = cursor.charFormat().font().pointSize();
cursor.setPosition (iCursorPos, QTextCursor::KeepAnchor);
curFont = cursor.charFormat().font();
do
{
iBlockLen++;
cursor.setPosition (iCursorPos+iBlockLen+1, QTextCursor::KeepAnchor);
inewPointSize = cursor.charFormat().font().pointSize();
cursor.setPosition (iCursorPos+iBlockLen, QTextCursor::KeepAnchor);
if ((iPointSize != inewPointSize)||(iCursorPos+iBlockLen >= endPos))
bEndofTheSameBlock = true;
int pointSize = curFont.pointSize() + delta; }while(!bEndofTheSameBlock);
curFont.setPointSize(pointSize);
//setting new parameners
curFont.setPointSize(iPointSize + delta);
textFormat.setFont(curFont); textFormat.setFont(curFont);
cursor.mergeCharFormat(textFormat); cursor.mergeCharFormat(textFormat);
delegated()->setTextCursor(cursor);
UBSettings::settings()->setFontPointSize(pointSize);
delegated()->document()->adjustSize(); iCursorPos += iBlockLen;
delegated()->setFont(curFont); cursor.setPosition (iCursorPos, QTextCursor::MoveAnchor);
} }
delegated()->document()->adjustSize();
delegated()->setFont(curFont);
UBSettings::settings()->setFontPointSize(iPointSize);
//returning initial selection //returning initial selection
cursor.setPosition (anchorPos, QTextCursor::MoveAnchor); cursor.setPosition (anchorPos, QTextCursor::MoveAnchor);
cursor.setPosition (cursorPos, QTextCursor::KeepAnchor); cursor.setPosition (cursorPos, QTextCursor::KeepAnchor);

Loading…
Cancel
Save