- QString txt = QString( "%1x%2" ).arg( selection.width() == 0 ? 2 : selection.width() )
- .arg( selection.height() == 0 ? 2 : selection.height() );
- QRect textRect = painter.boundingRect( rect(), Qt::AlignLeft, txt );
- QRect boundingRect = textRect.adjusted( -4, 0, 0, 0);
-
- if ( textRect.width() < r.width() - 2*handleSize &&
- textRect.height() < r.height() - 2*handleSize &&
- ( r.width() > 100 && r.height() > 100 ) ) // center, unsuitable for small selections
- {
- boundingRect.moveCenter( r.center() );
- textRect.moveCenter( r.center() );
- }
- else if ( r.y() - 3 > textRect.height() &&
- r.x() + textRect.width() < rect().right() ) // on top, left aligned
- {
- boundingRect.moveBottomLeft( QPoint( r.x(), r.y() - 3 ) );
- textRect.moveBottomLeft( QPoint( r.x() + 2, r.y() - 3 ) );
- }
- else if ( r.x() - 3 > textRect.width() ) // left, top aligned
- {
- boundingRect.moveTopRight( QPoint( r.x() - 3, r.y() ) );
- textRect.moveTopRight( QPoint( r.x() - 5, r.y() ) );
- }
- else if ( r.bottom() + 3 + textRect.height() < rect().bottom() &&
- r.right() > textRect.width() ) // at bottom, right aligned
- {
- boundingRect.moveTopRight( QPoint( r.right(), r.bottom() + 3 ) );
- textRect.moveTopRight( QPoint( r.right() - 2, r.bottom() + 3 ) );
- }
- else if ( r.right() + textRect.width() + 3 < rect().width() ) // right, bottom aligned
- {
- boundingRect.moveBottomLeft( QPoint( r.right() + 3, r.bottom() ) );
- textRect.moveBottomLeft( QPoint( r.right() + 5, r.bottom() ) );
+ QString txt = QString("%1x%2").arg(selection.width() == 0 ? 2 : selection.width())
+ .arg(selection.height() == 0 ? 2 : selection.height());
+ QRect textRect = painter.boundingRect(rect(), Qt::AlignLeft, txt);
+ QRect boundingRect = textRect.adjusted(-4, 0, 0, 0);
+
+ if (textRect.width() < r.width() - 2*handleSize &&
+ textRect.height() < r.height() - 2*handleSize &&
+ (r.width() > 100 && r.height() > 100)) { // center, unsuitable for small selections
+ boundingRect.moveCenter(r.center());
+ textRect.moveCenter(r.center());
+ } else if (r.y() - 3 > textRect.height() &&
+ r.x() + textRect.width() < rect().right()) { // on top, left aligned
+ boundingRect.moveBottomLeft(QPoint(r.x(), r.y() - 3));
+ textRect.moveBottomLeft(QPoint(r.x() + 2, r.y() - 3));
+ } else if (r.x() - 3 > textRect.width()) { // left, top aligned
+ boundingRect.moveTopRight(QPoint(r.x() - 3, r.y()));
+ textRect.moveTopRight(QPoint(r.x() - 5, r.y()));
+ } else if (r.bottom() + 3 + textRect.height() < rect().bottom() &&
+ r.right() > textRect.width()) { // at bottom, right aligned
+ boundingRect.moveTopRight(QPoint(r.right(), r.bottom() + 3));
+ textRect.moveTopRight(QPoint(r.right() - 2, r.bottom() + 3));
+ } else if (r.right() + textRect.width() + 3 < rect().width()) { // right, bottom aligned
+ boundingRect.moveBottomLeft(QPoint(r.right() + 3, r.bottom()));
+ textRect.moveBottomLeft(QPoint(r.right() + 5, r.bottom()));