qsizegrip.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qsizegrip.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12static QWidget *qt_sizegrip_topLevelWidget(QWidget* w)-
13{-
14 while (w
wDescription
TRUEnever evaluated
FALSEnever evaluated
&& !w->isWindow()
!w->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
&& w->windowType() != Qt::SubWindow
w->windowType(... Qt::SubWindowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
15 w = w->parentWidget();
never executed: w = w->parentWidget();
0
16 return
never executed: return w;
w;
never executed: return w;
0
17}-
18-
19class QSizeGripPrivate : public QWidgetPrivate-
20{-
21 inline QSizeGrip* q_func() { return static_cast<QSizeGrip *>(q_ptr); } inline const QSizeGrip* q_func() const { return static_cast<const QSizeGrip *>(q_ptr); } friend class QSizeGrip;-
22public:-
23 QSizeGripPrivate();-
24 void init();-
25 QPoint p;-
26 QRect r;-
27 int d;-
28 int dxMax;-
29 int dyMax;-
30 Qt::Corner m_corner;-
31 bool gotMousePress;-
32 QPointer<QWidget> tlw;-
33-
34-
35-
36 Qt::Corner corner() const;-
37 inline bool atBottom() const-
38 {-
39 return
never executed: return m_corner == Qt::BottomRightCorner || m_corner == Qt::BottomLeftCorner;
m_corner == Qt::BottomRightCorner || m_corner == Qt::BottomLeftCorner;
never executed: return m_corner == Qt::BottomRightCorner || m_corner == Qt::BottomLeftCorner;
0
40 }-
41-
42 inline bool atLeft() const-
43 {-
44 return
never executed: return m_corner == Qt::BottomLeftCorner || m_corner == Qt::TopLeftCorner;
m_corner == Qt::BottomLeftCorner || m_corner == Qt::TopLeftCorner;
never executed: return m_corner == Qt::BottomLeftCorner || m_corner == Qt::TopLeftCorner;
0
45 }-
46-
47 void updateTopLevelWidget()-
48 {-
49 QSizeGrip * const q = q_func();-
50 QWidget *w = qt_sizegrip_topLevelWidget(q);-
51 if (tlw == w
tlw == wDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
52 return;
never executed: return;
0
53 if (tlw
tlwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
54 tlw->removeEventFilter(q);
never executed: tlw->removeEventFilter(q);
0
55 tlw = w;-
56 if (tlw
tlwDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
57 tlw->installEventFilter(q);
never executed: tlw->installEventFilter(q);
0
58 }
never executed: end of block
0
59-
60-
61-
62-
63-
64 void _q_showIfNotHidden()-
65 {-
66 QSizeGrip * const q = q_func();-
67 bool showSizeGrip = !(q->isHidden()
q->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& q->testAttribute(Qt::WA_WState_ExplicitShowHide)
q->testAttribu...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
68 updateTopLevelWidget();-
69 if (tlw
tlwDescription
TRUEnever evaluated
FALSEnever evaluated
&& showSizeGrip
showSizeGripDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
70 Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen;-
71-
72 sizeGripNotVisibleState |= Qt::WindowMaximized;-
73-
74-
75 showSizeGrip = !(tlw->windowState() & sizeGripNotVisibleState);-
76 }
never executed: end of block
0
77 if (showSizeGrip
showSizeGripDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
78 q->setVisible(true);
never executed: q->setVisible(true);
0
79 }
never executed: end of block
0
80-
81 bool m_platformSizeGrip;-
82};-
83-
84QSizeGripPrivate::QSizeGripPrivate()-
85 : dxMax(0)-
86 , dyMax(0)-
87 , gotMousePress(false)-
88 , tlw(0)-
89 , m_platformSizeGrip(false)-
90{-
91}
never executed: end of block
0
92Qt::Corner QSizeGripPrivate::corner() const-
93{-
94 const QSizeGrip * const q = q_func();-
95 QWidget *tlw = qt_sizegrip_topLevelWidget(const_cast<QSizeGrip *>(q));-
96 const QPoint sizeGripPos = q->mapTo(tlw, QPoint(0, 0));-
97 bool isAtBottom = sizeGripPos.y() >= tlw->height() / 2;-
98 bool isAtLeft = sizeGripPos.x() <= tlw->width() / 2;-
99 if (isAtLeft
isAtLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
100 return
never executed: return isAtBottom ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
isAtBottom ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
never executed: return isAtBottom ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
0
101 else-
102 return
never executed: return isAtBottom ? Qt::BottomRightCorner : Qt::TopRightCorner;
isAtBottom ? Qt::BottomRightCorner : Qt::TopRightCorner;
never executed: return isAtBottom ? Qt::BottomRightCorner : Qt::TopRightCorner;
0
103}-
104QSizeGrip::QSizeGrip(QWidget * parent)-
105 : QWidget(*new QSizeGripPrivate, parent, 0)-
106{-
107 QSizeGripPrivate * const d = d_func();-
108 d->init();-
109}
never executed: end of block
0
110-
111-
112void QSizeGripPrivate::init()-
113{-
114 QSizeGrip * const q = q_func();-
115 m_corner = q->isLeftToRight()
q->isLeftToRight()Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::BottomRightCorner : Qt::BottomLeftCorner;
0
116-
117-
118 q->setCursor(m_corner == Qt::TopLeftCorner || m_corner == Qt::BottomRightCorner-
119 ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor);-
120-
121 q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));-
122 updateTopLevelWidget();-
123}
never executed: end of block
0
124-
125-
126-
127-
128-
129QSizeGrip::~QSizeGrip()-
130{-
131}-
132-
133-
134-
135-
136QSize QSizeGrip::sizeHint() const-
137{-
138 QStyleOption opt(0);-
139 opt.init(this);-
140 return
never executed: return (style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this). expandedTo(QApplication::globalStrut()));
(style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this).
never executed: return (style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this). expandedTo(QApplication::globalStrut()));
0
141 expandedTo(QApplication::globalStrut()));
never executed: return (style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this). expandedTo(QApplication::globalStrut()));
0
142}-
143void QSizeGrip::paintEvent(QPaintEvent *event)-
144{-
145 (void)event;;-
146 QSizeGripPrivate * const d = d_func();-
147 QPainter painter(this);-
148 QStyleOptionSizeGrip opt;-
149 opt.init(this);-
150 opt.corner = d->m_corner;-
151 style()->drawControl(QStyle::CE_SizeGrip, &opt, &painter, this);-
152}
never executed: end of block
0
153void QSizeGrip::mousePressEvent(QMouseEvent * e)-
154{-
155 if (e->button() != Qt::LeftButton
e->button() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
156 QWidget::mousePressEvent(e);-
157 return;
never executed: return;
0
158 }-
159-
160 QSizeGripPrivate * const d = d_func();-
161 QWidget *tlw = qt_sizegrip_topLevelWidget(this);-
162 d->p = e->globalPos();-
163 d->gotMousePress = true;-
164 d->r = tlw->geometry();-
165-
166-
167 d->m_platformSizeGrip = false;-
168 if (tlw->isWindow()
tlw->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
169 && tlw->windowHandle()
tlw->windowHandle()Description
TRUEnever evaluated
FALSEnever evaluated
0
170 && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
!(tlw->windowF...owManagerHint)Description
TRUEnever evaluated
FALSEnever evaluated
0
171 && !tlw->testAttribute(Qt::WA_DontShowOnScreen)
!tlw->testAttr...tShowOnScreen)Description
TRUEnever evaluated
FALSEnever evaluated
0
172 && !tlw->hasHeightForWidth()
!tlw->hasHeightForWidth()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
173 QPlatformWindow *platformWindow = tlw->windowHandle()->handle();-
174 const QPoint topLevelPos = mapTo(tlw, e->pos());-
175 d->m_platformSizeGrip = platformWindow
platformWindowDescription
TRUEnever evaluated
FALSEnever evaluated
&& platformWindow->startSystemResize(topLevelPos, d->m_corner)
platformWindow..., d->m_corner)Description
TRUEnever evaluated
FALSEnever evaluated
;
0
176 }
never executed: end of block
0
177-
178 if (d->m_platformSizeGrip
d->m_platformSizeGripDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
179 return;
never executed: return;
0
180-
181-
182 QRect availableGeometry;-
183 bool hasVerticalSizeConstraint = true;-
184 bool hasHorizontalSizeConstraint = true;-
185 if (tlw->isWindow()
tlw->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
186 availableGeometry = QApplication::desktop()->availableGeometry(tlw);
never executed: availableGeometry = QApplication::desktop()->availableGeometry(tlw);
0
187 else {-
188 const QWidget *tlwParent = tlw->parentWidget();-
189-
190-
191-
192-
193 QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(tlwParent->parentWidget());-
194 if (scrollArea
scrollAreaDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
195 hasHorizontalSizeConstraint = scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff;-
196 hasVerticalSizeConstraint = scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff;-
197 }
never executed: end of block
0
198-
199 availableGeometry = tlwParent->contentsRect();-
200 }
never executed: end of block
0
201-
202-
203 const QRect frameGeometry = tlw->frameGeometry();-
204 const int titleBarHeight = qMax(tlw->geometry().y() - frameGeometry.y(), 0);-
205 const int bottomDecoration = qMax(frameGeometry.height() - tlw->height() - titleBarHeight, 0);-
206 const int leftRightDecoration = qMax((frameGeometry.width() - tlw->width()) / 2, 0);-
207-
208-
209-
210 if (d->atBottom()
d->atBottom()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
211 if (hasVerticalSizeConstraint
hasVerticalSizeConstraintDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
212 d->dyMax = availableGeometry.bottom() - d->r.bottom() - bottomDecoration;
never executed: d->dyMax = availableGeometry.bottom() - d->r.bottom() - bottomDecoration;
0
213 else-
214 d->dyMax = 2147483647;
never executed: d->dyMax = 2147483647;
0
215 } else {-
216 if (hasVerticalSizeConstraint
hasVerticalSizeConstraintDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
217 d->dyMax = availableGeometry.y() - d->r.y() + titleBarHeight;
never executed: d->dyMax = availableGeometry.y() - d->r.y() + titleBarHeight;
0
218 else-
219 d->dyMax = -2147483647;
never executed: d->dyMax = -2147483647;
0
220 }-
221-
222-
223-
224 if (d->atLeft()
d->atLeft()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
225 if (hasHorizontalSizeConstraint
hasHorizontalSizeConstraintDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
226 d->dxMax = availableGeometry.x() - d->r.x() + leftRightDecoration;
never executed: d->dxMax = availableGeometry.x() - d->r.x() + leftRightDecoration;
0
227 else-
228 d->dxMax = -2147483647;
never executed: d->dxMax = -2147483647;
0
229 } else {-
230 if (hasHorizontalSizeConstraint
hasHorizontalSizeConstraintDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
231 d->dxMax = availableGeometry.right() - d->r.right() - leftRightDecoration;
never executed: d->dxMax = availableGeometry.right() - d->r.right() - leftRightDecoration;
0
232 else-
233 d->dxMax = 2147483647;
never executed: d->dxMax = 2147483647;
0
234 }-
235}-
236-
237-
238-
239-
240-
241-
242-
243void QSizeGrip::mouseMoveEvent(QMouseEvent * e)-
244{-
245 QSizeGripPrivate * const d = d_func();-
246 if (e->buttons() != Qt::LeftButton
e->buttons() != Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
|| d->m_platformSizeGrip
d->m_platformSizeGripDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
247 QWidget::mouseMoveEvent(e);-
248 return;
never executed: return;
0
249 }-
250-
251 QWidget* tlw = qt_sizegrip_topLevelWidget(this);-
252 if (!d->gotMousePress
!d->gotMousePressDescription
TRUEnever evaluated
FALSEnever evaluated
|| tlw->testAttribute(Qt::WA_WState_ConfigPending)
tlw->testAttri...ConfigPending)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
253 return;
never executed: return;
0
254-
255 QPoint np(e->globalPos());-
256-
257-
258 QSize ns;-
259 if (d->atBottom()
d->atBottom()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
260 ns.rheight() = d->r.height() + qMin(np.y() - d->p.y(), d->dyMax);
never executed: ns.rheight() = d->r.height() + qMin(np.y() - d->p.y(), d->dyMax);
0
261 else-
262 ns.rheight() = d->r.height() - qMax(np.y() - d->p.y(), d->dyMax);
never executed: ns.rheight() = d->r.height() - qMax(np.y() - d->p.y(), d->dyMax);
0
263-
264 if (d->atLeft()
d->atLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
265 ns.rwidth() = d->r.width() - qMax(np.x() - d->p.x(), d->dxMax);
never executed: ns.rwidth() = d->r.width() - qMax(np.x() - d->p.x(), d->dxMax);
0
266 else-
267 ns.rwidth() = d->r.width() + qMin(np.x() - d->p.x(), d->dxMax);
never executed: ns.rwidth() = d->r.width() + qMin(np.x() - d->p.x(), d->dxMax);
0
268-
269 ns = QLayout::closestAcceptableSize(tlw, ns);-
270-
271 QPoint p;-
272 QRect nr(p, ns);-
273 if (d->atBottom()
d->atBottom()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
274 if (d->atLeft()
d->atLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
275 nr.moveTopRight(d->r.topRight());
never executed: nr.moveTopRight(d->r.topRight());
0
276 else-
277 nr.moveTopLeft(d->r.topLeft());
never executed: nr.moveTopLeft(d->r.topLeft());
0
278 } else {-
279 if (d->atLeft()
d->atLeft()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
280 nr.moveBottomRight(d->r.bottomRight());
never executed: nr.moveBottomRight(d->r.bottomRight());
0
281 else-
282 nr.moveBottomLeft(d->r.bottomLeft());
never executed: nr.moveBottomLeft(d->r.bottomLeft());
0
283 }-
284-
285 tlw->setGeometry(nr);-
286}
never executed: end of block
0
287-
288-
289-
290-
291void QSizeGrip::mouseReleaseEvent(QMouseEvent *mouseEvent)-
292{-
293 if (mouseEvent->button() == Qt::LeftButton
mouseEvent->bu...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
294 QSizeGripPrivate * const d = d_func();-
295 d->gotMousePress = false;-
296 d->p = QPoint();-
297 }
never executed: end of block
else {
0
298 QWidget::mouseReleaseEvent(mouseEvent);-
299 }
never executed: end of block
0
300}-
301-
302-
303-
304-
305void QSizeGrip::moveEvent(QMoveEvent * )-
306{-
307 QSizeGripPrivate * const d = d_func();-
308-
309 if (!d->p.isNull()
!d->p.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
310 return;
never executed: return;
0
311-
312 d->m_corner = d->corner();-
313-
314 setCursor(d->m_corner == Qt::TopLeftCorner || d->m_corner == Qt::BottomRightCorner-
315 ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor);-
316-
317}
never executed: end of block
0
318-
319-
320-
321-
322void QSizeGrip::showEvent(QShowEvent *showEvent)-
323{-
324-
325-
326-
327 QWidget::showEvent(showEvent);-
328}
never executed: end of block
0
329-
330-
331-
332-
333void QSizeGrip::hideEvent(QHideEvent *hideEvent)-
334{-
335-
336-
337-
338 QWidget::hideEvent(hideEvent);-
339}
never executed: end of block
0
340-
341-
342-
343-
344void QSizeGrip::setVisible(bool visible)-
345{-
346 QWidget::setVisible(visible);-
347}
never executed: end of block
0
348-
349-
350bool QSizeGrip::eventFilter(QObject *o, QEvent *e)-
351{-
352 QSizeGripPrivate * const d = d_func();-
353 if ((isHidden()
isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& testAttribute(Qt::WA_WState_ExplicitShowHide)
testAttribute(...licitShowHide)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
354 || e->type() != QEvent::WindowStateChange
e->type() != Q...dowStateChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
355 || o != d->tlw
o != d->tlwDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
356 return
never executed: return QWidget::eventFilter(o, e);
QWidget::eventFilter(o, e);
never executed: return QWidget::eventFilter(o, e);
0
357 }-
358 Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen;-
359-
360 sizeGripNotVisibleState |= Qt::WindowMaximized;-
361-
362-
363 setVisible(!(d->tlw->windowState() & sizeGripNotVisibleState));-
364 setAttribute(Qt::WA_WState_ExplicitShowHide, false);-
365 return
never executed: return QWidget::eventFilter(o, e);
QWidget::eventFilter(o, e);
never executed: return QWidget::eventFilter(o, e);
0
366}-
367-
368-
369-
370-
371bool QSizeGrip::event(QEvent *event)-
372{-
373 return
never executed: return QWidget::event(event);
QWidget::event(event);
never executed: return QWidget::event(event);
0
374}-
375-
376-
377-
Switch to Source codePreprocessed file

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