Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | static bool resizeHorizontalDirectionFixed = false; | - |
9 | static bool resizeVerticalDirectionFixed = false; | - |
10 | | - |
11 | QWidgetResizeHandler::QWidgetResizeHandler(QWidget *parent, QWidget *cw) | - |
12 | : QObject(parent), widget(parent), childWidget(cw ? cw : parent), | - |
13 | fw(0), extrahei(0), buttonDown(false), moveResizeMode(false), sizeprotect(true), movingEnabled(true) | - |
14 | { | - |
15 | mode = Nowhere; | - |
16 | widget->setMouseTracking(true); | - |
17 | QFrame *frame = qobject_cast<QFrame*>(widget); | - |
18 | range = frame ? frame->frameWidth() : 4; partially evaluated: frame no Evaluation Count:0 | yes Evaluation Count:27 |
| 0-27 |
19 | range = qMax(4, range); | - |
20 | activeForMove = activeForResize = true; | - |
21 | widget->installEventFilter(this); | - |
22 | } executed: } Execution Count:27 | 27 |
23 | | - |
24 | void QWidgetResizeHandler::setActive(Action ac, bool b) | - |
25 | { | - |
26 | if (ac & Move) evaluated: ac & Move yes Evaluation Count:27 | yes Evaluation Count:22 |
| 22-27 |
27 | activeForMove = b; executed: activeForMove = b; Execution Count:27 | 27 |
28 | if (ac & Resize) partially evaluated: ac & Resize yes Evaluation Count:49 | no Evaluation Count:0 |
| 0-49 |
29 | activeForResize = b; executed: activeForResize = b; Execution Count:49 | 49 |
30 | | - |
31 | if (!isActive()) evaluated: !isActive() yes Evaluation Count:39 | yes Evaluation Count:10 |
| 10-39 |
32 | setMouseCursor(Nowhere); executed: setMouseCursor(Nowhere); Execution Count:39 | 39 |
33 | } executed: } Execution Count:49 | 49 |
34 | | - |
35 | bool QWidgetResizeHandler::isActive(Action ac) const | - |
36 | { | - |
37 | bool b = false; | - |
38 | if (ac & Move) b = activeForMove; partially evaluated: ac & Move yes Evaluation Count:742 | no Evaluation Count:0 |
executed: b = activeForMove; Execution Count:742 | 0-742 |
39 | if (ac & Resize) b |= activeForResize; partially evaluated: ac & Resize yes Evaluation Count:742 | no Evaluation Count:0 |
executed: b |= activeForResize; Execution Count:742 | 0-742 |
40 | | - |
41 | return b; executed: return b; Execution Count:742 | 742 |
42 | } | - |
43 | | - |
44 | bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee) | - |
45 | { | - |
46 | if (!isActive() evaluated: !isActive() yes Evaluation Count:597 | yes Evaluation Count:96 |
| 96-597 |
47 | || (ee->type() != QEvent::MouseButtonPress partially evaluated: ee->type() != QEvent::MouseButtonPress yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
48 | && ee->type() != QEvent::MouseButtonRelease partially evaluated: ee->type() != QEvent::MouseButtonRelease yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
49 | && ee->type() != QEvent::MouseMove partially evaluated: ee->type() != QEvent::MouseMove yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
50 | && ee->type() != QEvent::KeyPress partially evaluated: ee->type() != QEvent::KeyPress yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
51 | && ee->type() != QEvent::ShortcutOverride) partially evaluated: ee->type() != QEvent::ShortcutOverride yes Evaluation Count:96 | no Evaluation Count:0 |
| 0-96 |
52 | ) | - |
53 | return false; executed: return false; Execution Count:693 | 693 |
54 | | - |
55 | qt_noop(); | - |
56 | QWidget *w = widget; | - |
57 | if (QApplication::activePopupWidget()) { never evaluated: QApplication::activePopupWidget() | 0 |
58 | if (buttonDown && ee->type() == QEvent::MouseButtonRelease) never evaluated: buttonDown never evaluated: ee->type() == QEvent::MouseButtonRelease | 0 |
59 | buttonDown = false; never executed: buttonDown = false; | 0 |
60 | return false; never executed: return false; | 0 |
61 | } | - |
62 | | - |
63 | QMouseEvent *e = (QMouseEvent*)ee; | - |
64 | switch (e->type()) { | - |
65 | case QEvent::MouseButtonPress: { | - |
66 | if (w->isMaximized()) never evaluated: w->isMaximized() | 0 |
67 | break; | 0 |
68 | if (!widget->rect().contains(widget->mapFromGlobal(e->globalPos()))) never evaluated: !widget->rect().contains(widget->mapFromGlobal(e->globalPos())) | 0 |
69 | return false; never executed: return false; | 0 |
70 | if (e->button() == Qt::LeftButton) { never evaluated: e->button() == Qt::LeftButton | 0 |
71 | buttonDown = false; | - |
72 | activate(); | - |
73 | bool me = movingEnabled; | - |
74 | movingEnabled = (me && o == widget); never evaluated: o == widget | 0 |
75 | mouseMoveEvent(e); | - |
76 | movingEnabled = me; | - |
77 | buttonDown = true; | - |
78 | moveOffset = widget->mapFromGlobal(e->globalPos()); | - |
79 | invertedMoveOffset = widget->rect().bottomRight() - moveOffset; | - |
80 | if (mode == Center) { never evaluated: mode == Center | 0 |
81 | if (movingEnabled) never evaluated: movingEnabled | 0 |
82 | return true; never executed: return true; | 0 |
83 | } else { | 0 |
84 | return true; never executed: return true; | 0 |
85 | } | - |
86 | } | - |
87 | } break; | 0 |
88 | case QEvent::MouseButtonRelease: | - |
89 | if (w->isMaximized()) never evaluated: w->isMaximized() | 0 |
90 | break; | 0 |
91 | if (e->button() == Qt::LeftButton) { never evaluated: e->button() == Qt::LeftButton | 0 |
92 | moveResizeMode = false; | - |
93 | buttonDown = false; | - |
94 | widget->releaseMouse(); | - |
95 | widget->releaseKeyboard(); | - |
96 | if (mode == Center) { never evaluated: mode == Center | 0 |
97 | if (movingEnabled) never evaluated: movingEnabled | 0 |
98 | return true; never executed: return true; | 0 |
99 | } else { | 0 |
100 | return true; never executed: return true; | 0 |
101 | } | - |
102 | } | - |
103 | break; | 0 |
104 | case QEvent::MouseMove: { | - |
105 | if (w->isMaximized()) never evaluated: w->isMaximized() | 0 |
106 | break; | 0 |
107 | buttonDown = buttonDown && (e->buttons() & Qt::LeftButton); never evaluated: buttonDown never evaluated: (e->buttons() & Qt::LeftButton) | 0 |
108 | bool me = movingEnabled; | - |
109 | movingEnabled = (me && o == widget && (buttonDown || moveResizeMode)); never evaluated: o == widget never evaluated: buttonDown never evaluated: moveResizeMode | 0 |
110 | mouseMoveEvent(e); | - |
111 | movingEnabled = me; | - |
112 | if (mode == Center) { never evaluated: mode == Center | 0 |
113 | if (movingEnabled) never evaluated: movingEnabled | 0 |
114 | return true; never executed: return true; | 0 |
115 | } else { | 0 |
116 | return true; never executed: return true; | 0 |
117 | } | - |
118 | } break; | 0 |
119 | case QEvent::KeyPress: | - |
120 | keyPressEvent((QKeyEvent*)e); | - |
121 | break; | 0 |
122 | case QEvent::ShortcutOverride: | - |
123 | if (buttonDown) { never evaluated: buttonDown | 0 |
124 | ((QKeyEvent*)ee)->accept(); | - |
125 | return true; never executed: return true; | 0 |
126 | } | - |
127 | break; | 0 |
128 | default: | - |
129 | break; | 0 |
130 | } | - |
131 | | - |
132 | return false; never executed: return false; | 0 |
133 | } | - |
134 | | - |
135 | void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e) | - |
136 | { | - |
137 | QPoint pos = widget->mapFromGlobal(e->globalPos()); | - |
138 | if (!moveResizeMode && !buttonDown) { never evaluated: !moveResizeMode never evaluated: !buttonDown | 0 |
139 | if (pos.y() <= range && pos.x() <= range) never evaluated: pos.y() <= range never evaluated: pos.x() <= range | 0 |
140 | mode = TopLeft; never executed: mode = TopLeft; | 0 |
141 | else if (pos.y() >= widget->height()-range && pos.x() >= widget->width()-range) never evaluated: pos.y() >= widget->height()-range never evaluated: pos.x() >= widget->width()-range | 0 |
142 | mode = BottomRight; never executed: mode = BottomRight; | 0 |
143 | else if (pos.y() >= widget->height()-range && pos.x() <= range) never evaluated: pos.y() >= widget->height()-range never evaluated: pos.x() <= range | 0 |
144 | mode = BottomLeft; never executed: mode = BottomLeft; | 0 |
145 | else if (pos.y() <= range && pos.x() >= widget->width()-range) never evaluated: pos.y() <= range never evaluated: pos.x() >= widget->width()-range | 0 |
146 | mode = TopRight; never executed: mode = TopRight; | 0 |
147 | else if (pos.y() <= range) never evaluated: pos.y() <= range | 0 |
148 | mode = Top; never executed: mode = Top; | 0 |
149 | else if (pos.y() >= widget->height()-range) never evaluated: pos.y() >= widget->height()-range | 0 |
150 | mode = Bottom; never executed: mode = Bottom; | 0 |
151 | else if (pos.x() <= range) never evaluated: pos.x() <= range | 0 |
152 | mode = Left; never executed: mode = Left; | 0 |
153 | else if ( pos.x() >= widget->width()-range) never evaluated: pos.x() >= widget->width()-range | 0 |
154 | mode = Right; never executed: mode = Right; | 0 |
155 | else if (widget->rect().contains(pos)) never evaluated: widget->rect().contains(pos) | 0 |
156 | mode = Center; never executed: mode = Center; | 0 |
157 | else | - |
158 | mode = Nowhere; never executed: mode = Nowhere; | 0 |
159 | | - |
160 | if (widget->isMinimized() || !isActive(Resize)) never evaluated: widget->isMinimized() never evaluated: !isActive(Resize) | 0 |
161 | mode = Center; never executed: mode = Center; | 0 |
162 | | - |
163 | setMouseCursor(mode); | - |
164 | | - |
165 | return; | 0 |
166 | } | - |
167 | | - |
168 | if (mode == Center && !movingEnabled) never evaluated: mode == Center never evaluated: !movingEnabled | 0 |
169 | return; | 0 |
170 | | - |
171 | if (widget->testAttribute(Qt::WA_WState_ConfigPending)) never evaluated: widget->testAttribute(Qt::WA_WState_ConfigPending) | 0 |
172 | return; | 0 |
173 | | - |
174 | | - |
175 | QPoint globalPos = (!widget->isWindow() && widget->parentWidget()) ? never evaluated: !widget->isWindow() never evaluated: widget->parentWidget() | 0 |
176 | widget->parentWidget()->mapFromGlobal(e->globalPos()) : e->globalPos(); | - |
177 | if (!widget->isWindow() && !widget->parentWidget()->rect().contains(globalPos)) { never evaluated: !widget->isWindow() never evaluated: !widget->parentWidget()->rect().contains(globalPos) | 0 |
178 | if (globalPos.x() < 0) never evaluated: globalPos.x() < 0 | 0 |
179 | globalPos.rx() = 0; never executed: globalPos.rx() = 0; | 0 |
180 | if (globalPos.y() < 0) never evaluated: globalPos.y() < 0 | 0 |
181 | globalPos.ry() = 0; never executed: globalPos.ry() = 0; | 0 |
182 | if (sizeprotect && globalPos.x() > widget->parentWidget()->width()) never evaluated: sizeprotect never evaluated: globalPos.x() > widget->parentWidget()->width() | 0 |
183 | globalPos.rx() = widget->parentWidget()->width(); never executed: globalPos.rx() = widget->parentWidget()->width(); | 0 |
184 | if (sizeprotect && globalPos.y() > widget->parentWidget()->height()) never evaluated: sizeprotect never evaluated: globalPos.y() > widget->parentWidget()->height() | 0 |
185 | globalPos.ry() = widget->parentWidget()->height(); never executed: globalPos.ry() = widget->parentWidget()->height(); | 0 |
186 | } | 0 |
187 | | - |
188 | QPoint p = globalPos + invertedMoveOffset; | - |
189 | QPoint pp = globalPos - moveOffset; | - |
190 | | - |
191 | | - |
192 | if (QGuiApplication::platformName() == QLatin1String("xcb")) { never evaluated: QGuiApplication::platformName() == QLatin1String("xcb") | 0 |
193 | const QRect desktop = QApplication::desktop()->availableGeometry(widget); | - |
194 | pp.rx() = qMax(pp.x(), desktop.left()); | - |
195 | pp.ry() = qMax(pp.y(), desktop.top()); | - |
196 | p.rx() = qMin(p.x(), desktop.right()); | - |
197 | p.ry() = qMin(p.y(), desktop.bottom()); | - |
198 | } | 0 |
199 | | - |
200 | QSize ms = qSmartMinSize(childWidget); | - |
201 | int mw = ms.width(); | - |
202 | int mh = ms.height(); | - |
203 | if (childWidget != widget) { never evaluated: childWidget != widget | 0 |
204 | mw += 2 * fw; | - |
205 | mh += 2 * fw + extrahei; | - |
206 | } | 0 |
207 | | - |
208 | QSize maxsize(childWidget->maximumSize()); | - |
209 | if (childWidget != widget) never evaluated: childWidget != widget | 0 |
210 | maxsize += QSize(2 * fw, 2 * fw + extrahei); never executed: maxsize += QSize(2 * fw, 2 * fw + extrahei); | 0 |
211 | QSize mpsize(widget->geometry().right() - pp.x() + 1, | - |
212 | widget->geometry().bottom() - pp.y() + 1); | - |
213 | mpsize = mpsize.expandedTo(widget->minimumSize()).expandedTo(QSize(mw, mh)) | - |
214 | .boundedTo(maxsize); | - |
215 | QPoint mp(widget->geometry().right() - mpsize.width() + 1, | - |
216 | widget->geometry().bottom() - mpsize.height() + 1); | - |
217 | | - |
218 | QRect geom = widget->geometry(); | - |
219 | | - |
220 | switch (mode) { | - |
221 | case TopLeft: | - |
222 | geom = QRect(mp, widget->geometry().bottomRight()) ; | - |
223 | break; | 0 |
224 | case BottomRight: | - |
225 | geom = QRect(widget->geometry().topLeft(), p) ; | - |
226 | break; | 0 |
227 | case BottomLeft: | - |
228 | geom = QRect(QPoint(mp.x(), widget->geometry().y()), QPoint(widget->geometry().right(), p.y())) ; | - |
229 | break; | 0 |
230 | case TopRight: | - |
231 | geom = QRect(QPoint(widget->geometry().x(), mp.y()), QPoint(p.x(), widget->geometry().bottom())) ; | - |
232 | break; | 0 |
233 | case Top: | - |
234 | geom = QRect(QPoint(widget->geometry().left(), mp.y()), widget->geometry().bottomRight()) ; | - |
235 | break; | 0 |
236 | case Bottom: | - |
237 | geom = QRect(widget->geometry().topLeft(), QPoint(widget->geometry().right(), p.y())) ; | - |
238 | break; | 0 |
239 | case Left: | - |
240 | geom = QRect(QPoint(mp.x(), widget->geometry().top()), widget->geometry().bottomRight()) ; | - |
241 | break; | 0 |
242 | case Right: | - |
243 | geom = QRect(widget->geometry().topLeft(), QPoint(p.x(), widget->geometry().bottom())) ; | - |
244 | break; | 0 |
245 | case Center: | - |
246 | geom.moveTopLeft(pp); | - |
247 | break; | 0 |
248 | default: | - |
249 | break; | 0 |
250 | } | - |
251 | | - |
252 | geom = QRect(geom.topLeft(), | - |
253 | geom.size().expandedTo(widget->minimumSize()) | - |
254 | .expandedTo(QSize(mw, mh)) | - |
255 | .boundedTo(maxsize)); | - |
256 | | - |
257 | if (geom != widget->geometry() && never evaluated: geom != widget->geometry() | 0 |
258 | (widget->isWindow() || widget->parentWidget()->rect().intersects(geom))) { never evaluated: widget->isWindow() never evaluated: widget->parentWidget()->rect().intersects(geom) | 0 |
259 | if (mode == Center) never evaluated: mode == Center | 0 |
260 | widget->move(geom.topLeft()); never executed: widget->move(geom.topLeft()); | 0 |
261 | else | - |
262 | widget->setGeometry(geom); never executed: widget->setGeometry(geom); | 0 |
263 | } | - |
264 | } | 0 |
265 | | - |
266 | void QWidgetResizeHandler::setMouseCursor(MousePosition m) | - |
267 | { | - |
268 | | - |
269 | | - |
270 | | - |
271 | QObjectList children = widget->children(); | - |
272 | for (int i = 0; i < children.size(); ++i) { evaluated: i < children.size() yes Evaluation Count:180 | yes Evaluation Count:39 |
| 39-180 |
273 | if (QWidget *w = qobject_cast<QWidget*>(children.at(i))) { evaluated: QWidget *w = qobject_cast<QWidget*>(children.at(i)) yes Evaluation Count:84 | yes Evaluation Count:96 |
| 84-96 |
274 | if (!w->testAttribute(Qt::WA_SetCursor)) { evaluated: !w->testAttribute(Qt::WA_SetCursor) yes Evaluation Count:57 | yes Evaluation Count:27 |
| 27-57 |
275 | w->setCursor(Qt::ArrowCursor); | - |
276 | } executed: } Execution Count:57 | 57 |
277 | } executed: } Execution Count:84 | 84 |
278 | } executed: } Execution Count:180 | 180 |
279 | | - |
280 | switch (m) { | - |
281 | case TopLeft: | - |
282 | case BottomRight: | - |
283 | widget->setCursor(Qt::SizeFDiagCursor); | - |
284 | break; | 0 |
285 | case BottomLeft: | - |
286 | case TopRight: | - |
287 | widget->setCursor(Qt::SizeBDiagCursor); | - |
288 | break; | 0 |
289 | case Top: | - |
290 | case Bottom: | - |
291 | widget->setCursor(Qt::SizeVerCursor); | - |
292 | break; | 0 |
293 | case Left: | - |
294 | case Right: | - |
295 | widget->setCursor(Qt::SizeHorCursor); | - |
296 | break; | 0 |
297 | default: | - |
298 | widget->setCursor(Qt::ArrowCursor); | - |
299 | break; executed: break; Execution Count:39 | 39 |
300 | } | - |
301 | | - |
302 | } executed: } Execution Count:39 | 39 |
303 | | - |
304 | void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e) | - |
305 | { | - |
306 | if (!isMove() && !isResize()) never evaluated: !isMove() never evaluated: !isResize() | 0 |
307 | return; | 0 |
308 | bool is_control = e->modifiers() & Qt::ControlModifier; | - |
309 | int delta = is_control?1:8; never evaluated: is_control | 0 |
310 | QPoint pos = QCursor::pos(); | - |
311 | switch (e->key()) { | - |
312 | case Qt::Key_Left: | - |
313 | pos.rx() -= delta; | - |
314 | if (pos.x() <= QApplication::desktop()->geometry().left()) { never evaluated: pos.x() <= QApplication::desktop()->geometry().left() | 0 |
315 | if (mode == TopLeft || mode == BottomLeft) { never evaluated: mode == TopLeft never evaluated: mode == BottomLeft | 0 |
316 | moveOffset.rx() += delta; | - |
317 | invertedMoveOffset.rx() += delta; | - |
318 | } else { | 0 |
319 | moveOffset.rx() -= delta; | - |
320 | invertedMoveOffset.rx() -= delta; | - |
321 | } | 0 |
322 | } | - |
323 | if (isResize() && !resizeHorizontalDirectionFixed) { never evaluated: isResize() never evaluated: !resizeHorizontalDirectionFixed | 0 |
324 | resizeHorizontalDirectionFixed = true; | - |
325 | if (mode == BottomRight) never evaluated: mode == BottomRight | 0 |
326 | mode = BottomLeft; never executed: mode = BottomLeft; | 0 |
327 | else if (mode == TopRight) never evaluated: mode == TopRight | 0 |
328 | mode = TopLeft; never executed: mode = TopLeft; | 0 |
329 | | - |
330 | setMouseCursor(mode); | - |
331 | widget->grabMouse(widget->cursor()); | - |
332 | | - |
333 | | - |
334 | | - |
335 | } | 0 |
336 | break; | 0 |
337 | case Qt::Key_Right: | - |
338 | pos.rx() += delta; | - |
339 | if (pos.x() >= QApplication::desktop()->geometry().right()) { never evaluated: pos.x() >= QApplication::desktop()->geometry().right() | 0 |
340 | if (mode == TopRight || mode == BottomRight) { never evaluated: mode == TopRight never evaluated: mode == BottomRight | 0 |
341 | moveOffset.rx() += delta; | - |
342 | invertedMoveOffset.rx() += delta; | - |
343 | } else { | 0 |
344 | moveOffset.rx() -= delta; | - |
345 | invertedMoveOffset.rx() -= delta; | - |
346 | } | 0 |
347 | } | - |
348 | if (isResize() && !resizeHorizontalDirectionFixed) { never evaluated: isResize() never evaluated: !resizeHorizontalDirectionFixed | 0 |
349 | resizeHorizontalDirectionFixed = true; | - |
350 | if (mode == BottomLeft) never evaluated: mode == BottomLeft | 0 |
351 | mode = BottomRight; never executed: mode = BottomRight; | 0 |
352 | else if (mode == TopLeft) never evaluated: mode == TopLeft | 0 |
353 | mode = TopRight; never executed: mode = TopRight; | 0 |
354 | | - |
355 | setMouseCursor(mode); | - |
356 | widget->grabMouse(widget->cursor()); | - |
357 | | - |
358 | | - |
359 | | - |
360 | } | 0 |
361 | break; | 0 |
362 | case Qt::Key_Up: | - |
363 | pos.ry() -= delta; | - |
364 | if (pos.y() <= QApplication::desktop()->geometry().top()) { never evaluated: pos.y() <= QApplication::desktop()->geometry().top() | 0 |
365 | if (mode == TopLeft || mode == TopRight) { never evaluated: mode == TopLeft never evaluated: mode == TopRight | 0 |
366 | moveOffset.ry() += delta; | - |
367 | invertedMoveOffset.ry() += delta; | - |
368 | } else { | 0 |
369 | moveOffset.ry() -= delta; | - |
370 | invertedMoveOffset.ry() -= delta; | - |
371 | } | 0 |
372 | } | - |
373 | if (isResize() && !resizeVerticalDirectionFixed) { never evaluated: isResize() never evaluated: !resizeVerticalDirectionFixed | 0 |
374 | resizeVerticalDirectionFixed = true; | - |
375 | if (mode == BottomLeft) never evaluated: mode == BottomLeft | 0 |
376 | mode = TopLeft; never executed: mode = TopLeft; | 0 |
377 | else if (mode == BottomRight) never evaluated: mode == BottomRight | 0 |
378 | mode = TopRight; never executed: mode = TopRight; | 0 |
379 | | - |
380 | setMouseCursor(mode); | - |
381 | widget->grabMouse(widget->cursor()); | - |
382 | | - |
383 | | - |
384 | | - |
385 | } | 0 |
386 | break; | 0 |
387 | case Qt::Key_Down: | - |
388 | pos.ry() += delta; | - |
389 | if (pos.y() >= QApplication::desktop()->geometry().bottom()) { never evaluated: pos.y() >= QApplication::desktop()->geometry().bottom() | 0 |
390 | if (mode == BottomLeft || mode == BottomRight) { never evaluated: mode == BottomLeft never evaluated: mode == BottomRight | 0 |
391 | moveOffset.ry() += delta; | - |
392 | invertedMoveOffset.ry() += delta; | - |
393 | } else { | 0 |
394 | moveOffset.ry() -= delta; | - |
395 | invertedMoveOffset.ry() -= delta; | - |
396 | } | 0 |
397 | } | - |
398 | if (isResize() && !resizeVerticalDirectionFixed) { never evaluated: isResize() never evaluated: !resizeVerticalDirectionFixed | 0 |
399 | resizeVerticalDirectionFixed = true; | - |
400 | if (mode == TopLeft) never evaluated: mode == TopLeft | 0 |
401 | mode = BottomLeft; never executed: mode = BottomLeft; | 0 |
402 | else if (mode == TopRight) never evaluated: mode == TopRight | 0 |
403 | mode = BottomRight; never executed: mode = BottomRight; | 0 |
404 | | - |
405 | setMouseCursor(mode); | - |
406 | widget->grabMouse(widget->cursor()); | - |
407 | | - |
408 | | - |
409 | | - |
410 | } | 0 |
411 | break; | 0 |
412 | case Qt::Key_Space: | - |
413 | case Qt::Key_Return: | - |
414 | case Qt::Key_Enter: | - |
415 | case Qt::Key_Escape: | - |
416 | moveResizeMode = false; | - |
417 | widget->releaseMouse(); | - |
418 | widget->releaseKeyboard(); | - |
419 | buttonDown = false; | - |
420 | break; | 0 |
421 | default: | - |
422 | return; | 0 |
423 | } | - |
424 | QCursor::setPos(pos); | - |
425 | } | 0 |
426 | | - |
427 | | - |
428 | void QWidgetResizeHandler::doResize() | - |
429 | { | - |
430 | if (!activeForResize) never evaluated: !activeForResize | 0 |
431 | return; | 0 |
432 | | - |
433 | moveResizeMode = true; | - |
434 | moveOffset = widget->mapFromGlobal(QCursor::pos()); | - |
435 | if (moveOffset.x() < widget->width()/2) { never evaluated: moveOffset.x() < widget->width()/2 | 0 |
436 | if (moveOffset.y() < widget->height()/2) never evaluated: moveOffset.y() < widget->height()/2 | 0 |
437 | mode = TopLeft; never executed: mode = TopLeft; | 0 |
438 | else | - |
439 | mode = BottomLeft; never executed: mode = BottomLeft; | 0 |
440 | } else { | - |
441 | if (moveOffset.y() < widget->height()/2) never evaluated: moveOffset.y() < widget->height()/2 | 0 |
442 | mode = TopRight; never executed: mode = TopRight; | 0 |
443 | else | - |
444 | mode = BottomRight; never executed: mode = BottomRight; | 0 |
445 | } | - |
446 | invertedMoveOffset = widget->rect().bottomRight() - moveOffset; | - |
447 | | - |
448 | setMouseCursor(mode); | - |
449 | widget->grabMouse(widget->cursor() ); | - |
450 | | - |
451 | | - |
452 | | - |
453 | widget->grabKeyboard(); | - |
454 | resizeHorizontalDirectionFixed = false; | - |
455 | resizeVerticalDirectionFixed = false; | - |
456 | } | 0 |
457 | | - |
458 | void QWidgetResizeHandler::doMove() | - |
459 | { | - |
460 | if (!activeForMove) never evaluated: !activeForMove | 0 |
461 | return; | 0 |
462 | | - |
463 | mode = Center; | - |
464 | moveResizeMode = true; | - |
465 | moveOffset = widget->mapFromGlobal(QCursor::pos()); | - |
466 | invertedMoveOffset = widget->rect().bottomRight() - moveOffset; | - |
467 | | - |
468 | widget->grabMouse(Qt::SizeAllCursor); | - |
469 | | - |
470 | | - |
471 | | - |
472 | widget->grabKeyboard(); | - |
473 | } | 0 |
474 | | - |
475 | | - |
476 | | - |
| | |