qwidgetresizehandler.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qwidgetresizehandler.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qwidgetresizehandler_p.h"-
41-
42#ifndef QT_NO_RESIZEHANDLER-
43#include "qframe.h"-
44#include "qapplication.h"-
45#include "qdesktopwidget.h"-
46#include "qcursor.h"-
47#include "qsizegrip.h"-
48#include "qevent.h"-
49#include "qdebug.h"-
50#include "private/qlayoutengine_p.h"-
51-
52QT_BEGIN_NAMESPACE-
53-
54#define RANGE 4-
55-
56static bool resizeHorizontalDirectionFixed = false;-
57static bool resizeVerticalDirectionFixed = false;-
58-
59// ### fixme: Qt 6: No longer export QWidgetResizeHandler and remove "Move"-
60// functionality. Currently, only the resize functionality is used by QDockWidget.-
61// Historically, the class was used in Qt 3's QWorkspace (predecessor to QMdiArea).-
62-
63QWidgetResizeHandler::QWidgetResizeHandler(QWidget *parent, QWidget *cw)-
64 : QObject(parent), widget(parent), childWidget(cw ? cw : parent),-
65 fw(0), extrahei(0), buttonDown(false), moveResizeMode(false), sizeprotect(true), movingEnabled(true)-
66{-
67 mode = Nowhere;-
68 widget->setMouseTracking(true);-
69 QFrame *frame = qobject_cast<QFrame*>(widget);-
70 range = frame ? frame->frameWidth() : RANGE;
frameDescription
TRUEnever evaluated
FALSEnever evaluated
0
71 range = qMax(RANGE, range);-
72 activeForMove = activeForResize = true;-
73 widget->installEventFilter(this);-
74}
never executed: end of block
0
75-
76void QWidgetResizeHandler::setActive(Action ac, bool b)-
77{-
78 if (ac & Move)
ac & MoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
79 activeForMove = b;
never executed: activeForMove = b;
0
80 if (ac & Resize)
ac & ResizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
81 activeForResize = b;
never executed: activeForResize = b;
0
82-
83 if (!isActive())
!isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
84 setMouseCursor(Nowhere);
never executed: setMouseCursor(Nowhere);
0
85}
never executed: end of block
0
86-
87bool QWidgetResizeHandler::isActive(Action ac) const-
88{-
89 bool b = false;-
90 if (ac & Move) b = activeForMove;
never executed: b = activeForMove;
ac & MoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
91 if (ac & Resize) b |= activeForResize;
never executed: b |= activeForResize;
ac & ResizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
92-
93 return b;
never executed: return b;
0
94}-
95-
96bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)-
97{-
98 if (!isActive()
!isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
99 || (ee->type() != QEvent::MouseButtonPress
ee->type() != ...useButtonPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
100 && ee->type() != QEvent::MouseButtonRelease
ee->type() != ...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
101 && ee->type() != QEvent::MouseMove
ee->type() != ...ent::MouseMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
102 && ee->type() != QEvent::KeyPress
ee->type() != QEvent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
0
103 && ee->type() != QEvent::ShortcutOverride)
ee->type() != ...ortcutOverrideDescription
TRUEnever evaluated
FALSEnever evaluated
0
104 )-
105 return false;
never executed: return false;
0
106-
107 Q_ASSERT(o == widget);-
108 QWidget *w = widget;-
109 if (QApplication::activePopupWidget()) {
QApplication::...ePopupWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
110 if (buttonDown && ee->type() == QEvent::MouseButtonRelease)
buttonDownDescription
TRUEnever evaluated
FALSEnever evaluated
ee->type() == ...eButtonReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
111 buttonDown = false;
never executed: buttonDown = false;
0
112 return false;
never executed: return false;
0
113 }-
114-
115 QMouseEvent *e = (QMouseEvent*)ee;-
116 switch (e->type()) {-
117 case QEvent::MouseButtonPress: {
never executed: case QEvent::MouseButtonPress:
0
118 if (w->isMaximized())
w->isMaximized()Description
TRUEnever evaluated
FALSEnever evaluated
0
119 break;
never executed: break;
0
120 if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos())))
!widget->rect(...>globalPos()))Description
TRUEnever evaluated
FALSEnever evaluated
0
121 return false;
never executed: return false;
0
122 if (e->button() == Qt::LeftButton) {
e->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
123#if defined(Q_DEAD_CODE_FROM_QT4_X11)-
124 /*-
125 Implicit grabs do not stop the X server from changing-
126 the cursor in children, which looks *really* bad when-
127 doing resizingk, so we grab the cursor. Note that we do-
128 not do this on Windows since double clicks are lost due-
129 to the grab (see change 198463).-
130 */-
131 if (e->spontaneous())-
132# if !defined(QT_NO_CURSOR)-
133 widget->grabMouse(widget->cursor());-
134# else-
135 widget->grabMouse();-
136# endif // QT_NO_CURSOR-
137#endif // Q_DEAD_CODE_FROM_QT4_X11-
138 buttonDown = false;-
139 emit activate();-
140 bool me = movingEnabled;-
141 movingEnabled = (me && o == widget);
meDescription
TRUEnever evaluated
FALSEnever evaluated
o == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
142 mouseMoveEvent(e);-
143 movingEnabled = me;-
144 buttonDown = true;-
145 moveOffset = widget->mapFromGlobal(e->globalPos());-
146 invertedMoveOffset = widget->rect().bottomRight() - moveOffset;-
147 if (mode == Center) {
mode == CenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
148 if (movingEnabled)
movingEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
149 return true;
never executed: return true;
0
150 } else {
never executed: end of block
0
151 return true;
never executed: return true;
0
152 }-
153 }-
154 } break;
never executed: break;
0
155 case QEvent::MouseButtonRelease:
never executed: case QEvent::MouseButtonRelease:
0
156 if (w->isMaximized())
w->isMaximized()Description
TRUEnever evaluated
FALSEnever evaluated
0
157 break;
never executed: break;
0
158 if (e->button() == Qt::LeftButton) {
e->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
0
159 moveResizeMode = false;-
160 buttonDown = false;-
161 widget->releaseMouse();-
162 widget->releaseKeyboard();-
163 if (mode == Center) {
mode == CenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
164 if (movingEnabled)
movingEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
165 return true;
never executed: return true;
0
166 } else {
never executed: end of block
0
167 return true;
never executed: return true;
0
168 }-
169 }-
170 break;
never executed: break;
0
171 case QEvent::MouseMove: {
never executed: case QEvent::MouseMove:
0
172 if (w->isMaximized())
w->isMaximized()Description
TRUEnever evaluated
FALSEnever evaluated
0
173 break;
never executed: break;
0
174 buttonDown = buttonDown && (e->buttons() & Qt::LeftButton); // safety, state machine broken!
buttonDownDescription
TRUEnever evaluated
FALSEnever evaluated
(e->buttons() ...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
175 bool me = movingEnabled;-
176 movingEnabled = (me && o == widget && (buttonDown || moveResizeMode));
meDescription
TRUEnever evaluated
FALSEnever evaluated
o == widgetDescription
TRUEnever evaluated
FALSEnever evaluated
buttonDownDescription
TRUEnever evaluated
FALSEnever evaluated
moveResizeModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
177 mouseMoveEvent(e);-
178 movingEnabled = me;-
179 if (mode == Center) {
mode == CenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
180 if (movingEnabled)
movingEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
181 return true;
never executed: return true;
0
182 } else {
never executed: end of block
0
183 return true;
never executed: return true;
0
184 }-
185 } break;
never executed: break;
0
186 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
187 keyPressEvent((QKeyEvent*)e);-
188 break;
never executed: break;
0
189 case QEvent::ShortcutOverride:
never executed: case QEvent::ShortcutOverride:
0
190 if (buttonDown) {
buttonDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
191 ((QKeyEvent*)ee)->accept();-
192 return true;
never executed: return true;
0
193 }-
194 break;
never executed: break;
0
195 default:
never executed: default:
0
196 break;
never executed: break;
0
197 }-
198-
199 return false;
never executed: return false;
0
200}-
201-
202void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)-
203{-
204 QPoint pos = widget->mapFromGlobal(e->globalPos());-
205 if (!moveResizeMode && !buttonDown) {
!moveResizeModeDescription
TRUEnever evaluated
FALSEnever evaluated
!buttonDownDescription
TRUEnever evaluated
FALSEnever evaluated
0
206 if (pos.y() <= range && pos.x() <= range)
pos.y() <= rangeDescription
TRUEnever evaluated
FALSEnever evaluated
pos.x() <= rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
207 mode = TopLeft;
never executed: mode = TopLeft;
0
208 else if (pos.y() >= widget->height()-range && pos.x() >= widget->width()-range)
pos.y() >= wid...height()-rangeDescription
TRUEnever evaluated
FALSEnever evaluated
pos.x() >= wid...>width()-rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
209 mode = BottomRight;
never executed: mode = BottomRight;
0
210 else if (pos.y() >= widget->height()-range && pos.x() <= range)
pos.y() >= wid...height()-rangeDescription
TRUEnever evaluated
FALSEnever evaluated
pos.x() <= rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
211 mode = BottomLeft;
never executed: mode = BottomLeft;
0
212 else if (pos.y() <= range && pos.x() >= widget->width()-range)
pos.y() <= rangeDescription
TRUEnever evaluated
FALSEnever evaluated
pos.x() >= wid...>width()-rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
213 mode = TopRight;
never executed: mode = TopRight;
0
214 else if (pos.y() <= range)
pos.y() <= rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
215 mode = Top;
never executed: mode = Top;
0
216 else if (pos.y() >= widget->height()-range)
pos.y() >= wid...height()-rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
217 mode = Bottom;
never executed: mode = Bottom;
0
218 else if (pos.x() <= range)
pos.x() <= rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
219 mode = Left;
never executed: mode = Left;
0
220 else if ( pos.x() >= widget->width()-range)
pos.x() >= wid...>width()-rangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
221 mode = Right;
never executed: mode = Right;
0
222 else if (widget->rect().contains(pos))
widget->rect().contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
0
223 mode = Center;
never executed: mode = Center;
0
224 else-
225 mode = Nowhere;
never executed: mode = Nowhere;
0
226-
227 if (widget->isMinimized() || !isActive(Resize))
widget->isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
!isActive(Resize)Description
TRUEnever evaluated
FALSEnever evaluated
0
228 mode = Center;
never executed: mode = Center;
0
229#ifndef QT_NO_CURSOR-
230 setMouseCursor(mode);-
231#endif-
232 return;
never executed: return;
0
233 }-
234-
235 if (mode == Center && !movingEnabled)
mode == CenterDescription
TRUEnever evaluated
FALSEnever evaluated
!movingEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
236 return;
never executed: return;
0
237-
238 if (widget->testAttribute(Qt::WA_WState_ConfigPending))
widget->testAt...ConfigPending)Description
TRUEnever evaluated
FALSEnever evaluated
0
239 return;
never executed: return;
0
240-
241-
242 QPoint globalPos = (!widget->isWindow() && widget->parentWidget()) ?
!widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
widget->parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
243 widget->parentWidget()->mapFromGlobal(e->globalPos()) : e->globalPos();-
244 if (!widget->isWindow() && !widget->parentWidget()->rect().contains(globalPos)) {
!widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
!widget->paren...ins(globalPos)Description
TRUEnever evaluated
FALSEnever evaluated
0
245 if (globalPos.x() < 0)
globalPos.x() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
246 globalPos.rx() = 0;
never executed: globalPos.rx() = 0;
0
247 if (globalPos.y() < 0)
globalPos.y() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
248 globalPos.ry() = 0;
never executed: globalPos.ry() = 0;
0
249 if (sizeprotect && globalPos.x() > widget->parentWidget()->width())
sizeprotectDescription
TRUEnever evaluated
FALSEnever evaluated
globalPos.x() ...get()->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
250 globalPos.rx() = widget->parentWidget()->width();
never executed: globalPos.rx() = widget->parentWidget()->width();
0
251 if (sizeprotect && globalPos.y() > widget->parentWidget()->height())
sizeprotectDescription
TRUEnever evaluated
FALSEnever evaluated
globalPos.y() ...et()->height()Description
TRUEnever evaluated
FALSEnever evaluated
0
252 globalPos.ry() = widget->parentWidget()->height();
never executed: globalPos.ry() = widget->parentWidget()->height();
0
253 }
never executed: end of block
0
254-
255 QPoint p = globalPos + invertedMoveOffset;-
256 QPoint pp = globalPos - moveOffset;-
257-
258 // Workaround for window managers which refuse to move a tool window partially offscreen.-
259 if (QGuiApplication::platformName() == QLatin1String("xcb")) {
QGuiApplicatio...1String("xcb")Description
TRUEnever evaluated
FALSEnever evaluated
0
260 const QRect desktop = QApplication::desktop()->availableGeometry(widget);-
261 pp.rx() = qMax(pp.x(), desktop.left());-
262 pp.ry() = qMax(pp.y(), desktop.top());-
263 p.rx() = qMin(p.x(), desktop.right());-
264 p.ry() = qMin(p.y(), desktop.bottom());-
265 }
never executed: end of block
0
266-
267 QSize ms = qSmartMinSize(childWidget);-
268 int mw = ms.width();-
269 int mh = ms.height();-
270 if (childWidget != widget) {
childWidget != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
271 mw += 2 * fw;-
272 mh += 2 * fw + extrahei;-
273 }
never executed: end of block
0
274-
275 QSize maxsize(childWidget->maximumSize());-
276 if (childWidget != widget)
childWidget != widgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
277 maxsize += QSize(2 * fw, 2 * fw + extrahei);
never executed: maxsize += QSize(2 * fw, 2 * fw + extrahei);
0
278 QSize mpsize(widget->geometry().right() - pp.x() + 1,-
279 widget->geometry().bottom() - pp.y() + 1);-
280 mpsize = mpsize.expandedTo(widget->minimumSize()).expandedTo(QSize(mw, mh))-
281 .boundedTo(maxsize);-
282 QPoint mp(widget->geometry().right() - mpsize.width() + 1,-
283 widget->geometry().bottom() - mpsize.height() + 1);-
284-
285 QRect geom = widget->geometry();-
286-
287 switch (mode) {-
288 case TopLeft:
never executed: case TopLeft:
0
289 geom = QRect(mp, widget->geometry().bottomRight()) ;-
290 break;
never executed: break;
0
291 case BottomRight:
never executed: case BottomRight:
0
292 geom = QRect(widget->geometry().topLeft(), p) ;-
293 break;
never executed: break;
0
294 case BottomLeft:
never executed: case BottomLeft:
0
295 geom = QRect(QPoint(mp.x(), widget->geometry().y()), QPoint(widget->geometry().right(), p.y())) ;-
296 break;
never executed: break;
0
297 case TopRight:
never executed: case TopRight:
0
298 geom = QRect(QPoint(widget->geometry().x(), mp.y()), QPoint(p.x(), widget->geometry().bottom())) ;-
299 break;
never executed: break;
0
300 case Top:
never executed: case Top:
0
301 geom = QRect(QPoint(widget->geometry().left(), mp.y()), widget->geometry().bottomRight()) ;-
302 break;
never executed: break;
0
303 case Bottom:
never executed: case Bottom:
0
304 geom = QRect(widget->geometry().topLeft(), QPoint(widget->geometry().right(), p.y())) ;-
305 break;
never executed: break;
0
306 case Left:
never executed: case Left:
0
307 geom = QRect(QPoint(mp.x(), widget->geometry().top()), widget->geometry().bottomRight()) ;-
308 break;
never executed: break;
0
309 case Right:
never executed: case Right:
0
310 geom = QRect(widget->geometry().topLeft(), QPoint(p.x(), widget->geometry().bottom())) ;-
311 break;
never executed: break;
0
312 case Center:
never executed: case Center:
0
313 geom.moveTopLeft(pp);-
314 break;
never executed: break;
0
315 default:
never executed: default:
0
316 break;
never executed: break;
0
317 }-
318-
319 geom = QRect(geom.topLeft(),-
320 geom.size().expandedTo(widget->minimumSize())-
321 .expandedTo(QSize(mw, mh))-
322 .boundedTo(maxsize));-
323-
324 if (geom != widget->geometry() &&
geom != widget->geometry()Description
TRUEnever evaluated
FALSEnever evaluated
0
325 (widget->isWindow() || widget->parentWidget()->rect().intersects(geom))) {
widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
widget->parent...tersects(geom)Description
TRUEnever evaluated
FALSEnever evaluated
0
326 if (mode == Center)
mode == CenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
327 widget->move(geom.topLeft());
never executed: widget->move(geom.topLeft());
0
328 else-
329 widget->setGeometry(geom);
never executed: widget->setGeometry(geom);
0
330 }-
331}
never executed: end of block
0
332-
333void QWidgetResizeHandler::setMouseCursor(MousePosition m)-
334{-
335#ifdef QT_NO_CURSOR-
336 Q_UNUSED(m);-
337#else-
338 QObjectList children = widget->children();-
339 for (int i = 0; i < children.size(); ++i) {
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
340 if (QWidget *w = qobject_cast<QWidget*>(children.at(i))) {
QWidget *w = q...hildren.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
0
341 if (!w->testAttribute(Qt::WA_SetCursor)) {
!w->testAttrib...:WA_SetCursor)Description
TRUEnever evaluated
FALSEnever evaluated
0
342 w->setCursor(Qt::ArrowCursor);-
343 }
never executed: end of block
0
344 }
never executed: end of block
0
345 }
never executed: end of block
0
346-
347 switch (m) {-
348 case TopLeft:
never executed: case TopLeft:
0
349 case BottomRight:
never executed: case BottomRight:
0
350 widget->setCursor(Qt::SizeFDiagCursor);-
351 break;
never executed: break;
0
352 case BottomLeft:
never executed: case BottomLeft:
0
353 case TopRight:
never executed: case TopRight:
0
354 widget->setCursor(Qt::SizeBDiagCursor);-
355 break;
never executed: break;
0
356 case Top:
never executed: case Top:
0
357 case Bottom:
never executed: case Bottom:
0
358 widget->setCursor(Qt::SizeVerCursor);-
359 break;
never executed: break;
0
360 case Left:
never executed: case Left:
0
361 case Right:
never executed: case Right:
0
362 widget->setCursor(Qt::SizeHorCursor);-
363 break;
never executed: break;
0
364 default:
never executed: default:
0
365 widget->setCursor(Qt::ArrowCursor);-
366 break;
never executed: break;
0
367 }-
368#endif // QT_NO_CURSOR-
369}-
370-
371void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)-
372{-
373 if (!isMove() && !isResize())
!isMove()Description
TRUEnever evaluated
FALSEnever evaluated
!isResize()Description
TRUEnever evaluated
FALSEnever evaluated
0
374 return;
never executed: return;
0
375 bool is_control = e->modifiers() & Qt::ControlModifier;-
376 int delta = is_control?1:8;
is_controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
377 QPoint pos = QCursor::pos();-
378 switch (e->key()) {-
379 case Qt::Key_Left:
never executed: case Qt::Key_Left:
0
380 pos.rx() -= delta;-
381 if (pos.x() <= QApplication::desktop()->geometry().left()) {
pos.x() <= QAp...metry().left()Description
TRUEnever evaluated
FALSEnever evaluated
0
382 if (mode == TopLeft || mode == BottomLeft) {
mode == TopLeftDescription
TRUEnever evaluated
FALSEnever evaluated
mode == BottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
383 moveOffset.rx() += delta;-
384 invertedMoveOffset.rx() += delta;-
385 } else {
never executed: end of block
0
386 moveOffset.rx() -= delta;-
387 invertedMoveOffset.rx() -= delta;-
388 }
never executed: end of block
0
389 }-
390 if (isResize() && !resizeHorizontalDirectionFixed) {
isResize()Description
TRUEnever evaluated
FALSEnever evaluated
!resizeHorizon...DirectionFixedDescription
TRUEnever evaluated
FALSEnever evaluated
0
391 resizeHorizontalDirectionFixed = true;-
392 if (mode == BottomRight)
mode == BottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 mode = BottomLeft;
never executed: mode = BottomLeft;
0
394 else if (mode == TopRight)
mode == TopRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
395 mode = TopLeft;
never executed: mode = TopLeft;
0
396#ifndef QT_NO_CURSOR-
397 setMouseCursor(mode);-
398 widget->grabMouse(widget->cursor());-
399#else-
400 widget->grabMouse();-
401#endif-
402 }
never executed: end of block
0
403 break;
never executed: break;
0
404 case Qt::Key_Right:
never executed: case Qt::Key_Right:
0
405 pos.rx() += delta;-
406 if (pos.x() >= QApplication::desktop()->geometry().right()) {
pos.x() >= QAp...etry().right()Description
TRUEnever evaluated
FALSEnever evaluated
0
407 if (mode == TopRight || mode == BottomRight) {
mode == TopRightDescription
TRUEnever evaluated
FALSEnever evaluated
mode == BottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
408 moveOffset.rx() += delta;-
409 invertedMoveOffset.rx() += delta;-
410 } else {
never executed: end of block
0
411 moveOffset.rx() -= delta;-
412 invertedMoveOffset.rx() -= delta;-
413 }
never executed: end of block
0
414 }-
415 if (isResize() && !resizeHorizontalDirectionFixed) {
isResize()Description
TRUEnever evaluated
FALSEnever evaluated
!resizeHorizon...DirectionFixedDescription
TRUEnever evaluated
FALSEnever evaluated
0
416 resizeHorizontalDirectionFixed = true;-
417 if (mode == BottomLeft)
mode == BottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
418 mode = BottomRight;
never executed: mode = BottomRight;
0
419 else if (mode == TopLeft)
mode == TopLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
420 mode = TopRight;
never executed: mode = TopRight;
0
421#ifndef QT_NO_CURSOR-
422 setMouseCursor(mode);-
423 widget->grabMouse(widget->cursor());-
424#else-
425 widget->grabMouse();-
426#endif-
427 }
never executed: end of block
0
428 break;
never executed: break;
0
429 case Qt::Key_Up:
never executed: case Qt::Key_Up:
0
430 pos.ry() -= delta;-
431 if (pos.y() <= QApplication::desktop()->geometry().top()) {
pos.y() <= QAp...ometry().top()Description
TRUEnever evaluated
FALSEnever evaluated
0
432 if (mode == TopLeft || mode == TopRight) {
mode == TopLeftDescription
TRUEnever evaluated
FALSEnever evaluated
mode == TopRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
433 moveOffset.ry() += delta;-
434 invertedMoveOffset.ry() += delta;-
435 } else {
never executed: end of block
0
436 moveOffset.ry() -= delta;-
437 invertedMoveOffset.ry() -= delta;-
438 }
never executed: end of block
0
439 }-
440 if (isResize() && !resizeVerticalDirectionFixed) {
isResize()Description
TRUEnever evaluated
FALSEnever evaluated
!resizeVerticalDirectionFixedDescription
TRUEnever evaluated
FALSEnever evaluated
0
441 resizeVerticalDirectionFixed = true;-
442 if (mode == BottomLeft)
mode == BottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
443 mode = TopLeft;
never executed: mode = TopLeft;
0
444 else if (mode == BottomRight)
mode == BottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
445 mode = TopRight;
never executed: mode = TopRight;
0
446#ifndef QT_NO_CURSOR-
447 setMouseCursor(mode);-
448 widget->grabMouse(widget->cursor());-
449#else-
450 widget->grabMouse();-
451#endif-
452 }
never executed: end of block
0
453 break;
never executed: break;
0
454 case Qt::Key_Down:
never executed: case Qt::Key_Down:
0
455 pos.ry() += delta;-
456 if (pos.y() >= QApplication::desktop()->geometry().bottom()) {
pos.y() >= QAp...try().bottom()Description
TRUEnever evaluated
FALSEnever evaluated
0
457 if (mode == BottomLeft || mode == BottomRight) {
mode == BottomLeftDescription
TRUEnever evaluated
FALSEnever evaluated
mode == BottomRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
458 moveOffset.ry() += delta;-
459 invertedMoveOffset.ry() += delta;-
460 } else {
never executed: end of block
0
461 moveOffset.ry() -= delta;-
462 invertedMoveOffset.ry() -= delta;-
463 }
never executed: end of block
0
464 }-
465 if (isResize() && !resizeVerticalDirectionFixed) {
isResize()Description
TRUEnever evaluated
FALSEnever evaluated
!resizeVerticalDirectionFixedDescription
TRUEnever evaluated
FALSEnever evaluated
0
466 resizeVerticalDirectionFixed = true;-
467 if (mode == TopLeft)
mode == TopLeftDescription
TRUEnever evaluated
FALSEnever evaluated
0
468 mode = BottomLeft;
never executed: mode = BottomLeft;
0
469 else if (mode == TopRight)
mode == TopRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
470 mode = BottomRight;
never executed: mode = BottomRight;
0
471#ifndef QT_NO_CURSOR-
472 setMouseCursor(mode);-
473 widget->grabMouse(widget->cursor());-
474#else-
475 widget->grabMouse();-
476#endif-
477 }
never executed: end of block
0
478 break;
never executed: break;
0
479 case Qt::Key_Space:
never executed: case Qt::Key_Space:
0
480 case Qt::Key_Return:
never executed: case Qt::Key_Return:
0
481 case Qt::Key_Enter:
never executed: case Qt::Key_Enter:
0
482 case Qt::Key_Escape:
never executed: case Qt::Key_Escape:
0
483 moveResizeMode = false;-
484 widget->releaseMouse();-
485 widget->releaseKeyboard();-
486 buttonDown = false;-
487 break;
never executed: break;
0
488 default:
never executed: default:
0
489 return;
never executed: return;
0
490 }-
491 QCursor::setPos(pos);-
492}
never executed: end of block
0
493-
494-
495void QWidgetResizeHandler::doResize()-
496{-
497 if (!activeForResize)
!activeForResizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
498 return;
never executed: return;
0
499-
500 moveResizeMode = true;-
501 moveOffset = widget->mapFromGlobal(QCursor::pos());-
502 if (moveOffset.x() < widget->width()/2) {
moveOffset.x()...get->width()/2Description
TRUEnever evaluated
FALSEnever evaluated
0
503 if (moveOffset.y() < widget->height()/2)
moveOffset.y()...et->height()/2Description
TRUEnever evaluated
FALSEnever evaluated
0
504 mode = TopLeft;
never executed: mode = TopLeft;
0
505 else-
506 mode = BottomLeft;
never executed: mode = BottomLeft;
0
507 } else {-
508 if (moveOffset.y() < widget->height()/2)
moveOffset.y()...et->height()/2Description
TRUEnever evaluated
FALSEnever evaluated
0
509 mode = TopRight;
never executed: mode = TopRight;
0
510 else-
511 mode = BottomRight;
never executed: mode = BottomRight;
0
512 }-
513 invertedMoveOffset = widget->rect().bottomRight() - moveOffset;-
514#ifndef QT_NO_CURSOR-
515 setMouseCursor(mode);-
516 widget->grabMouse(widget->cursor() );-
517#else-
518 widget->grabMouse();-
519#endif-
520 widget->grabKeyboard();-
521 resizeHorizontalDirectionFixed = false;-
522 resizeVerticalDirectionFixed = false;-
523}
never executed: end of block
0
524-
525void QWidgetResizeHandler::doMove()-
526{-
527 if (!activeForMove)
!activeForMoveDescription
TRUEnever evaluated
FALSEnever evaluated
0
528 return;
never executed: return;
0
529-
530 mode = Center;-
531 moveResizeMode = true;-
532 moveOffset = widget->mapFromGlobal(QCursor::pos());-
533 invertedMoveOffset = widget->rect().bottomRight() - moveOffset;-
534#ifndef QT_NO_CURSOR-
535 widget->grabMouse(Qt::SizeAllCursor);-
536#else-
537 widget->grabMouse();-
538#endif-
539 widget->grabKeyboard();-
540}
never executed: end of block
0
541-
542QT_END_NAMESPACE-
543-
544#include "moc_qwidgetresizehandler_p.cpp"-
545-
546#endif //QT_NO_RESIZEHANDLER-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9