qmdisubwindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmdisubwindow.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10using namespace QMdi;-
11-
12static const QStyle::SubControl SubControls[] =-
13{-
14 QStyle::SC_TitleBarLabel,-
15 QStyle::SC_TitleBarSysMenu,-
16 QStyle::SC_TitleBarMinButton,-
17 QStyle::SC_TitleBarMaxButton,-
18 QStyle::SC_TitleBarShadeButton,-
19 QStyle::SC_TitleBarCloseButton,-
20 QStyle::SC_TitleBarNormalButton,-
21 QStyle::SC_TitleBarUnshadeButton,-
22 QStyle::SC_TitleBarContextHelpButton-
23};-
24static const int NumSubControls = sizeof(SubControls) / sizeof(SubControls[0]);-
25-
26static const Qt::WindowFlags CustomizeWindowFlags =-
27 Qt::FramelessWindowHint-
28 | Qt::CustomizeWindowHint-
29 | Qt::WindowTitleHint-
30 | Qt::WindowSystemMenuHint-
31 | Qt::WindowMinimizeButtonHint-
32 | Qt::WindowMaximizeButtonHint-
33 | Qt::WindowMinMaxButtonsHint;-
34-
35-
36static const int BoundaryMargin = 5;-
37-
38static inline int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag,-
39 int delta, int maxDelta, int minDelta)-
40{-
41 if (cflags & moveFlag) {-
42 if (delta > 0)-
43 return (cflags & resizeFlag) ? qMin(delta, maxDelta) : delta;-
44 return (cflags & resizeFlag) ? qMax(delta, minDelta) : delta;-
45 }-
46 return 0;-
47}-
48-
49static inline int getResizeDeltaComponent(uint cflags, uint resizeFlag,-
50 uint resizeReverseFlag, int delta)-
51{-
52 if (cflags & resizeFlag) {-
53 if (cflags & resizeReverseFlag)-
54 return -delta;-
55 return delta;-
56 }-
57 return 0;-
58}-
59-
60static inline bool isChildOfQMdiSubWindow(const QWidget *child)-
61{-
62 ((!(child)) ? qt_assert("child",__FILE__,215221) : qt_noop());-
63 QWidget *parent = child->parentWidget();-
64 while (parent) {-
65 if (qobject_cast<QMdiSubWindow *>(parent))-
66 return true;-
67 parent = parent->parentWidget();-
68 }-
69 return false;-
70}-
71-
72static inline bool isChildOfTabbedQMdiArea(const QMdiSubWindow *child)-
73{-
74 ((!(child)) ? qt_assert("child",__FILE__,227233) : qt_noop());-
75 if (QMdiArea *mdiArea = child->mdiArea()) {-
76 if (mdiArea->viewMode() == QMdiArea::TabbedView)-
77 return true;-
78 }-
79 return false;-
80}-
81-
82template<typename T>-
83static inline ControlElement<T> *ptr(QWidget *widget)-
84{-
85 if (widget && widget->qt_metacast("ControlElement")-
86 && strcmp(widget->metaObject()->className(), T::staticMetaObject.className()) == 0) {-
87 return static_cast<ControlElement<T> *>(widget);-
88 }-
89 return 0;-
90}-
91-
92QString QMdiSubWindowPrivate::originalWindowTitle()-
93{-
94 QMdiSubWindow * const q = q_func();-
95 if (originalTitle.isNull()) {-
96 originalTitle = q->window()->windowTitle();-
97 if (originalTitle.isNull())-
98 originalTitle = QLatin1String("");-
99 }-
100 return originalTitle;-
101}-
102-
103void QMdiSubWindowPrivate::setNewWindowTitle()-
104{-
105 QMdiSubWindow * const q = q_func();-
106 QString childTitle = q->windowTitle();-
107 if (childTitle.isEmpty())-
108 return;-
109 QString original = originalWindowTitle();-
110 if (!original.isEmpty()) {-
111 if (!original.contains(QMdiSubWindow::tr("- [%1]").arg(childTitle)))-
112 q->window()->setWindowTitle(QMdiSubWindow::tr("%1 - [%2]").arg(original, childTitle));-
113-
114 } else {-
115 q->window()->setWindowTitle(childTitle);-
116 }-
117}-
118-
119static inline bool isHoverControl(QStyle::SubControl control)-
120{-
121 return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel;-
122}-
123static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt,-
124 QStyle::ComplexControl complexControl, QStyle::SubControl subControl)-
125{-
126 ((!(helpEvent)) ? qt_assert("helpEvent",__FILE__,288294) : qt_noop());-
127 ((!(helpEvent->type() == QEvent::ToolTip)) ? qt_assert("helpEvent->type() == QEvent::ToolTip",__FILE__,289295) : qt_noop());-
128 ((!(widget)) ? qt_assert("widget",__FILE__,290296) : qt_noop());-
129 if (complexControl == QStyle::CC_MdiControls) {-
130 if (subControl == QStyle::SC_MdiMinButton)-
131 subControl = QStyle::SC_TitleBarMinButton;-
132 else if (subControl == QStyle::SC_MdiCloseButton)-
133 subControl = QStyle::SC_TitleBarCloseButton;-
134 else if (subControl == QStyle::SC_MdiNormalButton)-
135 subControl = QStyle::SC_TitleBarNormalButton;-
136 else-
137 subControl = QStyle::SC_None;-
138 }-
139-
140-
141 if (subControl == QStyle::SC_None)-
142 return;-
143-
144 QString toolTip;-
145-
146 switch (subControl) {-
147 case QStyle::SC_TitleBarMinButton:-
148 toolTip = QMdiSubWindow::tr("Minimize");-
149 break;-
150 case QStyle::SC_TitleBarMaxButton:-
151 toolTip = QMdiSubWindow::tr("Maximize");-
152 break;-
153 case QStyle::SC_TitleBarUnshadeButton:-
154 toolTip = QMdiSubWindow::tr("Unshade");-
155 break;-
156 case QStyle::SC_TitleBarShadeButton:-
157 toolTip = QMdiSubWindow::tr("Shade");-
158 break;-
159 case QStyle::SC_TitleBarNormalButton:-
160 if (widget->isMaximized() || !qobject_cast<QMdiSubWindow *>(widget))-
161 toolTip = QMdiSubWindow::tr("Restore Down");-
162 else-
163 toolTip = QMdiSubWindow::tr("Restore");-
164 break;-
165 case QStyle::SC_TitleBarCloseButton:-
166 toolTip = QMdiSubWindow::tr("Close");-
167 break;-
168 case QStyle::SC_TitleBarContextHelpButton:-
169 toolTip = QMdiSubWindow::tr("Help");-
170 break;-
171 case QStyle::SC_TitleBarSysMenu:-
172 toolTip = QMdiSubWindow::tr("Menu");-
173 break;-
174 default:-
175 break;-
176 }-
177-
178 const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget);-
179 QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect);-
180}-
181-
182-
183namespace QMdi {-
184-
185-
186-
187-
188class ControlLabel : public QWidget-
189{-
190 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
191#pragma GCC diagnostic push-
192 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
193#pragma GCC diagnostic pop-
194 struct QPrivateSignal {};-
195public:-
196 ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0);-
197-
198 QSize sizeHint() const override;-
199-
200public :-
201 void _q_clicked();-
202 void _q_doubleClicked();-
203-
204protected:-
205 bool event(QEvent *event) override;-
206 void paintEvent(QPaintEvent *paintEvent) override;-
207 void mousePressEvent(QMouseEvent *mouseEvent) override;-
208 void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override;-
209 void mouseReleaseEvent(QMouseEvent *mouseEvent) override;-
210-
211private:-
212 QPixmap label;-
213 bool isPressed;-
214 void updateWindowIcon();-
215};-
216}-
217-
218ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent)-
219 : QWidget(parent), isPressed(false)-
220{-
221 (void)subWindow;;-
222 setFocusPolicy(Qt::NoFocus);-
223 updateWindowIcon();-
224 setFixedSize(label.size());-
225}-
226-
227-
228-
229-
230QSize ControlLabel::sizeHint() const-
231{-
232 return label.size();-
233}-
234-
235-
236-
237-
238bool ControlLabel::event(QEvent *event)-
239{-
240 if (event->type() == QEvent::WindowIconChange)-
241 updateWindowIcon();-
242-
243 else if (event->type() == QEvent::ToolTip) {-
244 QStyleOptionTitleBar options;-
245 options.initFrom(this);-
246 showToolTip(static_cast<QHelpEvent *>(event), this, options,-
247 QStyle::CC_TitleBar, QStyle::SC_TitleBarSysMenu);-
248 }-
249-
250 return QWidget::event(event);-
251}-
252-
253-
254-
255-
256void ControlLabel::paintEvent(QPaintEvent * )-
257{-
258 QPainter painter(this);-
259 painter.drawPixmap(0, 0, label);-
260}-
261-
262-
263-
264-
265void ControlLabel::mousePressEvent(QMouseEvent *mouseEvent)-
266{-
267 if (mouseEvent->button() != Qt::LeftButton) {-
268 mouseEvent->ignore();-
269 return;-
270 }-
271 isPressed = true;-
272}-
273-
274-
275-
276-
277void ControlLabel::mouseDoubleClickEvent(QMouseEvent *mouseEvent)-
278{-
279 if (mouseEvent->button() != Qt::LeftButton) {-
280 mouseEvent->ignore();-
281 return;-
282 }-
283 isPressed = false;-
284 _q_doubleClicked();-
285}-
286-
287-
288-
289-
290void ControlLabel::mouseReleaseEvent(QMouseEvent *mouseEvent)-
291{-
292 if (mouseEvent->button() != Qt::LeftButton) {-
293 mouseEvent->ignore();-
294 return;-
295 }-
296 if (isPressed) {-
297 isPressed = false;-
298 _q_clicked();-
299 }-
300}-
301-
302-
303-
304-
305void ControlLabel::updateWindowIcon()-
306{-
307 QIcon menuIcon = windowIcon();-
308 if (menuIcon.isNull())-
309 menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget());-
310 label = menuIcon.pixmap(16, 16);-
311 update();-
312}-
313-
314namespace QMdi {-
315-
316-
317-
318-
319class ControllerWidget : public QWidget-
320{-
321 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
322#pragma GCC diagnostic push-
323 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
324#pragma GCC diagnostic pop-
325 struct QPrivateSignal {};-
326public:-
327 ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0);-
328 QSize sizeHint() const override;-
329 void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible);-
330 inline bool hasVisibleControls() const-
331 {-
332 return (visibleControls & QStyle::SC_MdiMinButton)-
333 || (visibleControls & QStyle::SC_MdiNormalButton)-
334 || (visibleControls & QStyle::SC_MdiCloseButton);-
335 }-
336-
337public :-
338 void _q_minimize();-
339 void _q_restore();-
340 void _q_close();-
341-
342protected:-
343 void paintEvent(QPaintEvent *event) override;-
344 void mousePressEvent(QMouseEvent *event) override;-
345 void mouseReleaseEvent(QMouseEvent *event) override;-
346 void mouseMoveEvent(QMouseEvent *event) override;-
347 void leaveEvent(QEvent *event) override;-
348 bool event(QEvent *event) override;-
349-
350private:-
351 QStyle::SubControl activeControl;-
352 QStyle::SubControl hoverControl;-
353 QStyle::SubControls visibleControls;-
354 void initStyleOption(QStyleOptionComplex *option) const;-
355 QMdiArea *mdiArea;-
356 inline QStyle::SubControl getSubControl(const QPoint &pos) const-
357 {-
358 QStyleOptionComplex opt;-
359 initStyleOption(&opt);-
360 return style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, pos, mdiArea);-
361 }-
362};-
363}-
364-
365-
366-
367-
368ControllerWidget::ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent)-
369 : QWidget(parent),-
370 activeControl(QStyle::SC_None),-
371 hoverControl(QStyle::SC_None),-
372 visibleControls(QStyle::SC_None),-
373 mdiArea(0)-
374{-
375 if (subWindow->parentWidget())-
376 mdiArea = qobject_cast<QMdiArea *>(subWindow->parentWidget()->parentWidget());-
377 setFocusPolicy(Qt::NoFocus);-
378 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);-
379 setMouseTracking(true);-
380}-
381-
382-
383-
384-
385QSize ControllerWidget::sizeHint() const-
386{-
387 ensurePolished();-
388 QStyleOptionComplex opt;-
389 initStyleOption(&opt);-
390 QSize size(48, 16);-
391 return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, mdiArea);-
392}-
393-
394void ControllerWidget::setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible)-
395{-
396 QStyle::SubControl subControl = QStyle::SC_None;-
397-
398-
399 if (action == QMdiSubWindowPrivate::MaximizeAction
action == QMdi...MaximizeActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
400 subControl = QStyle::SC_MdiNormalButton;
never executed: subControl = QStyle::SC_MdiNormalButton;
0
401 else if (action == QMdiSubWindowPrivate::CloseAction
action == QMdi...e::CloseActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
402 subControl = QStyle::SC_MdiCloseButton;
never executed: subControl = QStyle::SC_MdiCloseButton;
0
403 else if (action == QMdiSubWindowPrivate::MinimizeAction
action == QMdi...MinimizeActionDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
404 subControl = QStyle::SC_MdiMinButton;
never executed: subControl = QStyle::SC_MdiMinButton;
0
405-
406 if (subControl == QStyle::SC_None
subControl == QStyle::SC_NoneDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
407 return;
never executed: return;
0
408-
409 if (visible && !(visibleControls & subControl))visibleControls|=.setFlag(subControl;-
else if (!, visible && (visibleControls & subControl))!(visibleControls & = ~subControl;));
410}
never executed: end of block
0
411-
412-
413-
414-
415void ControllerWidget::paintEvent(QPaintEvent * )-
416{-
417 QStyleOptionComplex opt;-
418 initStyleOption(&opt);-
419 if (activeControl == hoverControl) {-
420 opt.activeSubControls = activeControl;-
421 opt.state |= QStyle::State_Sunken;-
422 } else if (hoverControl != QStyle::SC_None && (activeControl == QStyle::SC_None)) {-
423 opt.activeSubControls = hoverControl;-
424 opt.state |= QStyle::State_MouseOver;-
425 }-
426 QPainter painter(this);-
427 style()->drawComplexControl(QStyle::CC_MdiControls, &opt, &painter, mdiArea);-
428}-
429-
430-
431-
432-
433void ControllerWidget::mousePressEvent(QMouseEvent *event)-
434{-
435 if (event->button() != Qt::LeftButton) {-
436 event->ignore();-
437 return;-
438 }-
439 activeControl = getSubControl(event->pos());-
440 update();-
441}-
442-
443-
444-
445-
446void ControllerWidget::mouseReleaseEvent(QMouseEvent *event)-
447{-
448 if (event->button() != Qt::LeftButton) {-
449 event->ignore();-
450 return;-
451 }-
452-
453 QStyle::SubControl under_mouse = getSubControl(event->pos());-
454 if (under_mouse == activeControl) {-
455 switch (activeControl) {-
456 case QStyle::SC_MdiCloseButton:-
457 _q_close();-
458 break;-
459 case QStyle::SC_MdiNormalButton:-
460 _q_restore();-
461 break;-
462 case QStyle::SC_MdiMinButton:-
463 _q_minimize();-
464 break;-
465 default:-
466 break;-
467 }-
468 }-
469-
470 activeControl = QStyle::SC_None;-
471 update();-
472}-
473-
474-
475-
476-
477void ControllerWidget::mouseMoveEvent(QMouseEvent *event)-
478{-
479 QStyle::SubControl under_mouse = getSubControl(event->pos());-
480-
481 if (hoverControl != under_mouse) {-
482 hoverControl = under_mouse;-
483 update();-
484 }-
485}-
486-
487-
488-
489-
490void ControllerWidget::leaveEvent(QEvent * )-
491{-
492 hoverControl = QStyle::SC_None;-
493 update();-
494}-
495-
496-
497-
498-
499bool ControllerWidget::event(QEvent *event)-
500{-
501-
502 if (event->type() == QEvent::ToolTip) {-
503 QStyleOptionComplex opt;-
504 initStyleOption(&opt);-
505 QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);-
506 showToolTip(helpEvent, this, opt, QStyle::CC_MdiControls, getSubControl(helpEvent->pos()));-
507 }-
508-
509 return QWidget::event(event);-
510}-
511-
512-
513-
514-
515void ControllerWidget::initStyleOption(QStyleOptionComplex *option) const-
516{-
517 option->initFrom(this);-
518 option->subControls = visibleControls;-
519 option->activeSubControls = QStyle::SC_None;-
520}-
521-
522-
523-
524-
525ControlContainer::ControlContainer(QMdiSubWindow *mdiChild)-
526 : QObject(mdiChild),-
527 previousLeft(0),-
528 previousRight(0),-
529-
530 m_menuBar(0),-
531-
532 mdiChild(mdiChild)-
533{-
534 ((!(mdiChild)) ? qt_assert("mdiChild",__FILE__,700703) : qt_noop());-
535-
536 m_controllerWidget = new ControlElement<ControllerWidget>(mdiChild);-
537 connect(m_controllerWidget, qFlagLocation("2""_q_close()" "\0" __FILE__ ":" "703""706"), mdiChild, qFlagLocation("1""close()" "\0" __FILE__ ":" "703""706"));-
538 connect(m_controllerWidget, qFlagLocation("2""_q_restore()" "\0" __FILE__ ":" "704""707"), mdiChild, qFlagLocation("1""showNormal()" "\0" __FILE__ ":" "704""707"));-
539 connect(m_controllerWidget, qFlagLocation("2""_q_minimize()" "\0" __FILE__ ":" "705""708"), mdiChild, qFlagLocation("1""showMinimized()" "\0" __FILE__ ":" "705""708"));-
540-
541 m_menuLabel = new ControlElement<ControlLabel>(mdiChild);-
542 m_menuLabel->setWindowIcon(mdiChild->windowIcon());-
543-
544 connect(m_menuLabel, qFlagLocation("2""_q_clicked()" "\0" __FILE__ ":" "710""713"), mdiChild, qFlagLocation("1""showSystemMenu()" "\0" __FILE__ ":" "710""713"));-
545-
546 connect(m_menuLabel, qFlagLocation("2""_q_doubleClicked()" "\0" __FILE__ ":" "712""715"), mdiChild, qFlagLocation("1""close()" "\0" __FILE__ ":" "712""715"));-
547}-
548-
549ControlContainer::~ControlContainer()-
550{-
551-
552 removeButtonsFromMenuBar();-
553-
554 delete m_menuLabel;-
555 m_menuLabel = 0;-
556 delete m_controllerWidget;-
557 m_controllerWidget = 0;-
558}-
559-
560-
561-
562-
563-
564QMenuBar *QMdiSubWindowPrivate::menuBar() const-
565{-
566-
567-
568-
569 const QMdiSubWindow * const q = q_func();-
570 if (!q->isMaximized() || drawTitleBarWhenMaximized() || isChildOfTabbedQMdiArea(q))-
571 return 0;-
572-
573 if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window()))-
574 return mainWindow->menuBar();-
575-
576 return 0;-
577-
578}-
579-
580-
581-
582-
583void ControlContainer::showButtonsInMenuBar(QMenuBar *menuBar)-
584{-
585 if (!menuBar || !mdiChild || mdiChild->windowFlags() & Qt::FramelessWindowHint)-
586 return;-
587 m_menuBar = menuBar;-
588-
589 if (m_menuLabel && mdiChild->windowFlags() & Qt::WindowSystemMenuHint) {-
590 QWidget *currentLeft = menuBar->cornerWidget(Qt::TopLeftCorner);-
591 if (currentLeft)-
592 currentLeft->hide();-
593 if (currentLeft != m_menuLabel) {-
594 menuBar->setCornerWidget(m_menuLabel, Qt::TopLeftCorner);-
595 previousLeft = currentLeft;-
596 }-
597 m_menuLabel->show();-
598 }-
599 ControllerWidget *controllerWidget = qobject_cast<ControllerWidget *>(m_controllerWidget);-
600 if (controllerWidget && controllerWidget->hasVisibleControls()) {-
601 QWidget *currentRight = menuBar->cornerWidget(Qt::TopRightCorner);-
602 if (currentRight)-
603 currentRight->hide();-
604 if (currentRight != m_controllerWidget) {-
605 menuBar->setCornerWidget(m_controllerWidget, Qt::TopRightCorner);-
606 previousRight = currentRight;-
607 }-
608 m_controllerWidget->show();-
609 }-
610 mdiChild->d_func()->setNewWindowTitle();-
611}-
612-
613-
614-
615-
616void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar)-
617{-
618 if (menuBar && menuBar != m_menuBar) {-
619-
620 previousRight = 0;-
621 previousLeft = 0;-
622 m_menuBar = menuBar;-
623 }-
624-
625 if (!m_menuBar || !mdiChild || qt_widget_private(mdiChild->window())->data.in_destructor)-
626 return;-
627-
628 QMdiSubWindow *child = 0;-
629 if (m_controllerWidget) {-
630 QWidget *currentRight = m_menuBar->cornerWidget(Qt::TopRightCorner);-
631 if (currentRight == m_controllerWidget) {-
632 if (ControlElement<ControllerWidget> *ce = ptr<ControllerWidget>(previousRight)) {-
633 if (!ce->mdiChild || !ce->mdiChild->isMaximized())-
634 previousRight = 0;-
635 else-
636 child = ce->mdiChild;-
637 }-
638 m_menuBar->setCornerWidget(previousRight, Qt::TopRightCorner);-
639 if (previousRight) {-
640 previousRight->show();-
641 previousRight = 0;-
642 }-
643 }-
644 m_controllerWidget->hide();-
645 m_controllerWidget->setParent(0);-
646 }-
647 if (m_menuLabel) {-
648 QWidget *currentLeft = m_menuBar->cornerWidget(Qt::TopLeftCorner);-
649 if (currentLeft == m_menuLabel) {-
650 if (ControlElement<ControlLabel> *ce = ptr<ControlLabel>(previousLeft)) {-
651 if (!ce->mdiChild || !ce->mdiChild->isMaximized())-
652 previousLeft = 0;-
653 else if (!child)-
654 child = mdiChild;-
655 }-
656 m_menuBar->setCornerWidget(previousLeft, Qt::TopLeftCorner);-
657 if (previousLeft) {-
658 previousLeft->show();-
659 previousLeft = 0;-
660 }-
661 }-
662 m_menuLabel->hide();-
663 m_menuLabel->setParent(0);-
664 }-
665 m_menuBar->update();-
666 if (child)-
667 child->d_func()->setNewWindowTitle();-
668 else if (mdiChild)-
669 mdiChild->window()->setWindowTitle(mdiChild->d_func()->originalWindowTitle());-
670}-
671-
672-
673-
674void ControlContainer::updateWindowIcon(const QIcon &windowIcon)-
675{-
676 if (m_menuLabel)-
677 m_menuLabel->setWindowIcon(windowIcon);-
678}-
679-
680-
681-
682-
683QMdiSubWindowPrivate::QMdiSubWindowPrivate()-
684 : baseWidget(0),-
685 restoreFocusWidget(0),-
686 controlContainer(0),-
687-
688 sizeGrip(0),-
689-
690-
691 rubberBand(0),-
692-
693 userMinimumSize(0,0),-
694 resizeEnabled(true),-
695 moveEnabled(true),-
696 isInInteractiveMode(false),-
697-
698 isInRubberBandMode(false),-
699-
700 isShadeMode(false),-
701 ignoreWindowTitleChange(false),-
702 ignoreNextActivationEvent(false),-
703 activationEnabled(true),-
704 isShadeRequestFromMinimizeMode(false),-
705 isMaximizeMode(false),-
706 isWidgetHiddenByUs(false),-
707 isActive(false),-
708 isExplicitlyDeactivated(false),-
709 keyboardSingleStep(5),-
710 keyboardPageStep(20),-
711 resizeTimerId(-1),-
712 currentOperation(None),-
713 hoveredSubControl(QStyle::SC_None),-
714 activeSubControl(QStyle::SC_None),-
715 focusInReason(Qt::ActiveWindowFocusReason)-
716{-
717 initOperationMap();-
718}-
719-
720-
721-
722-
723void QMdiSubWindowPrivate::_q_updateStaysOnTopHint()-
724{-
725-
726 QMdiSubWindow * const q = q_func();-
727 if (QAction *senderAction = qobject_cast<QAction *>(q->sender())) {-
728 if (senderAction->isChecked()) {-
729 q->setWindowFlags(q->windowFlags() | Qt::WindowStaysOnTopHint);-
730 q->raise();-
731 } else {-
732 q->setWindowFlags(q->windowFlags() & ~Qt::WindowStaysOnTopHint);-
733 q->lower();-
734 }-
735 }-
736-
737}-
738-
739-
740-
741-
742void QMdiSubWindowPrivate::_q_enterInteractiveMode()-
743{-
744-
745 QMdiSubWindow * const q = q_func();-
746 QAction *action = qobject_cast<QAction *>(q->sender());-
747 if (!action)-
748 return;-
749-
750 QPoint pressPos;-
751 if (actions[MoveAction] && actions[MoveAction] == action) {-
752 currentOperation = Move;-
753 pressPos = QPoint(q->width() / 2, titleBarHeight() - 1);-
754 } else if (actions[ResizeAction] && actions[ResizeAction] == action) {-
755 currentOperation = q->isLeftToRight() ? BottomRightResize : BottomLeftResize;-
756 int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q) / 2;-
757 int x = q->isLeftToRight() ? q->width() - offset : offset;-
758 pressPos = QPoint(x, q->height() - offset);-
759 } else {-
760 return;-
761 }-
762-
763 updateCursor();-
764-
765 q->cursor().setPos(q->mapToGlobal(pressPos));-
766-
767 mousePressPosition = q->mapToParent(pressPos);-
768 oldGeometry = q->geometry();-
769 isInInteractiveMode = true;-
770 q->setFocus();-
771-
772 if ((q->testOption(QMdiSubWindow::RubberBandResize)-
773 && (currentOperation == BottomRightResize || currentOperation == BottomLeftResize))-
774 || (q->testOption(QMdiSubWindow::RubberBandMove) && currentOperation == Move)) {-
775 enterRubberBandMode();-
776 } else-
777-
778 {-
779 q->grabMouse();-
780 }-
781-
782}-
783-
784-
785-
786-
787void QMdiSubWindowPrivate::_q_processFocusChanged(QWidget *old, QWidget *now)-
788{-
789 (void)old;;-
790 QMdiSubWindow * const q = q_func();-
791 if (now && (now == q || q->isAncestorOf(now))) {-
792 if (now == q && !isInInteractiveMode)-
793 setFocusWidget();-
794 setActive(true);-
795 }-
796}-
797-
798-
799-
800-
801void QMdiSubWindowPrivate::leaveInteractiveMode()-
802{-
803 QMdiSubWindow * const q = q_func();-
804-
805 if (isInRubberBandMode)-
806 leaveRubberBandMode();-
807 else-
808-
809 q->releaseMouse();-
810 isInInteractiveMode = false;-
811 currentOperation = None;-
812 updateDirtyRegions();-
813 updateCursor();-
814 if (baseWidget && baseWidget->focusWidget())-
815 baseWidget->focusWidget()->setFocus();-
816}-
817-
818-
819-
820-
821void QMdiSubWindowPrivate::removeBaseWidget()-
822{-
823 if (!baseWidget
!baseWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
824 return;
never executed: return;
0
825-
826 QMdiSubWindow * const q = q_func();-
827 baseWidget->removeEventFilter(q);-
828 if (layout
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
829 layout->removeWidget(baseWidget);
never executed: layout->removeWidget(baseWidget);
0
830 if (baseWidget->windowTitle() == q->windowTitle()
baseWidget->wi...>windowTitle()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
831 ignoreWindowTitleChange = true;-
832 q->setWindowTitle(QString());-
833 ignoreWindowTitleChange = false;-
834 q->setWindowModified(false);-
835 }
never executed: end of block
0
836 lastChildWindowTitle.clear();-
837-
838 if (baseWidget->parentWidget() == q
baseWidget->pa...tWidget() == qDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
839 baseWidget->setParent(0);
never executed: baseWidget->setParent(0);
0
840 baseWidget = 0;-
841 isWidgetHiddenByUs = false;-
842}
never executed: end of block
0
843-
844-
845-
846-
847void QMdiSubWindowPrivate::initOperationMap()-
848{-
849 operationMap.insert(Move, OperationInfo(HMove | VMove, Qt::ArrowCursor, false));-
850 operationMap.insert(TopResize, OperationInfo(VMove | VResize | VResizeReverse, Qt::SizeVerCursor));-
851 operationMap.insert(BottomResize, OperationInfo(VResize, Qt::SizeVerCursor));-
852 operationMap.insert(LeftResize, OperationInfo(HMove | HResize | HResizeReverse, Qt::SizeHorCursor));-
853 operationMap.insert(RightResize, OperationInfo(HResize, Qt::SizeHorCursor));-
854 operationMap.insert(TopLeftResize, OperationInfo(HMove | VMove | HResize | VResize | VResizeReverse-
855 | HResizeReverse, Qt::SizeFDiagCursor));-
856 operationMap.insert(TopRightResize, OperationInfo(VMove | HResize | VResize-
857 | VResizeReverse, Qt::SizeBDiagCursor));-
858 operationMap.insert(BottomLeftResize, OperationInfo(HMove | HResize | VResize | HResizeReverse,-
859 Qt::SizeBDiagCursor));-
860 operationMap.insert(BottomRightResize, OperationInfo(HResize | VResize, Qt::SizeFDiagCursor));-
861}-
862-
863-
864-
865-
866-
867-
868void QMdiSubWindowPrivate::createSystemMenu()-
869{-
870 QMdiSubWindow * const q = q_func();-
871 ((!(q)) ? qt_assert_x("QMdiSubWindowPrivate::createSystemMenu", "You can NOT call this function before QMdiSubWindow's ctor",-
872 __FILE__-
873 ,-
874 10361041-
875 ) : qt_noop())-
876 ;-
877 systemMenu = new QMenu(q);-
878 systemMenu->installEventFilter(q);-
879 const QStyle *style = q->style();-
880 addToSystemMenu(RestoreAction, QMdiSubWindow::tr("&Restore"), qFlagLocation("1""showNormal()" "\0" __FILE__ ":" "1040""1045"));-
881 actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, 0, q));-
882 actions[RestoreAction]->setEnabled(false);-
883 addToSystemMenu(MoveAction, QMdiSubWindow::tr("&Move"), qFlagLocation("1""_q_enterInteractiveMode()" "\0" __FILE__ ":" "1043""1048"));-
884 addToSystemMenu(ResizeAction, QMdiSubWindow::tr("&Size"), qFlagLocation("1""_q_enterInteractiveMode()" "\0" __FILE__ ":" "1044""1049"));-
885 addToSystemMenu(MinimizeAction, QMdiSubWindow::tr("Mi&nimize"), qFlagLocation("1""showMinimized()" "\0" __FILE__ ":" "1045""1050"));-
886 actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, 0, q));-
887 addToSystemMenu(MaximizeAction, QMdiSubWindow::tr("Ma&ximize"), qFlagLocation("1""showMaximized()" "\0" __FILE__ ":" "1047""1052"));-
888 actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, 0, q));-
889 addToSystemMenu(StayOnTopAction, QMdiSubWindow::tr("Stay on &Top"), qFlagLocation("1""_q_updateStaysOnTopHint()" "\0" __FILE__ ":" "1049""1054"));-
890 actions[StayOnTopAction]->setCheckable(true);-
891 systemMenu->addSeparator();-
892 addToSystemMenu(CloseAction, QMdiSubWindow::tr("&Close"), qFlagLocation("1""close()" "\0" __FILE__ ":" "1052""1057"));-
893 actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, 0, q));-
894-
895 actions[CloseAction]->setShortcuts(QKeySequence::Close);-
896-
897 updateActions();-
898}-
899-
900-
901-
902-
903-
904void QMdiSubWindowPrivate::updateCursor()-
905{-
906-
907 QMdiSubWindow * const q = q_func();-
908-
909-
910-
911-
912-
913 if (currentOperation == None) {-
914 q->unsetCursor();-
915 return;-
916 }-
917-
918 if (currentOperation == Move || operationMap.find(currentOperation).value().hover) {-
919 q->setCursor(operationMap.find(currentOperation).value().cursorShape);-
920 return;-
921 }-
922-
923}-
924-
925-
926-
927-
928void QMdiSubWindowPrivate::updateDirtyRegions()-
929{-
930-
931 if (!parent)-
932 return;-
933-
934 for (OperationInfoMap::iterator it = operationMap.begin(), end = operationMap.end(); it != end; ++it)-
935 it.value().region = getRegion(it.key());-
936}-
937-
938-
939-
940-
941void QMdiSubWindowPrivate::updateGeometryConstraints()-
942{-
943 QMdiSubWindow * const q = q_func();-
944 if (!parent)-
945 return;-
946-
947 internalMinimumSize = (!q->isMinimized() && !q->minimumSize().isNull())-
948 ? q->minimumSize() : q->minimumSizeHint();-
949 int margin, minWidth;-
950 sizeParameters(&margin, &minWidth);-
951 q->setContentsMargins(margin, titleBarHeight(), margin, margin);-
952 if (q->isMaximized() || (q->isMinimized() && !q->isShaded())) {-
953 moveEnabled = false;-
954 resizeEnabled = false;-
955 } else {-
956 moveEnabled = true;-
957 if ((q->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) || q->isShaded())-
958 resizeEnabled = false;-
959 else-
960 resizeEnabled = true;-
961 }-
962 updateDirtyRegions();-
963}-
964-
965-
966-
967-
968void QMdiSubWindowPrivate::updateMask()-
969{-
970 QMdiSubWindow * const q = q_func();-
971 if (!q->mask().isEmpty())-
972 q->clearMask();-
973-
974 if (!parent)-
975 return;-
976-
977 if ((q->isMaximized() && !drawTitleBarWhenMaximized())-
978 || q->windowFlags() & Qt::FramelessWindowHint)-
979 return;-
980-
981 if (resizeTimerId == -1)-
982 cachedStyleOptions = titleBarOptions();-
983 cachedStyleOptions.rect = q->rect();-
984 QStyleHintReturnMask frameMask;-
985 q->style()->styleHint(QStyle::SH_WindowFrame_Mask, &cachedStyleOptions, q, &frameMask);-
986 if (!frameMask.region.isEmpty())-
987 q->setMask(frameMask.region);-
988}-
989-
990-
991-
992-
993void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos)-
994{-
995 QMdiSubWindow * const q = q_func();-
996 ((!(currentOperation != None)) ? qt_assert("currentOperation != None",__FILE__,11561161) : qt_noop());-
997 ((!(parent)) ? qt_assert("parent",__FILE__,11571162) : qt_noop());-
998-
999 uint cflags = operationMap.find(currentOperation).value().changeFlags;-
1000 int posX = pos.x();-
1001 int posY = pos.y();-
1002-
1003 const bool restrictHorizontal = !q->testOption(QMdiSubWindow::AllowOutsideAreaHorizontally);-
1004 const bool restrictVertical = !q->testOption(QMdiSubWindow::AllowOutsideAreaVertically);-
1005-
1006 if (restrictHorizontal || restrictVertical) {-
1007 QRect parentRect = q->parentWidget()->rect();-
1008 if (restrictVertical && (cflags & VResizeReverse || currentOperation == Move)) {-
1009 posY = qMin(qMax(mousePressPosition.y() - oldGeometry.y(), posY),-
1010 parentRect.height() - BoundaryMargin);-
1011 }-
1012 if (currentOperation == Move) {-
1013 if (restrictHorizontal)-
1014 posX = qMin(qMax(BoundaryMargin, posX), parentRect.width() - BoundaryMargin);-
1015 if (restrictVertical)-
1016 posY = qMin(posY, parentRect.height() - BoundaryMargin);-
1017 } else {-
1018 if (restrictHorizontal) {-
1019 if (cflags & HResizeReverse)-
1020 posX = qMax(mousePressPosition.x() - oldGeometry.x(), posX);-
1021 else-
1022 posX = qMin(parentRect.width() - (oldGeometry.x() + oldGeometry.width()-
1023 - mousePressPosition.x()), posX);-
1024 }-
1025 if (restrictVertical && !(cflags & VResizeReverse)) {-
1026 posY = qMin(parentRect.height() - (oldGeometry.y() + oldGeometry.height()-
1027 - mousePressPosition.y()), posY);-
1028 }-
1029 }-
1030 }-
1031-
1032 QRect geometry;-
1033 if (cflags & (HMove | VMove)) {-
1034 int dx = getMoveDeltaComponent(cflags, HMove, HResize, posX - mousePressPosition.x(),-
1035 oldGeometry.width() - internalMinimumSize.width(),-
1036 oldGeometry.width() - q->maximumWidth());-
1037 int dy = getMoveDeltaComponent(cflags, VMove, VResize, posY - mousePressPosition.y(),-
1038 oldGeometry.height() - internalMinimumSize.height(),-
1039 oldGeometry.height() - q->maximumHeight());-
1040 geometry.setTopLeft(oldGeometry.topLeft() + QPoint(dx, dy));-
1041 } else {-
1042 geometry.setTopLeft(q->geometry().topLeft());-
1043 }-
1044-
1045 if (cflags & (HResize | VResize)) {-
1046 int dx = getResizeDeltaComponent(cflags, HResize, HResizeReverse,-
1047 posX - mousePressPosition.x());-
1048 int dy = getResizeDeltaComponent(cflags, VResize, VResizeReverse,-
1049 posY - mousePressPosition.y());-
1050 geometry.setSize(oldGeometry.size() + QSize(dx, dy));-
1051 } else {-
1052 geometry.setSize(q->geometry().size());-
1053 }-
1054-
1055 setNewGeometry(&geometry);-
1056}-
1057-
1058-
1059-
1060-
1061void QMdiSubWindowPrivate::setMinimizeMode()-
1062{-
1063 QMdiSubWindow * const q = q_func();-
1064 ((!(parent)) ? qt_assert("parent",__FILE__,12241229) : qt_noop());-
1065-
1066 ensureWindowState(Qt::WindowMinimized);-
1067 isShadeRequestFromMinimizeMode = true;-
1068 q->showShaded();-
1069 isShadeRequestFromMinimizeMode = false;-
1070-
1071 moveEnabled = false;-
1072-
1073 setEnabled(MoveAction, moveEnabled);-
1074-
1075-
1076 ((!(q->windowState() & Qt::WindowMinimized)) ? qt_assert("q->windowState() & Qt::WindowMinimized",__FILE__,12361241) : qt_noop());-
1077 ((!(!(q->windowState() & Qt::WindowMaximized))) ? qt_assert("!(q->windowState() & Qt::WindowMaximized)",__FILE__,12371242) : qt_noop());-
1078-
1079-
1080-
1081-
1082-
1083 setActive(true);-
1084}-
1085-
1086-
1087-
1088-
1089void QMdiSubWindowPrivate::setNormalMode()-
1090{-
1091 QMdiSubWindow * const q = q_func();-
1092 ((!(parent)) ? qt_assert("parent",__FILE__,12521257) : qt_noop());-
1093-
1094 isShadeMode = false;-
1095 isMaximizeMode = false;-
1096-
1097 ensureWindowState(Qt::WindowNoState);-
1098-
1099 removeButtonsFromMenuBar();-
1100-
1101-
1102-
1103-
1104 const bool wasVisible = q->isVisible();-
1105 if (wasVisible)-
1106 q->setVisible(false);-
1107-
1108-
1109 if (!userMinimumSize.isNull()) {-
1110 q->setMinimumSize(userMinimumSize);-
1111 userMinimumSize = QSize(0, 0);-
1112 }-
1113-
1114-
1115 if (baseWidget && isWidgetHiddenByUs) {-
1116 baseWidget->show();-
1117 isWidgetHiddenByUs = false;-
1118 }-
1119-
1120 updateGeometryConstraints();-
1121 QRect newGeometry = oldGeometry;-
1122 newGeometry.setSize(restoreSize.expandedTo(internalMinimumSize));-
1123 q->setGeometry(newGeometry);-
1124-
1125 if (wasVisible)-
1126 q->setVisible(true);-
1127-
1128-
1129 restoreSize.setWidth(-1);-
1130 restoreSize.setHeight(-1);-
1131-
1132-
1133 setSizeGripVisible(true);-
1134-
1135-
1136-
1137 setEnabled(MoveAction, true);-
1138 setEnabled(MaximizeAction, true);-
1139 setEnabled(MinimizeAction, true);-
1140 setEnabled(RestoreAction, false);-
1141 setEnabled(ResizeAction, resizeEnabled);-
1142-
1143-
1144 ((!(!(q_func()->windowState() & Qt::WindowMinimized))) ? qt_assert("!(q_func()->windowState() & Qt::WindowMinimized)",__FILE__,13041309) : qt_noop());-
1145-
1146-
1147-
1148 ((!((isMaximizeMode && q_func()->windowState() & Qt::WindowMaximized) || (!isMaximizeMode && !(q_func()->windowState() & Qt::WindowMaximized)))) ? qt_assert("(isMaximizeMode && q_func()->windowState() & Qt::WindowMaximized) || (!isMaximizeMode && !(q_func()->windowState() & Qt::WindowMaximized))",-
1149 __FILE__-
1150 ,-
1151 13091314-
1152 ) : qt_noop())-
1153 ;-
1154 ((!(!isShadeMode)) ? qt_assert("!isShadeMode",__FILE__,13101315) : qt_noop());-
1155-
1156 setActive(true);-
1157 restoreFocus();-
1158 updateMask();-
1159}-
1160-
1161inline void QMdiSubWindowPrivate::storeFocusWidget()-
1162{-
1163 if (QWidget *focus = QApplication::focusWidget()) {-
1164 if (!restoreFocusWidget && q_func()->isAncestorOf(focus))-
1165 restoreFocusWidget = focus;-
1166 }-
1167}-
1168-
1169-
1170-
1171-
1172void QMdiSubWindowPrivate::setMaximizeMode()-
1173{-
1174 QMdiSubWindow * const q = q_func();-
1175 ((!(parent)) ? qt_assert("parent",__FILE__,13311336) : qt_noop());-
1176-
1177 ensureWindowState(Qt::WindowMaximized);-
1178 isShadeMode = false;-
1179 isMaximizeMode = true;-
1180-
1181 storeFocusWidget();-
1182-
1183-
1184 setSizeGripVisible(false);-
1185-
1186-
1187-
1188 if (!restoreSize.isValid()) {-
1189 oldGeometry = q->geometry();-
1190 restoreSize.setWidth(oldGeometry.width());-
1191 restoreSize.setHeight(oldGeometry.height());-
1192 }-
1193-
1194-
1195-
1196 const bool wasVisible = q->isVisible();-
1197 if (wasVisible)-
1198 q->setVisible(false);-
1199-
1200-
1201 if (baseWidget && isWidgetHiddenByUs) {-
1202 baseWidget->show();-
1203 isWidgetHiddenByUs = false;-
1204 }-
1205-
1206 updateGeometryConstraints();-
1207-
1208 if (wasVisible) {-
1209-
1210 if (QMenuBar *mBar = menuBar())-
1211 showButtonsInMenuBar(mBar);-
1212 else-
1213-
1214 if (!controlContainer)-
1215 controlContainer = new ControlContainer(q);-
1216 }-
1217-
1218 QWidget *parent = q->parentWidget();-
1219 QRect availableRect = parent->contentsRect();-
1220-
1221-
1222 QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent->parentWidget());-
1223 if (scrollArea && scrollArea->viewport() == parent) {-
1224 QScrollBar *hbar = scrollArea->horizontalScrollBar();-
1225 QScrollBar *vbar = scrollArea->verticalScrollBar();-
1226 const int xOffset = hbar ? hbar->value() : 0;-
1227 const int yOffset = vbar ? vbar->value() : 0;-
1228 availableRect.adjust(-xOffset, -yOffset, -xOffset, -yOffset);-
1229 oldGeometry.adjust(xOffset, yOffset, xOffset, yOffset);-
1230 }-
1231-
1232 setNewGeometry(&availableRect);-
1233-
1234 ensureWindowState(Qt::WindowMaximized);-
1235-
1236 if (wasVisible)-
1237 q->setVisible(true);-
1238-
1239 resizeEnabled = false;-
1240 moveEnabled = false;-
1241-
1242-
1243 setEnabled(MoveAction, moveEnabled);-
1244 setEnabled(MaximizeAction, false);-
1245 setEnabled(MinimizeAction, true);-
1246 setEnabled(RestoreAction, true);-
1247 setEnabled(ResizeAction, resizeEnabled);-
1248-
1249-
1250 ((!(q->windowState() & Qt::WindowMaximized)) ? qt_assert("q->windowState() & Qt::WindowMaximized",__FILE__,14061411) : qt_noop());-
1251 ((!(!(q->windowState() & Qt::WindowMinimized))) ? qt_assert("!(q->windowState() & Qt::WindowMinimized)",__FILE__,14071412) : qt_noop());-
1252-
1253 restoreFocus();-
1254 updateMask();-
1255}-
1256-
1257-
1258-
1259-
1260void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus)-
1261{-
1262 QMdiSubWindow * const q = q_func();-
1263 if (!parent || !activationEnabled)-
1264 return;-
1265-
1266 if (activate && !isActive && q->isEnabled()) {-
1267 isActive = true;-
1268 isExplicitlyDeactivated = false;-
1269 Qt::WindowStates oldWindowState = q->windowState();-
1270 ensureWindowState(Qt::WindowActive);-
1271 q->aboutToActivate();-
1272-
1273 if (QMenuBar *mBar = menuBar())-
1274 showButtonsInMenuBar(mBar);-
1275-
1276 ((!(isActive)) ? qt_assert("isActive",__FILE__,14321437) : qt_noop());-
1277 q->windowStateChanged(oldWindowState, q->windowState());-
1278 } else if (!activate && isActive) {-
1279 isActive = false;-
1280 Qt::WindowStates oldWindowState = q->windowState();-
1281 q->overrideWindowState(q->windowState() & ~Qt::WindowActive);-
1282 if (changeFocus) {-
1283 storeFocusWidget();-
1284 QWidget *focusWidget = QApplication::focusWidget();-
1285 if (focusWidget && (focusWidget == q || q->isAncestorOf(focusWidget)))-
1286 focusWidget->clearFocus();-
1287 }-
1288 if (baseWidget)-
1289 baseWidget->overrideWindowState(baseWidget->windowState() & ~Qt::WindowActive);-
1290 ((!(!isActive)) ? qt_assert("!isActive",__FILE__,14461451) : qt_noop());-
1291 q->windowStateChanged(oldWindowState, q->windowState());-
1292 }-
1293-
1294 if (activate && isActive && q->isEnabled() && !q->hasFocus()-
1295 && !q->isAncestorOf(QApplication::focusWidget())) {-
1296 if (changeFocus)-
1297 setFocusWidget();-
1298 ensureWindowState(Qt::WindowActive);-
1299 }-
1300-
1301 int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q);-
1302 int titleBarHeight = this->titleBarHeight();-
1303 QRegion windowDecoration = QRegion(0, 0, q->width(), q->height());-
1304 windowDecoration -= QRegion(frameWidth, titleBarHeight, q->width() - 2 * frameWidth,-
1305 q->height() - titleBarHeight - frameWidth);-
1306-
1307-
1308-
1309 if (resizeTimerId != -1) {-
1310 q->killTimer(resizeTimerId);-
1311 resizeTimerId = -1;-
1312 updateDirtyRegions();-
1313 }-
1314-
1315 q->update(windowDecoration);-
1316}-
1317-
1318-
1319-
1320-
1321void QMdiSubWindowPrivate::processClickedSubControl()-
1322{-
1323 QMdiSubWindow * const q = q_func();-
1324 switch (activeSubControl) {-
1325 case QStyle::SC_TitleBarContextHelpButton:-
1326-
1327 QWhatsThis::enterWhatsThisMode();-
1328-
1329 break;-
1330 case QStyle::SC_TitleBarShadeButton:-
1331 q->showShaded();-
1332 hoveredSubControl = QStyle::SC_TitleBarUnshadeButton;-
1333 break;-
1334 case QStyle::SC_TitleBarUnshadeButton:-
1335 if (q->isShaded())-
1336 hoveredSubControl = QStyle::SC_TitleBarShadeButton;-
1337 q->showNormal();-
1338 break;-
1339 case QStyle::SC_TitleBarMinButton:-
1340 q->showMinimized();-
1341 break;-
1342 case QStyle::SC_TitleBarNormalButton:-
1343 if (q->isShaded())-
1344 hoveredSubControl = QStyle::SC_TitleBarMinButton;-
1345 q->showNormal();-
1346 break;-
1347 case QStyle::SC_TitleBarMaxButton:-
1348 q->showMaximized();-
1349 break;-
1350 case QStyle::SC_TitleBarCloseButton:-
1351 q->close();-
1352 break;-
1353 default:-
1354 break;-
1355 }-
1356}-
1357-
1358-
1359-
1360-
1361QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const-
1362{-
1363 const QMdiSubWindow * const q = q_func();-
1364 int width = q->width();-
1365 int height = q->height();-
1366 int titleBarHeight = this->titleBarHeight();-
1367 int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q);-
1368 int cornerConst = titleBarHeight - frameWidth;-
1369 int titleBarConst = 2 * titleBarHeight;-
1370-
1371 if (operation == Move) {-
1372 QStyleOptionTitleBar titleBarOptions = this->titleBarOptions();-
1373 QRegion move(frameWidth, frameWidth, width - 2 * frameWidth, cornerConst);-
1374-
1375-
1376 for (int i = 0; i < NumSubControls; ++i) {-
1377 if (SubControls[i] == QStyle::SC_TitleBarLabel)-
1378 continue;-
1379 move -= QRegion(q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions,-
1380 SubControls[i]));-
1381 }-
1382 return move;-
1383 }-
1384-
1385 QRegion region;-
1386-
1387-
1388-
1389-
1390-
1391 switch (operation) {-
1392 case TopResize:-
1393 region = QRegion(titleBarHeight, 0, width - titleBarConst, frameWidth);-
1394 break;-
1395 case BottomResize:-
1396 region = QRegion(titleBarHeight, height - frameWidth, width - titleBarConst, frameWidth);-
1397 break;-
1398 case LeftResize:-
1399 region = QRegion(0, titleBarHeight, frameWidth, height - titleBarConst);-
1400 break;-
1401 case RightResize:-
1402 region = QRegion(width - frameWidth, titleBarHeight, frameWidth, height - titleBarConst);-
1403 break;-
1404 case TopLeftResize:-
1405 region = QRegion(0, 0, titleBarHeight, titleBarHeight)-
1406 - QRegion(frameWidth, frameWidth, cornerConst, cornerConst);-
1407 break;-
1408 case TopRightResize:-
1409 region = QRegion(width - titleBarHeight, 0, titleBarHeight, titleBarHeight)-
1410 - QRegion(width - titleBarHeight, frameWidth, cornerConst, cornerConst);-
1411 break;-
1412 case BottomLeftResize:-
1413 region = QRegion(0, height - titleBarHeight, titleBarHeight, titleBarHeight)-
1414 - QRegion(frameWidth, height - titleBarHeight, cornerConst, cornerConst);-
1415 break;-
1416 case BottomRightResize:-
1417 region = QRegion(width - titleBarHeight, height - titleBarHeight, titleBarHeight, titleBarHeight)-
1418 - QRegion(width - titleBarHeight, height - titleBarHeight, cornerConst, cornerConst);-
1419 break;-
1420 default:-
1421 break;-
1422 }-
1423-
1424 return region;-
1425}-
1426-
1427-
1428-
1429-
1430QMdiSubWindowPrivate::Operation QMdiSubWindowPrivate::getOperation(const QPoint &pos) const-
1431{-
1432 OperationInfoMap::const_iterator it;-
1433 for (it = operationMap.constBegin(); it != operationMap.constEnd(); ++it)-
1434 if (it.value().region.contains(pos))-
1435 return it.key();-
1436 return None;-
1437}-
1438-
1439extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*);-
1440-
1441-
1442-
1443-
1444QStyleOptionTitleBar QMdiSubWindowPrivate::titleBarOptions() const-
1445{-
1446 const QMdiSubWindow * const q = q_func();-
1447 QStyleOptionTitleBar titleBarOptions;-
1448 titleBarOptions.initFrom(q);-
1449 if (activeSubControl != QStyle::SC_None) {-
1450 if (hoveredSubControl == activeSubControl) {-
1451 titleBarOptions.state |= QStyle::State_Sunken;-
1452 titleBarOptions.activeSubControls = activeSubControl;-
1453 }-
1454 } else if (autoRaise() && hoveredSubControl != QStyle::SC_None-
1455 && hoveredSubControl != QStyle::SC_TitleBarLabel) {-
1456 titleBarOptions.state |= QStyle::State_MouseOver;-
1457 titleBarOptions.activeSubControls = hoveredSubControl;-
1458 } else {-
1459 titleBarOptions.state &= ~QStyle::State_MouseOver;-
1460 titleBarOptions.activeSubControls = QStyle::SC_None;-
1461 }-
1462-
1463 titleBarOptions.subControls = QStyle::SC_All;-
1464 titleBarOptions.titleBarFlags = q->windowFlags();-
1465 titleBarOptions.titleBarState = q->windowState();-
1466 titleBarOptions.palette = titleBarPalette;-
1467 titleBarOptions.icon = menuIcon;-
1468-
1469 if (isActive) {-
1470 titleBarOptions.state |= QStyle::State_Active;-
1471 titleBarOptions.titleBarState |= QStyle::State_Active;-
1472 titleBarOptions.palette.setCurrentColorGroup(QPalette::Active);-
1473 } else {-
1474 titleBarOptions.state &= ~QStyle::State_Active;-
1475 titleBarOptions.palette.setCurrentColorGroup(QPalette::Inactive);-
1476 }-
1477-
1478 int border = hasBorder(titleBarOptions) ? 4 : 0;-
1479 int paintHeight = titleBarHeight(titleBarOptions);-
1480 paintHeight -= q->isMinimized() ? 2 * border : border;-
1481 titleBarOptions.rect = QRect(border, border, q->width() - 2 * border, paintHeight);-
1482-
1483 if (!windowTitle.isEmpty()) {-
1484-
1485-
1486 titleBarOptions.text = windowTitle;-
1487 titleBarOptions.fontMetrics = QFontMetrics(font);-
1488 int width = q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions,-
1489 QStyle::SC_TitleBarLabel, q).width();-
1490-
1491 titleBarOptions.text = titleBarOptions.fontMetrics.elidedText(windowTitle, Qt::ElideRight, width);-
1492 }-
1493 return titleBarOptions;-
1494}-
1495-
1496-
1497-
1498-
1499void QMdiSubWindowPrivate::ensureWindowState(Qt::WindowState state)-
1500{-
1501 QMdiSubWindow * const q = q_func();-
1502 Qt::WindowStates windowStates = q->windowState() | state;-
1503 switch (state) {-
1504 case Qt::WindowMinimized:-
1505 windowStates &= ~Qt::WindowMaximized;-
1506 windowStates &= ~Qt::WindowFullScreen;-
1507 windowStates &= ~Qt::WindowNoState;-
1508 break;-
1509 case Qt::WindowMaximized:-
1510 windowStates &= ~Qt::WindowMinimized;-
1511 windowStates &= ~Qt::WindowFullScreen;-
1512 windowStates &= ~Qt::WindowNoState;-
1513 break;-
1514 case Qt::WindowNoState:-
1515 windowStates &= ~Qt::WindowMinimized;-
1516 windowStates &= ~Qt::WindowMaximized;-
1517 windowStates &= ~Qt::WindowFullScreen;-
1518 break;-
1519 default:-
1520 break;-
1521 }-
1522 if (baseWidget) {-
1523 if (!(baseWidget->windowState() & Qt::WindowActive) && windowStates & Qt::WindowActive)-
1524 baseWidget->overrideWindowState(windowStates & ~Qt::WindowActive);-
1525 else-
1526 baseWidget->overrideWindowState(windowStates);-
1527 }-
1528 q->overrideWindowState(windowStates);-
1529}-
1530-
1531-
1532-
1533-
1534int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const-
1535{-
1536 const QMdiSubWindow * const q = q_func();-
1537 if (!parent || q->windowFlags() & Qt::FramelessWindowHint-
1538 || (q->isMaximized() && !drawTitleBarWhenMaximized())) {-
1539 return 0;-
1540 }-
1541-
1542 int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, q);-
1543 if (hasBorder(options))-
1544 height += q->isMinimized() ? 8 : 4;-
1545 return height;-
1546}-
1547-
1548-
1549-
1550-
1551void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const-
1552{-
1553 const QMdiSubWindow * const q = q_func();-
1554 Qt::WindowFlags flags = q->windowFlags();-
1555 if (!parent || flags & Qt::FramelessWindowHint) {-
1556 *margin = 0;-
1557 *minWidth = 0;-
1558 return;-
1559 }-
1560-
1561 if (q->isMaximized() && !drawTitleBarWhenMaximized())-
1562 *margin = 0;-
1563 else-
1564 *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q);-
1565-
1566 QStyleOptionTitleBar opt = this->titleBarOptions();-
1567 int tempWidth = 0;-
1568 for (int i = 0; i < NumSubControls; ++i) {-
1569 if (SubControls[i] == QStyle::SC_TitleBarLabel) {-
1570 tempWidth += 30;-
1571 continue;-
1572 }-
1573 QRect rect = q->style()->subControlRect(QStyle::CC_TitleBar, &opt, SubControls[i], q);-
1574 if (!rect.isValid())-
1575 continue;-
1576 tempWidth += rect.width();-
1577 }-
1578 *minWidth = tempWidth;-
1579}-
1580-
1581-
1582-
1583-
1584bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const-
1585{-
1586 const QMdiSubWindow * const q = q_func();-
1587 if (q->window()->testAttribute(Qt::WA_CanHostQMdiSubWindowTitleBar))-
1588 return false;-
1589-
1590 if (isChildOfTabbedQMdiArea(q))-
1591 return false;-
1592-
1593-
1594-
1595-
1596-
1597 if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q))-
1598 return true;-
1599-
1600-
1601-
1602-
1603 QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window());-
1604 if (!mainWindow || !qobject_cast<QMenuBar *>(mainWindow->menuWidget())-
1605 || mainWindow->menuWidget()->isHidden())-
1606 return true;-
1607-
1608 return isChildOfQMdiSubWindow(q);-
1609-
1610-
1611}-
1612-
1613-
1614-
1615-
1616-
1617-
1618void QMdiSubWindowPrivate::showButtonsInMenuBar(QMenuBar *menuBar)-
1619{-
1620 QMdiSubWindow * const q = q_func();-
1621 ((!(q->isMaximized() && !drawTitleBarWhenMaximized())) ? qt_assert("q->isMaximized() && !drawTitleBarWhenMaximized()",__FILE__,17951800) : qt_noop());-
1622-
1623 if (isChildOfTabbedQMdiArea(q))-
1624 return;-
1625-
1626 removeButtonsFromMenuBar();-
1627 if (!controlContainer)-
1628 controlContainer = new ControlContainer(q);-
1629-
1630 ignoreWindowTitleChange = true;-
1631 controlContainer->showButtonsInMenuBar(menuBar);-
1632 ignoreWindowTitleChange = false;-
1633-
1634 QWidget *topLevelWindow = q->window();-
1635 topLevelWindow->setWindowModified(q->isWindowModified());-
1636 topLevelWindow->installEventFilter(q);-
1637-
1638 int buttonHeight = 0;-
1639 if (controlContainer->controllerWidget())-
1640 buttonHeight = controlContainer->controllerWidget()->height();-
1641 else if (controlContainer->systemMenuLabel())-
1642 buttonHeight = controlContainer->systemMenuLabel()->height();-
1643-
1644-
1645 if (menuBar && menuBar->height() < buttonHeight-
1646 && topLevelWindow->layout()) {-
1647-
1648-
1649 QEvent event(QEvent::LayoutRequest);-
1650 QApplication::sendEvent(topLevelWindow, &event);-
1651 }-
1652}-
1653-
1654-
1655-
1656-
1657void QMdiSubWindowPrivate::removeButtonsFromMenuBar()-
1658{-
1659 QMdiSubWindow * const q = q_func();-
1660-
1661 if (!controlContainer || isChildOfTabbedQMdiArea(q))-
1662 return;-
1663-
1664 QMenuBar *currentMenuBar = 0;-
1665-
1666 if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) {-
1667-
1668-
1669 currentMenuBar = qobject_cast<QMenuBar *>(mainWindow->menuWidget());-
1670 }-
1671-
1672-
1673 ignoreWindowTitleChange = true;-
1674 controlContainer->removeButtonsFromMenuBar(currentMenuBar);-
1675 ignoreWindowTitleChange = false;-
1676-
1677 QWidget *topLevelWindow = q->window();-
1678 topLevelWindow->removeEventFilter(q);-
1679 if (baseWidget && !drawTitleBarWhenMaximized())-
1680 topLevelWindow->setWindowModified(false);-
1681 originalTitle = QString::null;-
1682}-
1683-
1684-
1685-
1686void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild)-
1687{-
1688 QMdiSubWindow * const q = q_func();-
1689 if (isRequestFromChild && !q->windowTitle().isEmpty() && !lastChildWindowTitle.isEmpty()-
1690 && lastChildWindowTitle != q->windowTitle()) {-
1691 return;-
1692 }-
1693-
1694 QWidget *titleWidget = 0;-
1695 if (isRequestFromChild)-
1696 titleWidget = baseWidget;-
1697 else-
1698 titleWidget = q;-
1699 if (!titleWidget || titleWidget->windowTitle().isEmpty())-
1700 return;-
1701-
1702 ignoreWindowTitleChange = true;-
1703 q->setWindowTitle(titleWidget->windowTitle());-
1704 if (q->maximizedButtonsWidget())-
1705 setNewWindowTitle();-
1706 ignoreWindowTitleChange = false;-
1707}-
1708-
1709-
1710void QMdiSubWindowPrivate::enterRubberBandMode()-
1711{-
1712 QMdiSubWindow * const q = q_func();-
1713 if (q->isMaximized())-
1714 return;-
1715 ((!(oldGeometry.isValid())) ? qt_assert("oldGeometry.isValid()",__FILE__,18891894) : qt_noop());-
1716 ((!(parent)) ? qt_assert("parent",__FILE__,18901895) : qt_noop());-
1717 if (!rubberBand) {-
1718 rubberBand = new QRubberBand(QRubberBand::Rectangle, q->parentWidget());-
1719-
1720 rubberBand->setObjectName(QLatin1String("qt_rubberband"));-
1721 }-
1722 QPoint rubberBandPos = q->mapToParent(QPoint(0, 0));-
1723 rubberBand->setGeometry(rubberBandPos.x(), rubberBandPos.y(),-
1724 oldGeometry.width(), oldGeometry.height());-
1725 rubberBand->show();-
1726 isInRubberBandMode = true;-
1727 q->grabMouse();-
1728}-
1729-
1730void QMdiSubWindowPrivate::leaveRubberBandMode()-
1731{-
1732 QMdiSubWindow * const q = q_func();-
1733 ((!(rubberBand)) ? qt_assert("rubberBand",__FILE__,19071912) : qt_noop());-
1734 ((!(isInRubberBandMode)) ? qt_assert("isInRubberBandMode",__FILE__,19081913) : qt_noop());-
1735 q->releaseMouse();-
1736 isInRubberBandMode = false;-
1737 q->setGeometry(rubberBand->geometry());-
1738 rubberBand->hide();-
1739 currentOperation = None;-
1740}-
1741-
1742-
1743-
1744QPalette QMdiSubWindowPrivate::desktopPalette() const-
1745{-
1746 const QMdiSubWindow * const q = q_func();-
1747 QPalette newPalette = q->palette();-
1748-
1749 bool colorsInitialized = false;-
1750 if (!colorsInitialized) {-
1751 newPalette.setColor(QPalette::Active, QPalette::Highlight,-
1752 newPalette.color(QPalette::Active, QPalette::Highlight));-
1753 newPalette.setColor(QPalette::Active, QPalette::Base,-
1754 newPalette.color(QPalette::Active, QPalette::Highlight));-
1755 newPalette.setColor(QPalette::Inactive, QPalette::Highlight,-
1756 newPalette.color(QPalette::Inactive, QPalette::Dark));-
1757 newPalette.setColor(QPalette::Inactive, QPalette::Base,-
1758 newPalette.color(QPalette::Inactive, QPalette::Dark));-
1759 newPalette.setColor(QPalette::Inactive, QPalette::HighlightedText,-
1760 newPalette.color(QPalette::Inactive, QPalette::Window));-
1761 }-
1762-
1763 return newPalette;-
1764}-
1765-
1766void QMdiSubWindowPrivate::updateActions()-
1767{-
1768 Qt::WindowFlags windowFlags = q_func()->windowFlags();-
1769-
1770 for (int i = 0; i < NumWindowStateActions; ++i)-
1771 setVisible(WindowStateAction(i), false);-
1772-
1773 if (windowFlags & Qt::FramelessWindowHint)-
1774 return;-
1775-
1776 setVisible(StayOnTopAction, true);-
1777 setVisible(MoveAction, moveEnabled);-
1778 setVisible(ResizeAction, resizeEnabled);-
1779-
1780-
1781 if (windowFlags & Qt::WindowSystemMenuHint)-
1782 setVisible(CloseAction, true);-
1783-
1784-
1785 if (windowFlags & (Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint))-
1786 setVisible(RestoreAction, true);-
1787-
1788-
1789 if (windowFlags & Qt::WindowMinimizeButtonHint)-
1790 setVisible(MinimizeAction, true);-
1791-
1792-
1793 if (windowFlags & Qt::WindowMaximizeButtonHint)-
1794 setVisible(MaximizeAction, true);-
1795}-
1796-
1797void QMdiSubWindowPrivate::setFocusWidget()-
1798{-
1799 QMdiSubWindow * const q = q_func();-
1800 if (!baseWidget) {-
1801 q->setFocus();-
1802 return;-
1803 }-
1804-
1805-
1806-
1807-
1808 if (focusInReason == Qt::TabFocusReason) {-
1809 q->focusNextChild();-
1810 return;-
1811 }-
1812-
1813-
1814 if (focusInReason == Qt::BacktabFocusReason) {-
1815 q->focusPreviousChild();-
1816 return;-
1817 }-
1818-
1819 if (!(q->windowState() & Qt::WindowMinimized) && restoreFocus())-
1820 return;-
1821-
1822 if (QWidget *focusWidget = baseWidget->focusWidget()) {-
1823 if (!focusWidget->hasFocus() && q->isAncestorOf(focusWidget)-
1824 && focusWidget->isVisible() && !q->isMinimized()-
1825 && focusWidget->focusPolicy() != Qt::NoFocus) {-
1826 focusWidget->setFocus();-
1827 } else {-
1828 q->setFocus();-
1829 }-
1830 return;-
1831 }-
1832-
1833 QWidget *focusWidget = q->nextInFocusChain();-
1834 while (focusWidget && focusWidget != q && focusWidget->focusPolicy() == Qt::NoFocus)-
1835 focusWidget = focusWidget->nextInFocusChain();-
1836 if (focusWidget && q->isAncestorOf(focusWidget))-
1837 focusWidget->setFocus();-
1838 else if (baseWidget->focusPolicy() != Qt::NoFocus)-
1839 baseWidget->setFocus();-
1840 else if (!q->hasFocus())-
1841 q->setFocus();-
1842}-
1843-
1844bool QMdiSubWindowPrivate::restoreFocus()-
1845{-
1846 if (restoreFocusWidget.isNull())-
1847 return false;-
1848 QWidget *candidate = restoreFocusWidget;-
1849 restoreFocusWidget.clear();-
1850 if (!candidate->hasFocus() && q_func()->isAncestorOf(candidate)-
1851 && candidate->isVisible()-
1852 && candidate->focusPolicy() != Qt::NoFocus) {-
1853 candidate->setFocus();-
1854 return true;-
1855 }-
1856 return candidate->hasFocus();-
1857}-
1858-
1859-
1860-
1861-
1862void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags)-
1863{-
1864 QMdiSubWindow * const q = q_func();-
1865-
1866 if (!parent) {-
1867 QWidgetPrivate::setWindowFlags(windowFlags);-
1868 return;-
1869 }-
1870-
1871 Qt::WindowFlags windowType = windowFlags & Qt::WindowType_Mask;-
1872 if (windowType == Qt::Dialog || windowFlags & Qt::MSWindowsFixedSizeDialogHint)-
1873 windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint;-
1874-
1875-
1876 if (!(windowFlags & CustomizeWindowFlags))-
1877 windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;-
1878 else if (windowFlags & Qt::FramelessWindowHint && windowFlags & Qt::WindowStaysOnTopHint)-
1879 windowFlags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint;-
1880 else if (windowFlags & Qt::FramelessWindowHint)-
1881 windowFlags = Qt::FramelessWindowHint;-
1882-
1883 windowFlags &= ~windowType;-
1884 windowFlags &= ~Qt::WindowFullscreenButtonHint;-
1885 windowFlags |= Qt::SubWindow;-
1886-
1887-
1888 if (QAction *stayOnTopAction = actions[QMdiSubWindowPrivate::StayOnTopAction]) {-
1889 if (windowFlags & Qt::WindowStaysOnTopHint)-
1890 stayOnTopAction->setChecked(true);-
1891 else-
1892 stayOnTopAction->setChecked(false);-
1893 }-
1894-
1895-
1896-
1897 if ((windowFlags & Qt::FramelessWindowHint) && sizeGrip)-
1898 delete sizeGrip;-
1899-
1900-
1901 QWidgetPrivate::setWindowFlags(windowFlags);-
1902 updateGeometryConstraints();-
1903 updateActions();-
1904 QSize currentSize = q->size();-
1905 if (q->isVisible() && (currentSize.width() < internalMinimumSize.width()-
1906 || currentSize.height() < internalMinimumSize.height())) {-
1907 q->resize(currentSize.expandedTo(internalMinimumSize));-
1908 }-
1909}-
1910-
1911void QMdiSubWindowPrivate::setVisible(WindowStateAction action, bool visible)-
1912{-
1913-
1914 if (actions[action])-
1915 actions[action]->setVisible(visible);-
1916-
1917-
1918 QMdiSubWindow * const q = q_func();-
1919 if (!controlContainer)-
1920 controlContainer = new ControlContainer(q);-
1921-
1922 if (ControllerWidget *ctrlWidget = qobject_cast<ControllerWidget *>-
1923 (controlContainer->controllerWidget())) {-
1924 ctrlWidget->setControlVisible(action, visible);-
1925 }-
1926}-
1927-
1928-
1929void QMdiSubWindowPrivate::setEnabled(WindowStateAction action, bool enable)-
1930{-
1931 if (actions[action])-
1932 actions[action]->setEnabled(enable);-
1933}-
1934-
1935-
1936void QMdiSubWindowPrivate::addToSystemMenu(WindowStateAction action, const QString &text,-
1937 const char *slot)-
1938{-
1939 if (!systemMenu)-
1940 return;-
1941 actions[action] = systemMenu->addAction(text, q_func(), slot);-
1942}-
1943-
1944-
1945-
1946-
1947-
1948-
1949QSize QMdiSubWindowPrivate::iconSize() const-
1950{-
1951 const QMdiSubWindow * const q = q_func();-
1952 if (!parent || q->windowFlags() & Qt::FramelessWindowHint)-
1953 return QSize(-1, -1);-
1954 return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight());-
1955}-
1956-
1957-
1958-
1959-
1960-
1961-
1962void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip)-
1963{-
1964 QMdiSubWindow * const q = q_func();-
1965 if (!newSizeGrip || sizeGrip || q->windowFlags() & Qt::FramelessWindowHint)-
1966 return;-
1967-
1968 if (layout && layout->indexOf(newSizeGrip) != -1)-
1969 return;-
1970 newSizeGrip->setFixedSize(newSizeGrip->sizeHint());-
1971 bool putSizeGripInLayout = layout ? true : false;-
1972-
1973-
1974-
1975-
1976 if (putSizeGripInLayout) {-
1977 layout->addWidget(newSizeGrip);-
1978 layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight);-
1979 } else {-
1980 newSizeGrip->setParent(q);-
1981 newSizeGrip->move(q->isLeftToRight() ? q->width() - newSizeGrip->width() : 0,-
1982 q->height() - newSizeGrip->height());-
1983 sizeGrip = newSizeGrip;-
1984 }-
1985 newSizeGrip->raise();-
1986 updateGeometryConstraints();-
1987 newSizeGrip->installEventFilter(q);-
1988}-
1989-
1990-
1991-
1992-
1993void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const-
1994{-
1995-
1996 const QList<QSizeGrip *> sizeGrips = q_func()->findChildren<QSizeGrip *>();-
1997 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(sizeGrips)>::type> _container_((sizeGrips)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QSizeGrip *grip = *_container_.i; _container_.control; _container_.control = 0: sizeGrips)-
1998 grip->setVisible(visible);
never executed: grip->setVisible(visible);
0
1999}
never executed: end of block
0
2000-
2001-
2002-
2003-
2004-
2005-
2006void QMdiSubWindowPrivate::updateInternalWindowTitle()-
2007{-
2008 QMdiSubWindow * const q = q_func();-
2009 if (q->isWindowModified()) {-
2010 windowTitle = q->windowTitle();-
2011 windowTitle.replace(QLatin1String("[*]"), QLatin1String("*"));-
2012 } else {-
2013 windowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);-
2014 }-
2015 q->update(0, 0, q->width(), titleBarHeight());-
2016}-
2017QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)-
2018 : QWidget(*new QMdiSubWindowPrivate, parent, 0)-
2019{-
2020 QMdiSubWindowPrivate * const d = d_func();-
2021-
2022 d->createSystemMenu();-
2023 addActions(d->systemMenu->actions());-
2024-
2025 d->setWindowFlags(flags);-
2026 setBackgroundRole(QPalette::Window);-
2027 setAutoFillBackground(true);-
2028 setMouseTracking(true);-
2029 setLayout(new QVBoxLayout);-
2030 setFocusPolicy(Qt::StrongFocus);-
2031 layout()->setMargin(0);-
2032 d->updateGeometryConstraints();-
2033 setAttribute(Qt::WA_Resized, false);-
2034 d->titleBarPalette = d->desktopPalette();-
2035 d->font = QApplication::font("QMdiSubWindowTitleBar");-
2036-
2037-
2038 if (windowIcon().isNull())-
2039 d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this);-
2040 else-
2041 d->menuIcon = windowIcon();-
2042-
2043 connect((static_cast<QApplication *>(QCoreApplication::instance())), qFlagLocation("2""focusChanged(QWidget*,QWidget*)" "\0" __FILE__ ":" "2273""2278"),-
2044 this, qFlagLocation("1""_q_processFocusChanged(QWidget*,QWidget*)" "\0" __FILE__ ":" "2274""2279"));-
2045}-
2046-
2047-
2048-
2049-
2050-
2051-
2052QMdiSubWindow::~QMdiSubWindow()-
2053{-
2054 QMdiSubWindowPrivate * const d = d_func();-
2055-
2056 d->removeButtonsFromMenuBar();-
2057-
2058 d->setActive(false);-
2059}-
2060void QMdiSubWindow::setWidget(QWidget *widget)-
2061{-
2062 QMdiSubWindowPrivate * const d = d_func();-
2063 if (!widget
!widgetDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2064 d->removeBaseWidget();-
2065 return;
never executed: return;
0
2066 }-
2067-
2068 if (__builtin_expect(!!(
__builtin_expe...idget), false)Description
TRUEnever evaluated
FALSEnever evaluated
widget == d->baseWidget)), false)
__builtin_expe...idget), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2069 QMessageLogger(__FILE__, 23112316, __PRETTY_FUNCTION__).warning("QMdiSubWindow::setWidget: widget is already set");-
2070 return;
never executed: return;
0
2071 }-
2072-
2073 bool wasResized = testAttribute(Qt::WA_Resized);-
2074 d->removeBaseWidget();-
2075-
2076 if (QLayout *layout = this->layout()
QLayout *layou...this->layout()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2077 layout->addWidget(widget);
never executed: layout->addWidget(widget);
0
2078 else-
2079 widget->setParent(this);
never executed: widget->setParent(this);
0
2080-
2081-
2082 QSizeGrip *sizeGrip = widget->findChild<QSizeGrip *>();-
2083 if (sizeGrip
sizeGripDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2084 sizeGrip->installEventFilter(this);
never executed: sizeGrip->installEventFilter(this);
0
2085 if (d->sizeGrip
d->sizeGripDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2086 d->sizeGrip->raise();
never executed: d->sizeGrip->raise();
0
2087-
2088-
2089 d->baseWidget = widget;-
2090 d->baseWidget->installEventFilter(this);-
2091-
2092 d->ignoreWindowTitleChange = true;-
2093 bool isWindowModified = this->isWindowModified();-
2094 if (windowTitle().isEmpty()
windowTitle().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2095 d->updateWindowTitle(true);-
2096 isWindowModified = d->baseWidget->isWindowModified();-
2097 }
never executed: end of block
0
2098 if (!this->isWindowModified()
!this->isWindowModified()Description
TRUEnever evaluated
FALSEnever evaluated
&& isWindowModified
isWindowModifiedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2099 && windowTitle().contains(QLatin1String("[*]"))
windowTitle()....String("[*]"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2100 setWindowModified(isWindowModified);-
2101 }
never executed: end of block
0
2102 d->lastChildWindowTitle = d->baseWidget->windowTitle();-
2103 d->ignoreWindowTitleChange = false;-
2104-
2105 if (windowIcon().isNull()
windowIcon().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->baseWidget->windowIcon().isNull()
!d->baseWidget...con().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2106 setWindowIcon(d->baseWidget->windowIcon());
never executed: setWindowIcon(d->baseWidget->windowIcon());
0
2107-
2108 d->updateGeometryConstraints();-
2109 if (!wasResized
!wasResizedDescription
TRUEnever evaluated
FALSEnever evaluated
&& testAttribute(Qt::WA_Resized)
testAttribute(Qt::WA_Resized)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2110 setAttribute(Qt::WA_Resized, false);
never executed: setAttribute(Qt::WA_Resized, false);
0
2111}
never executed: end of block
0
2112-
2113-
2114-
2115-
2116-
2117-
2118QWidget *QMdiSubWindow::widget() const-
2119{-
2120 return d_func()->baseWidget;-
2121}-
2122-
2123-
2124-
2125-
2126-
2127QWidget *QMdiSubWindow::maximizedButtonsWidget() const-
2128{-
2129 const QMdiSubWindowPrivate * const d = d_func();-
2130 if (isVisible() && d->controlContainer && isMaximized() && !d->drawTitleBarWhenMaximized()-
2131 && !isChildOfTabbedQMdiArea(this)) {-
2132 return d->controlContainer->controllerWidget();-
2133 }-
2134 return 0;-
2135}-
2136-
2137-
2138-
2139-
2140QWidget *QMdiSubWindow::maximizedSystemMenuIconWidget() const-
2141{-
2142 const QMdiSubWindowPrivate * const d = d_func();-
2143 if (isVisible() && d->controlContainer && isMaximized() && !d->drawTitleBarWhenMaximized()-
2144 && !isChildOfTabbedQMdiArea(this)) {-
2145 return d->controlContainer->systemMenuLabel();-
2146 }-
2147 return 0;-
2148}-
2149-
2150-
2151-
2152-
2153-
2154-
2155-
2156bool QMdiSubWindow::isShaded() const-
2157{-
2158 return d_func()->isShadeMode;-
2159}-
2160-
2161-
2162-
2163-
2164-
2165-
2166-
2167void QMdiSubWindow::setOption(SubWindowOption option, bool on)-
2168{-
2169 QMdiSubWindowPrivate * const d = d_func();-
2170 if (on && !(d->options & option))d->options|= option;-
else if (!on &&.setFlag(d->options & option))
d->options &= ~option;, on);
2171-
2172-
2173 if ((
(option & (Rub...bberBandMove))Description
TRUEnever evaluated
FALSEnever evaluated
option & (RubberBandResize | RubberBandMove))
(option & (Rub...bberBandMove))Description
TRUEnever evaluated
FALSEnever evaluated
&& !on
!onDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->isInRubberBandMode
d->isInRubberBandModeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2174 d->leaveRubberBandMode();
never executed: d->leaveRubberBandMode();
0
2175-
2176}
never executed: end of block
0
2177-
2178-
2179-
2180-
2181-
2182-
2183bool QMdiSubWindow::testOption(SubWindowOption option) const-
2184{-
2185 return d_func()->options & option;-
2186}-
2187int QMdiSubWindow::keyboardSingleStep() const-
2188{-
2189 return d_func()->keyboardSingleStep;-
2190}-
2191-
2192void QMdiSubWindow::setKeyboardSingleStep(int step)-
2193{-
2194-
2195-
2196-
2197 d_func()->keyboardSingleStep = step;-
2198}-
2199int QMdiSubWindow::keyboardPageStep() const-
2200{-
2201 return d_func()->keyboardPageStep;-
2202}-
2203-
2204void QMdiSubWindow::setKeyboardPageStep(int step)-
2205{-
2206-
2207-
2208-
2209 d_func()->keyboardPageStep = step;-
2210}-
2211void QMdiSubWindow::setSystemMenu(QMenu *systemMenu)-
2212{-
2213 QMdiSubWindowPrivate * const d = d_func();-
2214 if (__builtin_expect(!!(
__builtin_expe...mMenu), false)Description
TRUEnever evaluated
FALSEnever evaluated
systemMenu && systemMenu == d->systemMenu)), false)
__builtin_expe...mMenu), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2215 QMessageLogger(__FILE__, 25092511, __PRETTY_FUNCTION__).warning("QMdiSubWindow::setSystemMenu: system menu is already set");-
2216 return;
never executed: return;
0
2217 }-
2218-
2219 if (d->systemMenu
d->systemMenuDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2220 delete d->systemMenu;-
2221 d->systemMenu = 0;-
2222 }
never executed: end of block
0
2223-
2224 if (!systemMenu
!systemMenuDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2225 return;
never executed: return;
0
2226-
2227 if (systemMenu->parent() != this
systemMenu->parent() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2228 systemMenu->setParent(this);
never executed: systemMenu->setParent(this);
0
2229 d->systemMenu = systemMenu;-
2230}
never executed: end of block
0
2231QMenu *QMdiSubWindow::systemMenu() const-
2232{-
2233 return d_func()->systemMenu;-
2234}-
2235-
2236-
2237-
2238-
2239-
2240-
2241void QMdiSubWindow::showSystemMenu()-
2242{-
2243 QMdiSubWindowPrivate * const d = d_func();-
2244 if (!d->systemMenu)-
2245 return;-
2246-
2247 QPoint globalPopupPos;-
2248 if (QWidget *icon = maximizedSystemMenuIconWidget()) {-
2249 if (isLeftToRight())-
2250 globalPopupPos = icon->mapToGlobal(QPoint(0, icon->y() + icon->height()));-
2251 else-
2252 globalPopupPos = icon->mapToGlobal(QPoint(icon->width(), icon->y() + icon->height()));-
2253 } else {-
2254 if (isLeftToRight())-
2255 globalPopupPos = mapToGlobal(contentsRect().topLeft());-
2256 else-
2257 globalPopupPos = mapToGlobal(contentsRect().topRight()) + QPoint(1, 0);-
2258 }-
2259-
2260-
2261 if (isRightToLeft())-
2262 globalPopupPos -= QPoint(d->systemMenu->sizeHint().width(), 0);-
2263 d->systemMenu->popup(globalPopupPos);-
2264}-
2265QMdiArea *QMdiSubWindow::mdiArea() const-
2266{-
2267 QWidget *parent = parentWidget();-
2268 while (parent) {-
2269 if (QMdiArea *area = qobject_cast<QMdiArea *>(parent)) {-
2270 if (area->viewport() == parentWidget())-
2271 return area;-
2272 }-
2273 parent = parent->parentWidget();-
2274 }-
2275 return 0;-
2276}-
2277void QMdiSubWindow::showShaded()-
2278{-
2279 if (!parent()
!parent()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2280 return;
never executed: return;
0
2281-
2282 QMdiSubWindowPrivate * const d = d_func();-
2283-
2284 if (!d->isShadeRequestFromMinimizeMode
!d->isShadeReq...omMinimizeModeDescription
TRUEnever evaluated
FALSEnever evaluated
&& isShaded()
isShaded()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2285 return;
never executed: return;
0
2286-
2287 d->isMaximizeMode = false;-
2288-
2289 d->storeFocusWidget();-
2290-
2291 if (!d->isShadeRequestFromMinimizeMode
!d->isShadeReq...omMinimizeModeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2292 d->isShadeMode = true;-
2293 d->ensureWindowState(Qt::WindowMinimized);-
2294 }
never executed: end of block
0
2295-
2296-
2297 d->removeButtonsFromMenuBar();-
2298-
2299-
2300-
2301-
2302-
2303 if (hasFocus()
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
|| isAncestorOf(QApplication::focusWidget())
isAncestorOf(Q...focusWidget())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2304 d->ensureWindowState(Qt::WindowActive);
never executed: d->ensureWindowState(Qt::WindowActive);
0
2305-
2306-
2307 d->setSizeGripVisible(false);-
2308-
2309-
2310 if (!d->restoreSize.isValid()
!d->restoreSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->isShadeMode
d->isShadeModeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
2311 d->oldGeometry = geometry();-
2312 d->restoreSize.setWidth(d->oldGeometry.width());-
2313 d->restoreSize.setHeight(d->oldGeometry.height());-
2314 }
never executed: end of block
0
2315-
2316-
2317-
2318 const bool wasVisible = isVisible();-
2319 if (wasVisible
wasVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2320 setVisible(false);
never executed: setVisible(false);
0
2321-
2322 d->updateGeometryConstraints();-
2323-
2324 if (!minimumSize().isNull()
!minimumSize().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2325 d->userMinimumSize = minimumSize();-
2326 setMinimumSize(d->internalMinimumSize);-
2327 }
never executed: end of block
0
2328 resize(d->internalMinimumSize);-
2329-
2330-
2331 if (d->baseWidget
d->baseWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->baseWidget->isHidden())()
!d->baseWidget->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
&& !(windowFlags() & Qt::FramelessWindowHint)
!(windowFlags(...essWindowHint)Description
TRUEnever evaluated
FALSEnever evaluated
)
{
0
2332 d->baseWidget->hide();-
2333 d->isWidgetHiddenByUs = true;-
2334 }
never executed: end of block
0
2335-
2336 if (wasVisible
wasVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
2337 setVisible(true);
never executed: setVisible(true);
0
2338-
2339 d->setFocusWidget();-
2340 d->resizeEnabled = false;-
2341 d->moveEnabled = true;-
2342 d->updateDirtyRegions();-
2343 d->updateMask();-
2344-
2345-
2346 d->setEnabled(QMdiSubWindowPrivate::MinimizeAction, false);-
2347 d->setEnabled(QMdiSubWindowPrivate::ResizeAction, d->resizeEnabled);-
2348 d->setEnabled(QMdiSubWindowPrivate::MaximizeAction, true);-
2349 d->setEnabled(QMdiSubWindowPrivate::RestoreAction, true);-
2350 d->setEnabled(QMdiSubWindowPrivate::MoveAction, d->moveEnabled);-
2351-
2352}
never executed: end of block
0
2353-
2354-
2355-
2356-
2357bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)-
2358{-
2359 QMdiSubWindowPrivate * const d = d_func();-
2360 if (!object)-
2361 return QWidget::eventFilter(object, event);-
2362-
2363-
2364-
2365 if (d->systemMenu && d->systemMenu == object) {-
2366 if (event->type() == QEvent::MouseButtonDblClick) {-
2367 const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);-
2368 const QAction *action = d->systemMenu->actionAt(mouseEvent->pos());-
2369 if (!action || action->isEnabled())-
2370 close();-
2371 } else if (event->type() == QEvent::MouseMove) {-
2372 QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);-
2373 d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPos()));-
2374 } else if (event->type() == QEvent::Hide) {-
2375 d->activeSubControl = QStyle::SC_None;-
2376 update(QRegion(0, 0, width(), d->titleBarHeight()));-
2377 }-
2378 return QWidget::eventFilter(object, event);-
2379 }-
2380-
2381-
2382-
2383 if (object != d->baseWidget && parent() && qobject_cast<QSizeGrip *>(object)) {-
2384 if (event->type() != QEvent::MouseButtonPress || !testOption(QMdiSubWindow::RubberBandResize))-
2385 return QWidget::eventFilter(object, event);-
2386 const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);-
2387 d->mousePressPosition = parentWidget()->mapFromGlobal(mouseEvent->globalPos());-
2388 d->oldGeometry = geometry();-
2389 d->currentOperation = isLeftToRight() ? QMdiSubWindowPrivate::BottomRightResize-
2390 : QMdiSubWindowPrivate::BottomLeftResize;-
2391-
2392 d->enterRubberBandMode();-
2393-
2394 return true;-
2395 }-
2396-
2397-
2398 if (object != d->baseWidget && event->type() != QEvent::WindowTitleChange)-
2399 return QWidget::eventFilter(object, event);-
2400-
2401 switch (event->type()) {-
2402 case QEvent::Show:-
2403 d->setActive(true);-
2404 break;-
2405 case QEvent::ShowToParent:-
2406 if (!d->isWidgetHiddenByUs)-
2407 show();-
2408 break;-
2409 case QEvent::WindowStateChange: {-
2410 QWindowStateChangeEvent *changeEvent = static_cast<QWindowStateChangeEvent*>(event);-
2411 if (changeEvent->isOverride())-
2412 break;-
2413 Qt::WindowStates oldState = changeEvent->oldState();-
2414 Qt::WindowStates newState = d->baseWidget->windowState();-
2415 if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized))-
2416 showMinimized();-
2417 else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized))-
2418 showMaximized();-
2419 else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)))-
2420 showNormal();-
2421 break;-
2422 }-
2423 case QEvent::Enter:-
2424 d->currentOperation = QMdiSubWindowPrivate::None;-
2425 d->updateCursor();-
2426 break;-
2427 case QEvent::LayoutRequest:-
2428 d->updateGeometryConstraints();-
2429 break;-
2430 case QEvent::WindowTitleChange:-
2431 if (d->ignoreWindowTitleChange)-
2432 break;-
2433 if (object == d->baseWidget) {-
2434 d->updateWindowTitle(true);-
2435 d->lastChildWindowTitle = d->baseWidget->windowTitle();-
2436-
2437 } else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar()-
2438 ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {-
2439 d->originalTitle = QString::null;-
2440 if (d->baseWidget && d->baseWidget->windowTitle() == windowTitle())-
2441 d->updateWindowTitle(true);-
2442 else-
2443 d->updateWindowTitle(false);-
2444-
2445 }-
2446 break;-
2447 case QEvent::ModifiedChange: {-
2448 if (object != d->baseWidget)-
2449 break;-
2450 bool windowModified = d->baseWidget->isWindowModified();-
2451 if (!windowModified && d->baseWidget->windowTitle() != windowTitle())-
2452 break;-
2453 if (windowTitle().contains(QLatin1String("[*]")))-
2454 setWindowModified(windowModified);-
2455 break;-
2456 }-
2457 default:-
2458 break;-
2459 }-
2460 return QWidget::eventFilter(object, event);-
2461}-
2462-
2463-
2464-
2465-
2466bool QMdiSubWindow::event(QEvent *event)-
2467{-
2468 QMdiSubWindowPrivate * const d = d_func();-
2469 switch (event->type()) {-
2470 case QEvent::StyleChange: {-
2471 bool wasShaded = isShaded();-
2472 bool wasMinimized = isMinimized();-
2473 bool wasMaximized = isMaximized();-
2474-
2475 const QScopedValueRollback<bool> activationEnabledSaver(d->activationEnabled);-
2476 d->activationEnabled = false;-
2477-
2478 ensurePolished();-
2479 setContentsMargins(0, 0, 0, 0);-
2480 if (wasMinimized || wasMaximized || wasShaded)-
2481 showNormal();-
2482 d->updateGeometryConstraints();-
2483 resize(d->internalMinimumSize.expandedTo(size()));-
2484 d->updateMask();-
2485 d->updateDirtyRegions();-
2486 if (wasShaded)-
2487 showShaded();-
2488 else if (wasMinimized)-
2489 showMinimized();-
2490 else if (wasMaximized)-
2491 showMaximized();-
2492 break;-
2493 }-
2494 case QEvent::ParentAboutToChange:-
2495 d->setActive(false);-
2496 break;-
2497 case QEvent::ParentChange: {-
2498 bool wasResized = testAttribute(Qt::WA_Resized);-
2499-
2500 d->removeButtonsFromMenuBar();-
2501-
2502 d->currentOperation = QMdiSubWindowPrivate::None;-
2503 d->activeSubControl = QStyle::SC_None;-
2504 d->hoveredSubControl = QStyle::SC_None;-
2505-
2506 if (d->isInRubberBandMode)-
2507 d->leaveRubberBandMode();-
2508-
2509 d->isShadeMode = false;-
2510 d->isMaximizeMode = false;-
2511 d->isWidgetHiddenByUs = false;-
2512 if (!parent()) {-
2513-
2514-
2515-
2516-
2517 setOption(RubberBandResize, false);-
2518 setOption(RubberBandMove, false);-
2519 } else {-
2520 d->setWindowFlags(windowFlags());-
2521 }-
2522 setContentsMargins(0, 0, 0, 0);-
2523 d->updateGeometryConstraints();-
2524 d->updateCursor();-
2525 d->updateMask();-
2526 d->updateDirtyRegions();-
2527 d->updateActions();-
2528 if (!wasResized && testAttribute(Qt::WA_Resized))-
2529 setAttribute(Qt::WA_Resized, false);-
2530 break;-
2531 }-
2532 case QEvent::WindowActivate:-
2533 if (d->ignoreNextActivationEvent) {-
2534 d->ignoreNextActivationEvent = false;-
2535 break;-
2536 }-
2537 d->isExplicitlyDeactivated = false;-
2538 d->setActive(true);-
2539 break;-
2540 case QEvent::WindowDeactivate:-
2541 if (d->ignoreNextActivationEvent) {-
2542 d->ignoreNextActivationEvent = false;-
2543 break;-
2544 }-
2545 d->isExplicitlyDeactivated = true;-
2546 d->setActive(false);-
2547 break;-
2548 case QEvent::WindowTitleChange:-
2549 if (!d->ignoreWindowTitleChange)-
2550 d->updateWindowTitle(false);-
2551 d->updateInternalWindowTitle();-
2552 break;-
2553 case QEvent::ModifiedChange:-
2554 if (!windowTitle().contains(QLatin1String("[*]")))-
2555 break;-
2556-
2557 if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar()-
2558 ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {-
2559 window()->setWindowModified(isWindowModified());-
2560 }-
2561-
2562 d->updateInternalWindowTitle();-
2563 break;-
2564 case QEvent::LayoutDirectionChange:-
2565 d->updateDirtyRegions();-
2566 break;-
2567 case QEvent::LayoutRequest:-
2568 d->updateGeometryConstraints();-
2569 break;-
2570 case QEvent::WindowIconChange:-
2571 d->menuIcon = windowIcon();-
2572 if (d->menuIcon.isNull())-
2573 d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this);-
2574 if (d->controlContainer)-
2575 d->controlContainer->updateWindowIcon(d->menuIcon);-
2576 if (!maximizedSystemMenuIconWidget())-
2577 update(0, 0, width(), d->titleBarHeight());-
2578 break;-
2579 case QEvent::PaletteChange:-
2580 d->titleBarPalette = d->desktopPalette();-
2581 break;-
2582 case QEvent::FontChange:-
2583 d->font = font();-
2584 break;-
2585-
2586 case QEvent::ToolTip:-
2587 showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(),-
2588 QStyle::CC_TitleBar, d->hoveredSubControl);-
2589 break;-
2590-
2591 default:-
2592 break;-
2593 }-
2594 return QWidget::event(event);-
2595}-
2596-
2597-
2598-
2599-
2600void QMdiSubWindow::showEvent(QShowEvent *showEvent)-
2601{-
2602 QMdiSubWindowPrivate * const d = d_func();-
2603 if (!parent()) {-
2604 QWidget::showEvent(showEvent);-
2605 return;-
2606 }-
2607 d->updateDirtyRegions();-
2608-
2609-
2610-
2611 if (d->controlContainer) {-
2612 if (QMenuBar *menuBar = d->menuBar()) {-
2613 if (menuBar->cornerWidget(Qt::TopRightCorner) != maximizedButtonsWidget())-
2614 d->showButtonsInMenuBar(menuBar);-
2615 }-
2616 }-
2617-
2618 d->setActive(true);-
2619}-
2620-
2621-
2622-
2623-
2624void QMdiSubWindow::hideEvent(QHideEvent * )-
2625{-
2626-
2627 d_func()->removeButtonsFromMenuBar();-
2628-
2629}-
2630-
2631-
2632-
2633-
2634void QMdiSubWindow::changeEvent(QEvent *changeEvent)-
2635{-
2636 if (!parent()) {-
2637 QWidget::changeEvent(changeEvent);-
2638 return;-
2639 }-
2640-
2641 if (changeEvent->type() != QEvent::WindowStateChange) {-
2642 QWidget::changeEvent(changeEvent);-
2643 return;-
2644 }-
2645-
2646 QWindowStateChangeEvent *event = static_cast<QWindowStateChangeEvent *>(changeEvent);-
2647 if (event->isOverride()) {-
2648 event->ignore();-
2649 return;-
2650 }-
2651-
2652 Qt::WindowStates oldState = event->oldState();-
2653 Qt::WindowStates newState = windowState();-
2654 if (oldState == newState) {-
2655 changeEvent->ignore();-
2656 return;-
2657 }-
2658-
2659-
2660-
2661-
2662 QMdiSubWindowPrivate * const d = d_func();-
2663 if (!isVisible()) {-
2664 d->ensureWindowState(Qt::WindowNoState);-
2665 setVisible(true);-
2666 }-
2667-
2668 if (!d->oldGeometry.isValid())-
2669 d->oldGeometry = geometry();-
2670-
2671 if ((oldState & Qt::WindowActive) && (newState & Qt::WindowActive))-
2672 d->currentOperation = QMdiSubWindowPrivate::None;-
2673-
2674 if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized))-
2675 d->setMinimizeMode();-
2676 else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized))-
2677 d->setMaximizeMode();-
2678 else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)))-
2679 d->setNormalMode();-
2680-
2681 if (d->isActive)-
2682 d->ensureWindowState(Qt::WindowActive);-
2683 if (d->activationEnabled)-
2684 windowStateChanged(oldState, windowState());-
2685}-
2686-
2687-
2688-
2689-
2690void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent)-
2691{-
2692 QMdiSubWindowPrivate * const d = d_func();-
2693 bool acceptClose = true;-
2694 if (d->baseWidget)-
2695 acceptClose = d->baseWidget->close();-
2696 if (!acceptClose) {-
2697 closeEvent->ignore();-
2698 return;-
2699 }-
2700-
2701 d->removeButtonsFromMenuBar();-
2702-
2703 d->setActive(false);-
2704 if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) {-
2705 QChildEvent childRemoved(QEvent::ChildRemoved, this);-
2706 QApplication::sendEvent(parentWidget(), &childRemoved);-
2707 }-
2708 closeEvent->accept();-
2709}-
2710-
2711-
2712-
2713-
2714void QMdiSubWindow::leaveEvent(QEvent * )-
2715{-
2716 QMdiSubWindowPrivate * const d = d_func();-
2717 if (d->hoveredSubControl != QStyle::SC_None) {-
2718 d->hoveredSubControl = QStyle::SC_None;-
2719 update(QRegion(0, 0, width(), d->titleBarHeight()));-
2720 }-
2721}-
2722-
2723-
2724-
2725-
2726-
2727-
2728-
2729void QMdiSubWindow::resizeEvent(QResizeEvent *resizeEvent)-
2730{-
2731 QMdiSubWindowPrivate * const d = d_func();-
2732-
2733 if (d->sizeGrip) {-
2734 d->sizeGrip->move(isLeftToRight() ? width() - d->sizeGrip->width() : 0,-
2735 height() - d->sizeGrip->height());-
2736 }-
2737-
2738-
2739 if (!parent()) {-
2740 QWidget::resizeEvent(resizeEvent);-
2741 return;-
2742 }-
2743-
2744 if (d->isMaximizeMode)-
2745 d->ensureWindowState(Qt::WindowMaximized);-
2746-
2747 d->updateMask();-
2748 if (!isVisible())-
2749 return;-
2750-
2751 if (d->resizeTimerId <= 0)-
2752 d->cachedStyleOptions = d->titleBarOptions();-
2753 else-
2754 killTimer(d->resizeTimerId);-
2755 d->resizeTimerId = startTimer(200);-
2756}-
2757-
2758-
2759-
2760-
2761void QMdiSubWindow::timerEvent(QTimerEvent *timerEvent)-
2762{-
2763 QMdiSubWindowPrivate * const d = d_func();-
2764 if (timerEvent->timerId() == d->resizeTimerId) {-
2765 killTimer(d->resizeTimerId);-
2766 d->resizeTimerId = -1;-
2767 d->updateDirtyRegions();-
2768 }-
2769}-
2770-
2771-
2772-
2773-
2774void QMdiSubWindow::moveEvent(QMoveEvent *moveEvent)-
2775{-
2776 if (!parent()) {-
2777 QWidget::moveEvent(moveEvent);-
2778 return;-
2779 }-
2780-
2781 QMdiSubWindowPrivate * const d = d_func();-
2782 if (d->isMaximizeMode)-
2783 d->ensureWindowState(Qt::WindowMaximized);-
2784}-
2785-
2786-
2787-
2788-
2789void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)-
2790{-
2791 if (!parent()
!parent()Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(windowFlags()...essWindowHint)Description
TRUEnever evaluated
FALSEnever evaluated
windowFlags() & Qt::FramelessWindowHint)
(windowFlags()...essWindowHint)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2792 QWidget::paintEvent(paintEvent);-
2793 return;
never executed: return;
0
2794 }-
2795-
2796 QMdiSubWindowPrivate * const d = d_func();-
2797 if (isMaximized()
isMaximized()Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->drawTitleBarWhenMaximized()
!d->drawTitleB...henMaximized()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2798 return;
never executed: return;
0
2799-
2800 if (d->resizeTimerId != -1
d->resizeTimerId != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2801-
2802 int border = d->hasBorder(d->cachedStyleOptions)
d->hasBorder(d...dStyleOptions)Description
TRUEnever evaluated
FALSEnever evaluated
? 4 : 0;
0
2803 int titleBarHeight = d->titleBarHeight(d->cachedStyleOptions);-
2804 titleBarHeight -= isMinimized()
isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
? 2 * border : border;
0
2805 d->cachedStyleOptions.rect = QRect(border, border, width() - 2 * border, titleBarHeight);-
2806 if (!d->windowTitle.isEmpty()
!d->windowTitle.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
2807 int width = style()->subControlRect(QStyle::CC_TitleBar, &d->cachedStyleOptions,-
2808 QStyle::SC_TitleBarLabel, this).width();-
2809 d->cachedStyleOptions.text = d->cachedStyleOptions.fontMetrics-
2810 .elidedText(d->windowTitle, Qt::ElideRight, width);-
2811 }
never executed: end of block
0
2812 }
never executed: end of block
else {
0
2813-
2814 d->cachedStyleOptions = d->titleBarOptions();-
2815 }
never executed: end of block
0
2816-
2817 QStylePainter painter(this);-
2818 if (!d->windowTitle.isEmpty()
!d->windowTitle.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2819 painter.setFont(d->font);
never executed: painter.setFont(d->font);
0
2820 painter.drawComplexControl(QStyle::CC_TitleBar, d->cachedStyleOptions);-
2821-
2822 if (isMinimized()
isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->hasBorder(d->cachedStyleOptions)
!d->hasBorder(...dStyleOptions)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2823 return;
never executed: return;
0
2824-
2825 QStyleOptionFrame frameOptions;-
2826 frameOptions.initFrom(this);-
2827 frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this);-
2828 if (d->isActive)frameOptions.state|= QStyle::State_Active;-
else
frameOptions.state &= ~setFlag(QStyle::State_Active;, d->isActive);
2829-
2830-
2831 if (!isMinimized()
!isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
&& !d->hasBorder(d->cachedStyleOptions)
!d->hasBorder(...dStyleOptions)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2832 painter.setClipRect(rect().adjusted(0, d->titleBarHeight(d->cachedStyleOptions), 0, 0));
never executed: painter.setClipRect(rect().adjusted(0, d->titleBarHeight(d->cachedStyleOptions), 0, 0));
0
2833 if (!isMinimized()
!isMinimized()Description
TRUEnever evaluated
FALSEnever evaluated
|| d->hasBorder(d->cachedStyleOptions)
d->hasBorder(d...dStyleOptions)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
2834 painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions);
never executed: painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions);
0
2835}
never executed: end of block
0
2836-
2837-
2838-
2839-
2840void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent)-
2841{-
2842 if (!parent()) {-
2843 QWidget::mousePressEvent(mouseEvent);-
2844 return;-
2845 }-
2846-
2847 QMdiSubWindowPrivate * const d = d_func();-
2848 if (d->isInInteractiveMode)-
2849 d->leaveInteractiveMode();-
2850-
2851 if (d->isInRubberBandMode)-
2852 d->leaveRubberBandMode();-
2853-
2854-
2855 if (mouseEvent->button() != Qt::LeftButton) {-
2856 mouseEvent->ignore();-
2857 return;-
2858 }-
2859-
2860 if (d->currentOperation != QMdiSubWindowPrivate::None) {-
2861 d->updateCursor();-
2862 d->mousePressPosition = mapToParent(mouseEvent->pos());-
2863 if (d->resizeEnabled || d->moveEnabled)-
2864 d->oldGeometry = geometry();-
2865-
2866 if ((testOption(QMdiSubWindow::RubberBandResize) && d->isResizeOperation())-
2867 || (testOption(QMdiSubWindow::RubberBandMove) && d->isMoveOperation())) {-
2868 d->enterRubberBandMode();-
2869 }-
2870-
2871 return;-
2872 }-
2873-
2874 d->activeSubControl = d->hoveredSubControl;-
2875-
2876 if (d->activeSubControl == QStyle::SC_TitleBarSysMenu)-
2877 showSystemMenu();-
2878 else-
2879-
2880 update(QRegion(0, 0, width(), d->titleBarHeight()));-
2881}-
2882-
2883-
2884-
2885-
2886void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *mouseEvent)-
2887{-
2888 if (!parent()) {-
2889 QWidget::mouseDoubleClickEvent(mouseEvent);-
2890 return;-
2891 }-
2892-
2893 if (mouseEvent->button() != Qt::LeftButton) {-
2894 mouseEvent->ignore();-
2895 return;-
2896 }-
2897-
2898 QMdiSubWindowPrivate * const d = d_func();-
2899 if (!d->isMoveOperation()) {-
2900-
2901 if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu)-
2902 close();-
2903-
2904 return;-
2905 }-
2906-
2907 Qt::WindowFlags flags = windowFlags();-
2908 if (isMinimized()) {-
2909 if ((isShaded() && (flags & Qt::WindowShadeButtonHint))-
2910 || (flags & Qt::WindowMinimizeButtonHint)) {-
2911 showNormal();-
2912 }-
2913 return;-
2914 }-
2915-
2916 if (isMaximized()) {-
2917 if (flags & Qt::WindowMaximizeButtonHint)-
2918 showNormal();-
2919 return;-
2920 }-
2921-
2922 if (flags & Qt::WindowShadeButtonHint)-
2923 showShaded();-
2924 else if (flags & Qt::WindowMaximizeButtonHint)-
2925 showMaximized();-
2926}-
2927-
2928-
2929-
2930-
2931void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *mouseEvent)-
2932{-
2933 if (!parent()) {-
2934 QWidget::mouseReleaseEvent(mouseEvent);-
2935 return;-
2936 }-
2937-
2938 if (mouseEvent->button() != Qt::LeftButton) {-
2939 mouseEvent->ignore();-
2940 return;-
2941 }-
2942-
2943 QMdiSubWindowPrivate * const d = d_func();-
2944 if (d->currentOperation != QMdiSubWindowPrivate::None) {-
2945-
2946 if (d->isInRubberBandMode && !d->isInInteractiveMode)-
2947 d->leaveRubberBandMode();-
2948-
2949 if (d->resizeEnabled || d->moveEnabled)-
2950 d->oldGeometry = geometry();-
2951 }-
2952-
2953 d->currentOperation = d->getOperation(mouseEvent->pos());-
2954 d->updateCursor();-
2955-
2956 d->hoveredSubControl = d->getSubControl(mouseEvent->pos());-
2957 if (d->activeSubControl != QStyle::SC_None-
2958 && d->activeSubControl == d->hoveredSubControl) {-
2959 d->processClickedSubControl();-
2960 }-
2961 d->activeSubControl = QStyle::SC_None;-
2962 update(QRegion(0, 0, width(), d->titleBarHeight()));-
2963}-
2964-
2965-
2966-
2967-
2968void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)-
2969{-
2970 if (!parent()) {-
2971 QWidget::mouseMoveEvent(mouseEvent);-
2972 return;-
2973 }-
2974-
2975 QMdiSubWindowPrivate * const d = d_func();-
2976-
2977 if (!d->isMoveOperation() && !d->isResizeOperation()) {-
2978-
2979 const QStyleOptionTitleBar options = d->titleBarOptions();-
2980 QStyle::SubControl oldHover = d->hoveredSubControl;-
2981 d->hoveredSubControl = d->getSubControl(mouseEvent->pos());-
2982 QRegion hoverRegion;-
2983 if (isHoverControl(oldHover) && oldHover != d->hoveredSubControl)-
2984 hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this);-
2985 if (isHoverControl(d->hoveredSubControl) && d->hoveredSubControl != oldHover) {-
2986 hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options,-
2987 d->hoveredSubControl, this);-
2988 }-
2989-
2990-
2991-
2992-
2993 if (!hoverRegion.isEmpty())-
2994 update(hoverRegion);-
2995 }-
2996-
2997 if ((mouseEvent->buttons() & Qt::LeftButton) || d->isInInteractiveMode) {-
2998 if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled))-
2999 d->setNewGeometry(mapToParent(mouseEvent->pos()));-
3000 return;-
3001 }-
3002-
3003-
3004 d->currentOperation = d->getOperation(mouseEvent->pos());-
3005 if ((d->isResizeOperation() && !d->resizeEnabled) || (d->isMoveOperation() && !d->moveEnabled))-
3006 d->currentOperation = QMdiSubWindowPrivate::None;-
3007 d->updateCursor();-
3008}-
3009-
3010-
3011-
3012-
3013void QMdiSubWindow::keyPressEvent(QKeyEvent *keyEvent)-
3014{-
3015 QMdiSubWindowPrivate * const d = d_func();-
3016 if (!d->isInInteractiveMode || !parent()) {-
3017 keyEvent->ignore();-
3018 return;-
3019 }-
3020-
3021 QPoint delta;-
3022 switch (keyEvent->key()) {-
3023 case Qt::Key_Right:-
3024 if (keyEvent->modifiers() & Qt::ShiftModifier)-
3025 delta = QPoint(d->keyboardPageStep, 0);-
3026 else-
3027 delta = QPoint(d->keyboardSingleStep, 0);-
3028 break;-
3029 case Qt::Key_Up:-
3030 if (keyEvent->modifiers() & Qt::ShiftModifier)-
3031 delta = QPoint(0, -d->keyboardPageStep);-
3032 else-
3033 delta = QPoint(0, -d->keyboardSingleStep);-
3034 break;-
3035 case Qt::Key_Left:-
3036 if (keyEvent->modifiers() & Qt::ShiftModifier)-
3037 delta = QPoint(-d->keyboardPageStep, 0);-
3038 else-
3039 delta = QPoint(-d->keyboardSingleStep, 0);-
3040 break;-
3041 case Qt::Key_Down:-
3042 if (keyEvent->modifiers() & Qt::ShiftModifier)-
3043 delta = QPoint(0, d->keyboardPageStep);-
3044 else-
3045 delta = QPoint(0, d->keyboardSingleStep);-
3046 break;-
3047 case Qt::Key_Escape:-
3048 case Qt::Key_Return:-
3049 case Qt::Key_Enter:-
3050 d->leaveInteractiveMode();-
3051 return;-
3052 default:-
3053 keyEvent->ignore();-
3054 return;-
3055 }-
3056-
3057-
3058 QPoint newPosition = parentWidget()->mapFromGlobal(cursor().pos() + delta);-
3059 QRect oldGeometry =-
3060-
3061 d->isInRubberBandMode ? d->rubberBand->geometry() :-
3062-
3063 geometry();-
3064 d->setNewGeometry(newPosition);-
3065 QRect currentGeometry =-
3066-
3067 d->isInRubberBandMode ? d->rubberBand->geometry() :-
3068-
3069 geometry();-
3070 if (currentGeometry == oldGeometry)-
3071 return;-
3072-
3073-
3074-
3075 QPoint actualDelta;-
3076 if (d->isMoveOperation()) {-
3077 actualDelta = QPoint(currentGeometry.x() - oldGeometry.x(),-
3078 currentGeometry.y() - oldGeometry.y());-
3079 } else {-
3080 int dx = isLeftToRight() ? currentGeometry.width() - oldGeometry.width()-
3081 : currentGeometry.x() - oldGeometry.x();-
3082 actualDelta = QPoint(dx, currentGeometry.height() - oldGeometry.height());-
3083 }-
3084-
3085-
3086 if (actualDelta != delta)-
3087 newPosition += (actualDelta - delta);-
3088 cursor().setPos(parentWidget()->mapToGlobal(newPosition));-
3089-
3090}-
3091-
3092-
3093-
3094-
3095-
3096void QMdiSubWindow::contextMenuEvent(QContextMenuEvent *contextMenuEvent)-
3097{-
3098 QMdiSubWindowPrivate * const d = d_func();-
3099 if (!d->systemMenu) {-
3100 contextMenuEvent->ignore();-
3101 return;-
3102 }-
3103-
3104 if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu-
3105 || d->getRegion(QMdiSubWindowPrivate::Move).contains(contextMenuEvent->pos())) {-
3106 d->systemMenu->exec(contextMenuEvent->globalPos());-
3107 } else {-
3108 contextMenuEvent->ignore();-
3109 }-
3110}-
3111-
3112-
3113-
3114-
3115-
3116void QMdiSubWindow::focusInEvent(QFocusEvent *focusInEvent)-
3117{-
3118 d_func()->focusInReason = focusInEvent->reason();-
3119}-
3120-
3121-
3122-
3123-
3124void QMdiSubWindow::focusOutEvent(QFocusEvent * )-
3125{-
3126-
3127}-
3128-
3129-
3130-
3131-
3132void QMdiSubWindow::childEvent(QChildEvent *childEvent)-
3133{-
3134 if (childEvent->type() != QEvent::ChildPolished)-
3135 return;-
3136-
3137 if (QSizeGrip *sizeGrip = qobject_cast<QSizeGrip *>(childEvent->child()))-
3138 d_func()->setSizeGrip(sizeGrip);-
3139-
3140}-
3141-
3142-
3143-
3144-
3145QSize QMdiSubWindow::sizeHint() const-
3146{-
3147 const QMdiSubWindowPrivate * const d = d_func();-
3148 int margin, minWidth;-
3149 d->sizeParameters(&margin, &minWidth);-
3150 QSize size(2 * margin, d->titleBarHeight() + margin);-
3151 if (d->baseWidget && d->baseWidget->sizeHint().isValid())-
3152 size += d->baseWidget->sizeHint();-
3153 return size.expandedTo(minimumSizeHint());-
3154}-
3155-
3156-
3157-
3158-
3159QSize QMdiSubWindow::minimumSizeHint() const-
3160{-
3161 const QMdiSubWindowPrivate * const d = d_func();-
3162 if (isVisible())-
3163 ensurePolished();-
3164-
3165-
3166 if (parent() && isMinimized() && !isShaded())-
3167 return d->iconSize();-
3168-
3169-
3170 int margin, minWidth;-
3171 d->sizeParameters(&margin, &minWidth);-
3172 int decorationHeight = margin + d->titleBarHeight();-
3173 int minHeight = decorationHeight;-
3174-
3175-
3176 if (parent() && isShaded())-
3177 return QSize(qMax(minWidth, width()), d->titleBarHeight());-
3178-
3179-
3180 if (layout()) {-
3181 QSize minLayoutSize = layout()->minimumSize();-
3182 if (minLayoutSize.isValid()) {-
3183 minWidth = qMax(minWidth, minLayoutSize.width() + 2 * margin);-
3184 minHeight += minLayoutSize.height();-
3185 }-
3186 } else if (d->baseWidget && d->baseWidget->isVisible()) {-
3187 QSize minBaseWidgetSize = d->baseWidget->minimumSizeHint();-
3188 if (minBaseWidgetSize.isValid()) {-
3189 minWidth = qMax(minWidth, minBaseWidgetSize.width() + 2 * margin);-
3190 minHeight += minBaseWidgetSize.height();-
3191 }-
3192 }-
3193-
3194-
3195-
3196 int sizeGripHeight = 0;-
3197 if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this)))-
3198 sizeGripHeight = d->sizeGrip->height();-
3199-
3200-
3201-
3202-
3203 minHeight = qMax(minHeight, decorationHeight + sizeGripHeight);-
3204-
3205-
3206 return QSize(minWidth, minHeight).expandedTo(QApplication::globalStrut());-
3207}-
3208-
3209-
3210-
Switch to Source codePreprocessed file

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