4 #include <QApplication>
8 #if !TTK_QT_VERSION_CHECK(5,0,0) && defined(Q_OS_UNIX)
9 # define GEOMETRY(x, y, w, h) move(x, y); resize(w, h);
11 # define GEOMETRY(x, y, w, h) setGeometry(x, y, w, h);
27 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
28 setAttribute(Qt::WA_TranslucentBackground, transparent);
29 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
30 setMouseTracking(
true);
35 QWidget::eventFilter(
object, event);
36 if(QEvent::MouseMove == event->type())
39 QApplication::sendEvent(
this, mouseEvent);
46 QWidget::paintEvent(event);
52 const QPoint &point = mapFromGlobal(QCursor::pos());
55 setCursor(Qt::ArrowCursor);
62 QWidget::mousePressEvent(event);
68 if(event->button() == Qt::LeftButton)
85 QWidget::mouseMoveEvent(event);
96 QWidget::mouseReleaseEvent(event);
99 setCursor(QCursor(Qt::ArrowCursor));
105 const QPoint &point = mapFromGlobal(QCursor::pos());
108 setCursor(Qt::SizeHorCursor);
113 setCursor(Qt::SizeHorCursor);
118 setCursor(Qt::SizeVerCursor);
123 setCursor(Qt::SizeVerCursor);
128 setCursor(Qt::SizeFDiagCursor);
133 setCursor(Qt::SizeBDiagCursor);
138 setCursor(Qt::SizeBDiagCursor);
143 setCursor(Qt::SizeFDiagCursor);
148 setCursor(Qt::ArrowCursor);
155 const QPoint &point = QCursor::pos();
160 const int wValue = x() + width() - point.x();
161 if(minimumWidth() <= wValue && wValue <= maximumWidth())
163 GEOMETRY(point.x(), y(), wValue, height());
169 const int wValue = point.x() - x();
170 if(minimumWidth() <= wValue && wValue <= maximumWidth())
172 GEOMETRY(x(), y(), wValue, height());
178 const int hValue = y() - point.y() + height();
179 if(minimumHeight() <= hValue && hValue <= maximumHeight())
181 GEOMETRY(x(), point.y(), width(), hValue);
187 const int hValue = point.y() - y();
188 if(minimumHeight() <= hValue && hValue <= maximumHeight())
190 GEOMETRY(x(), y(), width(), hValue);
196 int yValue = point.y();
197 int xValue = point.x();
199 int wValue = pos().x() + width() - xValue;
200 int hValue = pos().y() + height() - yValue;
205 if(twValue - xValue >= maximumWidth())
207 xValue = twValue - maximumWidth();
208 wValue = maximumWidth();
211 if(twValue - xValue <= minimumWidth())
213 xValue = twValue - minimumWidth();
214 wValue = minimumWidth();
217 if(thValue - yValue >= maximumHeight())
219 yValue = thValue - maximumHeight();
220 hValue = maximumHeight();
223 if(thValue - yValue <= minimumHeight())
225 yValue = thValue - minimumHeight();
226 hValue = minimumHeight();
229 GEOMETRY(xValue, yValue, wValue, hValue);
234 int hValue = y() + height() - point.y();
235 const int wValue = point.x() - x();
236 int yValue = point.y();
238 if(hValue >= maximumHeight())
241 hValue = maximumHeight();
244 if(hValue <= minimumHeight())
247 hValue = minimumHeight();
255 int wValue = x() + width() - point.x();
257 int xValue = point.x();
260 if(twValue - xValue >= maximumWidth())
262 xValue = twValue - maximumWidth();
263 wValue = maximumWidth();
266 if(twValue - xValue <= minimumWidth())
268 xValue = twValue - minimumWidth();
269 wValue = minimumWidth();
277 const int wValue = point.x() - x();
278 const int hValue = point.y() - y();
288 for(QWidget *
object : objects)
290 object->installEventFilter(
this);
291 object->setMouseTracking(
true);
#define TTKStaticCast(x, y)
#define QtMouseGlobalPos(p)
The namespace of the process utils.