right.lineTo(pol.at(2));
QPainterPath mouseArea;
- qreal size = 8;
- if (getView())
- size /= m_view->matrix().m11();
- mouseArea.addRect(pos.x() - size / 2, pos.y() - size / 2, size, size);
+ qreal xsize = 12;
+ qreal ysize = 12;
+ if (getView()) {
+ xsize /= m_view->matrix().m11();
+ ysize /= m_view->matrix().m22();
+ }
+ mouseArea.addRect(pos.x() - xsize / 2, pos.y() - ysize / 2, xsize, ysize);
// Check for collisions between the mouse and the borders
if (mouseArea.contains(pol.at(0)))
painter->setPen(pen());
painter->drawRect(option->rect);
-
+ const QRectF r = painter->worldTransform().mapRect(option->rect);
+ painter->setWorldMatrixEnabled(false);
if (isEnabled()) {
- double handleSize = 6 / painter->worldTransform().m11();
- double halfHandleSize = handleSize / 2;
- painter->fillRect(-halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(option->rect.width() - halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(option->rect.width() - halfHandleSize, option->rect.height() - halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
- painter->fillRect(-halfHandleSize, option->rect.height() - halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
+ QRectF handle(0, 0, 6, 6);
+ handle.moveTopLeft(r.topLeft());
+ painter->fillRect(handle, QColor(Qt::yellow));
+ handle.moveTopRight(r.topRight());
+ painter->fillRect(handle, QColor(Qt::yellow));
+ handle.moveBottomLeft(r.bottomLeft());
+ painter->fillRect(handle, QColor(Qt::yellow));
+ handle.moveBottomRight(r.bottomRight());
+ painter->fillRect(handle, QColor(Qt::yellow));
}
+
+ // Draw cross at center
+ QPointF center = r.center();
+ painter->drawLine(center + QPointF(-6, 0), center + QPointF(6, 0));
+ painter->drawLine(center + QPointF(0, 6), center + QPointF(0, -6));
}
bool OnMonitorRectItem::getView()