7#include "windowresizehandler.h"
15class WindowResizeHandlerPrivate
22 bool updateMouseCursor(
const QPointF &globalMousePos);
23 void unsetMouseCursor();
28 bool overridingCursor =
false;
29 bool hitTestLeft(
const QPointF &pos);
30 bool hitTestRight(
const QPointF &pos);
31 bool hitTestTop(
const QPointF &pos);
32 bool hitTestBottom(
const QPointF &pos);
35PlasmaQuick::WindowResizeHandler::WindowResizeHandler(
QWindow *parent)
37 , d(new WindowResizeHandlerPrivate)
43WindowResizeHandler::~WindowResizeHandler()
45 d->window->removeEventFilter(
this);
48void WindowResizeHandler::setMargins(
const QMargins &margins)
53QMargins WindowResizeHandler::margins()
const
58void WindowResizeHandler::setActiveEdges(
Qt::Edges edges)
60 d->activeEdges = edges;
63Qt::Edges WindowResizeHandler::activeEdges()
const
65 return d->activeEdges;
68bool WindowResizeHandler::eventFilter(
QObject *watched,
QEvent *event)
71 switch (
event->type()) {
78 d->unsetMouseCursor();
89 const Qt::Edges sides = d->hitTest(globalMousePos) & d->activeEdges;
91 d->window->startSystemResize(sides);
102bool WindowResizeHandlerPrivate::updateMouseCursor(
const QPointF &globalMousePos)
104 Qt::Edges sides = hitTest(globalMousePos) & activeEdges;
128 overridingCursor =
true;
132void WindowResizeHandlerPrivate::unsetMouseCursor()
134 if (overridingCursor) {
136 overridingCursor =
false;
142 bool left = hitTestLeft(pos);
143 bool right = hitTestRight(pos);
144 bool top = hitTestTop(pos);
145 bool bottom = hitTestBottom(pos);
163bool WindowResizeHandlerPrivate::hitTestLeft(
const QPointF &pos)
166 const QRectF rect(geometry.
x(), geometry.
y(), margins.left(), geometry.
height());
167 return rect.contains(pos);
170bool WindowResizeHandlerPrivate::hitTestRight(
const QPointF &pos)
173 const QRectF rect(geometry.
x() + geometry.
width() - margins.right(), geometry.
y(), margins.right(), geometry.
height());
174 return rect.contains(pos);
177bool WindowResizeHandlerPrivate::hitTestTop(
const QPointF &pos)
180 const QRectF rect(geometry.
x(), geometry.
y(), geometry.
width(), margins.top());
181 return rect.contains(pos);
184bool WindowResizeHandlerPrivate::hitTestBottom(
const QPointF &pos)
187 const QRectF rect(geometry.
x(), geometry.
y() + geometry.
height() - margins.bottom(), geometry.
width(), margins.bottom());
188 return rect.contains(pos);
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
virtual bool event(QEvent *e)
void installEventFilter(QObject *filterObj)
QPointF globalPosition() const const
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)