SANKORE-466. Mechanism of text resizing improvement.

preferencesAboutTextFull
Aleksei Kanash 13 years ago
parent 484968fea2
commit 0d2565c25d
  1. 49
      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;
int iBlockLen;
int iPointSize;
int inewPointSize;
int iCursorPos = startPos;
// we search continuous blocks of the text with the same PointSize and allpy new settings for them.
while(iCursorPos < endPos)
{ {
// selecting single symbol bEndofTheSameBlock = false;
cursor.setPosition (i, QTextCursor::MoveAnchor); iBlockLen = 0;
cursor.setPosition (i+1, QTextCursor::KeepAnchor);
//setting new parameners cursor.setPosition (iCursorPos+1, QTextCursor::KeepAnchor);
QFont curFont = cursor.charFormat().font(); iPointSize = cursor.charFormat().font().pointSize();
cursor.setPosition (iCursorPos, QTextCursor::KeepAnchor);
curFont = cursor.charFormat().font();
do
{
iBlockLen++;
int pointSize = curFont.pointSize() + delta; cursor.setPosition (iCursorPos+iBlockLen+1, QTextCursor::KeepAnchor);
inewPointSize = cursor.charFormat().font().pointSize();
curFont.setPointSize(pointSize); cursor.setPosition (iCursorPos+iBlockLen, QTextCursor::KeepAnchor);
if ((iPointSize != inewPointSize)||(iCursorPos+iBlockLen >= endPos))
bEndofTheSameBlock = true;
}while(!bEndofTheSameBlock);
//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