35 #include <QApplication>
38 #include <QMouseEvent>
39 #include <QResizeEvent>
40 #include <QTimerEvent>
61 target_->removeEventFilter(
this);
69 target_->removeEventFilter(
this);
76 target_->installEventFilter(
this);
82 return rect_.toRect();
104 QApplication::restoreOverrideCursor();
124 switch (event->type())
126 case QEvent::MouseButtonPress:
128 case QEvent::MouseButtonRelease:
130 case QEvent::MouseMove:
146 if (!
rect_.contains(event->pos()))
160 if (event->button() == Qt::LeftButton)
164 #if QT_VERSION >= 0x050000
169 qWarning(
"changing state to %d",
state_);
191 if (event->button() == Qt::LeftButton)
209 #if QT_VERSION >= 0x050000
210 if (!
rect_.contains(event->localPos()))
212 if (!
rect_.contains(event->posF()))
217 QApplication::restoreOverrideCursor();
226 Qt::CursorShape shape;
227 #if QT_VERSION >= 0x050000
235 shape = Qt::SizeFDiagCursor;
239 shape = Qt::SizeBDiagCursor;
242 shape = Qt::SizeAllCursor;
247 QApplication::changeOverrideCursor(QCursor(shape));
251 QApplication::setOverrideCursor(QCursor(shape));
258 #if QT_VERSION >= 0x050000
274 #
if QT_VERSION >= 0x050000
286 #
if QT_VERSION >= 0x050000
298 #
if QT_VERSION >= 0x050000
310 #
if QT_VERSION >= 0x050000
319 qWarning(
"Unhandled state in PlaceableWindowProxy: %d",
state_);
328 const QPointF &p3)
const
330 QPointF v1 = p2 - p1;
331 QPointF v2 = p3 - p1;
333 double d = v1.x()*v2.y() - v1.y()*v2.x();
336 double new_width = std::abs(p3.x() - p1.x());
342 double new_height =
rect.height() /
rect.width() * new_width;
343 return QRectF(0, 0, new_width, new_height);
347 double new_height = std::abs(p3.y() - p1.y());
353 double new_width =
rect.width() /
rect.height() * new_height;
354 return QRectF(0, 0, new_width, new_height);
387 const QPointF &pt)
const
389 if (!
rect_.contains(pt))
394 const double threshold = 10.0;
395 double near_left = pt.x() -
rect_.left() < threshold;
396 double near_top = pt.y() -
rect_.top() < threshold;
397 double near_right =
rect_.right() - pt.x() < threshold;
398 double near_bottom =
rect_.bottom() - pt.y() < threshold;
400 if (near_top && near_left)
404 else if (near_top && near_right)
408 else if (near_bottom && near_left)
412 else if (near_bottom && near_right)