| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmdisubwindow.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | /*! | - | ||||||||||||||||||||||||
| 35 | \class QMdiSubWindow | - | ||||||||||||||||||||||||
| 36 | \brief The QMdiSubWindow class provides a subwindow class for | - | ||||||||||||||||||||||||
| 37 | QMdiArea. | - | ||||||||||||||||||||||||
| 38 | \since 4.3 | - | ||||||||||||||||||||||||
| 39 | \ingroup mainwindow-classes | - | ||||||||||||||||||||||||
| 40 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | QMdiSubWindow represents a top-level window in a QMdiArea, and consists | - | ||||||||||||||||||||||||
| 43 | of a title bar with window decorations, an internal widget, and | - | ||||||||||||||||||||||||
| 44 | (depending on the current style) a window frame and a size | - | ||||||||||||||||||||||||
| 45 | grip. QMdiSubWindow has its own layout, which consists of the | - | ||||||||||||||||||||||||
| 46 | title bar and a center area for the internal widget. | - | ||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | \image qmdisubwindowlayout.png | - | ||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | The most common way to construct a QMdiSubWindow is to call | - | ||||||||||||||||||||||||
| 51 | QMdiArea::addSubWindow() with the internal widget as the argument. | - | ||||||||||||||||||||||||
| 52 | You can also create a subwindow yourself, and set an internal | - | ||||||||||||||||||||||||
| 53 | widget by calling setWidget(). | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | You use the same API when programming with subwindows as with | - | ||||||||||||||||||||||||
| 56 | regular top-level windows (e.g., you can call functions such as | - | ||||||||||||||||||||||||
| 57 | show(), hide(), showMaximized(), and setWindowTitle()). | - | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | \section1 Subwindow Handling | - | ||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | QMdiSubWindow also supports behavior specific to subwindows in | - | ||||||||||||||||||||||||
| 62 | an MDI area. | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | By default, each QMdiSubWindow is visible inside the MDI area | - | ||||||||||||||||||||||||
| 65 | viewport when moved around, but it is also possible to specify | - | ||||||||||||||||||||||||
| 66 | transparent window movement and resizing behavior, where only | - | ||||||||||||||||||||||||
| 67 | the outline of a subwindow is updated during these operations. | - | ||||||||||||||||||||||||
| 68 | The setOption() function is used to enable this behavior. | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | The isShaded() function detects whether the subwindow is | - | ||||||||||||||||||||||||
| 71 | currently shaded (i.e., the window is collapsed so that only the | - | ||||||||||||||||||||||||
| 72 | title bar is visible). To enter shaded mode, call showShaded(). | - | ||||||||||||||||||||||||
| 73 | QMdiSubWindow emits the windowStateChanged() signal whenever the | - | ||||||||||||||||||||||||
| 74 | window state has changed (e.g., when the window becomes minimized, | - | ||||||||||||||||||||||||
| 75 | or is restored). It also emits aboutToActivate() before it is | - | ||||||||||||||||||||||||
| 76 | activated. | - | ||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | In keyboard-interactive mode, the windows are moved and resized | - | ||||||||||||||||||||||||
| 79 | with the keyboard. You can enter this mode through the system menu | - | ||||||||||||||||||||||||
| 80 | of the window. The keyboardSingleStep and keyboardPageStep | - | ||||||||||||||||||||||||
| 81 | properties control the distance the widget is moved or resized for | - | ||||||||||||||||||||||||
| 82 | each keypress event. When shift is pressed down page step is used; | - | ||||||||||||||||||||||||
| 83 | otherwise single step is used. | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | You can also change the active window with the keyboard. By | - | ||||||||||||||||||||||||
| 86 | pressing the control and tab keys at the same time, the next | - | ||||||||||||||||||||||||
| 87 | (using the current \l{QMdiArea::}{WindowOrder}) subwindow will be | - | ||||||||||||||||||||||||
| 88 | activated. By pressing control, shift, and tab, you will activate | - | ||||||||||||||||||||||||
| 89 | the previous window. This is equivalent to calling | - | ||||||||||||||||||||||||
| 90 | \l{QMdiArea::}{activateNextSubWindow()} and | - | ||||||||||||||||||||||||
| 91 | \l{QMdiArea::}{activatePreviousSubWindow()}. Note that these | - | ||||||||||||||||||||||||
| 92 | shortcuts overrides global shortcuts, but not the \l{QMdiArea}s | - | ||||||||||||||||||||||||
| 93 | shortcuts. | - | ||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | \sa QMdiArea | - | ||||||||||||||||||||||||
| 96 | */ | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | /*! | - | ||||||||||||||||||||||||
| 99 | \enum QMdiSubWindow::SubWindowOption | - | ||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||
| 101 | This enum describes options that customize the behavior | - | ||||||||||||||||||||||||
| 102 | of QMdiSubWindow. | - | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | \omitvalue AllowOutsideAreaHorizontally | - | ||||||||||||||||||||||||
| 105 | \omitvalue AllowOutsideAreaVertically | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | \value RubberBandResize If you enable this option, a rubber band | - | ||||||||||||||||||||||||
| 108 | control is used to represent the subwindow's outline, and the user | - | ||||||||||||||||||||||||
| 109 | resizes this instead of the subwindow itself. | - | ||||||||||||||||||||||||
| 110 | As a result, the subwindow maintains its original position and size | - | ||||||||||||||||||||||||
| 111 | until the resize operation has been completed, at which time it will | - | ||||||||||||||||||||||||
| 112 | receive a single QResizeEvent. | - | ||||||||||||||||||||||||
| 113 | By default, this option is disabled. | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | \value RubberBandMove If you enable this option, a rubber band | - | ||||||||||||||||||||||||
| 116 | control is used to represent the subwindow's outline, and the user | - | ||||||||||||||||||||||||
| 117 | moves this instead of the subwindow itself. | - | ||||||||||||||||||||||||
| 118 | As a result, the subwindow remains in its original position until | - | ||||||||||||||||||||||||
| 119 | the move operation has completed, at which time a QMoveEvent is | - | ||||||||||||||||||||||||
| 120 | sent to the window. By default, this option is disabled. | - | ||||||||||||||||||||||||
| 121 | */ | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | /*! | - | ||||||||||||||||||||||||
| 124 | \fn QMdiSubWindow::windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState) | - | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | QMdiSubWindow emits this signal after the window state changes. \a | - | ||||||||||||||||||||||||
| 127 | oldState is the window state before it changed, and \a newState is the | - | ||||||||||||||||||||||||
| 128 | new, current state. | - | ||||||||||||||||||||||||
| 129 | */ | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | /*! | - | ||||||||||||||||||||||||
| 132 | \fn QMdiSubWindow::aboutToActivate() | - | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | QMdiSubWindow emits this signal immediately before it is | - | ||||||||||||||||||||||||
| 135 | activated. After the subwindow has been activated, the QMdiArea that | - | ||||||||||||||||||||||||
| 136 | manages the subwindow will also emit the | - | ||||||||||||||||||||||||
| 137 | \l{QMdiArea::}{subWindowActivated()} signal. | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | \sa QMdiArea::subWindowActivated() | - | ||||||||||||||||||||||||
| 140 | */ | - | ||||||||||||||||||||||||
| 141 | - | |||||||||||||||||||||||||
| 142 | #include "qmdisubwindow_p.h" | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | #ifndef QT_NO_MDIAREA | - | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | #include <QApplication> | - | ||||||||||||||||||||||||
| 147 | #include <QStylePainter> | - | ||||||||||||||||||||||||
| 148 | #include <QVBoxLayout> | - | ||||||||||||||||||||||||
| 149 | #include <QMouseEvent> | - | ||||||||||||||||||||||||
| 150 | #include <QWhatsThis> | - | ||||||||||||||||||||||||
| 151 | #include <QToolTip> | - | ||||||||||||||||||||||||
| 152 | #include <QMainWindow> | - | ||||||||||||||||||||||||
| 153 | #include <QScrollBar> | - | ||||||||||||||||||||||||
| 154 | #include <QDebug> | - | ||||||||||||||||||||||||
| 155 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 156 | #include <private/qmacstyle_mac_p.h> | - | ||||||||||||||||||||||||
| 157 | #endif | - | ||||||||||||||||||||||||
| 158 | #include <QMdiArea> | - | ||||||||||||||||||||||||
| 159 | #include <QScopedValueRollback> | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | using namespace QMdi; | - | ||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||
| 165 | static const QStyle::SubControl SubControls[] = | - | ||||||||||||||||||||||||
| 166 | { | - | ||||||||||||||||||||||||
| 167 | QStyle::SC_TitleBarLabel, // 1 | - | ||||||||||||||||||||||||
| 168 | QStyle::SC_TitleBarSysMenu, // 2 | - | ||||||||||||||||||||||||
| 169 | QStyle::SC_TitleBarMinButton, // 3 | - | ||||||||||||||||||||||||
| 170 | QStyle::SC_TitleBarMaxButton, // 4 | - | ||||||||||||||||||||||||
| 171 | QStyle::SC_TitleBarShadeButton, // 5 | - | ||||||||||||||||||||||||
| 172 | QStyle::SC_TitleBarCloseButton, // 6 | - | ||||||||||||||||||||||||
| 173 | QStyle::SC_TitleBarNormalButton, // 7 | - | ||||||||||||||||||||||||
| 174 | QStyle::SC_TitleBarUnshadeButton, // 8 | - | ||||||||||||||||||||||||
| 175 | QStyle::SC_TitleBarContextHelpButton // 9 | - | ||||||||||||||||||||||||
| 176 | }; | - | ||||||||||||||||||||||||
| 177 | static const int NumSubControls = sizeof(SubControls) / sizeof(SubControls[0]); | - | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | static const Qt::WindowFlags CustomizeWindowFlags = | - | ||||||||||||||||||||||||
| 180 | Qt::FramelessWindowHint | - | ||||||||||||||||||||||||
| 181 | | Qt::CustomizeWindowHint | - | ||||||||||||||||||||||||
| 182 | | Qt::WindowTitleHint | - | ||||||||||||||||||||||||
| 183 | | Qt::WindowSystemMenuHint | - | ||||||||||||||||||||||||
| 184 | | Qt::WindowMinimizeButtonHint | - | ||||||||||||||||||||||||
| 185 | | Qt::WindowMaximizeButtonHint | - | ||||||||||||||||||||||||
| 186 | | Qt::WindowMinMaxButtonsHint; | - | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | static const int BoundaryMargin = 5; | - | ||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||
| 191 | static inline int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag, | - | ||||||||||||||||||||||||
| 192 | int delta, int maxDelta, int minDelta) | - | ||||||||||||||||||||||||
| 193 | { | - | ||||||||||||||||||||||||
| 194 | if (cflags & moveFlag) {
| 0 | ||||||||||||||||||||||||
| 195 | if (delta > 0)
| 0 | ||||||||||||||||||||||||
| 196 | return (cflags & resizeFlag) ? qMin(delta, maxDelta) : delta; never executed: return (cflags & resizeFlag) ? qMin(delta, maxDelta) : delta;
| 0 | ||||||||||||||||||||||||
| 197 | return (cflags & resizeFlag) ? qMax(delta, minDelta) : delta; never executed: return (cflags & resizeFlag) ? qMax(delta, minDelta) : delta;
| 0 | ||||||||||||||||||||||||
| 198 | } | - | ||||||||||||||||||||||||
| 199 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 200 | } | - | ||||||||||||||||||||||||
| 201 | - | |||||||||||||||||||||||||
| 202 | static inline int getResizeDeltaComponent(uint cflags, uint resizeFlag, | - | ||||||||||||||||||||||||
| 203 | uint resizeReverseFlag, int delta) | - | ||||||||||||||||||||||||
| 204 | { | - | ||||||||||||||||||||||||
| 205 | if (cflags & resizeFlag) {
| 0 | ||||||||||||||||||||||||
| 206 | if (cflags & resizeReverseFlag)
| 0 | ||||||||||||||||||||||||
| 207 | return -delta; never executed: return -delta; | 0 | ||||||||||||||||||||||||
| 208 | return delta; never executed: return delta; | 0 | ||||||||||||||||||||||||
| 209 | } | - | ||||||||||||||||||||||||
| 210 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 211 | } | - | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | static inline bool isChildOfQMdiSubWindow(const QWidget *child) | - | ||||||||||||||||||||||||
| 214 | { | - | ||||||||||||||||||||||||
| 215 | Q_ASSERT(child); | - | ||||||||||||||||||||||||
| 216 | QWidget *parent = child->parentWidget(); | - | ||||||||||||||||||||||||
| 217 | while (parent) {
| 0 | ||||||||||||||||||||||||
| 218 | if (qobject_cast<QMdiSubWindow *>(parent))
| 0 | ||||||||||||||||||||||||
| 219 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 220 | parent = parent->parentWidget(); | - | ||||||||||||||||||||||||
| 221 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 222 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 223 | } | - | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | static inline bool isChildOfTabbedQMdiArea(const QMdiSubWindow *child) | - | ||||||||||||||||||||||||
| 226 | { | - | ||||||||||||||||||||||||
| 227 | Q_ASSERT(child); | - | ||||||||||||||||||||||||
| 228 | if (QMdiArea *mdiArea = child->mdiArea()) {
| 0 | ||||||||||||||||||||||||
| 229 | if (mdiArea->viewMode() == QMdiArea::TabbedView)
| 0 | ||||||||||||||||||||||||
| 230 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 231 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 232 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 233 | } | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | template<typename T> | - | ||||||||||||||||||||||||
| 236 | static inline ControlElement<T> *ptr(QWidget *widget) | - | ||||||||||||||||||||||||
| 237 | { | - | ||||||||||||||||||||||||
| 238 | if (widget && widget->qt_metacast("ControlElement")
| 0 | ||||||||||||||||||||||||
| 239 | && strcmp(widget->metaObject()->className(), T::staticMetaObject.className()) == 0) {
| 0 | ||||||||||||||||||||||||
| 240 | return static_cast<ControlElement<T> *>(widget); never executed: return static_cast<ControlElement<T> *>(widget); | 0 | ||||||||||||||||||||||||
| 241 | } | - | ||||||||||||||||||||||||
| 242 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 243 | } | - | ||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||
| 245 | QString QMdiSubWindowPrivate::originalWindowTitle() | - | ||||||||||||||||||||||||
| 246 | { | - | ||||||||||||||||||||||||
| 247 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 248 | if (originalTitle.isNull()) {
| 0 | ||||||||||||||||||||||||
| 249 | originalTitle = q->window()->windowTitle(); | - | ||||||||||||||||||||||||
| 250 | if (originalTitle.isNull())
| 0 | ||||||||||||||||||||||||
| 251 | originalTitle = QLatin1String(""); never executed: originalTitle = QLatin1String(""); | 0 | ||||||||||||||||||||||||
| 252 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 253 | return originalTitle; never executed: return originalTitle; | 0 | ||||||||||||||||||||||||
| 254 | } | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | void QMdiSubWindowPrivate::setNewWindowTitle() | - | ||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||
| 258 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 259 | QString childTitle = q->windowTitle(); | - | ||||||||||||||||||||||||
| 260 | if (childTitle.isEmpty())
| 0 | ||||||||||||||||||||||||
| 261 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 262 | QString original = originalWindowTitle(); | - | ||||||||||||||||||||||||
| 263 | if (!original.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 264 | if (!original.contains(QMdiSubWindow::tr("- [%1]").arg(childTitle)))
| 0 | ||||||||||||||||||||||||
| 265 | q->window()->setWindowTitle(QMdiSubWindow::tr("%1 - [%2]").arg(original, childTitle)); never executed: q->window()->setWindowTitle(QMdiSubWindow::tr("%1 - [%2]").arg(original, childTitle)); | 0 | ||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||
| 267 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 268 | q->window()->setWindowTitle(childTitle); | - | ||||||||||||||||||||||||
| 269 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 270 | } | - | ||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | static inline bool isHoverControl(QStyle::SubControl control) | - | ||||||||||||||||||||||||
| 273 | { | - | ||||||||||||||||||||||||
| 274 | return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel; never executed: return control != QStyle::SC_None && control != QStyle::SC_TitleBarLabel;
| 0 | ||||||||||||||||||||||||
| 275 | } | - | ||||||||||||||||||||||||
| 276 | - | |||||||||||||||||||||||||
| 277 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||||||||
| 278 | static inline QRgb colorref2qrgb(COLORREF col) | - | ||||||||||||||||||||||||
| 279 | { | - | ||||||||||||||||||||||||
| 280 | return qRgb(GetRValue(col),GetGValue(col),GetBValue(col)); | - | ||||||||||||||||||||||||
| 281 | } | - | ||||||||||||||||||||||||
| 282 | #endif | - | ||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 285 | static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOptionComplex &opt, | - | ||||||||||||||||||||||||
| 286 | QStyle::ComplexControl complexControl, QStyle::SubControl subControl) | - | ||||||||||||||||||||||||
| 287 | { | - | ||||||||||||||||||||||||
| 288 | Q_ASSERT(helpEvent); | - | ||||||||||||||||||||||||
| 289 | Q_ASSERT(helpEvent->type() == QEvent::ToolTip); | - | ||||||||||||||||||||||||
| 290 | Q_ASSERT(widget); | - | ||||||||||||||||||||||||
| 291 | - | |||||||||||||||||||||||||
| 292 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 293 | // Native Mac windows don't show tool tip. | - | ||||||||||||||||||||||||
| 294 | if (qobject_cast<QMacStyle *>(widget->style())) | - | ||||||||||||||||||||||||
| 295 | return; | - | ||||||||||||||||||||||||
| 296 | #endif | - | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | // Convert CC_MdiControls to CC_TitleBar. Sub controls of different complex | - | ||||||||||||||||||||||||
| 299 | // controls cannot be in the same switch as they might have the same value. | - | ||||||||||||||||||||||||
| 300 | if (complexControl == QStyle::CC_MdiControls) {
| 0 | ||||||||||||||||||||||||
| 301 | if (subControl == QStyle::SC_MdiMinButton)
| 0 | ||||||||||||||||||||||||
| 302 | subControl = QStyle::SC_TitleBarMinButton; never executed: subControl = QStyle::SC_TitleBarMinButton; | 0 | ||||||||||||||||||||||||
| 303 | else if (subControl == QStyle::SC_MdiCloseButton)
| 0 | ||||||||||||||||||||||||
| 304 | subControl = QStyle::SC_TitleBarCloseButton; never executed: subControl = QStyle::SC_TitleBarCloseButton; | 0 | ||||||||||||||||||||||||
| 305 | else if (subControl == QStyle::SC_MdiNormalButton)
| 0 | ||||||||||||||||||||||||
| 306 | subControl = QStyle::SC_TitleBarNormalButton; never executed: subControl = QStyle::SC_TitleBarNormalButton; | 0 | ||||||||||||||||||||||||
| 307 | else | - | ||||||||||||||||||||||||
| 308 | subControl = QStyle::SC_None; never executed: subControl = QStyle::SC_None; | 0 | ||||||||||||||||||||||||
| 309 | } | - | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | // Don't change the tooltip for the base widget itself. | - | ||||||||||||||||||||||||
| 312 | if (subControl == QStyle::SC_None)
| 0 | ||||||||||||||||||||||||
| 313 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | QString toolTip; | - | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | switch (subControl) { | - | ||||||||||||||||||||||||
| 318 | case QStyle::SC_TitleBarMinButton: never executed: case QStyle::SC_TitleBarMinButton: | 0 | ||||||||||||||||||||||||
| 319 | toolTip = QMdiSubWindow::tr("Minimize"); | - | ||||||||||||||||||||||||
| 320 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 321 | case QStyle::SC_TitleBarMaxButton: never executed: case QStyle::SC_TitleBarMaxButton: | 0 | ||||||||||||||||||||||||
| 322 | toolTip = QMdiSubWindow::tr("Maximize"); | - | ||||||||||||||||||||||||
| 323 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 324 | case QStyle::SC_TitleBarUnshadeButton: never executed: case QStyle::SC_TitleBarUnshadeButton: | 0 | ||||||||||||||||||||||||
| 325 | toolTip = QMdiSubWindow::tr("Unshade"); | - | ||||||||||||||||||||||||
| 326 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 327 | case QStyle::SC_TitleBarShadeButton: never executed: case QStyle::SC_TitleBarShadeButton: | 0 | ||||||||||||||||||||||||
| 328 | toolTip = QMdiSubWindow::tr("Shade"); | - | ||||||||||||||||||||||||
| 329 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 330 | case QStyle::SC_TitleBarNormalButton: never executed: case QStyle::SC_TitleBarNormalButton: | 0 | ||||||||||||||||||||||||
| 331 | if (widget->isMaximized() || !qobject_cast<QMdiSubWindow *>(widget))
| 0 | ||||||||||||||||||||||||
| 332 | toolTip = QMdiSubWindow::tr("Restore Down"); never executed: toolTip = QMdiSubWindow::tr("Restore Down"); | 0 | ||||||||||||||||||||||||
| 333 | else | - | ||||||||||||||||||||||||
| 334 | toolTip = QMdiSubWindow::tr("Restore"); never executed: toolTip = QMdiSubWindow::tr("Restore"); | 0 | ||||||||||||||||||||||||
| 335 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 336 | case QStyle::SC_TitleBarCloseButton: never executed: case QStyle::SC_TitleBarCloseButton: | 0 | ||||||||||||||||||||||||
| 337 | toolTip = QMdiSubWindow::tr("Close"); | - | ||||||||||||||||||||||||
| 338 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 339 | case QStyle::SC_TitleBarContextHelpButton: never executed: case QStyle::SC_TitleBarContextHelpButton: | 0 | ||||||||||||||||||||||||
| 340 | toolTip = QMdiSubWindow::tr("Help"); | - | ||||||||||||||||||||||||
| 341 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 342 | case QStyle::SC_TitleBarSysMenu: never executed: case QStyle::SC_TitleBarSysMenu: | 0 | ||||||||||||||||||||||||
| 343 | toolTip = QMdiSubWindow::tr("Menu"); | - | ||||||||||||||||||||||||
| 344 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 345 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 346 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 347 | } | - | ||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||
| 349 | const QRect rect = widget->style()->subControlRect(complexControl, &opt, subControl, widget); | - | ||||||||||||||||||||||||
| 350 | QToolTip::showText(helpEvent->globalPos(), toolTip, widget, rect); | - | ||||||||||||||||||||||||
| 351 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 352 | #endif // QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | namespace QMdi { | - | ||||||||||||||||||||||||
| 355 | /* | - | ||||||||||||||||||||||||
| 356 | \class ControlLabel | - | ||||||||||||||||||||||||
| 357 | \internal | - | ||||||||||||||||||||||||
| 358 | */ | - | ||||||||||||||||||||||||
| 359 | class ControlLabel : public QWidget | - | ||||||||||||||||||||||||
| 360 | { | - | ||||||||||||||||||||||||
| 361 | Q_OBJECT | - | ||||||||||||||||||||||||
| 362 | public: | - | ||||||||||||||||||||||||
| 363 | ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0); | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | QSize sizeHint() const Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||
| 367 | signals: | - | ||||||||||||||||||||||||
| 368 | void _q_clicked(); | - | ||||||||||||||||||||||||
| 369 | void _q_doubleClicked(); | - | ||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||
| 371 | protected: | - | ||||||||||||||||||||||||
| 372 | bool event(QEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 373 | void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 374 | void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 375 | void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 376 | void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | private: | - | ||||||||||||||||||||||||
| 379 | QPixmap label; | - | ||||||||||||||||||||||||
| 380 | bool isPressed; | - | ||||||||||||||||||||||||
| 381 | void updateWindowIcon(); | - | ||||||||||||||||||||||||
| 382 | }; | - | ||||||||||||||||||||||||
| 383 | } // namespace QMdi | - | ||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | ControlLabel::ControlLabel(QMdiSubWindow *subWindow, QWidget *parent) | - | ||||||||||||||||||||||||
| 386 | : QWidget(parent), isPressed(false) | - | ||||||||||||||||||||||||
| 387 | { | - | ||||||||||||||||||||||||
| 388 | Q_UNUSED(subWindow); | - | ||||||||||||||||||||||||
| 389 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||||||||
| 390 | updateWindowIcon(); | - | ||||||||||||||||||||||||
| 391 | setFixedSize(label.size()); | - | ||||||||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | /* | - | ||||||||||||||||||||||||
| 395 | \internal | - | ||||||||||||||||||||||||
| 396 | */ | - | ||||||||||||||||||||||||
| 397 | QSize ControlLabel::sizeHint() const | - | ||||||||||||||||||||||||
| 398 | { | - | ||||||||||||||||||||||||
| 399 | return label.size(); never executed: return label.size(); | 0 | ||||||||||||||||||||||||
| 400 | } | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | /* | - | ||||||||||||||||||||||||
| 403 | \internal | - | ||||||||||||||||||||||||
| 404 | */ | - | ||||||||||||||||||||||||
| 405 | bool ControlLabel::event(QEvent *event) | - | ||||||||||||||||||||||||
| 406 | { | - | ||||||||||||||||||||||||
| 407 | if (event->type() == QEvent::WindowIconChange)
| 0 | ||||||||||||||||||||||||
| 408 | updateWindowIcon(); never executed: updateWindowIcon(); | 0 | ||||||||||||||||||||||||
| 409 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 410 | else if (event->type() == QEvent::ToolTip) {
| 0 | ||||||||||||||||||||||||
| 411 | QStyleOptionTitleBar options; | - | ||||||||||||||||||||||||
| 412 | options.initFrom(this); | - | ||||||||||||||||||||||||
| 413 | showToolTip(static_cast<QHelpEvent *>(event), this, options, | - | ||||||||||||||||||||||||
| 414 | QStyle::CC_TitleBar, QStyle::SC_TitleBarSysMenu); | - | ||||||||||||||||||||||||
| 415 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 416 | #endif | - | ||||||||||||||||||||||||
| 417 | return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||||||||
| 418 | } | - | ||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||
| 420 | /* | - | ||||||||||||||||||||||||
| 421 | \internal | - | ||||||||||||||||||||||||
| 422 | */ | - | ||||||||||||||||||||||||
| 423 | void ControlLabel::paintEvent(QPaintEvent * /*paintEvent*/) | - | ||||||||||||||||||||||||
| 424 | { | - | ||||||||||||||||||||||||
| 425 | QPainter painter(this); | - | ||||||||||||||||||||||||
| 426 | painter.drawPixmap(0, 0, label); | - | ||||||||||||||||||||||||
| 427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 428 | - | |||||||||||||||||||||||||
| 429 | /* | - | ||||||||||||||||||||||||
| 430 | \internal | - | ||||||||||||||||||||||||
| 431 | */ | - | ||||||||||||||||||||||||
| 432 | void ControlLabel::mousePressEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 433 | { | - | ||||||||||||||||||||||||
| 434 | if (mouseEvent->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 435 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 436 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 437 | } | - | ||||||||||||||||||||||||
| 438 | isPressed = true; | - | ||||||||||||||||||||||||
| 439 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | /* | - | ||||||||||||||||||||||||
| 442 | \internal | - | ||||||||||||||||||||||||
| 443 | */ | - | ||||||||||||||||||||||||
| 444 | void ControlLabel::mouseDoubleClickEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 445 | { | - | ||||||||||||||||||||||||
| 446 | if (mouseEvent->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 447 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 448 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 449 | } | - | ||||||||||||||||||||||||
| 450 | isPressed = false; | - | ||||||||||||||||||||||||
| 451 | emit _q_doubleClicked(); | - | ||||||||||||||||||||||||
| 452 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | /* | - | ||||||||||||||||||||||||
| 455 | \internal | - | ||||||||||||||||||||||||
| 456 | */ | - | ||||||||||||||||||||||||
| 457 | void ControlLabel::mouseReleaseEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 458 | { | - | ||||||||||||||||||||||||
| 459 | if (mouseEvent->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 460 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 461 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 462 | } | - | ||||||||||||||||||||||||
| 463 | if (isPressed) {
| 0 | ||||||||||||||||||||||||
| 464 | isPressed = false; | - | ||||||||||||||||||||||||
| 465 | emit _q_clicked(); | - | ||||||||||||||||||||||||
| 466 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | /* | - | ||||||||||||||||||||||||
| 470 | \internal | - | ||||||||||||||||||||||||
| 471 | */ | - | ||||||||||||||||||||||||
| 472 | void ControlLabel::updateWindowIcon() | - | ||||||||||||||||||||||||
| 473 | { | - | ||||||||||||||||||||||||
| 474 | QIcon menuIcon = windowIcon(); | - | ||||||||||||||||||||||||
| 475 | if (menuIcon.isNull())
| 0 | ||||||||||||||||||||||||
| 476 | menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget()); never executed: menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget()); | 0 | ||||||||||||||||||||||||
| 477 | label = menuIcon.pixmap(16, 16); | - | ||||||||||||||||||||||||
| 478 | update(); | - | ||||||||||||||||||||||||
| 479 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | namespace QMdi { | - | ||||||||||||||||||||||||
| 482 | /* | - | ||||||||||||||||||||||||
| 483 | \class ControllerWidget | - | ||||||||||||||||||||||||
| 484 | \internal | - | ||||||||||||||||||||||||
| 485 | */ | - | ||||||||||||||||||||||||
| 486 | class ControllerWidget : public QWidget | - | ||||||||||||||||||||||||
| 487 | { | - | ||||||||||||||||||||||||
| 488 | Q_OBJECT | - | ||||||||||||||||||||||||
| 489 | public: | - | ||||||||||||||||||||||||
| 490 | ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0); | - | ||||||||||||||||||||||||
| 491 | QSize sizeHint() const Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 492 | void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible); | - | ||||||||||||||||||||||||
| 493 | inline bool hasVisibleControls() const | - | ||||||||||||||||||||||||
| 494 | { | - | ||||||||||||||||||||||||
| 495 | return (visibleControls & QStyle::SC_MdiMinButton) never executed: return (visibleControls & QStyle::SC_MdiMinButton) || (visibleControls & QStyle::SC_MdiNormalButton) || (visibleControls & QStyle::SC_MdiCloseButton);
| 0 | ||||||||||||||||||||||||
| 496 | || (visibleControls & QStyle::SC_MdiNormalButton) never executed: return (visibleControls & QStyle::SC_MdiMinButton) || (visibleControls & QStyle::SC_MdiNormalButton) || (visibleControls & QStyle::SC_MdiCloseButton);
| 0 | ||||||||||||||||||||||||
| 497 | || (visibleControls & QStyle::SC_MdiCloseButton); never executed: return (visibleControls & QStyle::SC_MdiMinButton) || (visibleControls & QStyle::SC_MdiNormalButton) || (visibleControls & QStyle::SC_MdiCloseButton);
| 0 | ||||||||||||||||||||||||
| 498 | } | - | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | signals: | - | ||||||||||||||||||||||||
| 501 | void _q_minimize(); | - | ||||||||||||||||||||||||
| 502 | void _q_restore(); | - | ||||||||||||||||||||||||
| 503 | void _q_close(); | - | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | protected: | - | ||||||||||||||||||||||||
| 506 | void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 507 | void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 508 | void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 509 | void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 510 | void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 511 | bool event(QEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | private: | - | ||||||||||||||||||||||||
| 514 | QStyle::SubControl activeControl; | - | ||||||||||||||||||||||||
| 515 | QStyle::SubControl hoverControl; | - | ||||||||||||||||||||||||
| 516 | QStyle::SubControls visibleControls; | - | ||||||||||||||||||||||||
| 517 | void initStyleOption(QStyleOptionComplex *option) const; | - | ||||||||||||||||||||||||
| 518 | QMdiArea *mdiArea; | - | ||||||||||||||||||||||||
| 519 | inline QStyle::SubControl getSubControl(const QPoint &pos) const | - | ||||||||||||||||||||||||
| 520 | { | - | ||||||||||||||||||||||||
| 521 | QStyleOptionComplex opt; | - | ||||||||||||||||||||||||
| 522 | initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 523 | return style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, pos, mdiArea); never executed: return style()->hitTestComplexControl(QStyle::CC_MdiControls, &opt, pos, mdiArea); | 0 | ||||||||||||||||||||||||
| 524 | } | - | ||||||||||||||||||||||||
| 525 | }; | - | ||||||||||||||||||||||||
| 526 | } // namespace QMdi | - | ||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||
| 528 | /* | - | ||||||||||||||||||||||||
| 529 | \internal | - | ||||||||||||||||||||||||
| 530 | */ | - | ||||||||||||||||||||||||
| 531 | ControllerWidget::ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent) | - | ||||||||||||||||||||||||
| 532 | : QWidget(parent), | - | ||||||||||||||||||||||||
| 533 | activeControl(QStyle::SC_None), | - | ||||||||||||||||||||||||
| 534 | hoverControl(QStyle::SC_None), | - | ||||||||||||||||||||||||
| 535 | visibleControls(QStyle::SC_None), | - | ||||||||||||||||||||||||
| 536 | mdiArea(0) | - | ||||||||||||||||||||||||
| 537 | { | - | ||||||||||||||||||||||||
| 538 | if (subWindow->parentWidget())
| 0 | ||||||||||||||||||||||||
| 539 | mdiArea = qobject_cast<QMdiArea *>(subWindow->parentWidget()->parentWidget()); never executed: mdiArea = qobject_cast<QMdiArea *>(subWindow->parentWidget()->parentWidget()); | 0 | ||||||||||||||||||||||||
| 540 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||||||||
| 541 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); | - | ||||||||||||||||||||||||
| 542 | setMouseTracking(true); | - | ||||||||||||||||||||||||
| 543 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | /* | - | ||||||||||||||||||||||||
| 546 | \internal | - | ||||||||||||||||||||||||
| 547 | */ | - | ||||||||||||||||||||||||
| 548 | QSize ControllerWidget::sizeHint() const | - | ||||||||||||||||||||||||
| 549 | { | - | ||||||||||||||||||||||||
| 550 | ensurePolished(); | - | ||||||||||||||||||||||||
| 551 | QStyleOptionComplex opt; | - | ||||||||||||||||||||||||
| 552 | initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 553 | QSize size(48, 16); | - | ||||||||||||||||||||||||
| 554 | return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, mdiArea); never executed: return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, mdiArea); | 0 | ||||||||||||||||||||||||
| 555 | } | - | ||||||||||||||||||||||||
| 556 | - | |||||||||||||||||||||||||
| 557 | void ControllerWidget::setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible) | - | ||||||||||||||||||||||||
| 558 | { | - | ||||||||||||||||||||||||
| 559 | QStyle::SubControl subControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 560 | - | |||||||||||||||||||||||||
| 561 | // Map action from QMdiSubWindowPrivate::WindowStateAction to QStyle::SubControl. | - | ||||||||||||||||||||||||
| 562 | if (action == QMdiSubWindowPrivate::MaximizeAction)
| 0 | ||||||||||||||||||||||||
| 563 | subControl = QStyle::SC_MdiNormalButton; never executed: subControl = QStyle::SC_MdiNormalButton; | 0 | ||||||||||||||||||||||||
| 564 | else if (action == QMdiSubWindowPrivate::CloseAction)
| 0 | ||||||||||||||||||||||||
| 565 | subControl = QStyle::SC_MdiCloseButton; never executed: subControl = QStyle::SC_MdiCloseButton; | 0 | ||||||||||||||||||||||||
| 566 | else if (action == QMdiSubWindowPrivate::MinimizeAction)
| 0 | ||||||||||||||||||||||||
| 567 | subControl = QStyle::SC_MdiMinButton; never executed: subControl = QStyle::SC_MdiMinButton; | 0 | ||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | if (subControl == QStyle::SC_None)
| 0 | ||||||||||||||||||||||||
| 570 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||
| 572 | if (visible && !(visibleControls & subControl))
| 0 | ||||||||||||||||||||||||
| 573 | visibleControls |= subControl; never executed: visibleControls |= subControl; | 0 | ||||||||||||||||||||||||
| 574 | else if (!visible && (visibleControls & subControl))
| 0 | ||||||||||||||||||||||||
| 575 | visibleControls &= ~subControl; never executed: visibleControls &= ~subControl; | 0 | ||||||||||||||||||||||||
| 576 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | /* | - | ||||||||||||||||||||||||
| 579 | \internal | - | ||||||||||||||||||||||||
| 580 | */ | - | ||||||||||||||||||||||||
| 581 | void ControllerWidget::paintEvent(QPaintEvent * /*paintEvent*/) | - | ||||||||||||||||||||||||
| 582 | { | - | ||||||||||||||||||||||||
| 583 | QStyleOptionComplex opt; | - | ||||||||||||||||||||||||
| 584 | initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 585 | if (activeControl == hoverControl) {
| 0 | ||||||||||||||||||||||||
| 586 | opt.activeSubControls = activeControl; | - | ||||||||||||||||||||||||
| 587 | opt.state |= QStyle::State_Sunken; | - | ||||||||||||||||||||||||
| 588 | } else if (hoverControl != QStyle::SC_None && (activeControl == QStyle::SC_None)) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 589 | opt.activeSubControls = hoverControl; | - | ||||||||||||||||||||||||
| 590 | opt.state |= QStyle::State_MouseOver; | - | ||||||||||||||||||||||||
| 591 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 592 | QPainter painter(this); | - | ||||||||||||||||||||||||
| 593 | style()->drawComplexControl(QStyle::CC_MdiControls, &opt, &painter, mdiArea); | - | ||||||||||||||||||||||||
| 594 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 595 | - | |||||||||||||||||||||||||
| 596 | /* | - | ||||||||||||||||||||||||
| 597 | \internal | - | ||||||||||||||||||||||||
| 598 | */ | - | ||||||||||||||||||||||||
| 599 | void ControllerWidget::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 600 | { | - | ||||||||||||||||||||||||
| 601 | if (event->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 602 | event->ignore(); | - | ||||||||||||||||||||||||
| 603 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 604 | } | - | ||||||||||||||||||||||||
| 605 | activeControl = getSubControl(event->pos()); | - | ||||||||||||||||||||||||
| 606 | update(); | - | ||||||||||||||||||||||||
| 607 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | /* | - | ||||||||||||||||||||||||
| 610 | \internal | - | ||||||||||||||||||||||||
| 611 | */ | - | ||||||||||||||||||||||||
| 612 | void ControllerWidget::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 613 | { | - | ||||||||||||||||||||||||
| 614 | if (event->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 615 | event->ignore(); | - | ||||||||||||||||||||||||
| 616 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 617 | } | - | ||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||
| 619 | QStyle::SubControl under_mouse = getSubControl(event->pos()); | - | ||||||||||||||||||||||||
| 620 | if (under_mouse == activeControl) {
| 0 | ||||||||||||||||||||||||
| 621 | switch (activeControl) { | - | ||||||||||||||||||||||||
| 622 | case QStyle::SC_MdiCloseButton: never executed: case QStyle::SC_MdiCloseButton: | 0 | ||||||||||||||||||||||||
| 623 | emit _q_close(); | - | ||||||||||||||||||||||||
| 624 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 625 | case QStyle::SC_MdiNormalButton: never executed: case QStyle::SC_MdiNormalButton: | 0 | ||||||||||||||||||||||||
| 626 | emit _q_restore(); | - | ||||||||||||||||||||||||
| 627 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 628 | case QStyle::SC_MdiMinButton: never executed: case QStyle::SC_MdiMinButton: | 0 | ||||||||||||||||||||||||
| 629 | emit _q_minimize(); | - | ||||||||||||||||||||||||
| 630 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 631 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 632 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 633 | } | - | ||||||||||||||||||||||||
| 634 | } | - | ||||||||||||||||||||||||
| 635 | - | |||||||||||||||||||||||||
| 636 | activeControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 637 | update(); | - | ||||||||||||||||||||||||
| 638 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | /* | - | ||||||||||||||||||||||||
| 641 | \internal | - | ||||||||||||||||||||||||
| 642 | */ | - | ||||||||||||||||||||||||
| 643 | void ControllerWidget::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 644 | { | - | ||||||||||||||||||||||||
| 645 | QStyle::SubControl under_mouse = getSubControl(event->pos()); | - | ||||||||||||||||||||||||
| 646 | //test if hover state changes | - | ||||||||||||||||||||||||
| 647 | if (hoverControl != under_mouse) {
| 0 | ||||||||||||||||||||||||
| 648 | hoverControl = under_mouse; | - | ||||||||||||||||||||||||
| 649 | update(); | - | ||||||||||||||||||||||||
| 650 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 651 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 652 | - | |||||||||||||||||||||||||
| 653 | /* | - | ||||||||||||||||||||||||
| 654 | \internal | - | ||||||||||||||||||||||||
| 655 | */ | - | ||||||||||||||||||||||||
| 656 | void ControllerWidget::leaveEvent(QEvent * /*event*/) | - | ||||||||||||||||||||||||
| 657 | { | - | ||||||||||||||||||||||||
| 658 | hoverControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 659 | update(); | - | ||||||||||||||||||||||||
| 660 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | /* | - | ||||||||||||||||||||||||
| 663 | \internal | - | ||||||||||||||||||||||||
| 664 | */ | - | ||||||||||||||||||||||||
| 665 | bool ControllerWidget::event(QEvent *event) | - | ||||||||||||||||||||||||
| 666 | { | - | ||||||||||||||||||||||||
| 667 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 668 | if (event->type() == QEvent::ToolTip) {
| 0 | ||||||||||||||||||||||||
| 669 | QStyleOptionComplex opt; | - | ||||||||||||||||||||||||
| 670 | initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 671 | QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); | - | ||||||||||||||||||||||||
| 672 | showToolTip(helpEvent, this, opt, QStyle::CC_MdiControls, getSubControl(helpEvent->pos())); | - | ||||||||||||||||||||||||
| 673 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 674 | #endif // QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 675 | return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||||||||
| 676 | } | - | ||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||
| 678 | /* | - | ||||||||||||||||||||||||
| 679 | \internal | - | ||||||||||||||||||||||||
| 680 | */ | - | ||||||||||||||||||||||||
| 681 | void ControllerWidget::initStyleOption(QStyleOptionComplex *option) const | - | ||||||||||||||||||||||||
| 682 | { | - | ||||||||||||||||||||||||
| 683 | option->initFrom(this); | - | ||||||||||||||||||||||||
| 684 | option->subControls = visibleControls; | - | ||||||||||||||||||||||||
| 685 | option->activeSubControls = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 686 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | /* | - | ||||||||||||||||||||||||
| 689 | \internal | - | ||||||||||||||||||||||||
| 690 | */ | - | ||||||||||||||||||||||||
| 691 | ControlContainer::ControlContainer(QMdiSubWindow *mdiChild) | - | ||||||||||||||||||||||||
| 692 | : QObject(mdiChild), | - | ||||||||||||||||||||||||
| 693 | previousLeft(0), | - | ||||||||||||||||||||||||
| 694 | previousRight(0), | - | ||||||||||||||||||||||||
| 695 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 696 | m_menuBar(0), | - | ||||||||||||||||||||||||
| 697 | #endif | - | ||||||||||||||||||||||||
| 698 | mdiChild(mdiChild) | - | ||||||||||||||||||||||||
| 699 | { | - | ||||||||||||||||||||||||
| 700 | Q_ASSERT(mdiChild); | - | ||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | m_controllerWidget = new ControlElement<ControllerWidget>(mdiChild); | - | ||||||||||||||||||||||||
| 703 | connect(m_controllerWidget, SIGNAL(_q_close()), mdiChild, SLOT(close())); | - | ||||||||||||||||||||||||
| 704 | connect(m_controllerWidget, SIGNAL(_q_restore()), mdiChild, SLOT(showNormal())); | - | ||||||||||||||||||||||||
| 705 | connect(m_controllerWidget, SIGNAL(_q_minimize()), mdiChild, SLOT(showMinimized())); | - | ||||||||||||||||||||||||
| 706 | - | |||||||||||||||||||||||||
| 707 | m_menuLabel = new ControlElement<ControlLabel>(mdiChild); | - | ||||||||||||||||||||||||
| 708 | m_menuLabel->setWindowIcon(mdiChild->windowIcon()); | - | ||||||||||||||||||||||||
| 709 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 710 | connect(m_menuLabel, SIGNAL(_q_clicked()), mdiChild, SLOT(showSystemMenu())); | - | ||||||||||||||||||||||||
| 711 | #endif | - | ||||||||||||||||||||||||
| 712 | connect(m_menuLabel, SIGNAL(_q_doubleClicked()), mdiChild, SLOT(close())); | - | ||||||||||||||||||||||||
| 713 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||
| 715 | ControlContainer::~ControlContainer() | - | ||||||||||||||||||||||||
| 716 | { | - | ||||||||||||||||||||||||
| 717 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 718 | removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 719 | #endif | - | ||||||||||||||||||||||||
| 720 | delete m_menuLabel; | - | ||||||||||||||||||||||||
| 721 | m_menuLabel = 0; | - | ||||||||||||||||||||||||
| 722 | delete m_controllerWidget; | - | ||||||||||||||||||||||||
| 723 | m_controllerWidget = 0; | - | ||||||||||||||||||||||||
| 724 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||
| 726 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 727 | /* | - | ||||||||||||||||||||||||
| 728 | \internal | - | ||||||||||||||||||||||||
| 729 | */ | - | ||||||||||||||||||||||||
| 730 | QMenuBar *QMdiSubWindowPrivate::menuBar() const | - | ||||||||||||||||||||||||
| 731 | { | - | ||||||||||||||||||||||||
| 732 | #if defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 733 | return 0; | - | ||||||||||||||||||||||||
| 734 | #else | - | ||||||||||||||||||||||||
| 735 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 736 | if (!q->isMaximized() || drawTitleBarWhenMaximized() || isChildOfTabbedQMdiArea(q))
| 0 | ||||||||||||||||||||||||
| 737 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 738 | - | |||||||||||||||||||||||||
| 739 | if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window()))
| 0 | ||||||||||||||||||||||||
| 740 | return mainWindow->menuBar(); never executed: return mainWindow->menuBar(); | 0 | ||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 743 | #endif | - | ||||||||||||||||||||||||
| 744 | } | - | ||||||||||||||||||||||||
| 745 | - | |||||||||||||||||||||||||
| 746 | /* | - | ||||||||||||||||||||||||
| 747 | \internal | - | ||||||||||||||||||||||||
| 748 | */ | - | ||||||||||||||||||||||||
| 749 | void ControlContainer::showButtonsInMenuBar(QMenuBar *menuBar) | - | ||||||||||||||||||||||||
| 750 | { | - | ||||||||||||||||||||||||
| 751 | if (!menuBar || !mdiChild || mdiChild->windowFlags() & Qt::FramelessWindowHint)
| 0 | ||||||||||||||||||||||||
| 752 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 753 | m_menuBar = menuBar; | - | ||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | if (m_menuLabel && mdiChild->windowFlags() & Qt::WindowSystemMenuHint) {
| 0 | ||||||||||||||||||||||||
| 756 | QWidget *currentLeft = menuBar->cornerWidget(Qt::TopLeftCorner); | - | ||||||||||||||||||||||||
| 757 | if (currentLeft)
| 0 | ||||||||||||||||||||||||
| 758 | currentLeft->hide(); never executed: currentLeft->hide(); | 0 | ||||||||||||||||||||||||
| 759 | if (currentLeft != m_menuLabel) {
| 0 | ||||||||||||||||||||||||
| 760 | menuBar->setCornerWidget(m_menuLabel, Qt::TopLeftCorner); | - | ||||||||||||||||||||||||
| 761 | previousLeft = currentLeft; | - | ||||||||||||||||||||||||
| 762 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 763 | m_menuLabel->show(); | - | ||||||||||||||||||||||||
| 764 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 765 | ControllerWidget *controllerWidget = qobject_cast<ControllerWidget *>(m_controllerWidget); | - | ||||||||||||||||||||||||
| 766 | if (controllerWidget && controllerWidget->hasVisibleControls()) {
| 0 | ||||||||||||||||||||||||
| 767 | QWidget *currentRight = menuBar->cornerWidget(Qt::TopRightCorner); | - | ||||||||||||||||||||||||
| 768 | if (currentRight)
| 0 | ||||||||||||||||||||||||
| 769 | currentRight->hide(); never executed: currentRight->hide(); | 0 | ||||||||||||||||||||||||
| 770 | if (currentRight != m_controllerWidget) {
| 0 | ||||||||||||||||||||||||
| 771 | menuBar->setCornerWidget(m_controllerWidget, Qt::TopRightCorner); | - | ||||||||||||||||||||||||
| 772 | previousRight = currentRight; | - | ||||||||||||||||||||||||
| 773 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 774 | m_controllerWidget->show(); | - | ||||||||||||||||||||||||
| 775 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 776 | mdiChild->d_func()->setNewWindowTitle(); | - | ||||||||||||||||||||||||
| 777 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | /* | - | ||||||||||||||||||||||||
| 780 | \internal | - | ||||||||||||||||||||||||
| 781 | */ | - | ||||||||||||||||||||||||
| 782 | void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar) | - | ||||||||||||||||||||||||
| 783 | { | - | ||||||||||||||||||||||||
| 784 | if (menuBar && menuBar != m_menuBar) {
| 0 | ||||||||||||||||||||||||
| 785 | // m_menubar was deleted while sub-window was maximized | - | ||||||||||||||||||||||||
| 786 | previousRight = 0; | - | ||||||||||||||||||||||||
| 787 | previousLeft = 0; | - | ||||||||||||||||||||||||
| 788 | m_menuBar = menuBar; | - | ||||||||||||||||||||||||
| 789 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | if (!m_menuBar || !mdiChild || qt_widget_private(mdiChild->window())->data.in_destructor)
| 0 | ||||||||||||||||||||||||
| 792 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||
| 794 | QMdiSubWindow *child = 0; | - | ||||||||||||||||||||||||
| 795 | if (m_controllerWidget) {
| 0 | ||||||||||||||||||||||||
| 796 | QWidget *currentRight = m_menuBar->cornerWidget(Qt::TopRightCorner); | - | ||||||||||||||||||||||||
| 797 | if (currentRight == m_controllerWidget) {
| 0 | ||||||||||||||||||||||||
| 798 | if (ControlElement<ControllerWidget> *ce = ptr<ControllerWidget>(previousRight)) {
| 0 | ||||||||||||||||||||||||
| 799 | if (!ce->mdiChild || !ce->mdiChild->isMaximized())
| 0 | ||||||||||||||||||||||||
| 800 | previousRight = 0; never executed: previousRight = 0; | 0 | ||||||||||||||||||||||||
| 801 | else | - | ||||||||||||||||||||||||
| 802 | child = ce->mdiChild; never executed: child = ce->mdiChild; | 0 | ||||||||||||||||||||||||
| 803 | } | - | ||||||||||||||||||||||||
| 804 | m_menuBar->setCornerWidget(previousRight, Qt::TopRightCorner); | - | ||||||||||||||||||||||||
| 805 | if (previousRight) {
| 0 | ||||||||||||||||||||||||
| 806 | previousRight->show(); | - | ||||||||||||||||||||||||
| 807 | previousRight = 0; | - | ||||||||||||||||||||||||
| 808 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 809 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 810 | m_controllerWidget->hide(); | - | ||||||||||||||||||||||||
| 811 | m_controllerWidget->setParent(0); | - | ||||||||||||||||||||||||
| 812 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 813 | if (m_menuLabel) {
| 0 | ||||||||||||||||||||||||
| 814 | QWidget *currentLeft = m_menuBar->cornerWidget(Qt::TopLeftCorner); | - | ||||||||||||||||||||||||
| 815 | if (currentLeft == m_menuLabel) {
| 0 | ||||||||||||||||||||||||
| 816 | if (ControlElement<ControlLabel> *ce = ptr<ControlLabel>(previousLeft)) {
| 0 | ||||||||||||||||||||||||
| 817 | if (!ce->mdiChild || !ce->mdiChild->isMaximized())
| 0 | ||||||||||||||||||||||||
| 818 | previousLeft = 0; never executed: previousLeft = 0; | 0 | ||||||||||||||||||||||||
| 819 | else if (!child)
| 0 | ||||||||||||||||||||||||
| 820 | child = mdiChild; never executed: child = mdiChild; | 0 | ||||||||||||||||||||||||
| 821 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 822 | m_menuBar->setCornerWidget(previousLeft, Qt::TopLeftCorner); | - | ||||||||||||||||||||||||
| 823 | if (previousLeft) {
| 0 | ||||||||||||||||||||||||
| 824 | previousLeft->show(); | - | ||||||||||||||||||||||||
| 825 | previousLeft = 0; | - | ||||||||||||||||||||||||
| 826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 827 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 828 | m_menuLabel->hide(); | - | ||||||||||||||||||||||||
| 829 | m_menuLabel->setParent(0); | - | ||||||||||||||||||||||||
| 830 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 831 | m_menuBar->update(); | - | ||||||||||||||||||||||||
| 832 | if (child)
| 0 | ||||||||||||||||||||||||
| 833 | child->d_func()->setNewWindowTitle(); never executed: child->d_func()->setNewWindowTitle(); | 0 | ||||||||||||||||||||||||
| 834 | else if (mdiChild)
| 0 | ||||||||||||||||||||||||
| 835 | mdiChild->window()->setWindowTitle(mdiChild->d_func()->originalWindowTitle()); never executed: mdiChild->window()->setWindowTitle(mdiChild->d_func()->originalWindowTitle()); | 0 | ||||||||||||||||||||||||
| 836 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | #endif // QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | void ControlContainer::updateWindowIcon(const QIcon &windowIcon) | - | ||||||||||||||||||||||||
| 841 | { | - | ||||||||||||||||||||||||
| 842 | if (m_menuLabel)
| 0 | ||||||||||||||||||||||||
| 843 | m_menuLabel->setWindowIcon(windowIcon); never executed: m_menuLabel->setWindowIcon(windowIcon); | 0 | ||||||||||||||||||||||||
| 844 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||
| 846 | /*! | - | ||||||||||||||||||||||||
| 847 | \internal | - | ||||||||||||||||||||||||
| 848 | */ | - | ||||||||||||||||||||||||
| 849 | QMdiSubWindowPrivate::QMdiSubWindowPrivate() | - | ||||||||||||||||||||||||
| 850 | : baseWidget(0), | - | ||||||||||||||||||||||||
| 851 | restoreFocusWidget(0), | - | ||||||||||||||||||||||||
| 852 | controlContainer(0), | - | ||||||||||||||||||||||||
| 853 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 854 | sizeGrip(0), | - | ||||||||||||||||||||||||
| 855 | #endif | - | ||||||||||||||||||||||||
| 856 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 857 | rubberBand(0), | - | ||||||||||||||||||||||||
| 858 | #endif | - | ||||||||||||||||||||||||
| 859 | userMinimumSize(0,0), | - | ||||||||||||||||||||||||
| 860 | resizeEnabled(true), | - | ||||||||||||||||||||||||
| 861 | moveEnabled(true), | - | ||||||||||||||||||||||||
| 862 | isInInteractiveMode(false), | - | ||||||||||||||||||||||||
| 863 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 864 | isInRubberBandMode(false), | - | ||||||||||||||||||||||||
| 865 | #endif | - | ||||||||||||||||||||||||
| 866 | isShadeMode(false), | - | ||||||||||||||||||||||||
| 867 | ignoreWindowTitleChange(false), | - | ||||||||||||||||||||||||
| 868 | ignoreNextActivationEvent(false), | - | ||||||||||||||||||||||||
| 869 | activationEnabled(true), | - | ||||||||||||||||||||||||
| 870 | isShadeRequestFromMinimizeMode(false), | - | ||||||||||||||||||||||||
| 871 | isMaximizeMode(false), | - | ||||||||||||||||||||||||
| 872 | isWidgetHiddenByUs(false), | - | ||||||||||||||||||||||||
| 873 | isActive(false), | - | ||||||||||||||||||||||||
| 874 | isExplicitlyDeactivated(false), | - | ||||||||||||||||||||||||
| 875 | keyboardSingleStep(5), | - | ||||||||||||||||||||||||
| 876 | keyboardPageStep(20), | - | ||||||||||||||||||||||||
| 877 | resizeTimerId(-1), | - | ||||||||||||||||||||||||
| 878 | currentOperation(None), | - | ||||||||||||||||||||||||
| 879 | hoveredSubControl(QStyle::SC_None), | - | ||||||||||||||||||||||||
| 880 | activeSubControl(QStyle::SC_None), | - | ||||||||||||||||||||||||
| 881 | focusInReason(Qt::ActiveWindowFocusReason) | - | ||||||||||||||||||||||||
| 882 | { | - | ||||||||||||||||||||||||
| 883 | initOperationMap(); | - | ||||||||||||||||||||||||
| 884 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | /*! | - | ||||||||||||||||||||||||
| 887 | \internal | - | ||||||||||||||||||||||||
| 888 | */ | - | ||||||||||||||||||||||||
| 889 | void QMdiSubWindowPrivate::_q_updateStaysOnTopHint() | - | ||||||||||||||||||||||||
| 890 | { | - | ||||||||||||||||||||||||
| 891 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 892 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 893 | if (QAction *senderAction = qobject_cast<QAction *>(q->sender())) {
| 0 | ||||||||||||||||||||||||
| 894 | if (senderAction->isChecked()) {
| 0 | ||||||||||||||||||||||||
| 895 | q->setWindowFlags(q->windowFlags() | Qt::WindowStaysOnTopHint); | - | ||||||||||||||||||||||||
| 896 | q->raise(); | - | ||||||||||||||||||||||||
| 897 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 898 | q->setWindowFlags(q->windowFlags() & ~Qt::WindowStaysOnTopHint); | - | ||||||||||||||||||||||||
| 899 | q->lower(); | - | ||||||||||||||||||||||||
| 900 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 901 | } | - | ||||||||||||||||||||||||
| 902 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
| 903 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 904 | - | |||||||||||||||||||||||||
| 905 | /*! | - | ||||||||||||||||||||||||
| 906 | \internal | - | ||||||||||||||||||||||||
| 907 | */ | - | ||||||||||||||||||||||||
| 908 | void QMdiSubWindowPrivate::_q_enterInteractiveMode() | - | ||||||||||||||||||||||||
| 909 | { | - | ||||||||||||||||||||||||
| 910 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 911 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 912 | QAction *action = qobject_cast<QAction *>(q->sender()); | - | ||||||||||||||||||||||||
| 913 | if (!action)
| 0 | ||||||||||||||||||||||||
| 914 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||
| 916 | QPoint pressPos; | - | ||||||||||||||||||||||||
| 917 | if (actions[MoveAction] && actions[MoveAction] == action) {
| 0 | ||||||||||||||||||||||||
| 918 | currentOperation = Move; | - | ||||||||||||||||||||||||
| 919 | pressPos = QPoint(q->width() / 2, titleBarHeight() - 1); | - | ||||||||||||||||||||||||
| 920 | } else if (actions[ResizeAction] && actions[ResizeAction] == action) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 921 | currentOperation = q->isLeftToRight() ? BottomRightResize : BottomLeftResize;
| 0 | ||||||||||||||||||||||||
| 922 | int offset = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q) / 2; | - | ||||||||||||||||||||||||
| 923 | int x = q->isLeftToRight() ? q->width() - offset : offset;
| 0 | ||||||||||||||||||||||||
| 924 | pressPos = QPoint(x, q->height() - offset); | - | ||||||||||||||||||||||||
| 925 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 926 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 927 | } | - | ||||||||||||||||||||||||
| 928 | - | |||||||||||||||||||||||||
| 929 | updateCursor(); | - | ||||||||||||||||||||||||
| 930 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||
| 931 | q->cursor().setPos(q->mapToGlobal(pressPos)); | - | ||||||||||||||||||||||||
| 932 | #endif | - | ||||||||||||||||||||||||
| 933 | mousePressPosition = q->mapToParent(pressPos); | - | ||||||||||||||||||||||||
| 934 | oldGeometry = q->geometry(); | - | ||||||||||||||||||||||||
| 935 | isInInteractiveMode = true; | - | ||||||||||||||||||||||||
| 936 | q->setFocus(); | - | ||||||||||||||||||||||||
| 937 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 938 | if ((q->testOption(QMdiSubWindow::RubberBandResize)
| 0 | ||||||||||||||||||||||||
| 939 | && (currentOperation == BottomRightResize || currentOperation == BottomLeftResize))
| 0 | ||||||||||||||||||||||||
| 940 | || (q->testOption(QMdiSubWindow::RubberBandMove) && currentOperation == Move)) {
| 0 | ||||||||||||||||||||||||
| 941 | enterRubberBandMode(); | - | ||||||||||||||||||||||||
| 942 | } else never executed: end of block | 0 | ||||||||||||||||||||||||
| 943 | #endif // QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 944 | { | - | ||||||||||||||||||||||||
| 945 | q->grabMouse(); | - | ||||||||||||||||||||||||
| 946 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 947 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
| 948 | } | - | ||||||||||||||||||||||||
| 949 | - | |||||||||||||||||||||||||
| 950 | /*! | - | ||||||||||||||||||||||||
| 951 | \internal | - | ||||||||||||||||||||||||
| 952 | */ | - | ||||||||||||||||||||||||
| 953 | void QMdiSubWindowPrivate::_q_processFocusChanged(QWidget *old, QWidget *now) | - | ||||||||||||||||||||||||
| 954 | { | - | ||||||||||||||||||||||||
| 955 | Q_UNUSED(old); | - | ||||||||||||||||||||||||
| 956 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 957 | if (now && (now == q || q->isAncestorOf(now))) {
| 0 | ||||||||||||||||||||||||
| 958 | if (now == q && !isInInteractiveMode)
| 0 | ||||||||||||||||||||||||
| 959 | setFocusWidget(); never executed: setFocusWidget(); | 0 | ||||||||||||||||||||||||
| 960 | setActive(true); | - | ||||||||||||||||||||||||
| 961 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 962 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | /*! | - | ||||||||||||||||||||||||
| 965 | \internal | - | ||||||||||||||||||||||||
| 966 | */ | - | ||||||||||||||||||||||||
| 967 | void QMdiSubWindowPrivate::leaveInteractiveMode() | - | ||||||||||||||||||||||||
| 968 | { | - | ||||||||||||||||||||||||
| 969 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 970 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 971 | if (isInRubberBandMode)
| 0 | ||||||||||||||||||||||||
| 972 | leaveRubberBandMode(); never executed: leaveRubberBandMode(); | 0 | ||||||||||||||||||||||||
| 973 | else | - | ||||||||||||||||||||||||
| 974 | #endif | - | ||||||||||||||||||||||||
| 975 | q->releaseMouse(); never executed: q->releaseMouse(); | 0 | ||||||||||||||||||||||||
| 976 | isInInteractiveMode = false; | - | ||||||||||||||||||||||||
| 977 | currentOperation = None; | - | ||||||||||||||||||||||||
| 978 | updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 979 | updateCursor(); | - | ||||||||||||||||||||||||
| 980 | if (baseWidget && baseWidget->focusWidget())
| 0 | ||||||||||||||||||||||||
| 981 | baseWidget->focusWidget()->setFocus(); never executed: baseWidget->focusWidget()->setFocus(); | 0 | ||||||||||||||||||||||||
| 982 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 983 | - | |||||||||||||||||||||||||
| 984 | /*! | - | ||||||||||||||||||||||||
| 985 | \internal | - | ||||||||||||||||||||||||
| 986 | */ | - | ||||||||||||||||||||||||
| 987 | void QMdiSubWindowPrivate::removeBaseWidget() | - | ||||||||||||||||||||||||
| 988 | { | - | ||||||||||||||||||||||||
| 989 | if (!baseWidget)
| 0 | ||||||||||||||||||||||||
| 990 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 991 | - | |||||||||||||||||||||||||
| 992 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 993 | baseWidget->removeEventFilter(q); | - | ||||||||||||||||||||||||
| 994 | if (layout)
| 0 | ||||||||||||||||||||||||
| 995 | layout->removeWidget(baseWidget); never executed: layout->removeWidget(baseWidget); | 0 | ||||||||||||||||||||||||
| 996 | if (baseWidget->windowTitle() == q->windowTitle()) {
| 0 | ||||||||||||||||||||||||
| 997 | ignoreWindowTitleChange = true; | - | ||||||||||||||||||||||||
| 998 | q->setWindowTitle(QString()); | - | ||||||||||||||||||||||||
| 999 | ignoreWindowTitleChange = false; | - | ||||||||||||||||||||||||
| 1000 | q->setWindowModified(false); | - | ||||||||||||||||||||||||
| 1001 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1002 | lastChildWindowTitle.clear(); | - | ||||||||||||||||||||||||
| 1003 | baseWidget->setParent(0); | - | ||||||||||||||||||||||||
| 1004 | baseWidget = 0; | - | ||||||||||||||||||||||||
| 1005 | isWidgetHiddenByUs = false; | - | ||||||||||||||||||||||||
| 1006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||
| 1008 | /*! | - | ||||||||||||||||||||||||
| 1009 | \internal | - | ||||||||||||||||||||||||
| 1010 | */ | - | ||||||||||||||||||||||||
| 1011 | void QMdiSubWindowPrivate::initOperationMap() | - | ||||||||||||||||||||||||
| 1012 | { | - | ||||||||||||||||||||||||
| 1013 | operationMap.insert(Move, OperationInfo(HMove | VMove, Qt::ArrowCursor, false)); | - | ||||||||||||||||||||||||
| 1014 | operationMap.insert(TopResize, OperationInfo(VMove | VResize | VResizeReverse, Qt::SizeVerCursor)); | - | ||||||||||||||||||||||||
| 1015 | operationMap.insert(BottomResize, OperationInfo(VResize, Qt::SizeVerCursor)); | - | ||||||||||||||||||||||||
| 1016 | operationMap.insert(LeftResize, OperationInfo(HMove | HResize | HResizeReverse, Qt::SizeHorCursor)); | - | ||||||||||||||||||||||||
| 1017 | operationMap.insert(RightResize, OperationInfo(HResize, Qt::SizeHorCursor)); | - | ||||||||||||||||||||||||
| 1018 | operationMap.insert(TopLeftResize, OperationInfo(HMove | VMove | HResize | VResize | VResizeReverse | - | ||||||||||||||||||||||||
| 1019 | | HResizeReverse, Qt::SizeFDiagCursor)); | - | ||||||||||||||||||||||||
| 1020 | operationMap.insert(TopRightResize, OperationInfo(VMove | HResize | VResize | - | ||||||||||||||||||||||||
| 1021 | | VResizeReverse, Qt::SizeBDiagCursor)); | - | ||||||||||||||||||||||||
| 1022 | operationMap.insert(BottomLeftResize, OperationInfo(HMove | HResize | VResize | HResizeReverse, | - | ||||||||||||||||||||||||
| 1023 | Qt::SizeBDiagCursor)); | - | ||||||||||||||||||||||||
| 1024 | operationMap.insert(BottomRightResize, OperationInfo(HResize | VResize, Qt::SizeFDiagCursor)); | - | ||||||||||||||||||||||||
| 1025 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1026 | - | |||||||||||||||||||||||||
| 1027 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | /*! | - | ||||||||||||||||||||||||
| 1030 | \internal | - | ||||||||||||||||||||||||
| 1031 | */ | - | ||||||||||||||||||||||||
| 1032 | void QMdiSubWindowPrivate::createSystemMenu() | - | ||||||||||||||||||||||||
| 1033 | { | - | ||||||||||||||||||||||||
| 1034 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1035 | Q_ASSERT_X(q, "QMdiSubWindowPrivate::createSystemMenu", | - | ||||||||||||||||||||||||
| 1036 | "You can NOT call this function before QMdiSubWindow's ctor"); | - | ||||||||||||||||||||||||
| 1037 | systemMenu = new QMenu(q); | - | ||||||||||||||||||||||||
| 1038 | systemMenu->installEventFilter(q); | - | ||||||||||||||||||||||||
| 1039 | const QStyle *style = q->style(); | - | ||||||||||||||||||||||||
| 1040 | addToSystemMenu(RestoreAction, QMdiSubWindow::tr("&Restore"), SLOT(showNormal())); | - | ||||||||||||||||||||||||
| 1041 | actions[RestoreAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarNormalButton, 0, q)); | - | ||||||||||||||||||||||||
| 1042 | actions[RestoreAction]->setEnabled(false); | - | ||||||||||||||||||||||||
| 1043 | addToSystemMenu(MoveAction, QMdiSubWindow::tr("&Move"), SLOT(_q_enterInteractiveMode())); | - | ||||||||||||||||||||||||
| 1044 | addToSystemMenu(ResizeAction, QMdiSubWindow::tr("&Size"), SLOT(_q_enterInteractiveMode())); | - | ||||||||||||||||||||||||
| 1045 | addToSystemMenu(MinimizeAction, QMdiSubWindow::tr("Mi&nimize"), SLOT(showMinimized())); | - | ||||||||||||||||||||||||
| 1046 | actions[MinimizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMinButton, 0, q)); | - | ||||||||||||||||||||||||
| 1047 | addToSystemMenu(MaximizeAction, QMdiSubWindow::tr("Ma&ximize"), SLOT(showMaximized())); | - | ||||||||||||||||||||||||
| 1048 | actions[MaximizeAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarMaxButton, 0, q)); | - | ||||||||||||||||||||||||
| 1049 | addToSystemMenu(StayOnTopAction, QMdiSubWindow::tr("Stay on &Top"), SLOT(_q_updateStaysOnTopHint())); | - | ||||||||||||||||||||||||
| 1050 | actions[StayOnTopAction]->setCheckable(true); | - | ||||||||||||||||||||||||
| 1051 | systemMenu->addSeparator(); | - | ||||||||||||||||||||||||
| 1052 | addToSystemMenu(CloseAction, QMdiSubWindow::tr("&Close"), SLOT(close())); | - | ||||||||||||||||||||||||
| 1053 | actions[CloseAction]->setIcon(style->standardIcon(QStyle::SP_TitleBarCloseButton, 0, q)); | - | ||||||||||||||||||||||||
| 1054 | #if !defined(QT_NO_SHORTCUT) | - | ||||||||||||||||||||||||
| 1055 | actions[CloseAction]->setShortcuts(QKeySequence::Close); | - | ||||||||||||||||||||||||
| 1056 | #endif | - | ||||||||||||||||||||||||
| 1057 | updateActions(); | - | ||||||||||||||||||||||||
| 1058 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1059 | #endif | - | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | /*! | - | ||||||||||||||||||||||||
| 1062 | \internal | - | ||||||||||||||||||||||||
| 1063 | */ | - | ||||||||||||||||||||||||
| 1064 | void QMdiSubWindowPrivate::updateCursor() | - | ||||||||||||||||||||||||
| 1065 | { | - | ||||||||||||||||||||||||
| 1066 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||
| 1067 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1068 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 1069 | if (qobject_cast<QMacStyle *>(q->style())) | - | ||||||||||||||||||||||||
| 1070 | return; | - | ||||||||||||||||||||||||
| 1071 | #endif | - | ||||||||||||||||||||||||
| 1072 | - | |||||||||||||||||||||||||
| 1073 | if (currentOperation == None) {
| 0 | ||||||||||||||||||||||||
| 1074 | q->unsetCursor(); | - | ||||||||||||||||||||||||
| 1075 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1076 | } | - | ||||||||||||||||||||||||
| 1077 | - | |||||||||||||||||||||||||
| 1078 | if (currentOperation == Move || operationMap.find(currentOperation).value().hover) {
| 0 | ||||||||||||||||||||||||
| 1079 | q->setCursor(operationMap.find(currentOperation).value().cursorShape); | - | ||||||||||||||||||||||||
| 1080 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1081 | } | - | ||||||||||||||||||||||||
| 1082 | #endif | - | ||||||||||||||||||||||||
| 1083 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1084 | - | |||||||||||||||||||||||||
| 1085 | /*! | - | ||||||||||||||||||||||||
| 1086 | \internal | - | ||||||||||||||||||||||||
| 1087 | */ | - | ||||||||||||||||||||||||
| 1088 | void QMdiSubWindowPrivate::updateDirtyRegions() | - | ||||||||||||||||||||||||
| 1089 | { | - | ||||||||||||||||||||||||
| 1090 | // No update necessary | - | ||||||||||||||||||||||||
| 1091 | if (!parent)
| 0 | ||||||||||||||||||||||||
| 1092 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1093 | - | |||||||||||||||||||||||||
| 1094 | for (OperationInfoMap::iterator it = operationMap.begin(), end = operationMap.end(); it != end; ++it)
| 0 | ||||||||||||||||||||||||
| 1095 | it.value().region = getRegion(it.key()); never executed: it.value().region = getRegion(it.key()); | 0 | ||||||||||||||||||||||||
| 1096 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1097 | - | |||||||||||||||||||||||||
| 1098 | /*! | - | ||||||||||||||||||||||||
| 1099 | \internal | - | ||||||||||||||||||||||||
| 1100 | */ | - | ||||||||||||||||||||||||
| 1101 | void QMdiSubWindowPrivate::updateGeometryConstraints() | - | ||||||||||||||||||||||||
| 1102 | { | - | ||||||||||||||||||||||||
| 1103 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1104 | if (!parent)
| 0 | ||||||||||||||||||||||||
| 1105 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | internalMinimumSize = (!q->isMinimized() && !q->minimumSize().isNull())
| 0 | ||||||||||||||||||||||||
| 1108 | ? q->minimumSize() : q->minimumSizeHint(); | - | ||||||||||||||||||||||||
| 1109 | int margin, minWidth; | - | ||||||||||||||||||||||||
| 1110 | sizeParameters(&margin, &minWidth); | - | ||||||||||||||||||||||||
| 1111 | q->setContentsMargins(margin, titleBarHeight(), margin, margin); | - | ||||||||||||||||||||||||
| 1112 | if (q->isMaximized() || (q->isMinimized() && !q->isShaded())) {
| 0 | ||||||||||||||||||||||||
| 1113 | moveEnabled = false; | - | ||||||||||||||||||||||||
| 1114 | resizeEnabled = false; | - | ||||||||||||||||||||||||
| 1115 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1116 | moveEnabled = true; | - | ||||||||||||||||||||||||
| 1117 | if ((q->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) || q->isShaded())
| 0 | ||||||||||||||||||||||||
| 1118 | resizeEnabled = false; never executed: resizeEnabled = false; | 0 | ||||||||||||||||||||||||
| 1119 | else | - | ||||||||||||||||||||||||
| 1120 | resizeEnabled = true; never executed: resizeEnabled = true; | 0 | ||||||||||||||||||||||||
| 1121 | } | - | ||||||||||||||||||||||||
| 1122 | updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 1123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | /*! | - | ||||||||||||||||||||||||
| 1126 | \internal | - | ||||||||||||||||||||||||
| 1127 | */ | - | ||||||||||||||||||||||||
| 1128 | void QMdiSubWindowPrivate::updateMask() | - | ||||||||||||||||||||||||
| 1129 | { | - | ||||||||||||||||||||||||
| 1130 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1131 | if (!q->mask().isEmpty())
| 0 | ||||||||||||||||||||||||
| 1132 | q->clearMask(); never executed: q->clearMask(); | 0 | ||||||||||||||||||||||||
| 1133 | - | |||||||||||||||||||||||||
| 1134 | if (!parent)
| 0 | ||||||||||||||||||||||||
| 1135 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||
| 1137 | if ((q->isMaximized() && !drawTitleBarWhenMaximized())
| 0 | ||||||||||||||||||||||||
| 1138 | || q->windowFlags() & Qt::FramelessWindowHint)
| 0 | ||||||||||||||||||||||||
| 1139 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | if (resizeTimerId == -1)
| 0 | ||||||||||||||||||||||||
| 1142 | cachedStyleOptions = titleBarOptions(); never executed: cachedStyleOptions = titleBarOptions(); | 0 | ||||||||||||||||||||||||
| 1143 | cachedStyleOptions.rect = q->rect(); | - | ||||||||||||||||||||||||
| 1144 | QStyleHintReturnMask frameMask; | - | ||||||||||||||||||||||||
| 1145 | q->style()->styleHint(QStyle::SH_WindowFrame_Mask, &cachedStyleOptions, q, &frameMask); | - | ||||||||||||||||||||||||
| 1146 | if (!frameMask.region.isEmpty())
| 0 | ||||||||||||||||||||||||
| 1147 | q->setMask(frameMask.region); never executed: q->setMask(frameMask.region); | 0 | ||||||||||||||||||||||||
| 1148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1149 | - | |||||||||||||||||||||||||
| 1150 | /*! | - | ||||||||||||||||||||||||
| 1151 | \internal | - | ||||||||||||||||||||||||
| 1152 | */ | - | ||||||||||||||||||||||||
| 1153 | void QMdiSubWindowPrivate::setNewGeometry(const QPoint &pos) | - | ||||||||||||||||||||||||
| 1154 | { | - | ||||||||||||||||||||||||
| 1155 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1156 | Q_ASSERT(currentOperation != None); | - | ||||||||||||||||||||||||
| 1157 | Q_ASSERT(parent); | - | ||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||
| 1159 | uint cflags = operationMap.find(currentOperation).value().changeFlags; | - | ||||||||||||||||||||||||
| 1160 | int posX = pos.x(); | - | ||||||||||||||||||||||||
| 1161 | int posY = pos.y(); | - | ||||||||||||||||||||||||
| 1162 | - | |||||||||||||||||||||||||
| 1163 | const bool restrictHorizontal = !q->testOption(QMdiSubWindow::AllowOutsideAreaHorizontally); | - | ||||||||||||||||||||||||
| 1164 | const bool restrictVertical = !q->testOption(QMdiSubWindow::AllowOutsideAreaVertically); | - | ||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||
| 1166 | if (restrictHorizontal || restrictVertical) {
| 0 | ||||||||||||||||||||||||
| 1167 | QRect parentRect = q->parentWidget()->rect(); | - | ||||||||||||||||||||||||
| 1168 | if (restrictVertical && (cflags & VResizeReverse || currentOperation == Move)) {
| 0 | ||||||||||||||||||||||||
| 1169 | posY = qMin(qMax(mousePressPosition.y() - oldGeometry.y(), posY), | - | ||||||||||||||||||||||||
| 1170 | parentRect.height() - BoundaryMargin); | - | ||||||||||||||||||||||||
| 1171 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1172 | if (currentOperation == Move) {
| 0 | ||||||||||||||||||||||||
| 1173 | if (restrictHorizontal)
| 0 | ||||||||||||||||||||||||
| 1174 | posX = qMin(qMax(BoundaryMargin, posX), parentRect.width() - BoundaryMargin); never executed: posX = qMin(qMax(BoundaryMargin, posX), parentRect.width() - BoundaryMargin); | 0 | ||||||||||||||||||||||||
| 1175 | if (restrictVertical)
| 0 | ||||||||||||||||||||||||
| 1176 | posY = qMin(posY, parentRect.height() - BoundaryMargin); never executed: posY = qMin(posY, parentRect.height() - BoundaryMargin); | 0 | ||||||||||||||||||||||||
| 1177 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1178 | if (restrictHorizontal) {
| 0 | ||||||||||||||||||||||||
| 1179 | if (cflags & HResizeReverse)
| 0 | ||||||||||||||||||||||||
| 1180 | posX = qMax(mousePressPosition.x() - oldGeometry.x(), posX); never executed: posX = qMax(mousePressPosition.x() - oldGeometry.x(), posX); | 0 | ||||||||||||||||||||||||
| 1181 | else | - | ||||||||||||||||||||||||
| 1182 | posX = qMin(parentRect.width() - (oldGeometry.x() + oldGeometry.width() never executed: posX = qMin(parentRect.width() - (oldGeometry.x() + oldGeometry.width() - mousePressPosition.x()), posX); | 0 | ||||||||||||||||||||||||
| 1183 | - mousePressPosition.x()), posX); never executed: posX = qMin(parentRect.width() - (oldGeometry.x() + oldGeometry.width() - mousePressPosition.x()), posX); | 0 | ||||||||||||||||||||||||
| 1184 | } | - | ||||||||||||||||||||||||
| 1185 | if (restrictVertical && !(cflags & VResizeReverse)) {
| 0 | ||||||||||||||||||||||||
| 1186 | posY = qMin(parentRect.height() - (oldGeometry.y() + oldGeometry.height() | - | ||||||||||||||||||||||||
| 1187 | - mousePressPosition.y()), posY); | - | ||||||||||||||||||||||||
| 1188 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1189 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1190 | } | - | ||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | QRect geometry; | - | ||||||||||||||||||||||||
| 1193 | if (cflags & (HMove | VMove)) {
| 0 | ||||||||||||||||||||||||
| 1194 | int dx = getMoveDeltaComponent(cflags, HMove, HResize, posX - mousePressPosition.x(), | - | ||||||||||||||||||||||||
| 1195 | oldGeometry.width() - internalMinimumSize.width(), | - | ||||||||||||||||||||||||
| 1196 | oldGeometry.width() - q->maximumWidth()); | - | ||||||||||||||||||||||||
| 1197 | int dy = getMoveDeltaComponent(cflags, VMove, VResize, posY - mousePressPosition.y(), | - | ||||||||||||||||||||||||
| 1198 | oldGeometry.height() - internalMinimumSize.height(), | - | ||||||||||||||||||||||||
| 1199 | oldGeometry.height() - q->maximumHeight()); | - | ||||||||||||||||||||||||
| 1200 | geometry.setTopLeft(oldGeometry.topLeft() + QPoint(dx, dy)); | - | ||||||||||||||||||||||||
| 1201 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1202 | geometry.setTopLeft(q->geometry().topLeft()); | - | ||||||||||||||||||||||||
| 1203 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1204 | - | |||||||||||||||||||||||||
| 1205 | if (cflags & (HResize | VResize)) {
| 0 | ||||||||||||||||||||||||
| 1206 | int dx = getResizeDeltaComponent(cflags, HResize, HResizeReverse, | - | ||||||||||||||||||||||||
| 1207 | posX - mousePressPosition.x()); | - | ||||||||||||||||||||||||
| 1208 | int dy = getResizeDeltaComponent(cflags, VResize, VResizeReverse, | - | ||||||||||||||||||||||||
| 1209 | posY - mousePressPosition.y()); | - | ||||||||||||||||||||||||
| 1210 | geometry.setSize(oldGeometry.size() + QSize(dx, dy)); | - | ||||||||||||||||||||||||
| 1211 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1212 | geometry.setSize(q->geometry().size()); | - | ||||||||||||||||||||||||
| 1213 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | setNewGeometry(&geometry); | - | ||||||||||||||||||||||||
| 1216 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1217 | - | |||||||||||||||||||||||||
| 1218 | /*! | - | ||||||||||||||||||||||||
| 1219 | \internal | - | ||||||||||||||||||||||||
| 1220 | */ | - | ||||||||||||||||||||||||
| 1221 | void QMdiSubWindowPrivate::setMinimizeMode() | - | ||||||||||||||||||||||||
| 1222 | { | - | ||||||||||||||||||||||||
| 1223 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1224 | Q_ASSERT(parent); | - | ||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||
| 1226 | ensureWindowState(Qt::WindowMinimized); | - | ||||||||||||||||||||||||
| 1227 | isShadeRequestFromMinimizeMode = true; | - | ||||||||||||||||||||||||
| 1228 | q->showShaded(); | - | ||||||||||||||||||||||||
| 1229 | isShadeRequestFromMinimizeMode = false; | - | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | moveEnabled = false; | - | ||||||||||||||||||||||||
| 1232 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1233 | setEnabled(MoveAction, moveEnabled); | - | ||||||||||||||||||||||||
| 1234 | #endif | - | ||||||||||||||||||||||||
| 1235 | - | |||||||||||||||||||||||||
| 1236 | Q_ASSERT(q->windowState() & Qt::WindowMinimized); | - | ||||||||||||||||||||||||
| 1237 | Q_ASSERT(!(q->windowState() & Qt::WindowMaximized)); | - | ||||||||||||||||||||||||
| 1238 | // This should be a valid assert, but people can actually re-implement | - | ||||||||||||||||||||||||
| 1239 | // setVisible and do crazy stuff, so we're not guaranteed that | - | ||||||||||||||||||||||||
| 1240 | // the widget is hidden after calling hide(). | - | ||||||||||||||||||||||||
| 1241 | // Q_ASSERT(baseWidget ? baseWidget->isHidden() : true); | - | ||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | setActive(true); | - | ||||||||||||||||||||||||
| 1244 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||
| 1246 | /*! | - | ||||||||||||||||||||||||
| 1247 | \internal | - | ||||||||||||||||||||||||
| 1248 | */ | - | ||||||||||||||||||||||||
| 1249 | void QMdiSubWindowPrivate::setNormalMode() | - | ||||||||||||||||||||||||
| 1250 | { | - | ||||||||||||||||||||||||
| 1251 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1252 | Q_ASSERT(parent); | - | ||||||||||||||||||||||||
| 1253 | - | |||||||||||||||||||||||||
| 1254 | isShadeMode = false; | - | ||||||||||||||||||||||||
| 1255 | isMaximizeMode = false; | - | ||||||||||||||||||||||||
| 1256 | - | |||||||||||||||||||||||||
| 1257 | ensureWindowState(Qt::WindowNoState); | - | ||||||||||||||||||||||||
| 1258 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 1259 | removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 1260 | #endif | - | ||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | // Hide the window before we change the geometry to avoid multiple resize | - | ||||||||||||||||||||||||
| 1263 | // events and wrong window state. | - | ||||||||||||||||||||||||
| 1264 | const bool wasVisible = q->isVisible(); | - | ||||||||||||||||||||||||
| 1265 | if (wasVisible)
| 0 | ||||||||||||||||||||||||
| 1266 | q->setVisible(false); never executed: q->setVisible(false); | 0 | ||||||||||||||||||||||||
| 1267 | - | |||||||||||||||||||||||||
| 1268 | // Restore minimum size if set by user. | - | ||||||||||||||||||||||||
| 1269 | if (!userMinimumSize.isNull()) {
| 0 | ||||||||||||||||||||||||
| 1270 | q->setMinimumSize(userMinimumSize); | - | ||||||||||||||||||||||||
| 1271 | userMinimumSize = QSize(0, 0); | - | ||||||||||||||||||||||||
| 1272 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | // Show the internal widget if it was hidden by us, | - | ||||||||||||||||||||||||
| 1275 | if (baseWidget && isWidgetHiddenByUs) {
| 0 | ||||||||||||||||||||||||
| 1276 | baseWidget->show(); | - | ||||||||||||||||||||||||
| 1277 | isWidgetHiddenByUs = false; | - | ||||||||||||||||||||||||
| 1278 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 1281 | QRect newGeometry = oldGeometry; | - | ||||||||||||||||||||||||
| 1282 | newGeometry.setSize(restoreSize.expandedTo(internalMinimumSize)); | - | ||||||||||||||||||||||||
| 1283 | q->setGeometry(newGeometry); | - | ||||||||||||||||||||||||
| 1284 | - | |||||||||||||||||||||||||
| 1285 | if (wasVisible)
| 0 | ||||||||||||||||||||||||
| 1286 | q->setVisible(true); never executed: q->setVisible(true); | 0 | ||||||||||||||||||||||||
| 1287 | - | |||||||||||||||||||||||||
| 1288 | // Invalidate the restore size. | - | ||||||||||||||||||||||||
| 1289 | restoreSize.setWidth(-1); | - | ||||||||||||||||||||||||
| 1290 | restoreSize.setHeight(-1); | - | ||||||||||||||||||||||||
| 1291 | - | |||||||||||||||||||||||||
| 1292 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 1293 | setSizeGripVisible(true); | - | ||||||||||||||||||||||||
| 1294 | #endif | - | ||||||||||||||||||||||||
| 1295 | - | |||||||||||||||||||||||||
| 1296 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1297 | setEnabled(MoveAction, true); | - | ||||||||||||||||||||||||
| 1298 | setEnabled(MaximizeAction, true); | - | ||||||||||||||||||||||||
| 1299 | setEnabled(MinimizeAction, true); | - | ||||||||||||||||||||||||
| 1300 | setEnabled(RestoreAction, false); | - | ||||||||||||||||||||||||
| 1301 | setEnabled(ResizeAction, resizeEnabled); | - | ||||||||||||||||||||||||
| 1302 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1303 | - | |||||||||||||||||||||||||
| 1304 | Q_ASSERT(!(q_func()->windowState() & Qt::WindowMinimized)); | - | ||||||||||||||||||||||||
| 1305 | // This sub-window can be maximized when shown above if not the | - | ||||||||||||||||||||||||
| 1306 | // QMdiArea::DontMaximizeSubWindowOnActionvation is set. Make sure | - | ||||||||||||||||||||||||
| 1307 | // the Qt::WindowMaximized flag is set accordingly. | - | ||||||||||||||||||||||||
| 1308 | Q_ASSERT((isMaximizeMode && q_func()->windowState() & Qt::WindowMaximized) | - | ||||||||||||||||||||||||
| 1309 | || (!isMaximizeMode && !(q_func()->windowState() & Qt::WindowMaximized))); | - | ||||||||||||||||||||||||
| 1310 | Q_ASSERT(!isShadeMode); | - | ||||||||||||||||||||||||
| 1311 | - | |||||||||||||||||||||||||
| 1312 | setActive(true); | - | ||||||||||||||||||||||||
| 1313 | restoreFocus(); | - | ||||||||||||||||||||||||
| 1314 | updateMask(); | - | ||||||||||||||||||||||||
| 1315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1316 | - | |||||||||||||||||||||||||
| 1317 | inline void QMdiSubWindowPrivate::storeFocusWidget() | - | ||||||||||||||||||||||||
| 1318 | { | - | ||||||||||||||||||||||||
| 1319 | if (QWidget *focus = QApplication::focusWidget()) {
| 0 | ||||||||||||||||||||||||
| 1320 | if (!restoreFocusWidget && q_func()->isAncestorOf(focus))
| 0 | ||||||||||||||||||||||||
| 1321 | restoreFocusWidget = focus; never executed: restoreFocusWidget = focus; | 0 | ||||||||||||||||||||||||
| 1322 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1323 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1324 | - | |||||||||||||||||||||||||
| 1325 | /*! | - | ||||||||||||||||||||||||
| 1326 | \internal | - | ||||||||||||||||||||||||
| 1327 | */ | - | ||||||||||||||||||||||||
| 1328 | void QMdiSubWindowPrivate::setMaximizeMode() | - | ||||||||||||||||||||||||
| 1329 | { | - | ||||||||||||||||||||||||
| 1330 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1331 | Q_ASSERT(parent); | - | ||||||||||||||||||||||||
| 1332 | - | |||||||||||||||||||||||||
| 1333 | ensureWindowState(Qt::WindowMaximized); | - | ||||||||||||||||||||||||
| 1334 | isShadeMode = false; | - | ||||||||||||||||||||||||
| 1335 | isMaximizeMode = true; | - | ||||||||||||||||||||||||
| 1336 | - | |||||||||||||||||||||||||
| 1337 | storeFocusWidget(); | - | ||||||||||||||||||||||||
| 1338 | - | |||||||||||||||||||||||||
| 1339 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 1340 | setSizeGripVisible(false); | - | ||||||||||||||||||||||||
| 1341 | #endif | - | ||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||
| 1343 | // Store old geometry and set restore size if not already set. | - | ||||||||||||||||||||||||
| 1344 | if (!restoreSize.isValid()) {
| 0 | ||||||||||||||||||||||||
| 1345 | oldGeometry = q->geometry(); | - | ||||||||||||||||||||||||
| 1346 | restoreSize.setWidth(oldGeometry.width()); | - | ||||||||||||||||||||||||
| 1347 | restoreSize.setHeight(oldGeometry.height()); | - | ||||||||||||||||||||||||
| 1348 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||
| 1350 | // Hide the window before we change the geometry to avoid multiple resize | - | ||||||||||||||||||||||||
| 1351 | // events and wrong window state. | - | ||||||||||||||||||||||||
| 1352 | const bool wasVisible = q->isVisible(); | - | ||||||||||||||||||||||||
| 1353 | if (wasVisible)
| 0 | ||||||||||||||||||||||||
| 1354 | q->setVisible(false); never executed: q->setVisible(false); | 0 | ||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||
| 1356 | // Show the internal widget if it was hidden by us. | - | ||||||||||||||||||||||||
| 1357 | if (baseWidget && isWidgetHiddenByUs) {
| 0 | ||||||||||||||||||||||||
| 1358 | baseWidget->show(); | - | ||||||||||||||||||||||||
| 1359 | isWidgetHiddenByUs = false; | - | ||||||||||||||||||||||||
| 1360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1361 | - | |||||||||||||||||||||||||
| 1362 | updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||
| 1364 | if (wasVisible) {
| 0 | ||||||||||||||||||||||||
| 1365 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 1366 | if (QMenuBar *mBar = menuBar())
| 0 | ||||||||||||||||||||||||
| 1367 | showButtonsInMenuBar(mBar); never executed: showButtonsInMenuBar(mBar); | 0 | ||||||||||||||||||||||||
| 1368 | else | - | ||||||||||||||||||||||||
| 1369 | #endif | - | ||||||||||||||||||||||||
| 1370 | if (!controlContainer)
| 0 | ||||||||||||||||||||||||
| 1371 | controlContainer = new ControlContainer(q); never executed: controlContainer = new ControlContainer(q); | 0 | ||||||||||||||||||||||||
| 1372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | QWidget *parent = q->parentWidget(); | - | ||||||||||||||||||||||||
| 1375 | QRect availableRect = parent->contentsRect(); | - | ||||||||||||||||||||||||
| 1376 | - | |||||||||||||||||||||||||
| 1377 | // Adjust geometry if the sub-window is inside a scroll area. | - | ||||||||||||||||||||||||
| 1378 | QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent->parentWidget()); | - | ||||||||||||||||||||||||
| 1379 | if (scrollArea && scrollArea->viewport() == parent) {
| 0 | ||||||||||||||||||||||||
| 1380 | QScrollBar *hbar = scrollArea->horizontalScrollBar(); | - | ||||||||||||||||||||||||
| 1381 | QScrollBar *vbar = scrollArea->verticalScrollBar(); | - | ||||||||||||||||||||||||
| 1382 | const int xOffset = hbar ? hbar->value() : 0;
| 0 | ||||||||||||||||||||||||
| 1383 | const int yOffset = vbar ? vbar->value() : 0;
| 0 | ||||||||||||||||||||||||
| 1384 | availableRect.adjust(-xOffset, -yOffset, -xOffset, -yOffset); | - | ||||||||||||||||||||||||
| 1385 | oldGeometry.adjust(xOffset, yOffset, xOffset, yOffset); | - | ||||||||||||||||||||||||
| 1386 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1387 | - | |||||||||||||||||||||||||
| 1388 | setNewGeometry(&availableRect); | - | ||||||||||||||||||||||||
| 1389 | // QWidget::setGeometry will reset Qt::WindowMaximized so we have to update it here. | - | ||||||||||||||||||||||||
| 1390 | ensureWindowState(Qt::WindowMaximized); | - | ||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||
| 1392 | if (wasVisible)
| 0 | ||||||||||||||||||||||||
| 1393 | q->setVisible(true); never executed: q->setVisible(true); | 0 | ||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||
| 1395 | resizeEnabled = false; | - | ||||||||||||||||||||||||
| 1396 | moveEnabled = false; | - | ||||||||||||||||||||||||
| 1397 | - | |||||||||||||||||||||||||
| 1398 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1399 | setEnabled(MoveAction, moveEnabled); | - | ||||||||||||||||||||||||
| 1400 | setEnabled(MaximizeAction, false); | - | ||||||||||||||||||||||||
| 1401 | setEnabled(MinimizeAction, true); | - | ||||||||||||||||||||||||
| 1402 | setEnabled(RestoreAction, true); | - | ||||||||||||||||||||||||
| 1403 | setEnabled(ResizeAction, resizeEnabled); | - | ||||||||||||||||||||||||
| 1404 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1405 | - | |||||||||||||||||||||||||
| 1406 | Q_ASSERT(q->windowState() & Qt::WindowMaximized); | - | ||||||||||||||||||||||||
| 1407 | Q_ASSERT(!(q->windowState() & Qt::WindowMinimized)); | - | ||||||||||||||||||||||||
| 1408 | - | |||||||||||||||||||||||||
| 1409 | restoreFocus(); | - | ||||||||||||||||||||||||
| 1410 | updateMask(); | - | ||||||||||||||||||||||||
| 1411 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1412 | - | |||||||||||||||||||||||||
| 1413 | /*! | - | ||||||||||||||||||||||||
| 1414 | \internal | - | ||||||||||||||||||||||||
| 1415 | */ | - | ||||||||||||||||||||||||
| 1416 | void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus) | - | ||||||||||||||||||||||||
| 1417 | { | - | ||||||||||||||||||||||||
| 1418 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1419 | if (!parent || !activationEnabled)
| 0 | ||||||||||||||||||||||||
| 1420 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||
| 1422 | if (activate && !isActive && q->isEnabled()) {
| 0 | ||||||||||||||||||||||||
| 1423 | isActive = true; | - | ||||||||||||||||||||||||
| 1424 | isExplicitlyDeactivated = false; | - | ||||||||||||||||||||||||
| 1425 | Qt::WindowStates oldWindowState = q->windowState(); | - | ||||||||||||||||||||||||
| 1426 | ensureWindowState(Qt::WindowActive); | - | ||||||||||||||||||||||||
| 1427 | emit q->aboutToActivate(); | - | ||||||||||||||||||||||||
| 1428 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 1429 | if (QMenuBar *mBar = menuBar())
| 0 | ||||||||||||||||||||||||
| 1430 | showButtonsInMenuBar(mBar); never executed: showButtonsInMenuBar(mBar); | 0 | ||||||||||||||||||||||||
| 1431 | #endif | - | ||||||||||||||||||||||||
| 1432 | Q_ASSERT(isActive); | - | ||||||||||||||||||||||||
| 1433 | emit q->windowStateChanged(oldWindowState, q->windowState()); | - | ||||||||||||||||||||||||
| 1434 | } else if (!activate && isActive) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 1435 | isActive = false; | - | ||||||||||||||||||||||||
| 1436 | Qt::WindowStates oldWindowState = q->windowState(); | - | ||||||||||||||||||||||||
| 1437 | q->overrideWindowState(q->windowState() & ~Qt::WindowActive); | - | ||||||||||||||||||||||||
| 1438 | if (changeFocus) {
| 0 | ||||||||||||||||||||||||
| 1439 | storeFocusWidget(); | - | ||||||||||||||||||||||||
| 1440 | QWidget *focusWidget = QApplication::focusWidget(); | - | ||||||||||||||||||||||||
| 1441 | if (focusWidget && (focusWidget == q || q->isAncestorOf(focusWidget)))
| 0 | ||||||||||||||||||||||||
| 1442 | focusWidget->clearFocus(); never executed: focusWidget->clearFocus(); | 0 | ||||||||||||||||||||||||
| 1443 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1444 | if (baseWidget)
| 0 | ||||||||||||||||||||||||
| 1445 | baseWidget->overrideWindowState(baseWidget->windowState() & ~Qt::WindowActive); never executed: baseWidget->overrideWindowState(baseWidget->windowState() & ~Qt::WindowActive); | 0 | ||||||||||||||||||||||||
| 1446 | Q_ASSERT(!isActive); | - | ||||||||||||||||||||||||
| 1447 | emit q->windowStateChanged(oldWindowState, q->windowState()); | - | ||||||||||||||||||||||||
| 1448 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1449 | - | |||||||||||||||||||||||||
| 1450 | if (activate && isActive && q->isEnabled() && !q->hasFocus()
| 0 | ||||||||||||||||||||||||
| 1451 | && !q->isAncestorOf(QApplication::focusWidget())) {
| 0 | ||||||||||||||||||||||||
| 1452 | if (changeFocus)
| 0 | ||||||||||||||||||||||||
| 1453 | setFocusWidget(); never executed: setFocusWidget(); | 0 | ||||||||||||||||||||||||
| 1454 | ensureWindowState(Qt::WindowActive); | - | ||||||||||||||||||||||||
| 1455 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1456 | - | |||||||||||||||||||||||||
| 1457 | int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); | - | ||||||||||||||||||||||||
| 1458 | int titleBarHeight = this->titleBarHeight(); | - | ||||||||||||||||||||||||
| 1459 | QRegion windowDecoration = QRegion(0, 0, q->width(), q->height()); | - | ||||||||||||||||||||||||
| 1460 | windowDecoration -= QRegion(frameWidth, titleBarHeight, q->width() - 2 * frameWidth, | - | ||||||||||||||||||||||||
| 1461 | q->height() - titleBarHeight - frameWidth); | - | ||||||||||||||||||||||||
| 1462 | - | |||||||||||||||||||||||||
| 1463 | // Make sure we don't use cached style options if we get | - | ||||||||||||||||||||||||
| 1464 | // resize events right before activation/deactivation. | - | ||||||||||||||||||||||||
| 1465 | if (resizeTimerId != -1) {
| 0 | ||||||||||||||||||||||||
| 1466 | q->killTimer(resizeTimerId); | - | ||||||||||||||||||||||||
| 1467 | resizeTimerId = -1; | - | ||||||||||||||||||||||||
| 1468 | updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 1469 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1470 | - | |||||||||||||||||||||||||
| 1471 | q->update(windowDecoration); | - | ||||||||||||||||||||||||
| 1472 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1473 | - | |||||||||||||||||||||||||
| 1474 | /*! | - | ||||||||||||||||||||||||
| 1475 | \internal | - | ||||||||||||||||||||||||
| 1476 | */ | - | ||||||||||||||||||||||||
| 1477 | void QMdiSubWindowPrivate::processClickedSubControl() | - | ||||||||||||||||||||||||
| 1478 | { | - | ||||||||||||||||||||||||
| 1479 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1480 | switch (activeSubControl) { | - | ||||||||||||||||||||||||
| 1481 | case QStyle::SC_TitleBarContextHelpButton: never executed: case QStyle::SC_TitleBarContextHelpButton: | 0 | ||||||||||||||||||||||||
| 1482 | #ifndef QT_NO_WHATSTHIS | - | ||||||||||||||||||||||||
| 1483 | QWhatsThis::enterWhatsThisMode(); | - | ||||||||||||||||||||||||
| 1484 | #endif | - | ||||||||||||||||||||||||
| 1485 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1486 | case QStyle::SC_TitleBarShadeButton: never executed: case QStyle::SC_TitleBarShadeButton: | 0 | ||||||||||||||||||||||||
| 1487 | q->showShaded(); | - | ||||||||||||||||||||||||
| 1488 | hoveredSubControl = QStyle::SC_TitleBarUnshadeButton; | - | ||||||||||||||||||||||||
| 1489 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1490 | case QStyle::SC_TitleBarUnshadeButton: never executed: case QStyle::SC_TitleBarUnshadeButton: | 0 | ||||||||||||||||||||||||
| 1491 | if (q->isShaded())
| 0 | ||||||||||||||||||||||||
| 1492 | hoveredSubControl = QStyle::SC_TitleBarShadeButton; never executed: hoveredSubControl = QStyle::SC_TitleBarShadeButton; | 0 | ||||||||||||||||||||||||
| 1493 | q->showNormal(); | - | ||||||||||||||||||||||||
| 1494 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1495 | case QStyle::SC_TitleBarMinButton: never executed: case QStyle::SC_TitleBarMinButton: | 0 | ||||||||||||||||||||||||
| 1496 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 1497 | if (qobject_cast<QMacStyle *>(q->style())) { | - | ||||||||||||||||||||||||
| 1498 | if (q->isMinimized()) | - | ||||||||||||||||||||||||
| 1499 | q->showNormal(); | - | ||||||||||||||||||||||||
| 1500 | else | - | ||||||||||||||||||||||||
| 1501 | q->showMinimized(); | - | ||||||||||||||||||||||||
| 1502 | break; | - | ||||||||||||||||||||||||
| 1503 | } | - | ||||||||||||||||||||||||
| 1504 | #endif | - | ||||||||||||||||||||||||
| 1505 | q->showMinimized(); | - | ||||||||||||||||||||||||
| 1506 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1507 | case QStyle::SC_TitleBarNormalButton: never executed: case QStyle::SC_TitleBarNormalButton: | 0 | ||||||||||||||||||||||||
| 1508 | if (q->isShaded())
| 0 | ||||||||||||||||||||||||
| 1509 | hoveredSubControl = QStyle::SC_TitleBarMinButton; never executed: hoveredSubControl = QStyle::SC_TitleBarMinButton; | 0 | ||||||||||||||||||||||||
| 1510 | q->showNormal(); | - | ||||||||||||||||||||||||
| 1511 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1512 | case QStyle::SC_TitleBarMaxButton: never executed: case QStyle::SC_TitleBarMaxButton: | 0 | ||||||||||||||||||||||||
| 1513 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 1514 | if (qobject_cast<QMacStyle *>(q->style())) { | - | ||||||||||||||||||||||||
| 1515 | if (q->isMaximized()) | - | ||||||||||||||||||||||||
| 1516 | q->showNormal(); | - | ||||||||||||||||||||||||
| 1517 | else | - | ||||||||||||||||||||||||
| 1518 | q->showMaximized(); | - | ||||||||||||||||||||||||
| 1519 | break; | - | ||||||||||||||||||||||||
| 1520 | } | - | ||||||||||||||||||||||||
| 1521 | #endif | - | ||||||||||||||||||||||||
| 1522 | q->showMaximized(); | - | ||||||||||||||||||||||||
| 1523 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1524 | case QStyle::SC_TitleBarCloseButton: never executed: case QStyle::SC_TitleBarCloseButton: | 0 | ||||||||||||||||||||||||
| 1525 | q->close(); | - | ||||||||||||||||||||||||
| 1526 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1527 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1528 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1529 | } | - | ||||||||||||||||||||||||
| 1530 | } | - | ||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||
| 1532 | /*! | - | ||||||||||||||||||||||||
| 1533 | \internal | - | ||||||||||||||||||||||||
| 1534 | */ | - | ||||||||||||||||||||||||
| 1535 | QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const | - | ||||||||||||||||||||||||
| 1536 | { | - | ||||||||||||||||||||||||
| 1537 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1538 | int width = q->width(); | - | ||||||||||||||||||||||||
| 1539 | int height = q->height(); | - | ||||||||||||||||||||||||
| 1540 | int titleBarHeight = this->titleBarHeight(); | - | ||||||||||||||||||||||||
| 1541 | int frameWidth = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); | - | ||||||||||||||||||||||||
| 1542 | int cornerConst = titleBarHeight - frameWidth; | - | ||||||||||||||||||||||||
| 1543 | int titleBarConst = 2 * titleBarHeight; | - | ||||||||||||||||||||||||
| 1544 | - | |||||||||||||||||||||||||
| 1545 | if (operation == Move) {
| 0 | ||||||||||||||||||||||||
| 1546 | QStyleOptionTitleBar titleBarOptions = this->titleBarOptions(); | - | ||||||||||||||||||||||||
| 1547 | QRegion move(frameWidth, frameWidth, width - 2 * frameWidth, cornerConst); | - | ||||||||||||||||||||||||
| 1548 | // Depending on which window flags are set, activated sub controllers will | - | ||||||||||||||||||||||||
| 1549 | // be subtracted from the 'move' region. | - | ||||||||||||||||||||||||
| 1550 | for (int i = 0; i < NumSubControls; ++i) {
| 0 | ||||||||||||||||||||||||
| 1551 | if (SubControls[i] == QStyle::SC_TitleBarLabel)
| 0 | ||||||||||||||||||||||||
| 1552 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1553 | move -= QRegion(q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions, | - | ||||||||||||||||||||||||
| 1554 | SubControls[i])); | - | ||||||||||||||||||||||||
| 1555 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1556 | return move; never executed: return move; | 0 | ||||||||||||||||||||||||
| 1557 | } | - | ||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||
| 1559 | QRegion region; | - | ||||||||||||||||||||||||
| 1560 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 1561 | if (qobject_cast<QMacStyle *>(q->style())) | - | ||||||||||||||||||||||||
| 1562 | return region; | - | ||||||||||||||||||||||||
| 1563 | #endif | - | ||||||||||||||||||||||||
| 1564 | - | |||||||||||||||||||||||||
| 1565 | switch (operation) { | - | ||||||||||||||||||||||||
| 1566 | case TopResize: never executed: case TopResize: | 0 | ||||||||||||||||||||||||
| 1567 | region = QRegion(titleBarHeight, 0, width - titleBarConst, frameWidth); | - | ||||||||||||||||||||||||
| 1568 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1569 | case BottomResize: never executed: case BottomResize: | 0 | ||||||||||||||||||||||||
| 1570 | region = QRegion(titleBarHeight, height - frameWidth, width - titleBarConst, frameWidth); | - | ||||||||||||||||||||||||
| 1571 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1572 | case LeftResize: never executed: case LeftResize: | 0 | ||||||||||||||||||||||||
| 1573 | region = QRegion(0, titleBarHeight, frameWidth, height - titleBarConst); | - | ||||||||||||||||||||||||
| 1574 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1575 | case RightResize: never executed: case RightResize: | 0 | ||||||||||||||||||||||||
| 1576 | region = QRegion(width - frameWidth, titleBarHeight, frameWidth, height - titleBarConst); | - | ||||||||||||||||||||||||
| 1577 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1578 | case TopLeftResize: never executed: case TopLeftResize: | 0 | ||||||||||||||||||||||||
| 1579 | region = QRegion(0, 0, titleBarHeight, titleBarHeight) | - | ||||||||||||||||||||||||
| 1580 | - QRegion(frameWidth, frameWidth, cornerConst, cornerConst); | - | ||||||||||||||||||||||||
| 1581 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1582 | case TopRightResize: never executed: case TopRightResize: | 0 | ||||||||||||||||||||||||
| 1583 | region = QRegion(width - titleBarHeight, 0, titleBarHeight, titleBarHeight) | - | ||||||||||||||||||||||||
| 1584 | - QRegion(width - titleBarHeight, frameWidth, cornerConst, cornerConst); | - | ||||||||||||||||||||||||
| 1585 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1586 | case BottomLeftResize: never executed: case BottomLeftResize: | 0 | ||||||||||||||||||||||||
| 1587 | region = QRegion(0, height - titleBarHeight, titleBarHeight, titleBarHeight) | - | ||||||||||||||||||||||||
| 1588 | - QRegion(frameWidth, height - titleBarHeight, cornerConst, cornerConst); | - | ||||||||||||||||||||||||
| 1589 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1590 | case BottomRightResize: never executed: case BottomRightResize: | 0 | ||||||||||||||||||||||||
| 1591 | region = QRegion(width - titleBarHeight, height - titleBarHeight, titleBarHeight, titleBarHeight) | - | ||||||||||||||||||||||||
| 1592 | - QRegion(width - titleBarHeight, height - titleBarHeight, cornerConst, cornerConst); | - | ||||||||||||||||||||||||
| 1593 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1594 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1595 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1596 | } | - | ||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||
| 1598 | return region; never executed: return region; | 0 | ||||||||||||||||||||||||
| 1599 | } | - | ||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||
| 1601 | /*! | - | ||||||||||||||||||||||||
| 1602 | \internal | - | ||||||||||||||||||||||||
| 1603 | */ | - | ||||||||||||||||||||||||
| 1604 | QMdiSubWindowPrivate::Operation QMdiSubWindowPrivate::getOperation(const QPoint &pos) const | - | ||||||||||||||||||||||||
| 1605 | { | - | ||||||||||||||||||||||||
| 1606 | OperationInfoMap::const_iterator it; | - | ||||||||||||||||||||||||
| 1607 | for (it = operationMap.constBegin(); it != operationMap.constEnd(); ++it)
| 0 | ||||||||||||||||||||||||
| 1608 | if (it.value().region.contains(pos))
| 0 | ||||||||||||||||||||||||
| 1609 | return it.key(); never executed: return it.key(); | 0 | ||||||||||||||||||||||||
| 1610 | return None; never executed: return None; | 0 | ||||||||||||||||||||||||
| 1611 | } | - | ||||||||||||||||||||||||
| 1612 | - | |||||||||||||||||||||||||
| 1613 | extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); | - | ||||||||||||||||||||||||
| 1614 | - | |||||||||||||||||||||||||
| 1615 | /*! | - | ||||||||||||||||||||||||
| 1616 | \internal | - | ||||||||||||||||||||||||
| 1617 | */ | - | ||||||||||||||||||||||||
| 1618 | QStyleOptionTitleBar QMdiSubWindowPrivate::titleBarOptions() const | - | ||||||||||||||||||||||||
| 1619 | { | - | ||||||||||||||||||||||||
| 1620 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1621 | QStyleOptionTitleBar titleBarOptions; | - | ||||||||||||||||||||||||
| 1622 | titleBarOptions.initFrom(q); | - | ||||||||||||||||||||||||
| 1623 | if (activeSubControl != QStyle::SC_None) {
| 0 | ||||||||||||||||||||||||
| 1624 | if (hoveredSubControl == activeSubControl) {
| 0 | ||||||||||||||||||||||||
| 1625 | titleBarOptions.state |= QStyle::State_Sunken; | - | ||||||||||||||||||||||||
| 1626 | titleBarOptions.activeSubControls = activeSubControl; | - | ||||||||||||||||||||||||
| 1627 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1628 | } else if (autoRaise() && hoveredSubControl != QStyle::SC_None never executed: end of block
| 0 | ||||||||||||||||||||||||
| 1629 | && hoveredSubControl != QStyle::SC_TitleBarLabel) {
| 0 | ||||||||||||||||||||||||
| 1630 | titleBarOptions.state |= QStyle::State_MouseOver; | - | ||||||||||||||||||||||||
| 1631 | titleBarOptions.activeSubControls = hoveredSubControl; | - | ||||||||||||||||||||||||
| 1632 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1633 | titleBarOptions.state &= ~QStyle::State_MouseOver; | - | ||||||||||||||||||||||||
| 1634 | titleBarOptions.activeSubControls = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 1635 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1636 | - | |||||||||||||||||||||||||
| 1637 | titleBarOptions.subControls = QStyle::SC_All; | - | ||||||||||||||||||||||||
| 1638 | titleBarOptions.titleBarFlags = q->windowFlags(); | - | ||||||||||||||||||||||||
| 1639 | titleBarOptions.titleBarState = q->windowState(); | - | ||||||||||||||||||||||||
| 1640 | titleBarOptions.palette = titleBarPalette; | - | ||||||||||||||||||||||||
| 1641 | titleBarOptions.icon = menuIcon; | - | ||||||||||||||||||||||||
| 1642 | - | |||||||||||||||||||||||||
| 1643 | if (isActive) {
| 0 | ||||||||||||||||||||||||
| 1644 | titleBarOptions.state |= QStyle::State_Active; | - | ||||||||||||||||||||||||
| 1645 | titleBarOptions.titleBarState |= QStyle::State_Active; | - | ||||||||||||||||||||||||
| 1646 | titleBarOptions.palette.setCurrentColorGroup(QPalette::Active); | - | ||||||||||||||||||||||||
| 1647 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1648 | titleBarOptions.state &= ~QStyle::State_Active; | - | ||||||||||||||||||||||||
| 1649 | titleBarOptions.palette.setCurrentColorGroup(QPalette::Inactive); | - | ||||||||||||||||||||||||
| 1650 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1651 | - | |||||||||||||||||||||||||
| 1652 | int border = hasBorder(titleBarOptions) ? 4 : 0;
| 0 | ||||||||||||||||||||||||
| 1653 | int paintHeight = titleBarHeight(titleBarOptions); | - | ||||||||||||||||||||||||
| 1654 | paintHeight -= q->isMinimized() ? 2 * border : border;
| 0 | ||||||||||||||||||||||||
| 1655 | titleBarOptions.rect = QRect(border, border, q->width() - 2 * border, paintHeight); | - | ||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||
| 1657 | if (!windowTitle.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1658 | // Set the text here before asking for the width of the title bar label | - | ||||||||||||||||||||||||
| 1659 | // in case people uses the actual text to calculate the width. | - | ||||||||||||||||||||||||
| 1660 | titleBarOptions.text = windowTitle; | - | ||||||||||||||||||||||||
| 1661 | titleBarOptions.fontMetrics = QFontMetrics(font); | - | ||||||||||||||||||||||||
| 1662 | int width = q->style()->subControlRect(QStyle::CC_TitleBar, &titleBarOptions, | - | ||||||||||||||||||||||||
| 1663 | QStyle::SC_TitleBarLabel, q).width(); | - | ||||||||||||||||||||||||
| 1664 | // Set elided text if we don't have enough space for the entire title. | - | ||||||||||||||||||||||||
| 1665 | titleBarOptions.text = titleBarOptions.fontMetrics.elidedText(windowTitle, Qt::ElideRight, width); | - | ||||||||||||||||||||||||
| 1666 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1667 | return titleBarOptions; never executed: return titleBarOptions; | 0 | ||||||||||||||||||||||||
| 1668 | } | - | ||||||||||||||||||||||||
| 1669 | - | |||||||||||||||||||||||||
| 1670 | /*! | - | ||||||||||||||||||||||||
| 1671 | \internal | - | ||||||||||||||||||||||||
| 1672 | */ | - | ||||||||||||||||||||||||
| 1673 | void QMdiSubWindowPrivate::ensureWindowState(Qt::WindowState state) | - | ||||||||||||||||||||||||
| 1674 | { | - | ||||||||||||||||||||||||
| 1675 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1676 | Qt::WindowStates windowStates = q->windowState() | state; | - | ||||||||||||||||||||||||
| 1677 | switch (state) { | - | ||||||||||||||||||||||||
| 1678 | case Qt::WindowMinimized: never executed: case Qt::WindowMinimized: | 0 | ||||||||||||||||||||||||
| 1679 | windowStates &= ~Qt::WindowMaximized; | - | ||||||||||||||||||||||||
| 1680 | windowStates &= ~Qt::WindowFullScreen; | - | ||||||||||||||||||||||||
| 1681 | windowStates &= ~Qt::WindowNoState; | - | ||||||||||||||||||||||||
| 1682 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1683 | case Qt::WindowMaximized: never executed: case Qt::WindowMaximized: | 0 | ||||||||||||||||||||||||
| 1684 | windowStates &= ~Qt::WindowMinimized; | - | ||||||||||||||||||||||||
| 1685 | windowStates &= ~Qt::WindowFullScreen; | - | ||||||||||||||||||||||||
| 1686 | windowStates &= ~Qt::WindowNoState; | - | ||||||||||||||||||||||||
| 1687 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1688 | case Qt::WindowNoState: never executed: case Qt::WindowNoState: | 0 | ||||||||||||||||||||||||
| 1689 | windowStates &= ~Qt::WindowMinimized; | - | ||||||||||||||||||||||||
| 1690 | windowStates &= ~Qt::WindowMaximized; | - | ||||||||||||||||||||||||
| 1691 | windowStates &= ~Qt::WindowFullScreen; | - | ||||||||||||||||||||||||
| 1692 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1693 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1694 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1695 | } | - | ||||||||||||||||||||||||
| 1696 | if (baseWidget) {
| 0 | ||||||||||||||||||||||||
| 1697 | if (!(baseWidget->windowState() & Qt::WindowActive) && windowStates & Qt::WindowActive)
| 0 | ||||||||||||||||||||||||
| 1698 | baseWidget->overrideWindowState(windowStates & ~Qt::WindowActive); never executed: baseWidget->overrideWindowState(windowStates & ~Qt::WindowActive); | 0 | ||||||||||||||||||||||||
| 1699 | else | - | ||||||||||||||||||||||||
| 1700 | baseWidget->overrideWindowState(windowStates); never executed: baseWidget->overrideWindowState(windowStates); | 0 | ||||||||||||||||||||||||
| 1701 | } | - | ||||||||||||||||||||||||
| 1702 | q->overrideWindowState(windowStates); | - | ||||||||||||||||||||||||
| 1703 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1704 | - | |||||||||||||||||||||||||
| 1705 | /*! | - | ||||||||||||||||||||||||
| 1706 | \internal | - | ||||||||||||||||||||||||
| 1707 | */ | - | ||||||||||||||||||||||||
| 1708 | int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const | - | ||||||||||||||||||||||||
| 1709 | { | - | ||||||||||||||||||||||||
| 1710 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1711 | if (!parent || q->windowFlags() & Qt::FramelessWindowHint
| 0 | ||||||||||||||||||||||||
| 1712 | || (q->isMaximized() && !drawTitleBarWhenMaximized())) {
| 0 | ||||||||||||||||||||||||
| 1713 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1714 | } | - | ||||||||||||||||||||||||
| 1715 | - | |||||||||||||||||||||||||
| 1716 | int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, q); | - | ||||||||||||||||||||||||
| 1717 | if (hasBorder(options))
| 0 | ||||||||||||||||||||||||
| 1718 | height += q->isMinimized() ? 8 : 4; never executed: height += q->isMinimized() ? 8 : 4;
| 0 | ||||||||||||||||||||||||
| 1719 | return height; never executed: return height; | 0 | ||||||||||||||||||||||||
| 1720 | } | - | ||||||||||||||||||||||||
| 1721 | - | |||||||||||||||||||||||||
| 1722 | /*! | - | ||||||||||||||||||||||||
| 1723 | \internal | - | ||||||||||||||||||||||||
| 1724 | */ | - | ||||||||||||||||||||||||
| 1725 | void QMdiSubWindowPrivate::sizeParameters(int *margin, int *minWidth) const | - | ||||||||||||||||||||||||
| 1726 | { | - | ||||||||||||||||||||||||
| 1727 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1728 | Qt::WindowFlags flags = q->windowFlags(); | - | ||||||||||||||||||||||||
| 1729 | if (!parent || flags & Qt::FramelessWindowHint) {
| 0 | ||||||||||||||||||||||||
| 1730 | *margin = 0; | - | ||||||||||||||||||||||||
| 1731 | *minWidth = 0; | - | ||||||||||||||||||||||||
| 1732 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1733 | } | - | ||||||||||||||||||||||||
| 1734 | - | |||||||||||||||||||||||||
| 1735 | if (q->isMaximized() && !drawTitleBarWhenMaximized())
| 0 | ||||||||||||||||||||||||
| 1736 | *margin = 0; never executed: *margin = 0; | 0 | ||||||||||||||||||||||||
| 1737 | else | - | ||||||||||||||||||||||||
| 1738 | *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); never executed: *margin = q->style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, q); | 0 | ||||||||||||||||||||||||
| 1739 | - | |||||||||||||||||||||||||
| 1740 | QStyleOptionTitleBar opt = this->titleBarOptions(); | - | ||||||||||||||||||||||||
| 1741 | int tempWidth = 0; | - | ||||||||||||||||||||||||
| 1742 | for (int i = 0; i < NumSubControls; ++i) {
| 0 | ||||||||||||||||||||||||
| 1743 | if (SubControls[i] == QStyle::SC_TitleBarLabel) {
| 0 | ||||||||||||||||||||||||
| 1744 | tempWidth += 30; | - | ||||||||||||||||||||||||
| 1745 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1746 | } | - | ||||||||||||||||||||||||
| 1747 | QRect rect = q->style()->subControlRect(QStyle::CC_TitleBar, &opt, SubControls[i], q); | - | ||||||||||||||||||||||||
| 1748 | if (!rect.isValid())
| 0 | ||||||||||||||||||||||||
| 1749 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1750 | tempWidth += rect.width(); | - | ||||||||||||||||||||||||
| 1751 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1752 | *minWidth = tempWidth; | - | ||||||||||||||||||||||||
| 1753 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1754 | - | |||||||||||||||||||||||||
| 1755 | /*! | - | ||||||||||||||||||||||||
| 1756 | \internal | - | ||||||||||||||||||||||||
| 1757 | */ | - | ||||||||||||||||||||||||
| 1758 | bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const | - | ||||||||||||||||||||||||
| 1759 | { | - | ||||||||||||||||||||||||
| 1760 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1761 | if (q->window()->testAttribute(Qt::WA_CanHostQMdiSubWindowTitleBar))
| 0 | ||||||||||||||||||||||||
| 1762 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 1763 | - | |||||||||||||||||||||||||
| 1764 | if (isChildOfTabbedQMdiArea(q))
| 0 | ||||||||||||||||||||||||
| 1765 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 1766 | - | |||||||||||||||||||||||||
| 1767 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) || defined(Q_OS_WINCE_WM) | - | ||||||||||||||||||||||||
| 1768 | Q_UNUSED(isChildOfQMdiSubWindow); | - | ||||||||||||||||||||||||
| 1769 | return true; | - | ||||||||||||||||||||||||
| 1770 | #else | - | ||||||||||||||||||||||||
| 1771 | if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q))
| 0 | ||||||||||||||||||||||||
| 1772 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1773 | #if defined(QT_NO_MENUBAR) || defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 1774 | Q_UNUSED(isChildOfQMdiSubWindow); | - | ||||||||||||||||||||||||
| 1775 | return true; | - | ||||||||||||||||||||||||
| 1776 | #else | - | ||||||||||||||||||||||||
| 1777 | QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window()); | - | ||||||||||||||||||||||||
| 1778 | if (!mainWindow || !qobject_cast<QMenuBar *>(mainWindow->menuWidget())
| 0 | ||||||||||||||||||||||||
| 1779 | || mainWindow->menuWidget()->isHidden())
| 0 | ||||||||||||||||||||||||
| 1780 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1781 | - | |||||||||||||||||||||||||
| 1782 | return isChildOfQMdiSubWindow(q); never executed: return isChildOfQMdiSubWindow(q); | 0 | ||||||||||||||||||||||||
| 1783 | #endif | - | ||||||||||||||||||||||||
| 1784 | #endif | - | ||||||||||||||||||||||||
| 1785 | } | - | ||||||||||||||||||||||||
| 1786 | - | |||||||||||||||||||||||||
| 1787 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 1788 | - | |||||||||||||||||||||||||
| 1789 | /*! | - | ||||||||||||||||||||||||
| 1790 | \internal | - | ||||||||||||||||||||||||
| 1791 | */ | - | ||||||||||||||||||||||||
| 1792 | void QMdiSubWindowPrivate::showButtonsInMenuBar(QMenuBar *menuBar) | - | ||||||||||||||||||||||||
| 1793 | { | - | ||||||||||||||||||||||||
| 1794 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1795 | Q_ASSERT(q->isMaximized() && !drawTitleBarWhenMaximized()); | - | ||||||||||||||||||||||||
| 1796 | - | |||||||||||||||||||||||||
| 1797 | if (isChildOfTabbedQMdiArea(q))
| 0 | ||||||||||||||||||||||||
| 1798 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1799 | - | |||||||||||||||||||||||||
| 1800 | removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 1801 | if (!controlContainer)
| 0 | ||||||||||||||||||||||||
| 1802 | controlContainer = new ControlContainer(q); never executed: controlContainer = new ControlContainer(q); | 0 | ||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||
| 1804 | ignoreWindowTitleChange = true; | - | ||||||||||||||||||||||||
| 1805 | controlContainer->showButtonsInMenuBar(menuBar); | - | ||||||||||||||||||||||||
| 1806 | ignoreWindowTitleChange = false; | - | ||||||||||||||||||||||||
| 1807 | - | |||||||||||||||||||||||||
| 1808 | QWidget *topLevelWindow = q->window(); | - | ||||||||||||||||||||||||
| 1809 | topLevelWindow->setWindowModified(q->isWindowModified()); | - | ||||||||||||||||||||||||
| 1810 | topLevelWindow->installEventFilter(q); | - | ||||||||||||||||||||||||
| 1811 | - | |||||||||||||||||||||||||
| 1812 | int buttonHeight = 0; | - | ||||||||||||||||||||||||
| 1813 | if (controlContainer->controllerWidget())
| 0 | ||||||||||||||||||||||||
| 1814 | buttonHeight = controlContainer->controllerWidget()->height(); never executed: buttonHeight = controlContainer->controllerWidget()->height(); | 0 | ||||||||||||||||||||||||
| 1815 | else if (controlContainer->systemMenuLabel())
| 0 | ||||||||||||||||||||||||
| 1816 | buttonHeight = controlContainer->systemMenuLabel()->height(); never executed: buttonHeight = controlContainer->systemMenuLabel()->height(); | 0 | ||||||||||||||||||||||||
| 1817 | - | |||||||||||||||||||||||||
| 1818 | // This will rarely happen. | - | ||||||||||||||||||||||||
| 1819 | if (menuBar && menuBar->height() < buttonHeight
| 0 | ||||||||||||||||||||||||
| 1820 | && topLevelWindow->layout()) {
| 0 | ||||||||||||||||||||||||
| 1821 | // Make sure topLevelWindow->contentsRect returns correct geometry. | - | ||||||||||||||||||||||||
| 1822 | // topLevelWidget->updateGeoemtry will not do the trick here since it will post the event. | - | ||||||||||||||||||||||||
| 1823 | QEvent event(QEvent::LayoutRequest); | - | ||||||||||||||||||||||||
| 1824 | QApplication::sendEvent(topLevelWindow, &event); | - | ||||||||||||||||||||||||
| 1825 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1827 | - | |||||||||||||||||||||||||
| 1828 | /*! | - | ||||||||||||||||||||||||
| 1829 | \internal | - | ||||||||||||||||||||||||
| 1830 | */ | - | ||||||||||||||||||||||||
| 1831 | void QMdiSubWindowPrivate::removeButtonsFromMenuBar() | - | ||||||||||||||||||||||||
| 1832 | { | - | ||||||||||||||||||||||||
| 1833 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1834 | - | |||||||||||||||||||||||||
| 1835 | if (!controlContainer || isChildOfTabbedQMdiArea(q))
| 0 | ||||||||||||||||||||||||
| 1836 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1837 | - | |||||||||||||||||||||||||
| 1838 | QMenuBar *currentMenuBar = 0; | - | ||||||||||||||||||||||||
| 1839 | #ifndef QT_NO_MAINWINDOW | - | ||||||||||||||||||||||||
| 1840 | if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(q->window())) {
| 0 | ||||||||||||||||||||||||
| 1841 | // NB! We can't use menuBar() here because that one will actually create | - | ||||||||||||||||||||||||
| 1842 | // a menubar for us if not set. That's not what we want :-) | - | ||||||||||||||||||||||||
| 1843 | currentMenuBar = qobject_cast<QMenuBar *>(mainWindow->menuWidget()); | - | ||||||||||||||||||||||||
| 1844 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1845 | #endif | - | ||||||||||||||||||||||||
| 1846 | - | |||||||||||||||||||||||||
| 1847 | ignoreWindowTitleChange = true; | - | ||||||||||||||||||||||||
| 1848 | controlContainer->removeButtonsFromMenuBar(currentMenuBar); | - | ||||||||||||||||||||||||
| 1849 | ignoreWindowTitleChange = false; | - | ||||||||||||||||||||||||
| 1850 | - | |||||||||||||||||||||||||
| 1851 | QWidget *topLevelWindow = q->window(); | - | ||||||||||||||||||||||||
| 1852 | topLevelWindow->removeEventFilter(q); | - | ||||||||||||||||||||||||
| 1853 | if (baseWidget && !drawTitleBarWhenMaximized())
| 0 | ||||||||||||||||||||||||
| 1854 | topLevelWindow->setWindowModified(false); never executed: topLevelWindow->setWindowModified(false); | 0 | ||||||||||||||||||||||||
| 1855 | originalTitle = QString::null; | - | ||||||||||||||||||||||||
| 1856 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1857 | - | |||||||||||||||||||||||||
| 1858 | #endif // QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 1859 | - | |||||||||||||||||||||||||
| 1860 | void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild) | - | ||||||||||||||||||||||||
| 1861 | { | - | ||||||||||||||||||||||||
| 1862 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1863 | if (isRequestFromChild && !q->windowTitle().isEmpty() && !lastChildWindowTitle.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1864 | && lastChildWindowTitle != q->windowTitle()) {
| 0 | ||||||||||||||||||||||||
| 1865 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1866 | } | - | ||||||||||||||||||||||||
| 1867 | - | |||||||||||||||||||||||||
| 1868 | QWidget *titleWidget = 0; | - | ||||||||||||||||||||||||
| 1869 | if (isRequestFromChild)
| 0 | ||||||||||||||||||||||||
| 1870 | titleWidget = baseWidget; never executed: titleWidget = baseWidget; | 0 | ||||||||||||||||||||||||
| 1871 | else | - | ||||||||||||||||||||||||
| 1872 | titleWidget = q; never executed: titleWidget = q; | 0 | ||||||||||||||||||||||||
| 1873 | if (!titleWidget || titleWidget->windowTitle().isEmpty())
| 0 | ||||||||||||||||||||||||
| 1874 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1875 | - | |||||||||||||||||||||||||
| 1876 | ignoreWindowTitleChange = true; | - | ||||||||||||||||||||||||
| 1877 | q->setWindowTitle(titleWidget->windowTitle()); | - | ||||||||||||||||||||||||
| 1878 | if (q->maximizedButtonsWidget())
| 0 | ||||||||||||||||||||||||
| 1879 | setNewWindowTitle(); never executed: setNewWindowTitle(); | 0 | ||||||||||||||||||||||||
| 1880 | ignoreWindowTitleChange = false; | - | ||||||||||||||||||||||||
| 1881 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1882 | - | |||||||||||||||||||||||||
| 1883 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 1884 | void QMdiSubWindowPrivate::enterRubberBandMode() | - | ||||||||||||||||||||||||
| 1885 | { | - | ||||||||||||||||||||||||
| 1886 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1887 | if (q->isMaximized())
| 0 | ||||||||||||||||||||||||
| 1888 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1889 | Q_ASSERT(oldGeometry.isValid()); | - | ||||||||||||||||||||||||
| 1890 | Q_ASSERT(parent); | - | ||||||||||||||||||||||||
| 1891 | if (!rubberBand) {
| 0 | ||||||||||||||||||||||||
| 1892 | rubberBand = new QRubberBand(QRubberBand::Rectangle, q->parentWidget()); | - | ||||||||||||||||||||||||
| 1893 | // For accessibility to identify this special widget. | - | ||||||||||||||||||||||||
| 1894 | rubberBand->setObjectName(QLatin1String("qt_rubberband")); | - | ||||||||||||||||||||||||
| 1895 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1896 | QPoint rubberBandPos = q->mapToParent(QPoint(0, 0)); | - | ||||||||||||||||||||||||
| 1897 | rubberBand->setGeometry(rubberBandPos.x(), rubberBandPos.y(), | - | ||||||||||||||||||||||||
| 1898 | oldGeometry.width(), oldGeometry.height()); | - | ||||||||||||||||||||||||
| 1899 | rubberBand->show(); | - | ||||||||||||||||||||||||
| 1900 | isInRubberBandMode = true; | - | ||||||||||||||||||||||||
| 1901 | q->grabMouse(); | - | ||||||||||||||||||||||||
| 1902 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1903 | - | |||||||||||||||||||||||||
| 1904 | void QMdiSubWindowPrivate::leaveRubberBandMode() | - | ||||||||||||||||||||||||
| 1905 | { | - | ||||||||||||||||||||||||
| 1906 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1907 | Q_ASSERT(rubberBand); | - | ||||||||||||||||||||||||
| 1908 | Q_ASSERT(isInRubberBandMode); | - | ||||||||||||||||||||||||
| 1909 | q->releaseMouse(); | - | ||||||||||||||||||||||||
| 1910 | isInRubberBandMode = false; | - | ||||||||||||||||||||||||
| 1911 | q->setGeometry(rubberBand->geometry()); | - | ||||||||||||||||||||||||
| 1912 | rubberBand->hide(); | - | ||||||||||||||||||||||||
| 1913 | currentOperation = None; | - | ||||||||||||||||||||||||
| 1914 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1915 | #endif // QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 1916 | - | |||||||||||||||||||||||||
| 1917 | // Taken from the old QWorkspace (::readColors()) | - | ||||||||||||||||||||||||
| 1918 | QPalette QMdiSubWindowPrivate::desktopPalette() const | - | ||||||||||||||||||||||||
| 1919 | { | - | ||||||||||||||||||||||||
| 1920 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 1921 | QPalette newPalette = q->palette(); | - | ||||||||||||||||||||||||
| 1922 | - | |||||||||||||||||||||||||
| 1923 | bool colorsInitialized = false; | - | ||||||||||||||||||||||||
| 1924 | #ifdef Q_DEAD_CODE_FROM_QT4_WIN // ask system properties on windows | - | ||||||||||||||||||||||||
| 1925 | #ifndef SPI_GETGRADIENTCAPTIONS | - | ||||||||||||||||||||||||
| 1926 | #define SPI_GETGRADIENTCAPTIONS 0x1008 | - | ||||||||||||||||||||||||
| 1927 | #endif | - | ||||||||||||||||||||||||
| 1928 | #ifndef COLOR_GRADIENTACTIVECAPTION | - | ||||||||||||||||||||||||
| 1929 | #define COLOR_GRADIENTACTIVECAPTION 27 | - | ||||||||||||||||||||||||
| 1930 | #endif | - | ||||||||||||||||||||||||
| 1931 | #ifndef COLOR_GRADIENTINACTIVECAPTION | - | ||||||||||||||||||||||||
| 1932 | #define COLOR_GRADIENTINACTIVECAPTION 28 | - | ||||||||||||||||||||||||
| 1933 | #endif | - | ||||||||||||||||||||||||
| 1934 | if (QApplication::desktopSettingsAware()) { | - | ||||||||||||||||||||||||
| 1935 | newPalette.setColor(QPalette::Active, QPalette::Highlight, | - | ||||||||||||||||||||||||
| 1936 | colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION))); | - | ||||||||||||||||||||||||
| 1937 | newPalette.setColor(QPalette::Inactive, QPalette::Highlight, | - | ||||||||||||||||||||||||
| 1938 | colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION))); | - | ||||||||||||||||||||||||
| 1939 | newPalette.setColor(QPalette::Active, QPalette::HighlightedText, | - | ||||||||||||||||||||||||
| 1940 | colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT))); | - | ||||||||||||||||||||||||
| 1941 | newPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, | - | ||||||||||||||||||||||||
| 1942 | colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT))); | - | ||||||||||||||||||||||||
| 1943 | - | |||||||||||||||||||||||||
| 1944 | colorsInitialized = true; | - | ||||||||||||||||||||||||
| 1945 | BOOL hasGradient = false; | - | ||||||||||||||||||||||||
| 1946 | SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &hasGradient, 0); | - | ||||||||||||||||||||||||
| 1947 | - | |||||||||||||||||||||||||
| 1948 | if (hasGradient) { | - | ||||||||||||||||||||||||
| 1949 | newPalette.setColor(QPalette::Active, QPalette::Base, | - | ||||||||||||||||||||||||
| 1950 | colorref2qrgb(GetSysColor(COLOR_GRADIENTACTIVECAPTION))); | - | ||||||||||||||||||||||||
| 1951 | newPalette.setColor(QPalette::Inactive, QPalette::Base, | - | ||||||||||||||||||||||||
| 1952 | colorref2qrgb(GetSysColor(COLOR_GRADIENTINACTIVECAPTION))); | - | ||||||||||||||||||||||||
| 1953 | } else { | - | ||||||||||||||||||||||||
| 1954 | newPalette.setColor(QPalette::Active, QPalette::Base, | - | ||||||||||||||||||||||||
| 1955 | newPalette.color(QPalette::Active, QPalette::Highlight)); | - | ||||||||||||||||||||||||
| 1956 | newPalette.setColor(QPalette::Inactive, QPalette::Base, | - | ||||||||||||||||||||||||
| 1957 | newPalette.color(QPalette::Inactive, QPalette::Highlight)); | - | ||||||||||||||||||||||||
| 1958 | } | - | ||||||||||||||||||||||||
| 1959 | } | - | ||||||||||||||||||||||||
| 1960 | #endif // Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||||||||
| 1961 | if (!colorsInitialized) {
| 0 | ||||||||||||||||||||||||
| 1962 | newPalette.setColor(QPalette::Active, QPalette::Highlight, | - | ||||||||||||||||||||||||
| 1963 | newPalette.color(QPalette::Active, QPalette::Highlight)); | - | ||||||||||||||||||||||||
| 1964 | newPalette.setColor(QPalette::Active, QPalette::Base, | - | ||||||||||||||||||||||||
| 1965 | newPalette.color(QPalette::Active, QPalette::Highlight)); | - | ||||||||||||||||||||||||
| 1966 | newPalette.setColor(QPalette::Inactive, QPalette::Highlight, | - | ||||||||||||||||||||||||
| 1967 | newPalette.color(QPalette::Inactive, QPalette::Dark)); | - | ||||||||||||||||||||||||
| 1968 | newPalette.setColor(QPalette::Inactive, QPalette::Base, | - | ||||||||||||||||||||||||
| 1969 | newPalette.color(QPalette::Inactive, QPalette::Dark)); | - | ||||||||||||||||||||||||
| 1970 | newPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, | - | ||||||||||||||||||||||||
| 1971 | newPalette.color(QPalette::Inactive, QPalette::Window)); | - | ||||||||||||||||||||||||
| 1972 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1973 | - | |||||||||||||||||||||||||
| 1974 | return newPalette; never executed: return newPalette; | 0 | ||||||||||||||||||||||||
| 1975 | } | - | ||||||||||||||||||||||||
| 1976 | - | |||||||||||||||||||||||||
| 1977 | void QMdiSubWindowPrivate::updateActions() | - | ||||||||||||||||||||||||
| 1978 | { | - | ||||||||||||||||||||||||
| 1979 | Qt::WindowFlags windowFlags = q_func()->windowFlags(); | - | ||||||||||||||||||||||||
| 1980 | // Hide all | - | ||||||||||||||||||||||||
| 1981 | for (int i = 0; i < NumWindowStateActions; ++i)
| 0 | ||||||||||||||||||||||||
| 1982 | setVisible(WindowStateAction(i), false); never executed: setVisible(WindowStateAction(i), false); | 0 | ||||||||||||||||||||||||
| 1983 | - | |||||||||||||||||||||||||
| 1984 | if (windowFlags & Qt::FramelessWindowHint)
| 0 | ||||||||||||||||||||||||
| 1985 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1986 | - | |||||||||||||||||||||||||
| 1987 | setVisible(StayOnTopAction, true); | - | ||||||||||||||||||||||||
| 1988 | setVisible(MoveAction, moveEnabled); | - | ||||||||||||||||||||||||
| 1989 | setVisible(ResizeAction, resizeEnabled); | - | ||||||||||||||||||||||||
| 1990 | - | |||||||||||||||||||||||||
| 1991 | // CloseAction | - | ||||||||||||||||||||||||
| 1992 | if (windowFlags & Qt::WindowSystemMenuHint)
| 0 | ||||||||||||||||||||||||
| 1993 | setVisible(CloseAction, true); never executed: setVisible(CloseAction, true); | 0 | ||||||||||||||||||||||||
| 1994 | - | |||||||||||||||||||||||||
| 1995 | // RestoreAction | - | ||||||||||||||||||||||||
| 1996 | if (windowFlags & (Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint))
| 0 | ||||||||||||||||||||||||
| 1997 | setVisible(RestoreAction, true); never executed: setVisible(RestoreAction, true); | 0 | ||||||||||||||||||||||||
| 1998 | - | |||||||||||||||||||||||||
| 1999 | // MinimizeAction | - | ||||||||||||||||||||||||
| 2000 | if (windowFlags & Qt::WindowMinimizeButtonHint)
| 0 | ||||||||||||||||||||||||
| 2001 | setVisible(MinimizeAction, true); never executed: setVisible(MinimizeAction, true); | 0 | ||||||||||||||||||||||||
| 2002 | - | |||||||||||||||||||||||||
| 2003 | // MaximizeAction | - | ||||||||||||||||||||||||
| 2004 | if (windowFlags & Qt::WindowMaximizeButtonHint)
| 0 | ||||||||||||||||||||||||
| 2005 | setVisible(MaximizeAction, true); never executed: setVisible(MaximizeAction, true); | 0 | ||||||||||||||||||||||||
| 2006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2007 | - | |||||||||||||||||||||||||
| 2008 | void QMdiSubWindowPrivate::setFocusWidget() | - | ||||||||||||||||||||||||
| 2009 | { | - | ||||||||||||||||||||||||
| 2010 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2011 | if (!baseWidget) {
| 0 | ||||||||||||||||||||||||
| 2012 | q->setFocus(); | - | ||||||||||||||||||||||||
| 2013 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2014 | } | - | ||||||||||||||||||||||||
| 2015 | - | |||||||||||||||||||||||||
| 2016 | // This will give focus to the next child if possible, otherwise | - | ||||||||||||||||||||||||
| 2017 | // do nothing, hence it's not possible to tab between windows with | - | ||||||||||||||||||||||||
| 2018 | // just hitting tab (unless Qt::TabFocus is removed from the focus policy). | - | ||||||||||||||||||||||||
| 2019 | if (focusInReason == Qt::TabFocusReason) {
| 0 | ||||||||||||||||||||||||
| 2020 | q->focusNextChild(); | - | ||||||||||||||||||||||||
| 2021 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2022 | } | - | ||||||||||||||||||||||||
| 2023 | - | |||||||||||||||||||||||||
| 2024 | // Same as above, but gives focus to the previous child. | - | ||||||||||||||||||||||||
| 2025 | if (focusInReason == Qt::BacktabFocusReason) {
| 0 | ||||||||||||||||||||||||
| 2026 | q->focusPreviousChild(); | - | ||||||||||||||||||||||||
| 2027 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2028 | } | - | ||||||||||||||||||||||||
| 2029 | - | |||||||||||||||||||||||||
| 2030 | if (!(q->windowState() & Qt::WindowMinimized) && restoreFocus())
| 0 | ||||||||||||||||||||||||
| 2031 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2032 | - | |||||||||||||||||||||||||
| 2033 | if (QWidget *focusWidget = baseWidget->focusWidget()) {
| 0 | ||||||||||||||||||||||||
| 2034 | if (!focusWidget->hasFocus() && q->isAncestorOf(focusWidget)
| 0 | ||||||||||||||||||||||||
| 2035 | && focusWidget->isVisible() && !q->isMinimized()
| 0 | ||||||||||||||||||||||||
| 2036 | && focusWidget->focusPolicy() != Qt::NoFocus) {
| 0 | ||||||||||||||||||||||||
| 2037 | focusWidget->setFocus(); | - | ||||||||||||||||||||||||
| 2038 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2039 | q->setFocus(); | - | ||||||||||||||||||||||||
| 2040 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2041 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2042 | } | - | ||||||||||||||||||||||||
| 2043 | - | |||||||||||||||||||||||||
| 2044 | QWidget *focusWidget = q->nextInFocusChain(); | - | ||||||||||||||||||||||||
| 2045 | while (focusWidget && focusWidget != q && focusWidget->focusPolicy() == Qt::NoFocus)
| 0 | ||||||||||||||||||||||||
| 2046 | focusWidget = focusWidget->nextInFocusChain(); never executed: focusWidget = focusWidget->nextInFocusChain(); | 0 | ||||||||||||||||||||||||
| 2047 | if (focusWidget && q->isAncestorOf(focusWidget))
| 0 | ||||||||||||||||||||||||
| 2048 | focusWidget->setFocus(); never executed: focusWidget->setFocus(); | 0 | ||||||||||||||||||||||||
| 2049 | else if (baseWidget->focusPolicy() != Qt::NoFocus)
| 0 | ||||||||||||||||||||||||
| 2050 | baseWidget->setFocus(); never executed: baseWidget->setFocus(); | 0 | ||||||||||||||||||||||||
| 2051 | else if (!q->hasFocus())
| 0 | ||||||||||||||||||||||||
| 2052 | q->setFocus(); never executed: q->setFocus(); | 0 | ||||||||||||||||||||||||
| 2053 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2054 | - | |||||||||||||||||||||||||
| 2055 | bool QMdiSubWindowPrivate::restoreFocus() | - | ||||||||||||||||||||||||
| 2056 | { | - | ||||||||||||||||||||||||
| 2057 | if (restoreFocusWidget.isNull())
| 0 | ||||||||||||||||||||||||
| 2058 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 2059 | QWidget *candidate = restoreFocusWidget; | - | ||||||||||||||||||||||||
| 2060 | restoreFocusWidget.clear(); | - | ||||||||||||||||||||||||
| 2061 | if (!candidate->hasFocus() && q_func()->isAncestorOf(candidate)
| 0 | ||||||||||||||||||||||||
| 2062 | && candidate->isVisible()
| 0 | ||||||||||||||||||||||||
| 2063 | && candidate->focusPolicy() != Qt::NoFocus) {
| 0 | ||||||||||||||||||||||||
| 2064 | candidate->setFocus(); | - | ||||||||||||||||||||||||
| 2065 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 2066 | } | - | ||||||||||||||||||||||||
| 2067 | return candidate->hasFocus(); never executed: return candidate->hasFocus(); | 0 | ||||||||||||||||||||||||
| 2068 | } | - | ||||||||||||||||||||||||
| 2069 | - | |||||||||||||||||||||||||
| 2070 | /*! | - | ||||||||||||||||||||||||
| 2071 | \internal | - | ||||||||||||||||||||||||
| 2072 | */ | - | ||||||||||||||||||||||||
| 2073 | void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags) | - | ||||||||||||||||||||||||
| 2074 | { | - | ||||||||||||||||||||||||
| 2075 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2076 | - | |||||||||||||||||||||||||
| 2077 | if (!parent) {
| 0 | ||||||||||||||||||||||||
| 2078 | QWidgetPrivate::setWindowFlags(windowFlags); | - | ||||||||||||||||||||||||
| 2079 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2080 | } | - | ||||||||||||||||||||||||
| 2081 | - | |||||||||||||||||||||||||
| 2082 | Qt::WindowFlags windowType = windowFlags & Qt::WindowType_Mask; | - | ||||||||||||||||||||||||
| 2083 | if (windowType == Qt::Dialog || windowFlags & Qt::MSWindowsFixedSizeDialogHint)
| 0 | ||||||||||||||||||||||||
| 2084 | windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; never executed: windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint; | 0 | ||||||||||||||||||||||||
| 2085 | - | |||||||||||||||||||||||||
| 2086 | // Set standard flags if none of the customize flags are set | - | ||||||||||||||||||||||||
| 2087 | if (!(windowFlags & CustomizeWindowFlags))
| 0 | ||||||||||||||||||||||||
| 2088 | windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; never executed: windowFlags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; | 0 | ||||||||||||||||||||||||
| 2089 | else if (windowFlags & Qt::FramelessWindowHint && windowFlags & Qt::WindowStaysOnTopHint)
| 0 | ||||||||||||||||||||||||
| 2090 | windowFlags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint; never executed: windowFlags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint; | 0 | ||||||||||||||||||||||||
| 2091 | else if (windowFlags & Qt::FramelessWindowHint)
| 0 | ||||||||||||||||||||||||
| 2092 | windowFlags = Qt::FramelessWindowHint; never executed: windowFlags = Qt::FramelessWindowHint; | 0 | ||||||||||||||||||||||||
| 2093 | - | |||||||||||||||||||||||||
| 2094 | windowFlags &= ~windowType; | - | ||||||||||||||||||||||||
| 2095 | windowFlags &= ~Qt::WindowFullscreenButtonHint; | - | ||||||||||||||||||||||||
| 2096 | windowFlags |= Qt::SubWindow; | - | ||||||||||||||||||||||||
| 2097 | - | |||||||||||||||||||||||||
| 2098 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 2099 | if (QAction *stayOnTopAction = actions[QMdiSubWindowPrivate::StayOnTopAction]) {
| 0 | ||||||||||||||||||||||||
| 2100 | if (windowFlags & Qt::WindowStaysOnTopHint)
| 0 | ||||||||||||||||||||||||
| 2101 | stayOnTopAction->setChecked(true); never executed: stayOnTopAction->setChecked(true); | 0 | ||||||||||||||||||||||||
| 2102 | else | - | ||||||||||||||||||||||||
| 2103 | stayOnTopAction->setChecked(false); never executed: stayOnTopAction->setChecked(false); | 0 | ||||||||||||||||||||||||
| 2104 | } | - | ||||||||||||||||||||||||
| 2105 | #endif | - | ||||||||||||||||||||||||
| 2106 | - | |||||||||||||||||||||||||
| 2107 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 2108 | if ((windowFlags & Qt::FramelessWindowHint) && sizeGrip)
| 0 | ||||||||||||||||||||||||
| 2109 | delete sizeGrip; never executed: delete sizeGrip; | 0 | ||||||||||||||||||||||||
| 2110 | #endif | - | ||||||||||||||||||||||||
| 2111 | - | |||||||||||||||||||||||||
| 2112 | QWidgetPrivate::setWindowFlags(windowFlags); | - | ||||||||||||||||||||||||
| 2113 | updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2114 | updateActions(); | - | ||||||||||||||||||||||||
| 2115 | QSize currentSize = q->size(); | - | ||||||||||||||||||||||||
| 2116 | if (q->isVisible() && (currentSize.width() < internalMinimumSize.width()
| 0 | ||||||||||||||||||||||||
| 2117 | || currentSize.height() < internalMinimumSize.height())) {
| 0 | ||||||||||||||||||||||||
| 2118 | q->resize(currentSize.expandedTo(internalMinimumSize)); | - | ||||||||||||||||||||||||
| 2119 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2120 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||
| 2122 | void QMdiSubWindowPrivate::setVisible(WindowStateAction action, bool visible) | - | ||||||||||||||||||||||||
| 2123 | { | - | ||||||||||||||||||||||||
| 2124 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 2125 | if (actions[action])
| 0 | ||||||||||||||||||||||||
| 2126 | actions[action]->setVisible(visible); never executed: actions[action]->setVisible(visible); | 0 | ||||||||||||||||||||||||
| 2127 | #endif | - | ||||||||||||||||||||||||
| 2128 | - | |||||||||||||||||||||||||
| 2129 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2130 | if (!controlContainer)
| 0 | ||||||||||||||||||||||||
| 2131 | controlContainer = new ControlContainer(q); never executed: controlContainer = new ControlContainer(q); | 0 | ||||||||||||||||||||||||
| 2132 | - | |||||||||||||||||||||||||
| 2133 | if (ControllerWidget *ctrlWidget = qobject_cast<ControllerWidget *>
| 0 | ||||||||||||||||||||||||
| 2134 | (controlContainer->controllerWidget())) {
| 0 | ||||||||||||||||||||||||
| 2135 | ctrlWidget->setControlVisible(action, visible); | - | ||||||||||||||||||||||||
| 2136 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2137 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2138 | - | |||||||||||||||||||||||||
| 2139 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 2140 | void QMdiSubWindowPrivate::setEnabled(WindowStateAction action, bool enable) | - | ||||||||||||||||||||||||
| 2141 | { | - | ||||||||||||||||||||||||
| 2142 | if (actions[action])
| 0 | ||||||||||||||||||||||||
| 2143 | actions[action]->setEnabled(enable); never executed: actions[action]->setEnabled(enable); | 0 | ||||||||||||||||||||||||
| 2144 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2145 | - | |||||||||||||||||||||||||
| 2146 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 2147 | void QMdiSubWindowPrivate::addToSystemMenu(WindowStateAction action, const QString &text, | - | ||||||||||||||||||||||||
| 2148 | const char *slot) | - | ||||||||||||||||||||||||
| 2149 | { | - | ||||||||||||||||||||||||
| 2150 | if (!systemMenu)
| 0 | ||||||||||||||||||||||||
| 2151 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2152 | actions[action] = systemMenu->addAction(text, q_func(), slot); | - | ||||||||||||||||||||||||
| 2153 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2154 | #endif | - | ||||||||||||||||||||||||
| 2155 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
| 2156 | - | |||||||||||||||||||||||||
| 2157 | /*! | - | ||||||||||||||||||||||||
| 2158 | \internal | - | ||||||||||||||||||||||||
| 2159 | */ | - | ||||||||||||||||||||||||
| 2160 | QSize QMdiSubWindowPrivate::iconSize() const | - | ||||||||||||||||||||||||
| 2161 | { | - | ||||||||||||||||||||||||
| 2162 | Q_Q(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2163 | if (!parent || q->windowFlags() & Qt::FramelessWindowHint)
| 0 | ||||||||||||||||||||||||
| 2164 | return QSize(-1, -1); never executed: return QSize(-1, -1); | 0 | ||||||||||||||||||||||||
| 2165 | return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight()); never executed: return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight()); | 0 | ||||||||||||||||||||||||
| 2166 | } | - | ||||||||||||||||||||||||
| 2167 | - | |||||||||||||||||||||||||
| 2168 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 2169 | - | |||||||||||||||||||||||||
| 2170 | /*! | - | ||||||||||||||||||||||||
| 2171 | \internal | - | ||||||||||||||||||||||||
| 2172 | */ | - | ||||||||||||||||||||||||
| 2173 | void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) | - | ||||||||||||||||||||||||
| 2174 | { | - | ||||||||||||||||||||||||
| 2175 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2176 | if (!newSizeGrip || sizeGrip || q->windowFlags() & Qt::FramelessWindowHint)
| 0 | ||||||||||||||||||||||||
| 2177 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2178 | - | |||||||||||||||||||||||||
| 2179 | if (layout && layout->indexOf(newSizeGrip) != -1)
| 0 | ||||||||||||||||||||||||
| 2180 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2181 | newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); | - | ||||||||||||||||||||||||
| 2182 | bool putSizeGripInLayout = layout ? true : false;
| 0 | ||||||||||||||||||||||||
| 2183 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 2184 | if (qobject_cast<QMacStyle *>(q->style())) | - | ||||||||||||||||||||||||
| 2185 | putSizeGripInLayout = false; | - | ||||||||||||||||||||||||
| 2186 | #endif | - | ||||||||||||||||||||||||
| 2187 | if (putSizeGripInLayout) {
| 0 | ||||||||||||||||||||||||
| 2188 | layout->addWidget(newSizeGrip); | - | ||||||||||||||||||||||||
| 2189 | layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight); | - | ||||||||||||||||||||||||
| 2190 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2191 | newSizeGrip->setParent(q); | - | ||||||||||||||||||||||||
| 2192 | newSizeGrip->move(q->isLeftToRight() ? q->width() - newSizeGrip->width() : 0, | - | ||||||||||||||||||||||||
| 2193 | q->height() - newSizeGrip->height()); | - | ||||||||||||||||||||||||
| 2194 | sizeGrip = newSizeGrip; | - | ||||||||||||||||||||||||
| 2195 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2196 | newSizeGrip->raise(); | - | ||||||||||||||||||||||||
| 2197 | updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2198 | newSizeGrip->installEventFilter(q); | - | ||||||||||||||||||||||||
| 2199 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2200 | - | |||||||||||||||||||||||||
| 2201 | /*! | - | ||||||||||||||||||||||||
| 2202 | \internal | - | ||||||||||||||||||||||||
| 2203 | */ | - | ||||||||||||||||||||||||
| 2204 | void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const | - | ||||||||||||||||||||||||
| 2205 | { | - | ||||||||||||||||||||||||
| 2206 | // See if we can find any size grips | - | ||||||||||||||||||||||||
| 2207 | QList<QSizeGrip *> sizeGrips = q_func()->findChildren<QSizeGrip *>(); | - | ||||||||||||||||||||||||
| 2208 | foreach (QSizeGrip *grip, sizeGrips) | - | ||||||||||||||||||||||||
| 2209 | grip->setVisible(visible); never executed: grip->setVisible(visible); | 0 | ||||||||||||||||||||||||
| 2210 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2211 | - | |||||||||||||||||||||||||
| 2212 | #endif // QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 2213 | - | |||||||||||||||||||||||||
| 2214 | /*! | - | ||||||||||||||||||||||||
| 2215 | \internal | - | ||||||||||||||||||||||||
| 2216 | */ | - | ||||||||||||||||||||||||
| 2217 | void QMdiSubWindowPrivate::updateInternalWindowTitle() | - | ||||||||||||||||||||||||
| 2218 | { | - | ||||||||||||||||||||||||
| 2219 | Q_Q(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2220 | if (q->isWindowModified()) {
| 0 | ||||||||||||||||||||||||
| 2221 | windowTitle = q->windowTitle(); | - | ||||||||||||||||||||||||
| 2222 | windowTitle.replace(QLatin1String("[*]"), QLatin1String("*")); | - | ||||||||||||||||||||||||
| 2223 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2224 | windowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q); | - | ||||||||||||||||||||||||
| 2225 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2226 | q->update(0, 0, q->width(), titleBarHeight()); | - | ||||||||||||||||||||||||
| 2227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2228 | - | |||||||||||||||||||||||||
| 2229 | /*! | - | ||||||||||||||||||||||||
| 2230 | Constructs a new QMdiSubWindow widget. The \a parent and \a | - | ||||||||||||||||||||||||
| 2231 | flags arguments are passed to QWidget's constructor. | - | ||||||||||||||||||||||||
| 2232 | - | |||||||||||||||||||||||||
| 2233 | Instead of using addSubWindow(), it is also simply possible to | - | ||||||||||||||||||||||||
| 2234 | use setParent() when you add the subwindow to a QMdiArea. | - | ||||||||||||||||||||||||
| 2235 | - | |||||||||||||||||||||||||
| 2236 | Note that only \l{QMdiSubWindow}s can be set as children of | - | ||||||||||||||||||||||||
| 2237 | QMdiArea; you cannot, for instance, write: | - | ||||||||||||||||||||||||
| 2238 | - | |||||||||||||||||||||||||
| 2239 | \code | - | ||||||||||||||||||||||||
| 2240 | //bad code | - | ||||||||||||||||||||||||
| 2241 | QMdiArea mdiArea; | - | ||||||||||||||||||||||||
| 2242 | QTextEdit editor(&mdiArea); // invalid child widget | - | ||||||||||||||||||||||||
| 2243 | \endcode | - | ||||||||||||||||||||||||
| 2244 | - | |||||||||||||||||||||||||
| 2245 | \sa QMdiArea::addSubWindow() | - | ||||||||||||||||||||||||
| 2246 | */ | - | ||||||||||||||||||||||||
| 2247 | QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags) | - | ||||||||||||||||||||||||
| 2248 | : QWidget(*new QMdiSubWindowPrivate, parent, 0) | - | ||||||||||||||||||||||||
| 2249 | { | - | ||||||||||||||||||||||||
| 2250 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2251 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 2252 | d->createSystemMenu(); | - | ||||||||||||||||||||||||
| 2253 | addActions(d->systemMenu->actions()); | - | ||||||||||||||||||||||||
| 2254 | #endif | - | ||||||||||||||||||||||||
| 2255 | d->setWindowFlags(flags); | - | ||||||||||||||||||||||||
| 2256 | setBackgroundRole(QPalette::Window); | - | ||||||||||||||||||||||||
| 2257 | setAutoFillBackground(true); | - | ||||||||||||||||||||||||
| 2258 | setMouseTracking(true); | - | ||||||||||||||||||||||||
| 2259 | setLayout(new QVBoxLayout); | - | ||||||||||||||||||||||||
| 2260 | setFocusPolicy(Qt::StrongFocus); | - | ||||||||||||||||||||||||
| 2261 | layout()->setMargin(0); | - | ||||||||||||||||||||||||
| 2262 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2263 | setAttribute(Qt::WA_Resized, false); | - | ||||||||||||||||||||||||
| 2264 | d->titleBarPalette = d->desktopPalette(); | - | ||||||||||||||||||||||||
| 2265 | d->font = QApplication::font("QMdiSubWindowTitleBar"); | - | ||||||||||||||||||||||||
| 2266 | // We don't want the menu icon by default on mac. | - | ||||||||||||||||||||||||
| 2267 | #ifndef Q_OS_MAC | - | ||||||||||||||||||||||||
| 2268 | if (windowIcon().isNull())
| 0 | ||||||||||||||||||||||||
| 2269 | d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); never executed: d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); | 0 | ||||||||||||||||||||||||
| 2270 | else | - | ||||||||||||||||||||||||
| 2271 | d->menuIcon = windowIcon(); never executed: d->menuIcon = windowIcon(); | 0 | ||||||||||||||||||||||||
| 2272 | #endif | - | ||||||||||||||||||||||||
| 2273 | connect(qApp, SIGNAL(focusChanged(QWidget*,QWidget*)), | - | ||||||||||||||||||||||||
| 2274 | this, SLOT(_q_processFocusChanged(QWidget*,QWidget*))); | - | ||||||||||||||||||||||||
| 2275 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2276 | - | |||||||||||||||||||||||||
| 2277 | /*! | - | ||||||||||||||||||||||||
| 2278 | Destroys the subwindow. | - | ||||||||||||||||||||||||
| 2279 | - | |||||||||||||||||||||||||
| 2280 | \sa QMdiArea::removeSubWindow() | - | ||||||||||||||||||||||||
| 2281 | */ | - | ||||||||||||||||||||||||
| 2282 | QMdiSubWindow::~QMdiSubWindow() | - | ||||||||||||||||||||||||
| 2283 | { | - | ||||||||||||||||||||||||
| 2284 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2285 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2286 | d->removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 2287 | #endif | - | ||||||||||||||||||||||||
| 2288 | d->setActive(false); | - | ||||||||||||||||||||||||
| 2289 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2290 | - | |||||||||||||||||||||||||
| 2291 | /*! | - | ||||||||||||||||||||||||
| 2292 | Sets \a widget as the internal widget of this subwindow. The | - | ||||||||||||||||||||||||
| 2293 | internal widget is displayed in the center of the subwindow | - | ||||||||||||||||||||||||
| 2294 | beneath the title bar. | - | ||||||||||||||||||||||||
| 2295 | - | |||||||||||||||||||||||||
| 2296 | QMdiSubWindow takes temporary ownership of \a widget; you do | - | ||||||||||||||||||||||||
| 2297 | not have to delete it. Any existing internal widget will be | - | ||||||||||||||||||||||||
| 2298 | removed and reparented to the root window. | - | ||||||||||||||||||||||||
| 2299 | - | |||||||||||||||||||||||||
| 2300 | \sa widget() | - | ||||||||||||||||||||||||
| 2301 | */ | - | ||||||||||||||||||||||||
| 2302 | void QMdiSubWindow::setWidget(QWidget *widget) | - | ||||||||||||||||||||||||
| 2303 | { | - | ||||||||||||||||||||||||
| 2304 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2305 | if (!widget) {
| 0 | ||||||||||||||||||||||||
| 2306 | d->removeBaseWidget(); | - | ||||||||||||||||||||||||
| 2307 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2308 | } | - | ||||||||||||||||||||||||
| 2309 | - | |||||||||||||||||||||||||
| 2310 | if (widget == d->baseWidget) {
| 0 | ||||||||||||||||||||||||
| 2311 | qWarning("QMdiSubWindow::setWidget: widget is already set"); | - | ||||||||||||||||||||||||
| 2312 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2313 | } | - | ||||||||||||||||||||||||
| 2314 | - | |||||||||||||||||||||||||
| 2315 | bool wasResized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||
| 2316 | d->removeBaseWidget(); | - | ||||||||||||||||||||||||
| 2317 | - | |||||||||||||||||||||||||
| 2318 | if (QLayout *layout = this->layout())
| 0 | ||||||||||||||||||||||||
| 2319 | layout->addWidget(widget); never executed: layout->addWidget(widget); | 0 | ||||||||||||||||||||||||
| 2320 | else | - | ||||||||||||||||||||||||
| 2321 | widget->setParent(this); never executed: widget->setParent(this); | 0 | ||||||||||||||||||||||||
| 2322 | - | |||||||||||||||||||||||||
| 2323 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 2324 | QSizeGrip *sizeGrip = widget->findChild<QSizeGrip *>(); | - | ||||||||||||||||||||||||
| 2325 | if (sizeGrip)
| 0 | ||||||||||||||||||||||||
| 2326 | sizeGrip->installEventFilter(this); never executed: sizeGrip->installEventFilter(this); | 0 | ||||||||||||||||||||||||
| 2327 | if (d->sizeGrip)
| 0 | ||||||||||||||||||||||||
| 2328 | d->sizeGrip->raise(); never executed: d->sizeGrip->raise(); | 0 | ||||||||||||||||||||||||
| 2329 | #endif | - | ||||||||||||||||||||||||
| 2330 | - | |||||||||||||||||||||||||
| 2331 | d->baseWidget = widget; | - | ||||||||||||||||||||||||
| 2332 | d->baseWidget->installEventFilter(this); | - | ||||||||||||||||||||||||
| 2333 | - | |||||||||||||||||||||||||
| 2334 | d->ignoreWindowTitleChange = true; | - | ||||||||||||||||||||||||
| 2335 | bool isWindowModified = this->isWindowModified(); | - | ||||||||||||||||||||||||
| 2336 | if (windowTitle().isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 2337 | d->updateWindowTitle(true); | - | ||||||||||||||||||||||||
| 2338 | isWindowModified = d->baseWidget->isWindowModified(); | - | ||||||||||||||||||||||||
| 2339 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2340 | if (!this->isWindowModified() && isWindowModified
| 0 | ||||||||||||||||||||||||
| 2341 | && windowTitle().contains(QLatin1String("[*]"))) {
| 0 | ||||||||||||||||||||||||
| 2342 | setWindowModified(isWindowModified); | - | ||||||||||||||||||||||||
| 2343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2344 | d->lastChildWindowTitle = d->baseWidget->windowTitle(); | - | ||||||||||||||||||||||||
| 2345 | d->ignoreWindowTitleChange = false; | - | ||||||||||||||||||||||||
| 2346 | - | |||||||||||||||||||||||||
| 2347 | if (windowIcon().isNull() && !d->baseWidget->windowIcon().isNull())
| 0 | ||||||||||||||||||||||||
| 2348 | setWindowIcon(d->baseWidget->windowIcon()); never executed: setWindowIcon(d->baseWidget->windowIcon()); | 0 | ||||||||||||||||||||||||
| 2349 | - | |||||||||||||||||||||||||
| 2350 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2351 | if (!wasResized && testAttribute(Qt::WA_Resized))
| 0 | ||||||||||||||||||||||||
| 2352 | setAttribute(Qt::WA_Resized, false); never executed: setAttribute(Qt::WA_Resized, false); | 0 | ||||||||||||||||||||||||
| 2353 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2354 | - | |||||||||||||||||||||||||
| 2355 | /*! | - | ||||||||||||||||||||||||
| 2356 | Returns the current internal widget. | - | ||||||||||||||||||||||||
| 2357 | - | |||||||||||||||||||||||||
| 2358 | \sa setWidget() | - | ||||||||||||||||||||||||
| 2359 | */ | - | ||||||||||||||||||||||||
| 2360 | QWidget *QMdiSubWindow::widget() const | - | ||||||||||||||||||||||||
| 2361 | { | - | ||||||||||||||||||||||||
| 2362 | return d_func()->baseWidget; never executed: return d_func()->baseWidget; | 0 | ||||||||||||||||||||||||
| 2363 | } | - | ||||||||||||||||||||||||
| 2364 | - | |||||||||||||||||||||||||
| 2365 | - | |||||||||||||||||||||||||
| 2366 | /*! | - | ||||||||||||||||||||||||
| 2367 | \internal | - | ||||||||||||||||||||||||
| 2368 | */ | - | ||||||||||||||||||||||||
| 2369 | QWidget *QMdiSubWindow::maximizedButtonsWidget() const | - | ||||||||||||||||||||||||
| 2370 | { | - | ||||||||||||||||||||||||
| 2371 | Q_D(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2372 | if (isVisible() && d->controlContainer && isMaximized() && !d->drawTitleBarWhenMaximized()
| 0 | ||||||||||||||||||||||||
| 2373 | && !isChildOfTabbedQMdiArea(this)) {
| 0 | ||||||||||||||||||||||||
| 2374 | return d->controlContainer->controllerWidget(); never executed: return d->controlContainer->controllerWidget(); | 0 | ||||||||||||||||||||||||
| 2375 | } | - | ||||||||||||||||||||||||
| 2376 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2377 | } | - | ||||||||||||||||||||||||
| 2378 | - | |||||||||||||||||||||||||
| 2379 | /*! | - | ||||||||||||||||||||||||
| 2380 | \internal | - | ||||||||||||||||||||||||
| 2381 | */ | - | ||||||||||||||||||||||||
| 2382 | QWidget *QMdiSubWindow::maximizedSystemMenuIconWidget() const | - | ||||||||||||||||||||||||
| 2383 | { | - | ||||||||||||||||||||||||
| 2384 | Q_D(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2385 | if (isVisible() && d->controlContainer && isMaximized() && !d->drawTitleBarWhenMaximized()
| 0 | ||||||||||||||||||||||||
| 2386 | && !isChildOfTabbedQMdiArea(this)) {
| 0 | ||||||||||||||||||||||||
| 2387 | return d->controlContainer->systemMenuLabel(); never executed: return d->controlContainer->systemMenuLabel(); | 0 | ||||||||||||||||||||||||
| 2388 | } | - | ||||||||||||||||||||||||
| 2389 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2390 | } | - | ||||||||||||||||||||||||
| 2391 | - | |||||||||||||||||||||||||
| 2392 | /*! | - | ||||||||||||||||||||||||
| 2393 | Returns \c true if this window is shaded; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 2394 | - | |||||||||||||||||||||||||
| 2395 | A window is shaded if it is collapsed so that only the title bar is | - | ||||||||||||||||||||||||
| 2396 | visible. | - | ||||||||||||||||||||||||
| 2397 | */ | - | ||||||||||||||||||||||||
| 2398 | bool QMdiSubWindow::isShaded() const | - | ||||||||||||||||||||||||
| 2399 | { | - | ||||||||||||||||||||||||
| 2400 | return d_func()->isShadeMode; never executed: return d_func()->isShadeMode; | 0 | ||||||||||||||||||||||||
| 2401 | } | - | ||||||||||||||||||||||||
| 2402 | - | |||||||||||||||||||||||||
| 2403 | /*! | - | ||||||||||||||||||||||||
| 2404 | If \a on is true, \a option is enabled on the subwindow; otherwise it is | - | ||||||||||||||||||||||||
| 2405 | disabled. See SubWindowOption for the effect of each option. | - | ||||||||||||||||||||||||
| 2406 | - | |||||||||||||||||||||||||
| 2407 | \sa SubWindowOption, testOption() | - | ||||||||||||||||||||||||
| 2408 | */ | - | ||||||||||||||||||||||||
| 2409 | void QMdiSubWindow::setOption(SubWindowOption option, bool on) | - | ||||||||||||||||||||||||
| 2410 | { | - | ||||||||||||||||||||||||
| 2411 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2412 | if (on && !(d->options & option))
| 0 | ||||||||||||||||||||||||
| 2413 | d->options |= option; never executed: d->options |= option; | 0 | ||||||||||||||||||||||||
| 2414 | else if (!on && (d->options & option))
| 0 | ||||||||||||||||||||||||
| 2415 | d->options &= ~option; never executed: d->options &= ~option; | 0 | ||||||||||||||||||||||||
| 2416 | - | |||||||||||||||||||||||||
| 2417 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 2418 | if ((option & (RubberBandResize | RubberBandMove)) && !on && d->isInRubberBandMode)
| 0 | ||||||||||||||||||||||||
| 2419 | d->leaveRubberBandMode(); never executed: d->leaveRubberBandMode(); | 0 | ||||||||||||||||||||||||
| 2420 | #endif | - | ||||||||||||||||||||||||
| 2421 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2422 | - | |||||||||||||||||||||||||
| 2423 | /*! | - | ||||||||||||||||||||||||
| 2424 | Returns \c true if \a option is enabled; otherwise returns \c false. | - | ||||||||||||||||||||||||
| 2425 | - | |||||||||||||||||||||||||
| 2426 | \sa SubWindowOption, setOption() | - | ||||||||||||||||||||||||
| 2427 | */ | - | ||||||||||||||||||||||||
| 2428 | bool QMdiSubWindow::testOption(SubWindowOption option) const | - | ||||||||||||||||||||||||
| 2429 | { | - | ||||||||||||||||||||||||
| 2430 | return d_func()->options & option; never executed: return d_func()->options & option; | 0 | ||||||||||||||||||||||||
| 2431 | } | - | ||||||||||||||||||||||||
| 2432 | - | |||||||||||||||||||||||||
| 2433 | /*! | - | ||||||||||||||||||||||||
| 2434 | \property QMdiSubWindow::keyboardSingleStep | - | ||||||||||||||||||||||||
| 2435 | \brief sets how far a widget should move or resize when using the | - | ||||||||||||||||||||||||
| 2436 | keyboard arrow keys. | - | ||||||||||||||||||||||||
| 2437 | - | |||||||||||||||||||||||||
| 2438 | When in keyboard-interactive mode, you can use the arrow and page keys to | - | ||||||||||||||||||||||||
| 2439 | either move or resize the window. This property controls the arrow keys. | - | ||||||||||||||||||||||||
| 2440 | The common way to enter keyboard interactive mode is to enter the | - | ||||||||||||||||||||||||
| 2441 | subwindow menu, and select either "resize" or "move". | - | ||||||||||||||||||||||||
| 2442 | - | |||||||||||||||||||||||||
| 2443 | The default keyboard single step value is 5 pixels. | - | ||||||||||||||||||||||||
| 2444 | - | |||||||||||||||||||||||||
| 2445 | \sa keyboardPageStep | - | ||||||||||||||||||||||||
| 2446 | */ | - | ||||||||||||||||||||||||
| 2447 | int QMdiSubWindow::keyboardSingleStep() const | - | ||||||||||||||||||||||||
| 2448 | { | - | ||||||||||||||||||||||||
| 2449 | return d_func()->keyboardSingleStep; never executed: return d_func()->keyboardSingleStep; | 0 | ||||||||||||||||||||||||
| 2450 | } | - | ||||||||||||||||||||||||
| 2451 | - | |||||||||||||||||||||||||
| 2452 | void QMdiSubWindow::setKeyboardSingleStep(int step) | - | ||||||||||||||||||||||||
| 2453 | { | - | ||||||||||||||||||||||||
| 2454 | // Haven't done any boundary check here since negative step only | - | ||||||||||||||||||||||||
| 2455 | // means inverted behavior, which is OK if the user want it. | - | ||||||||||||||||||||||||
| 2456 | // A step equal to zero means "do nothing". | - | ||||||||||||||||||||||||
| 2457 | d_func()->keyboardSingleStep = step; | - | ||||||||||||||||||||||||
| 2458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2459 | - | |||||||||||||||||||||||||
| 2460 | /*! | - | ||||||||||||||||||||||||
| 2461 | \property QMdiSubWindow::keyboardPageStep | - | ||||||||||||||||||||||||
| 2462 | \brief sets how far a widget should move or resize when using the | - | ||||||||||||||||||||||||
| 2463 | keyboard page keys. | - | ||||||||||||||||||||||||
| 2464 | - | |||||||||||||||||||||||||
| 2465 | When in keyboard-interactive mode, you can use the arrow and page keys to | - | ||||||||||||||||||||||||
| 2466 | either move or resize the window. This property controls the page | - | ||||||||||||||||||||||||
| 2467 | keys. The common way to enter keyboard interactive mode is to enter the | - | ||||||||||||||||||||||||
| 2468 | subwindow menu, and select either "resize" or "move". | - | ||||||||||||||||||||||||
| 2469 | - | |||||||||||||||||||||||||
| 2470 | The default keyboard page step value is 20 pixels. | - | ||||||||||||||||||||||||
| 2471 | - | |||||||||||||||||||||||||
| 2472 | \sa keyboardSingleStep | - | ||||||||||||||||||||||||
| 2473 | */ | - | ||||||||||||||||||||||||
| 2474 | int QMdiSubWindow::keyboardPageStep() const | - | ||||||||||||||||||||||||
| 2475 | { | - | ||||||||||||||||||||||||
| 2476 | return d_func()->keyboardPageStep; never executed: return d_func()->keyboardPageStep; | 0 | ||||||||||||||||||||||||
| 2477 | } | - | ||||||||||||||||||||||||
| 2478 | - | |||||||||||||||||||||||||
| 2479 | void QMdiSubWindow::setKeyboardPageStep(int step) | - | ||||||||||||||||||||||||
| 2480 | { | - | ||||||||||||||||||||||||
| 2481 | // Haven't done any boundary check here since negative step only | - | ||||||||||||||||||||||||
| 2482 | // means inverted behavior, which is OK if the user want it. | - | ||||||||||||||||||||||||
| 2483 | // A step equal to zero means "do nothing". | - | ||||||||||||||||||||||||
| 2484 | d_func()->keyboardPageStep = step; | - | ||||||||||||||||||||||||
| 2485 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2486 | - | |||||||||||||||||||||||||
| 2487 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 2488 | /*! | - | ||||||||||||||||||||||||
| 2489 | Sets \a systemMenu as the current system menu for this subwindow. | - | ||||||||||||||||||||||||
| 2490 | - | |||||||||||||||||||||||||
| 2491 | By default, each QMdiSubWindow has a standard system menu. | - | ||||||||||||||||||||||||
| 2492 | - | |||||||||||||||||||||||||
| 2493 | QActions for the system menu created by QMdiSubWindow will | - | ||||||||||||||||||||||||
| 2494 | automatically be updated depending on the current window state; | - | ||||||||||||||||||||||||
| 2495 | e.g., the minimize action will be disabled after the window is | - | ||||||||||||||||||||||||
| 2496 | minimized. | - | ||||||||||||||||||||||||
| 2497 | - | |||||||||||||||||||||||||
| 2498 | QActions added by the user are not updated by QMdiSubWindow. | - | ||||||||||||||||||||||||
| 2499 | - | |||||||||||||||||||||||||
| 2500 | QMdiSubWindow takes ownership of \a systemMenu; you do not have to | - | ||||||||||||||||||||||||
| 2501 | delete it. Any existing menus will be deleted. | - | ||||||||||||||||||||||||
| 2502 | - | |||||||||||||||||||||||||
| 2503 | \sa systemMenu(), showSystemMenu() | - | ||||||||||||||||||||||||
| 2504 | */ | - | ||||||||||||||||||||||||
| 2505 | void QMdiSubWindow::setSystemMenu(QMenu *systemMenu) | - | ||||||||||||||||||||||||
| 2506 | { | - | ||||||||||||||||||||||||
| 2507 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2508 | if (systemMenu && systemMenu == d->systemMenu) {
| 0 | ||||||||||||||||||||||||
| 2509 | qWarning("QMdiSubWindow::setSystemMenu: system menu is already set"); | - | ||||||||||||||||||||||||
| 2510 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2511 | } | - | ||||||||||||||||||||||||
| 2512 | - | |||||||||||||||||||||||||
| 2513 | if (d->systemMenu) {
| 0 | ||||||||||||||||||||||||
| 2514 | delete d->systemMenu; | - | ||||||||||||||||||||||||
| 2515 | d->systemMenu = 0; | - | ||||||||||||||||||||||||
| 2516 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2517 | - | |||||||||||||||||||||||||
| 2518 | if (!systemMenu)
| 0 | ||||||||||||||||||||||||
| 2519 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2520 | - | |||||||||||||||||||||||||
| 2521 | if (systemMenu->parent() != this)
| 0 | ||||||||||||||||||||||||
| 2522 | systemMenu->setParent(this); never executed: systemMenu->setParent(this); | 0 | ||||||||||||||||||||||||
| 2523 | d->systemMenu = systemMenu; | - | ||||||||||||||||||||||||
| 2524 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2525 | - | |||||||||||||||||||||||||
| 2526 | /*! | - | ||||||||||||||||||||||||
| 2527 | Returns a pointer to the current system menu, or zero if no system | - | ||||||||||||||||||||||||
| 2528 | menu is set. QMdiSubWindow provides a default system menu, but you can | - | ||||||||||||||||||||||||
| 2529 | also set the menu with setSystemMenu(). | - | ||||||||||||||||||||||||
| 2530 | - | |||||||||||||||||||||||||
| 2531 | \sa setSystemMenu(), showSystemMenu() | - | ||||||||||||||||||||||||
| 2532 | */ | - | ||||||||||||||||||||||||
| 2533 | QMenu *QMdiSubWindow::systemMenu() const | - | ||||||||||||||||||||||||
| 2534 | { | - | ||||||||||||||||||||||||
| 2535 | return d_func()->systemMenu; never executed: return d_func()->systemMenu; | 0 | ||||||||||||||||||||||||
| 2536 | } | - | ||||||||||||||||||||||||
| 2537 | - | |||||||||||||||||||||||||
| 2538 | /*! | - | ||||||||||||||||||||||||
| 2539 | Shows the system menu below the system menu icon in the title bar. | - | ||||||||||||||||||||||||
| 2540 | - | |||||||||||||||||||||||||
| 2541 | \sa setSystemMenu(), systemMenu() | - | ||||||||||||||||||||||||
| 2542 | */ | - | ||||||||||||||||||||||||
| 2543 | void QMdiSubWindow::showSystemMenu() | - | ||||||||||||||||||||||||
| 2544 | { | - | ||||||||||||||||||||||||
| 2545 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2546 | if (!d->systemMenu)
| 0 | ||||||||||||||||||||||||
| 2547 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2548 | - | |||||||||||||||||||||||||
| 2549 | QPoint globalPopupPos; | - | ||||||||||||||||||||||||
| 2550 | if (QWidget *icon = maximizedSystemMenuIconWidget()) {
| 0 | ||||||||||||||||||||||||
| 2551 | if (isLeftToRight())
| 0 | ||||||||||||||||||||||||
| 2552 | globalPopupPos = icon->mapToGlobal(QPoint(0, icon->y() + icon->height())); never executed: globalPopupPos = icon->mapToGlobal(QPoint(0, icon->y() + icon->height())); | 0 | ||||||||||||||||||||||||
| 2553 | else | - | ||||||||||||||||||||||||
| 2554 | globalPopupPos = icon->mapToGlobal(QPoint(icon->width(), icon->y() + icon->height())); never executed: globalPopupPos = icon->mapToGlobal(QPoint(icon->width(), icon->y() + icon->height())); | 0 | ||||||||||||||||||||||||
| 2555 | } else { | - | ||||||||||||||||||||||||
| 2556 | if (isLeftToRight())
| 0 | ||||||||||||||||||||||||
| 2557 | globalPopupPos = mapToGlobal(contentsRect().topLeft()); never executed: globalPopupPos = mapToGlobal(contentsRect().topLeft()); | 0 | ||||||||||||||||||||||||
| 2558 | else // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top()) | - | ||||||||||||||||||||||||
| 2559 | globalPopupPos = mapToGlobal(contentsRect().topRight()) + QPoint(1, 0); never executed: globalPopupPos = mapToGlobal(contentsRect().topRight()) + QPoint(1, 0); | 0 | ||||||||||||||||||||||||
| 2560 | } | - | ||||||||||||||||||||||||
| 2561 | - | |||||||||||||||||||||||||
| 2562 | // Adjust x() with -menuwidth in reverse mode. | - | ||||||||||||||||||||||||
| 2563 | if (isRightToLeft())
| 0 | ||||||||||||||||||||||||
| 2564 | globalPopupPos -= QPoint(d->systemMenu->sizeHint().width(), 0); never executed: globalPopupPos -= QPoint(d->systemMenu->sizeHint().width(), 0); | 0 | ||||||||||||||||||||||||
| 2565 | d->systemMenu->popup(globalPopupPos); | - | ||||||||||||||||||||||||
| 2566 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2567 | #endif // QT_NO_MENU | - | ||||||||||||||||||||||||
| 2568 | - | |||||||||||||||||||||||||
| 2569 | /*! | - | ||||||||||||||||||||||||
| 2570 | \since 4.4 | - | ||||||||||||||||||||||||
| 2571 | - | |||||||||||||||||||||||||
| 2572 | Returns the area containing this sub-window, or 0 if there is none. | - | ||||||||||||||||||||||||
| 2573 | - | |||||||||||||||||||||||||
| 2574 | \sa QMdiArea::addSubWindow() | - | ||||||||||||||||||||||||
| 2575 | */ | - | ||||||||||||||||||||||||
| 2576 | QMdiArea *QMdiSubWindow::mdiArea() const | - | ||||||||||||||||||||||||
| 2577 | { | - | ||||||||||||||||||||||||
| 2578 | QWidget *parent = parentWidget(); | - | ||||||||||||||||||||||||
| 2579 | while (parent) {
| 0 | ||||||||||||||||||||||||
| 2580 | if (QMdiArea *area = qobject_cast<QMdiArea *>(parent)) {
| 0 | ||||||||||||||||||||||||
| 2581 | if (area->viewport() == parentWidget())
| 0 | ||||||||||||||||||||||||
| 2582 | return area; never executed: return area; | 0 | ||||||||||||||||||||||||
| 2583 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2584 | parent = parent->parentWidget(); | - | ||||||||||||||||||||||||
| 2585 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2586 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 2587 | } | - | ||||||||||||||||||||||||
| 2588 | - | |||||||||||||||||||||||||
| 2589 | /*! | - | ||||||||||||||||||||||||
| 2590 | Calling this function makes the subwindow enter the shaded mode. | - | ||||||||||||||||||||||||
| 2591 | When the subwindow is shaded, only the title bar is visible. | - | ||||||||||||||||||||||||
| 2592 | - | |||||||||||||||||||||||||
| 2593 | Although shading is not supported by all styles, this function will | - | ||||||||||||||||||||||||
| 2594 | still show the subwindow as shaded, regardless of whether support | - | ||||||||||||||||||||||||
| 2595 | for shading is available. However, when used with styles without | - | ||||||||||||||||||||||||
| 2596 | shading support, the user will be unable to return from shaded mode | - | ||||||||||||||||||||||||
| 2597 | through the user interface (e.g., through a shade button in the title | - | ||||||||||||||||||||||||
| 2598 | bar). | - | ||||||||||||||||||||||||
| 2599 | - | |||||||||||||||||||||||||
| 2600 | \sa isShaded() | - | ||||||||||||||||||||||||
| 2601 | */ | - | ||||||||||||||||||||||||
| 2602 | void QMdiSubWindow::showShaded() | - | ||||||||||||||||||||||||
| 2603 | { | - | ||||||||||||||||||||||||
| 2604 | if (!parent())
| 0 | ||||||||||||||||||||||||
| 2605 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2606 | - | |||||||||||||||||||||||||
| 2607 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2608 | // setMinimizeMode uses this function. | - | ||||||||||||||||||||||||
| 2609 | if (!d->isShadeRequestFromMinimizeMode && isShaded())
| 0 | ||||||||||||||||||||||||
| 2610 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2611 | - | |||||||||||||||||||||||||
| 2612 | d->isMaximizeMode = false; | - | ||||||||||||||||||||||||
| 2613 | - | |||||||||||||||||||||||||
| 2614 | d->storeFocusWidget(); | - | ||||||||||||||||||||||||
| 2615 | - | |||||||||||||||||||||||||
| 2616 | if (!d->isShadeRequestFromMinimizeMode) {
| 0 | ||||||||||||||||||||||||
| 2617 | d->isShadeMode = true; | - | ||||||||||||||||||||||||
| 2618 | d->ensureWindowState(Qt::WindowMinimized); | - | ||||||||||||||||||||||||
| 2619 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2620 | - | |||||||||||||||||||||||||
| 2621 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2622 | d->removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 2623 | #endif | - | ||||||||||||||||||||||||
| 2624 | - | |||||||||||||||||||||||||
| 2625 | // showMinimized() will reset Qt::WindowActive, which makes sense | - | ||||||||||||||||||||||||
| 2626 | // for top level widgets, but in MDI it makes sense to have an | - | ||||||||||||||||||||||||
| 2627 | // active window which is minimized. | - | ||||||||||||||||||||||||
| 2628 | if (hasFocus() || isAncestorOf(QApplication::focusWidget()))
| 0 | ||||||||||||||||||||||||
| 2629 | d->ensureWindowState(Qt::WindowActive); never executed: d->ensureWindowState(Qt::WindowActive); | 0 | ||||||||||||||||||||||||
| 2630 | - | |||||||||||||||||||||||||
| 2631 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 2632 | d->setSizeGripVisible(false); | - | ||||||||||||||||||||||||
| 2633 | #endif | - | ||||||||||||||||||||||||
| 2634 | - | |||||||||||||||||||||||||
| 2635 | if (!d->restoreSize.isValid() || d->isShadeMode) {
| 0 | ||||||||||||||||||||||||
| 2636 | d->oldGeometry = geometry(); | - | ||||||||||||||||||||||||
| 2637 | d->restoreSize.setWidth(d->oldGeometry.width()); | - | ||||||||||||||||||||||||
| 2638 | d->restoreSize.setHeight(d->oldGeometry.height()); | - | ||||||||||||||||||||||||
| 2639 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2640 | - | |||||||||||||||||||||||||
| 2641 | // Hide the window before we change the geometry to avoid multiple resize | - | ||||||||||||||||||||||||
| 2642 | // events and wrong window state. | - | ||||||||||||||||||||||||
| 2643 | const bool wasVisible = isVisible(); | - | ||||||||||||||||||||||||
| 2644 | if (wasVisible)
| 0 | ||||||||||||||||||||||||
| 2645 | setVisible(false); never executed: setVisible(false); | 0 | ||||||||||||||||||||||||
| 2646 | - | |||||||||||||||||||||||||
| 2647 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2648 | // Update minimum size to internalMinimumSize if set by user. | - | ||||||||||||||||||||||||
| 2649 | if (!minimumSize().isNull()) {
| 0 | ||||||||||||||||||||||||
| 2650 | d->userMinimumSize = minimumSize(); | - | ||||||||||||||||||||||||
| 2651 | setMinimumSize(d->internalMinimumSize); | - | ||||||||||||||||||||||||
| 2652 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2653 | resize(d->internalMinimumSize); | - | ||||||||||||||||||||||||
| 2654 | - | |||||||||||||||||||||||||
| 2655 | // Hide the internal widget if not already hidden by the user. | - | ||||||||||||||||||||||||
| 2656 | if (d->baseWidget && !d->baseWidget->isHidden()) {
| 0 | ||||||||||||||||||||||||
| 2657 | d->baseWidget->hide(); | - | ||||||||||||||||||||||||
| 2658 | d->isWidgetHiddenByUs = true; | - | ||||||||||||||||||||||||
| 2659 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2660 | - | |||||||||||||||||||||||||
| 2661 | if (wasVisible)
| 0 | ||||||||||||||||||||||||
| 2662 | setVisible(true); never executed: setVisible(true); | 0 | ||||||||||||||||||||||||
| 2663 | - | |||||||||||||||||||||||||
| 2664 | d->setFocusWidget(); | - | ||||||||||||||||||||||||
| 2665 | d->resizeEnabled = false; | - | ||||||||||||||||||||||||
| 2666 | d->moveEnabled = true; | - | ||||||||||||||||||||||||
| 2667 | d->updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 2668 | d->updateMask(); | - | ||||||||||||||||||||||||
| 2669 | - | |||||||||||||||||||||||||
| 2670 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 2671 | d->setEnabled(QMdiSubWindowPrivate::MinimizeAction, false); | - | ||||||||||||||||||||||||
| 2672 | d->setEnabled(QMdiSubWindowPrivate::ResizeAction, d->resizeEnabled); | - | ||||||||||||||||||||||||
| 2673 | d->setEnabled(QMdiSubWindowPrivate::MaximizeAction, true); | - | ||||||||||||||||||||||||
| 2674 | d->setEnabled(QMdiSubWindowPrivate::RestoreAction, true); | - | ||||||||||||||||||||||||
| 2675 | d->setEnabled(QMdiSubWindowPrivate::MoveAction, d->moveEnabled); | - | ||||||||||||||||||||||||
| 2676 | #endif | - | ||||||||||||||||||||||||
| 2677 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2678 | - | |||||||||||||||||||||||||
| 2679 | /*! | - | ||||||||||||||||||||||||
| 2680 | \reimp | - | ||||||||||||||||||||||||
| 2681 | */ | - | ||||||||||||||||||||||||
| 2682 | bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) | - | ||||||||||||||||||||||||
| 2683 | { | - | ||||||||||||||||||||||||
| 2684 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2685 | if (!object)
| 0 | ||||||||||||||||||||||||
| 2686 | return QWidget::eventFilter(object, event); never executed: return QWidget::eventFilter(object, event); | 0 | ||||||||||||||||||||||||
| 2687 | - | |||||||||||||||||||||||||
| 2688 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 2689 | // System menu events. | - | ||||||||||||||||||||||||
| 2690 | if (d->systemMenu && d->systemMenu == object) {
| 0 | ||||||||||||||||||||||||
| 2691 | if (event->type() == QEvent::MouseButtonDblClick) {
| 0 | ||||||||||||||||||||||||
| 2692 | const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event); | - | ||||||||||||||||||||||||
| 2693 | const QAction *action = d->systemMenu->actionAt(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 2694 | if (!action || action->isEnabled())
| 0 | ||||||||||||||||||||||||
| 2695 | close(); never executed: close(); | 0 | ||||||||||||||||||||||||
| 2696 | } else if (event->type() == QEvent::MouseMove) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2697 | QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); | - | ||||||||||||||||||||||||
| 2698 | d->hoveredSubControl = d->getSubControl(mapFromGlobal(mouseEvent->globalPos())); | - | ||||||||||||||||||||||||
| 2699 | } else if (event->type() == QEvent::Hide) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2700 | d->activeSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 2701 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - | ||||||||||||||||||||||||
| 2702 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2703 | return QWidget::eventFilter(object, event); never executed: return QWidget::eventFilter(object, event); | 0 | ||||||||||||||||||||||||
| 2704 | } | - | ||||||||||||||||||||||||
| 2705 | #endif | - | ||||||||||||||||||||||||
| 2706 | - | |||||||||||||||||||||||||
| 2707 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 2708 | if (object != d->baseWidget && parent() && qobject_cast<QSizeGrip *>(object)) {
| 0 | ||||||||||||||||||||||||
| 2709 | if (event->type() != QEvent::MouseButtonPress || !testOption(QMdiSubWindow::RubberBandResize))
| 0 | ||||||||||||||||||||||||
| 2710 | return QWidget::eventFilter(object, event); never executed: return QWidget::eventFilter(object, event); | 0 | ||||||||||||||||||||||||
| 2711 | const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); | - | ||||||||||||||||||||||||
| 2712 | d->mousePressPosition = parentWidget()->mapFromGlobal(mouseEvent->globalPos()); | - | ||||||||||||||||||||||||
| 2713 | d->oldGeometry = geometry(); | - | ||||||||||||||||||||||||
| 2714 | d->currentOperation = isLeftToRight() ? QMdiSubWindowPrivate::BottomRightResize
| 0 | ||||||||||||||||||||||||
| 2715 | : QMdiSubWindowPrivate::BottomLeftResize; | - | ||||||||||||||||||||||||
| 2716 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 2717 | d->enterRubberBandMode(); | - | ||||||||||||||||||||||||
| 2718 | #endif | - | ||||||||||||||||||||||||
| 2719 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 2720 | } | - | ||||||||||||||||||||||||
| 2721 | #endif | - | ||||||||||||||||||||||||
| 2722 | - | |||||||||||||||||||||||||
| 2723 | if (object != d->baseWidget && event->type() != QEvent::WindowTitleChange)
| 0 | ||||||||||||||||||||||||
| 2724 | return QWidget::eventFilter(object, event); never executed: return QWidget::eventFilter(object, event); | 0 | ||||||||||||||||||||||||
| 2725 | - | |||||||||||||||||||||||||
| 2726 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 2727 | case QEvent::Show: never executed: case QEvent::Show: | 0 | ||||||||||||||||||||||||
| 2728 | d->setActive(true); | - | ||||||||||||||||||||||||
| 2729 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2730 | case QEvent::ShowToParent: never executed: case QEvent::ShowToParent: | 0 | ||||||||||||||||||||||||
| 2731 | if (!d->isWidgetHiddenByUs)
| 0 | ||||||||||||||||||||||||
| 2732 | show(); never executed: show(); | 0 | ||||||||||||||||||||||||
| 2733 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2734 | case QEvent::WindowStateChange: { never executed: case QEvent::WindowStateChange: | 0 | ||||||||||||||||||||||||
| 2735 | QWindowStateChangeEvent *changeEvent = static_cast<QWindowStateChangeEvent*>(event); | - | ||||||||||||||||||||||||
| 2736 | if (changeEvent->isOverride())
| 0 | ||||||||||||||||||||||||
| 2737 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2738 | Qt::WindowStates oldState = changeEvent->oldState(); | - | ||||||||||||||||||||||||
| 2739 | Qt::WindowStates newState = d->baseWidget->windowState(); | - | ||||||||||||||||||||||||
| 2740 | if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized))
| 0 | ||||||||||||||||||||||||
| 2741 | showMinimized(); never executed: showMinimized(); | 0 | ||||||||||||||||||||||||
| 2742 | else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized))
| 0 | ||||||||||||||||||||||||
| 2743 | showMaximized(); never executed: showMaximized(); | 0 | ||||||||||||||||||||||||
| 2744 | else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)))
| 0 | ||||||||||||||||||||||||
| 2745 | showNormal(); never executed: showNormal(); | 0 | ||||||||||||||||||||||||
| 2746 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2747 | } | - | ||||||||||||||||||||||||
| 2748 | case QEvent::Enter: never executed: case QEvent::Enter: | 0 | ||||||||||||||||||||||||
| 2749 | d->currentOperation = QMdiSubWindowPrivate::None; | - | ||||||||||||||||||||||||
| 2750 | d->updateCursor(); | - | ||||||||||||||||||||||||
| 2751 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2752 | case QEvent::LayoutRequest: never executed: case QEvent::LayoutRequest: | 0 | ||||||||||||||||||||||||
| 2753 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2754 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2755 | case QEvent::WindowTitleChange: never executed: case QEvent::WindowTitleChange: | 0 | ||||||||||||||||||||||||
| 2756 | if (d->ignoreWindowTitleChange)
| 0 | ||||||||||||||||||||||||
| 2757 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2758 | if (object == d->baseWidget) {
| 0 | ||||||||||||||||||||||||
| 2759 | d->updateWindowTitle(true); | - | ||||||||||||||||||||||||
| 2760 | d->lastChildWindowTitle = d->baseWidget->windowTitle(); | - | ||||||||||||||||||||||||
| 2761 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2762 | } else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() never executed: end of block
| 0 | ||||||||||||||||||||||||
| 2763 | ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {
| 0 | ||||||||||||||||||||||||
| 2764 | d->originalTitle = QString::null; | - | ||||||||||||||||||||||||
| 2765 | if (d->baseWidget && d->baseWidget->windowTitle() == windowTitle())
| 0 | ||||||||||||||||||||||||
| 2766 | d->updateWindowTitle(true); never executed: d->updateWindowTitle(true); | 0 | ||||||||||||||||||||||||
| 2767 | else | - | ||||||||||||||||||||||||
| 2768 | d->updateWindowTitle(false); never executed: d->updateWindowTitle(false); | 0 | ||||||||||||||||||||||||
| 2769 | #endif | - | ||||||||||||||||||||||||
| 2770 | } | - | ||||||||||||||||||||||||
| 2771 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2772 | case QEvent::ModifiedChange: { never executed: case QEvent::ModifiedChange: | 0 | ||||||||||||||||||||||||
| 2773 | if (object != d->baseWidget)
| 0 | ||||||||||||||||||||||||
| 2774 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2775 | bool windowModified = d->baseWidget->isWindowModified(); | - | ||||||||||||||||||||||||
| 2776 | if (!windowModified && d->baseWidget->windowTitle() != windowTitle())
| 0 | ||||||||||||||||||||||||
| 2777 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2778 | if (windowTitle().contains(QLatin1String("[*]")))
| 0 | ||||||||||||||||||||||||
| 2779 | setWindowModified(windowModified); never executed: setWindowModified(windowModified); | 0 | ||||||||||||||||||||||||
| 2780 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2781 | } | - | ||||||||||||||||||||||||
| 2782 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 2783 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2784 | } | - | ||||||||||||||||||||||||
| 2785 | return QWidget::eventFilter(object, event); never executed: return QWidget::eventFilter(object, event); | 0 | ||||||||||||||||||||||||
| 2786 | } | - | ||||||||||||||||||||||||
| 2787 | - | |||||||||||||||||||||||||
| 2788 | /*! | - | ||||||||||||||||||||||||
| 2789 | \reimp | - | ||||||||||||||||||||||||
| 2790 | */ | - | ||||||||||||||||||||||||
| 2791 | bool QMdiSubWindow::event(QEvent *event) | - | ||||||||||||||||||||||||
| 2792 | { | - | ||||||||||||||||||||||||
| 2793 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2794 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 2795 | case QEvent::StyleChange: { never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||
| 2796 | bool wasShaded = isShaded(); | - | ||||||||||||||||||||||||
| 2797 | bool wasMinimized = isMinimized(); | - | ||||||||||||||||||||||||
| 2798 | bool wasMaximized = isMaximized(); | - | ||||||||||||||||||||||||
| 2799 | // Don't emit subWindowActivated, the app doesn't have to know about our hacks | - | ||||||||||||||||||||||||
| 2800 | const QScopedValueRollback<bool> activationEnabledSaver(d->activationEnabled); | - | ||||||||||||||||||||||||
| 2801 | d->activationEnabled = false; | - | ||||||||||||||||||||||||
| 2802 | - | |||||||||||||||||||||||||
| 2803 | ensurePolished(); | - | ||||||||||||||||||||||||
| 2804 | setContentsMargins(0, 0, 0, 0); | - | ||||||||||||||||||||||||
| 2805 | if (wasMinimized || wasMaximized || wasShaded)
| 0 | ||||||||||||||||||||||||
| 2806 | showNormal(); never executed: showNormal(); | 0 | ||||||||||||||||||||||||
| 2807 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2808 | resize(d->internalMinimumSize.expandedTo(size())); | - | ||||||||||||||||||||||||
| 2809 | d->updateMask(); | - | ||||||||||||||||||||||||
| 2810 | d->updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 2811 | if (wasShaded)
| 0 | ||||||||||||||||||||||||
| 2812 | showShaded(); never executed: showShaded(); | 0 | ||||||||||||||||||||||||
| 2813 | else if (wasMinimized)
| 0 | ||||||||||||||||||||||||
| 2814 | showMinimized(); never executed: showMinimized(); | 0 | ||||||||||||||||||||||||
| 2815 | else if (wasMaximized)
| 0 | ||||||||||||||||||||||||
| 2816 | showMaximized(); never executed: showMaximized(); | 0 | ||||||||||||||||||||||||
| 2817 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2818 | } | - | ||||||||||||||||||||||||
| 2819 | case QEvent::ParentAboutToChange: never executed: case QEvent::ParentAboutToChange: | 0 | ||||||||||||||||||||||||
| 2820 | d->setActive(false); | - | ||||||||||||||||||||||||
| 2821 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2822 | case QEvent::ParentChange: { never executed: case QEvent::ParentChange: | 0 | ||||||||||||||||||||||||
| 2823 | bool wasResized = testAttribute(Qt::WA_Resized); | - | ||||||||||||||||||||||||
| 2824 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2825 | d->removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 2826 | #endif | - | ||||||||||||||||||||||||
| 2827 | d->currentOperation = QMdiSubWindowPrivate::None; | - | ||||||||||||||||||||||||
| 2828 | d->activeSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 2829 | d->hoveredSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 2830 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 2831 | if (d->isInRubberBandMode)
| 0 | ||||||||||||||||||||||||
| 2832 | d->leaveRubberBandMode(); never executed: d->leaveRubberBandMode(); | 0 | ||||||||||||||||||||||||
| 2833 | #endif | - | ||||||||||||||||||||||||
| 2834 | d->isShadeMode = false; | - | ||||||||||||||||||||||||
| 2835 | d->isMaximizeMode = false; | - | ||||||||||||||||||||||||
| 2836 | d->isWidgetHiddenByUs = false; | - | ||||||||||||||||||||||||
| 2837 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 2838 | #if !defined(QT_NO_SIZEGRIP) && defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 2839 | if (qobject_cast<QMacStyle *>(style())) | - | ||||||||||||||||||||||||
| 2840 | delete d->sizeGrip; | - | ||||||||||||||||||||||||
| 2841 | #endif | - | ||||||||||||||||||||||||
| 2842 | setOption(RubberBandResize, false); | - | ||||||||||||||||||||||||
| 2843 | setOption(RubberBandMove, false); | - | ||||||||||||||||||||||||
| 2844 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2845 | d->setWindowFlags(windowFlags()); | - | ||||||||||||||||||||||||
| 2846 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2847 | setContentsMargins(0, 0, 0, 0); | - | ||||||||||||||||||||||||
| 2848 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2849 | d->updateCursor(); | - | ||||||||||||||||||||||||
| 2850 | d->updateMask(); | - | ||||||||||||||||||||||||
| 2851 | d->updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 2852 | d->updateActions(); | - | ||||||||||||||||||||||||
| 2853 | if (!wasResized && testAttribute(Qt::WA_Resized))
| 0 | ||||||||||||||||||||||||
| 2854 | setAttribute(Qt::WA_Resized, false); never executed: setAttribute(Qt::WA_Resized, false); | 0 | ||||||||||||||||||||||||
| 2855 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2856 | } | - | ||||||||||||||||||||||||
| 2857 | case QEvent::WindowActivate: never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||||||||
| 2858 | if (d->ignoreNextActivationEvent) {
| 0 | ||||||||||||||||||||||||
| 2859 | d->ignoreNextActivationEvent = false; | - | ||||||||||||||||||||||||
| 2860 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2861 | } | - | ||||||||||||||||||||||||
| 2862 | d->isExplicitlyDeactivated = false; | - | ||||||||||||||||||||||||
| 2863 | d->setActive(true); | - | ||||||||||||||||||||||||
| 2864 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2865 | case QEvent::WindowDeactivate: never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||||||||
| 2866 | if (d->ignoreNextActivationEvent) {
| 0 | ||||||||||||||||||||||||
| 2867 | d->ignoreNextActivationEvent = false; | - | ||||||||||||||||||||||||
| 2868 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2869 | } | - | ||||||||||||||||||||||||
| 2870 | d->isExplicitlyDeactivated = true; | - | ||||||||||||||||||||||||
| 2871 | d->setActive(false); | - | ||||||||||||||||||||||||
| 2872 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2873 | case QEvent::WindowTitleChange: never executed: case QEvent::WindowTitleChange: | 0 | ||||||||||||||||||||||||
| 2874 | if (!d->ignoreWindowTitleChange)
| 0 | ||||||||||||||||||||||||
| 2875 | d->updateWindowTitle(false); never executed: d->updateWindowTitle(false); | 0 | ||||||||||||||||||||||||
| 2876 | d->updateInternalWindowTitle(); | - | ||||||||||||||||||||||||
| 2877 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2878 | case QEvent::ModifiedChange: never executed: case QEvent::ModifiedChange: | 0 | ||||||||||||||||||||||||
| 2879 | if (!windowTitle().contains(QLatin1String("[*]")))
| 0 | ||||||||||||||||||||||||
| 2880 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2881 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2882 | if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar()
| 0 | ||||||||||||||||||||||||
| 2883 | ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {
| 0 | ||||||||||||||||||||||||
| 2884 | window()->setWindowModified(isWindowModified()); | - | ||||||||||||||||||||||||
| 2885 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2886 | #endif // QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2887 | d->updateInternalWindowTitle(); | - | ||||||||||||||||||||||||
| 2888 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2889 | case QEvent::LayoutDirectionChange: never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||||||||
| 2890 | d->updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 2891 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2892 | case QEvent::LayoutRequest: never executed: case QEvent::LayoutRequest: | 0 | ||||||||||||||||||||||||
| 2893 | d->updateGeometryConstraints(); | - | ||||||||||||||||||||||||
| 2894 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2895 | case QEvent::WindowIconChange: never executed: case QEvent::WindowIconChange: | 0 | ||||||||||||||||||||||||
| 2896 | d->menuIcon = windowIcon(); | - | ||||||||||||||||||||||||
| 2897 | if (d->menuIcon.isNull())
| 0 | ||||||||||||||||||||||||
| 2898 | d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); never executed: d->menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, this); | 0 | ||||||||||||||||||||||||
| 2899 | if (d->controlContainer)
| 0 | ||||||||||||||||||||||||
| 2900 | d->controlContainer->updateWindowIcon(d->menuIcon); never executed: d->controlContainer->updateWindowIcon(d->menuIcon); | 0 | ||||||||||||||||||||||||
| 2901 | if (!maximizedSystemMenuIconWidget())
| 0 | ||||||||||||||||||||||||
| 2902 | update(0, 0, width(), d->titleBarHeight()); never executed: update(0, 0, width(), d->titleBarHeight()); | 0 | ||||||||||||||||||||||||
| 2903 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2904 | case QEvent::PaletteChange: never executed: case QEvent::PaletteChange: | 0 | ||||||||||||||||||||||||
| 2905 | d->titleBarPalette = d->desktopPalette(); | - | ||||||||||||||||||||||||
| 2906 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2907 | case QEvent::FontChange: never executed: case QEvent::FontChange: | 0 | ||||||||||||||||||||||||
| 2908 | d->font = font(); | - | ||||||||||||||||||||||||
| 2909 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2910 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 2911 | case QEvent::ToolTip: never executed: case QEvent::ToolTip: | 0 | ||||||||||||||||||||||||
| 2912 | showToolTip(static_cast<QHelpEvent *>(event), this, d->titleBarOptions(), | - | ||||||||||||||||||||||||
| 2913 | QStyle::CC_TitleBar, d->hoveredSubControl); | - | ||||||||||||||||||||||||
| 2914 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2915 | #endif | - | ||||||||||||||||||||||||
| 2916 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 2917 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 2918 | } | - | ||||||||||||||||||||||||
| 2919 | return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||||||||
| 2920 | } | - | ||||||||||||||||||||||||
| 2921 | - | |||||||||||||||||||||||||
| 2922 | /*! | - | ||||||||||||||||||||||||
| 2923 | \reimp | - | ||||||||||||||||||||||||
| 2924 | */ | - | ||||||||||||||||||||||||
| 2925 | void QMdiSubWindow::showEvent(QShowEvent *showEvent) | - | ||||||||||||||||||||||||
| 2926 | { | - | ||||||||||||||||||||||||
| 2927 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 2928 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 2929 | QWidget::showEvent(showEvent); | - | ||||||||||||||||||||||||
| 2930 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2931 | } | - | ||||||||||||||||||||||||
| 2932 | - | |||||||||||||||||||||||||
| 2933 | #if !defined(QT_NO_SIZEGRIP) && defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 2934 | if (qobject_cast<QMacStyle *>(style()) && !d->sizeGrip | - | ||||||||||||||||||||||||
| 2935 | && !(windowFlags() & Qt::FramelessWindowHint)) { | - | ||||||||||||||||||||||||
| 2936 | d->setSizeGrip(new QSizeGrip(this)); | - | ||||||||||||||||||||||||
| 2937 | Q_ASSERT(d->sizeGrip); | - | ||||||||||||||||||||||||
| 2938 | if (isMinimized()) | - | ||||||||||||||||||||||||
| 2939 | d->setSizeGripVisible(false); | - | ||||||||||||||||||||||||
| 2940 | else | - | ||||||||||||||||||||||||
| 2941 | d->setSizeGripVisible(true); | - | ||||||||||||||||||||||||
| 2942 | resize(size().expandedTo(d->internalMinimumSize)); | - | ||||||||||||||||||||||||
| 2943 | } | - | ||||||||||||||||||||||||
| 2944 | #endif | - | ||||||||||||||||||||||||
| 2945 | - | |||||||||||||||||||||||||
| 2946 | d->updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 2947 | // Show buttons in the menu bar if they're already not there. | - | ||||||||||||||||||||||||
| 2948 | // We want to do this when QMdiSubWindow becomes visible after being hidden. | - | ||||||||||||||||||||||||
| 2949 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2950 | if (d->controlContainer) {
| 0 | ||||||||||||||||||||||||
| 2951 | if (QMenuBar *menuBar = d->menuBar()) {
| 0 | ||||||||||||||||||||||||
| 2952 | if (menuBar->cornerWidget(Qt::TopRightCorner) != maximizedButtonsWidget())
| 0 | ||||||||||||||||||||||||
| 2953 | d->showButtonsInMenuBar(menuBar); never executed: d->showButtonsInMenuBar(menuBar); | 0 | ||||||||||||||||||||||||
| 2954 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2955 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2956 | #endif | - | ||||||||||||||||||||||||
| 2957 | d->setActive(true); | - | ||||||||||||||||||||||||
| 2958 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2959 | - | |||||||||||||||||||||||||
| 2960 | /*! | - | ||||||||||||||||||||||||
| 2961 | \reimp | - | ||||||||||||||||||||||||
| 2962 | */ | - | ||||||||||||||||||||||||
| 2963 | void QMdiSubWindow::hideEvent(QHideEvent * /*hideEvent*/) | - | ||||||||||||||||||||||||
| 2964 | { | - | ||||||||||||||||||||||||
| 2965 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2966 | d_func()->removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 2967 | #endif | - | ||||||||||||||||||||||||
| 2968 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2969 | - | |||||||||||||||||||||||||
| 2970 | /*! | - | ||||||||||||||||||||||||
| 2971 | \reimp | - | ||||||||||||||||||||||||
| 2972 | */ | - | ||||||||||||||||||||||||
| 2973 | void QMdiSubWindow::changeEvent(QEvent *changeEvent) | - | ||||||||||||||||||||||||
| 2974 | { | - | ||||||||||||||||||||||||
| 2975 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 2976 | QWidget::changeEvent(changeEvent); | - | ||||||||||||||||||||||||
| 2977 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2978 | } | - | ||||||||||||||||||||||||
| 2979 | - | |||||||||||||||||||||||||
| 2980 | if (changeEvent->type() != QEvent::WindowStateChange) {
| 0 | ||||||||||||||||||||||||
| 2981 | QWidget::changeEvent(changeEvent); | - | ||||||||||||||||||||||||
| 2982 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2983 | } | - | ||||||||||||||||||||||||
| 2984 | - | |||||||||||||||||||||||||
| 2985 | QWindowStateChangeEvent *event = static_cast<QWindowStateChangeEvent *>(changeEvent); | - | ||||||||||||||||||||||||
| 2986 | if (event->isOverride()) {
| 0 | ||||||||||||||||||||||||
| 2987 | event->ignore(); | - | ||||||||||||||||||||||||
| 2988 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2989 | } | - | ||||||||||||||||||||||||
| 2990 | - | |||||||||||||||||||||||||
| 2991 | Qt::WindowStates oldState = event->oldState(); | - | ||||||||||||||||||||||||
| 2992 | Qt::WindowStates newState = windowState(); | - | ||||||||||||||||||||||||
| 2993 | if (oldState == newState) {
| 0 | ||||||||||||||||||||||||
| 2994 | changeEvent->ignore(); | - | ||||||||||||||||||||||||
| 2995 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 2996 | } | - | ||||||||||||||||||||||||
| 2997 | - | |||||||||||||||||||||||||
| 2998 | // QWidget ensures that the widget is visible _after_ setWindowState(), | - | ||||||||||||||||||||||||
| 2999 | // but we need to ensure that the widget is visible _before_ | - | ||||||||||||||||||||||||
| 3000 | // setWindowState() returns. | - | ||||||||||||||||||||||||
| 3001 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3002 | if (!isVisible()) {
| 0 | ||||||||||||||||||||||||
| 3003 | d->ensureWindowState(Qt::WindowNoState); | - | ||||||||||||||||||||||||
| 3004 | setVisible(true); | - | ||||||||||||||||||||||||
| 3005 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3006 | - | |||||||||||||||||||||||||
| 3007 | if (!d->oldGeometry.isValid())
| 0 | ||||||||||||||||||||||||
| 3008 | d->oldGeometry = geometry(); never executed: d->oldGeometry = geometry(); | 0 | ||||||||||||||||||||||||
| 3009 | - | |||||||||||||||||||||||||
| 3010 | if ((oldState & Qt::WindowActive) && (newState & Qt::WindowActive))
| 0 | ||||||||||||||||||||||||
| 3011 | d->currentOperation = QMdiSubWindowPrivate::None; never executed: d->currentOperation = QMdiSubWindowPrivate::None; | 0 | ||||||||||||||||||||||||
| 3012 | - | |||||||||||||||||||||||||
| 3013 | if (!(oldState & Qt::WindowMinimized) && (newState & Qt::WindowMinimized))
| 0 | ||||||||||||||||||||||||
| 3014 | d->setMinimizeMode(); never executed: d->setMinimizeMode(); | 0 | ||||||||||||||||||||||||
| 3015 | else if (!(oldState & Qt::WindowMaximized) && (newState & Qt::WindowMaximized))
| 0 | ||||||||||||||||||||||||
| 3016 | d->setMaximizeMode(); never executed: d->setMaximizeMode(); | 0 | ||||||||||||||||||||||||
| 3017 | else if (!(newState & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)))
| 0 | ||||||||||||||||||||||||
| 3018 | d->setNormalMode(); never executed: d->setNormalMode(); | 0 | ||||||||||||||||||||||||
| 3019 | - | |||||||||||||||||||||||||
| 3020 | if (d->isActive)
| 0 | ||||||||||||||||||||||||
| 3021 | d->ensureWindowState(Qt::WindowActive); never executed: d->ensureWindowState(Qt::WindowActive); | 0 | ||||||||||||||||||||||||
| 3022 | if (d->activationEnabled)
| 0 | ||||||||||||||||||||||||
| 3023 | emit windowStateChanged(oldState, windowState()); never executed: windowStateChanged(oldState, windowState()); | 0 | ||||||||||||||||||||||||
| 3024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3025 | - | |||||||||||||||||||||||||
| 3026 | /*! | - | ||||||||||||||||||||||||
| 3027 | \reimp | - | ||||||||||||||||||||||||
| 3028 | */ | - | ||||||||||||||||||||||||
| 3029 | void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent) | - | ||||||||||||||||||||||||
| 3030 | { | - | ||||||||||||||||||||||||
| 3031 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3032 | bool acceptClose = true; | - | ||||||||||||||||||||||||
| 3033 | if (d->baseWidget)
| 0 | ||||||||||||||||||||||||
| 3034 | acceptClose = d->baseWidget->close(); never executed: acceptClose = d->baseWidget->close(); | 0 | ||||||||||||||||||||||||
| 3035 | if (!acceptClose) {
| 0 | ||||||||||||||||||||||||
| 3036 | closeEvent->ignore(); | - | ||||||||||||||||||||||||
| 3037 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3038 | } | - | ||||||||||||||||||||||||
| 3039 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 3040 | d->removeButtonsFromMenuBar(); | - | ||||||||||||||||||||||||
| 3041 | #endif | - | ||||||||||||||||||||||||
| 3042 | d->setActive(false); | - | ||||||||||||||||||||||||
| 3043 | if (parentWidget() && testAttribute(Qt::WA_DeleteOnClose)) {
| 0 | ||||||||||||||||||||||||
| 3044 | QChildEvent childRemoved(QEvent::ChildRemoved, this); | - | ||||||||||||||||||||||||
| 3045 | QApplication::sendEvent(parentWidget(), &childRemoved); | - | ||||||||||||||||||||||||
| 3046 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3047 | closeEvent->accept(); | - | ||||||||||||||||||||||||
| 3048 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3049 | - | |||||||||||||||||||||||||
| 3050 | /*! | - | ||||||||||||||||||||||||
| 3051 | \reimp | - | ||||||||||||||||||||||||
| 3052 | */ | - | ||||||||||||||||||||||||
| 3053 | void QMdiSubWindow::leaveEvent(QEvent * /*leaveEvent*/) | - | ||||||||||||||||||||||||
| 3054 | { | - | ||||||||||||||||||||||||
| 3055 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3056 | if (d->hoveredSubControl != QStyle::SC_None) {
| 0 | ||||||||||||||||||||||||
| 3057 | d->hoveredSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 3058 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - | ||||||||||||||||||||||||
| 3059 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3060 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3061 | - | |||||||||||||||||||||||||
| 3062 | /*! | - | ||||||||||||||||||||||||
| 3063 | \reimp | - | ||||||||||||||||||||||||
| 3064 | - | |||||||||||||||||||||||||
| 3065 | \warning When maximizing or restoring a subwindow, the resulting call to this function | - | ||||||||||||||||||||||||
| 3066 | may have an invalid QResizeEvent::oldSize(). | - | ||||||||||||||||||||||||
| 3067 | */ | - | ||||||||||||||||||||||||
| 3068 | void QMdiSubWindow::resizeEvent(QResizeEvent *resizeEvent) | - | ||||||||||||||||||||||||
| 3069 | { | - | ||||||||||||||||||||||||
| 3070 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3071 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 3072 | if (d->sizeGrip) {
| 0 | ||||||||||||||||||||||||
| 3073 | d->sizeGrip->move(isLeftToRight() ? width() - d->sizeGrip->width() : 0, | - | ||||||||||||||||||||||||
| 3074 | height() - d->sizeGrip->height()); | - | ||||||||||||||||||||||||
| 3075 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3076 | #endif | - | ||||||||||||||||||||||||
| 3077 | - | |||||||||||||||||||||||||
| 3078 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 3079 | QWidget::resizeEvent(resizeEvent); | - | ||||||||||||||||||||||||
| 3080 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3081 | } | - | ||||||||||||||||||||||||
| 3082 | - | |||||||||||||||||||||||||
| 3083 | if (d->isMaximizeMode)
| 0 | ||||||||||||||||||||||||
| 3084 | d->ensureWindowState(Qt::WindowMaximized); never executed: d->ensureWindowState(Qt::WindowMaximized); | 0 | ||||||||||||||||||||||||
| 3085 | - | |||||||||||||||||||||||||
| 3086 | d->updateMask(); | - | ||||||||||||||||||||||||
| 3087 | if (!isVisible())
| 0 | ||||||||||||||||||||||||
| 3088 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3089 | - | |||||||||||||||||||||||||
| 3090 | if (d->resizeTimerId <= 0)
| 0 | ||||||||||||||||||||||||
| 3091 | d->cachedStyleOptions = d->titleBarOptions(); never executed: d->cachedStyleOptions = d->titleBarOptions(); | 0 | ||||||||||||||||||||||||
| 3092 | else | - | ||||||||||||||||||||||||
| 3093 | killTimer(d->resizeTimerId); never executed: killTimer(d->resizeTimerId); | 0 | ||||||||||||||||||||||||
| 3094 | d->resizeTimerId = startTimer(200); | - | ||||||||||||||||||||||||
| 3095 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3096 | - | |||||||||||||||||||||||||
| 3097 | /*! | - | ||||||||||||||||||||||||
| 3098 | \reimp | - | ||||||||||||||||||||||||
| 3099 | */ | - | ||||||||||||||||||||||||
| 3100 | void QMdiSubWindow::timerEvent(QTimerEvent *timerEvent) | - | ||||||||||||||||||||||||
| 3101 | { | - | ||||||||||||||||||||||||
| 3102 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3103 | if (timerEvent->timerId() == d->resizeTimerId) {
| 0 | ||||||||||||||||||||||||
| 3104 | killTimer(d->resizeTimerId); | - | ||||||||||||||||||||||||
| 3105 | d->resizeTimerId = -1; | - | ||||||||||||||||||||||||
| 3106 | d->updateDirtyRegions(); | - | ||||||||||||||||||||||||
| 3107 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3108 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3109 | - | |||||||||||||||||||||||||
| 3110 | /*! | - | ||||||||||||||||||||||||
| 3111 | \reimp | - | ||||||||||||||||||||||||
| 3112 | */ | - | ||||||||||||||||||||||||
| 3113 | void QMdiSubWindow::moveEvent(QMoveEvent *moveEvent) | - | ||||||||||||||||||||||||
| 3114 | { | - | ||||||||||||||||||||||||
| 3115 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 3116 | QWidget::moveEvent(moveEvent); | - | ||||||||||||||||||||||||
| 3117 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3118 | } | - | ||||||||||||||||||||||||
| 3119 | - | |||||||||||||||||||||||||
| 3120 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3121 | if (d->isMaximizeMode)
| 0 | ||||||||||||||||||||||||
| 3122 | d->ensureWindowState(Qt::WindowMaximized); never executed: d->ensureWindowState(Qt::WindowMaximized); | 0 | ||||||||||||||||||||||||
| 3123 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3124 | - | |||||||||||||||||||||||||
| 3125 | /*! | - | ||||||||||||||||||||||||
| 3126 | \reimp | - | ||||||||||||||||||||||||
| 3127 | */ | - | ||||||||||||||||||||||||
| 3128 | void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent) | - | ||||||||||||||||||||||||
| 3129 | { | - | ||||||||||||||||||||||||
| 3130 | if (!parent() || (windowFlags() & Qt::FramelessWindowHint)) {
| 0 | ||||||||||||||||||||||||
| 3131 | QWidget::paintEvent(paintEvent); | - | ||||||||||||||||||||||||
| 3132 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3133 | } | - | ||||||||||||||||||||||||
| 3134 | - | |||||||||||||||||||||||||
| 3135 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3136 | if (isMaximized() && !d->drawTitleBarWhenMaximized())
| 0 | ||||||||||||||||||||||||
| 3137 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3138 | - | |||||||||||||||||||||||||
| 3139 | if (d->resizeTimerId != -1) {
| 0 | ||||||||||||||||||||||||
| 3140 | // Only update the style option rect and the window title. | - | ||||||||||||||||||||||||
| 3141 | int border = d->hasBorder(d->cachedStyleOptions) ? 4 : 0;
| 0 | ||||||||||||||||||||||||
| 3142 | int titleBarHeight = d->titleBarHeight(d->cachedStyleOptions); | - | ||||||||||||||||||||||||
| 3143 | titleBarHeight -= isMinimized() ? 2 * border : border;
| 0 | ||||||||||||||||||||||||
| 3144 | d->cachedStyleOptions.rect = QRect(border, border, width() - 2 * border, titleBarHeight); | - | ||||||||||||||||||||||||
| 3145 | if (!d->windowTitle.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 3146 | int width = style()->subControlRect(QStyle::CC_TitleBar, &d->cachedStyleOptions, | - | ||||||||||||||||||||||||
| 3147 | QStyle::SC_TitleBarLabel, this).width(); | - | ||||||||||||||||||||||||
| 3148 | d->cachedStyleOptions.text = d->cachedStyleOptions.fontMetrics | - | ||||||||||||||||||||||||
| 3149 | .elidedText(d->windowTitle, Qt::ElideRight, width); | - | ||||||||||||||||||||||||
| 3150 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3151 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3152 | // Force full update. | - | ||||||||||||||||||||||||
| 3153 | d->cachedStyleOptions = d->titleBarOptions(); | - | ||||||||||||||||||||||||
| 3154 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3155 | - | |||||||||||||||||||||||||
| 3156 | QStylePainter painter(this); | - | ||||||||||||||||||||||||
| 3157 | if (!d->windowTitle.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3158 | painter.setFont(d->font); never executed: painter.setFont(d->font); | 0 | ||||||||||||||||||||||||
| 3159 | painter.drawComplexControl(QStyle::CC_TitleBar, d->cachedStyleOptions); | - | ||||||||||||||||||||||||
| 3160 | - | |||||||||||||||||||||||||
| 3161 | if (isMinimized() && !d->hasBorder(d->cachedStyleOptions))
| 0 | ||||||||||||||||||||||||
| 3162 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3163 | - | |||||||||||||||||||||||||
| 3164 | QStyleOptionFrame frameOptions; | - | ||||||||||||||||||||||||
| 3165 | frameOptions.initFrom(this); | - | ||||||||||||||||||||||||
| 3166 | frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, this); | - | ||||||||||||||||||||||||
| 3167 | if (d->isActive)
| 0 | ||||||||||||||||||||||||
| 3168 | frameOptions.state |= QStyle::State_Active; never executed: frameOptions.state |= QStyle::State_Active; | 0 | ||||||||||||||||||||||||
| 3169 | else | - | ||||||||||||||||||||||||
| 3170 | frameOptions.state &= ~QStyle::State_Active; never executed: frameOptions.state &= ~QStyle::State_Active; | 0 | ||||||||||||||||||||||||
| 3171 | - | |||||||||||||||||||||||||
| 3172 | // ### Ensure that we do not require setting the cliprect for 4.4 | - | ||||||||||||||||||||||||
| 3173 | if (!isMinimized() && !d->hasBorder(d->cachedStyleOptions))
| 0 | ||||||||||||||||||||||||
| 3174 | 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 | ||||||||||||||||||||||||
| 3175 | if (!isMinimized() || d->hasBorder(d->cachedStyleOptions))
| 0 | ||||||||||||||||||||||||
| 3176 | painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions); never executed: painter.drawPrimitive(QStyle::PE_FrameWindow, frameOptions); | 0 | ||||||||||||||||||||||||
| 3177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3178 | - | |||||||||||||||||||||||||
| 3179 | /*! | - | ||||||||||||||||||||||||
| 3180 | \reimp | - | ||||||||||||||||||||||||
| 3181 | */ | - | ||||||||||||||||||||||||
| 3182 | void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 3183 | { | - | ||||||||||||||||||||||||
| 3184 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 3185 | QWidget::mousePressEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 3186 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3187 | } | - | ||||||||||||||||||||||||
| 3188 | - | |||||||||||||||||||||||||
| 3189 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3190 | if (d->isInInteractiveMode)
| 0 | ||||||||||||||||||||||||
| 3191 | d->leaveInteractiveMode(); never executed: d->leaveInteractiveMode(); | 0 | ||||||||||||||||||||||||
| 3192 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 3193 | if (d->isInRubberBandMode)
| 0 | ||||||||||||||||||||||||
| 3194 | d->leaveRubberBandMode(); never executed: d->leaveRubberBandMode(); | 0 | ||||||||||||||||||||||||
| 3195 | #endif | - | ||||||||||||||||||||||||
| 3196 | - | |||||||||||||||||||||||||
| 3197 | if (mouseEvent->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 3198 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 3199 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3200 | } | - | ||||||||||||||||||||||||
| 3201 | - | |||||||||||||||||||||||||
| 3202 | if (d->currentOperation != QMdiSubWindowPrivate::None) {
| 0 | ||||||||||||||||||||||||
| 3203 | d->updateCursor(); | - | ||||||||||||||||||||||||
| 3204 | d->mousePressPosition = mapToParent(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 3205 | if (d->resizeEnabled || d->moveEnabled)
| 0 | ||||||||||||||||||||||||
| 3206 | d->oldGeometry = geometry(); never executed: d->oldGeometry = geometry(); | 0 | ||||||||||||||||||||||||
| 3207 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 3208 | if ((testOption(QMdiSubWindow::RubberBandResize) && d->isResizeOperation())
| 0 | ||||||||||||||||||||||||
| 3209 | || (testOption(QMdiSubWindow::RubberBandMove) && d->isMoveOperation())) {
| 0 | ||||||||||||||||||||||||
| 3210 | d->enterRubberBandMode(); | - | ||||||||||||||||||||||||
| 3211 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3212 | #endif | - | ||||||||||||||||||||||||
| 3213 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3214 | } | - | ||||||||||||||||||||||||
| 3215 | - | |||||||||||||||||||||||||
| 3216 | d->activeSubControl = d->hoveredSubControl; | - | ||||||||||||||||||||||||
| 3217 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 3218 | if (d->activeSubControl == QStyle::SC_TitleBarSysMenu)
| 0 | ||||||||||||||||||||||||
| 3219 | showSystemMenu(); never executed: showSystemMenu(); | 0 | ||||||||||||||||||||||||
| 3220 | else | - | ||||||||||||||||||||||||
| 3221 | #endif | - | ||||||||||||||||||||||||
| 3222 | update(QRegion(0, 0, width(), d->titleBarHeight())); never executed: update(QRegion(0, 0, width(), d->titleBarHeight())); | 0 | ||||||||||||||||||||||||
| 3223 | } | - | ||||||||||||||||||||||||
| 3224 | - | |||||||||||||||||||||||||
| 3225 | /*! | - | ||||||||||||||||||||||||
| 3226 | \reimp | - | ||||||||||||||||||||||||
| 3227 | */ | - | ||||||||||||||||||||||||
| 3228 | void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 3229 | { | - | ||||||||||||||||||||||||
| 3230 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 3231 | QWidget::mouseDoubleClickEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 3232 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3233 | } | - | ||||||||||||||||||||||||
| 3234 | - | |||||||||||||||||||||||||
| 3235 | if (mouseEvent->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 3236 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 3237 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3238 | } | - | ||||||||||||||||||||||||
| 3239 | - | |||||||||||||||||||||||||
| 3240 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3241 | if (!d->isMoveOperation()) {
| 0 | ||||||||||||||||||||||||
| 3242 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 3243 | if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu)
| 0 | ||||||||||||||||||||||||
| 3244 | close(); never executed: close(); | 0 | ||||||||||||||||||||||||
| 3245 | #endif | - | ||||||||||||||||||||||||
| 3246 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3247 | } | - | ||||||||||||||||||||||||
| 3248 | - | |||||||||||||||||||||||||
| 3249 | Qt::WindowFlags flags = windowFlags(); | - | ||||||||||||||||||||||||
| 3250 | if (isMinimized()) {
| 0 | ||||||||||||||||||||||||
| 3251 | if ((isShaded() && (flags & Qt::WindowShadeButtonHint))
| 0 | ||||||||||||||||||||||||
| 3252 | || (flags & Qt::WindowMinimizeButtonHint)) {
| 0 | ||||||||||||||||||||||||
| 3253 | showNormal(); | - | ||||||||||||||||||||||||
| 3254 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3255 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3256 | } | - | ||||||||||||||||||||||||
| 3257 | - | |||||||||||||||||||||||||
| 3258 | if (isMaximized()) {
| 0 | ||||||||||||||||||||||||
| 3259 | if (flags & Qt::WindowMaximizeButtonHint)
| 0 | ||||||||||||||||||||||||
| 3260 | showNormal(); never executed: showNormal(); | 0 | ||||||||||||||||||||||||
| 3261 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3262 | } | - | ||||||||||||||||||||||||
| 3263 | - | |||||||||||||||||||||||||
| 3264 | if (flags & Qt::WindowShadeButtonHint)
| 0 | ||||||||||||||||||||||||
| 3265 | showShaded(); never executed: showShaded(); | 0 | ||||||||||||||||||||||||
| 3266 | else if (flags & Qt::WindowMaximizeButtonHint)
| 0 | ||||||||||||||||||||||||
| 3267 | showMaximized(); never executed: showMaximized(); | 0 | ||||||||||||||||||||||||
| 3268 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3269 | - | |||||||||||||||||||||||||
| 3270 | /*! | - | ||||||||||||||||||||||||
| 3271 | \reimp | - | ||||||||||||||||||||||||
| 3272 | */ | - | ||||||||||||||||||||||||
| 3273 | void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 3274 | { | - | ||||||||||||||||||||||||
| 3275 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 3276 | QWidget::mouseReleaseEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 3277 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3278 | } | - | ||||||||||||||||||||||||
| 3279 | - | |||||||||||||||||||||||||
| 3280 | if (mouseEvent->button() != Qt::LeftButton) {
| 0 | ||||||||||||||||||||||||
| 3281 | mouseEvent->ignore(); | - | ||||||||||||||||||||||||
| 3282 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3283 | } | - | ||||||||||||||||||||||||
| 3284 | - | |||||||||||||||||||||||||
| 3285 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3286 | if (d->currentOperation != QMdiSubWindowPrivate::None) {
| 0 | ||||||||||||||||||||||||
| 3287 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 3288 | if (d->isInRubberBandMode && !d->isInInteractiveMode)
| 0 | ||||||||||||||||||||||||
| 3289 | d->leaveRubberBandMode(); never executed: d->leaveRubberBandMode(); | 0 | ||||||||||||||||||||||||
| 3290 | #endif | - | ||||||||||||||||||||||||
| 3291 | if (d->resizeEnabled || d->moveEnabled)
| 0 | ||||||||||||||||||||||||
| 3292 | d->oldGeometry = geometry(); never executed: d->oldGeometry = geometry(); | 0 | ||||||||||||||||||||||||
| 3293 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3294 | - | |||||||||||||||||||||||||
| 3295 | d->currentOperation = d->getOperation(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 3296 | d->updateCursor(); | - | ||||||||||||||||||||||||
| 3297 | - | |||||||||||||||||||||||||
| 3298 | d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 3299 | if (d->activeSubControl != QStyle::SC_None
| 0 | ||||||||||||||||||||||||
| 3300 | && d->activeSubControl == d->hoveredSubControl) {
| 0 | ||||||||||||||||||||||||
| 3301 | d->processClickedSubControl(); | - | ||||||||||||||||||||||||
| 3302 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3303 | d->activeSubControl = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 3304 | update(QRegion(0, 0, width(), d->titleBarHeight())); | - | ||||||||||||||||||||||||
| 3305 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3306 | - | |||||||||||||||||||||||||
| 3307 | /*! | - | ||||||||||||||||||||||||
| 3308 | \reimp | - | ||||||||||||||||||||||||
| 3309 | */ | - | ||||||||||||||||||||||||
| 3310 | void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent) | - | ||||||||||||||||||||||||
| 3311 | { | - | ||||||||||||||||||||||||
| 3312 | if (!parent()) {
| 0 | ||||||||||||||||||||||||
| 3313 | QWidget::mouseMoveEvent(mouseEvent); | - | ||||||||||||||||||||||||
| 3314 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3315 | } | - | ||||||||||||||||||||||||
| 3316 | - | |||||||||||||||||||||||||
| 3317 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3318 | // No update needed if we're in a move/resize operation. | - | ||||||||||||||||||||||||
| 3319 | if (!d->isMoveOperation() && !d->isResizeOperation()) {
| 0 | ||||||||||||||||||||||||
| 3320 | // Find previous and current hover region. | - | ||||||||||||||||||||||||
| 3321 | const QStyleOptionTitleBar options = d->titleBarOptions(); | - | ||||||||||||||||||||||||
| 3322 | QStyle::SubControl oldHover = d->hoveredSubControl; | - | ||||||||||||||||||||||||
| 3323 | d->hoveredSubControl = d->getSubControl(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 3324 | QRegion hoverRegion; | - | ||||||||||||||||||||||||
| 3325 | if (isHoverControl(oldHover) && oldHover != d->hoveredSubControl)
| 0 | ||||||||||||||||||||||||
| 3326 | hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this); never executed: hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, oldHover, this); | 0 | ||||||||||||||||||||||||
| 3327 | if (isHoverControl(d->hoveredSubControl) && d->hoveredSubControl != oldHover) {
| 0 | ||||||||||||||||||||||||
| 3328 | hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options, | - | ||||||||||||||||||||||||
| 3329 | d->hoveredSubControl, this); | - | ||||||||||||||||||||||||
| 3330 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3331 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 3332 | if (qobject_cast<QMacStyle *>(style()) && !hoverRegion.isEmpty()) | - | ||||||||||||||||||||||||
| 3333 | hoverRegion += QRegion(0, 0, width(), d->titleBarHeight(options)); | - | ||||||||||||||||||||||||
| 3334 | #endif | - | ||||||||||||||||||||||||
| 3335 | if (!hoverRegion.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3336 | update(hoverRegion); never executed: update(hoverRegion); | 0 | ||||||||||||||||||||||||
| 3337 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3338 | - | |||||||||||||||||||||||||
| 3339 | if ((mouseEvent->buttons() & Qt::LeftButton) || d->isInInteractiveMode) {
| 0 | ||||||||||||||||||||||||
| 3340 | if ((d->isResizeOperation() && d->resizeEnabled) || (d->isMoveOperation() && d->moveEnabled))
| 0 | ||||||||||||||||||||||||
| 3341 | d->setNewGeometry(mapToParent(mouseEvent->pos())); never executed: d->setNewGeometry(mapToParent(mouseEvent->pos())); | 0 | ||||||||||||||||||||||||
| 3342 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3343 | } | - | ||||||||||||||||||||||||
| 3344 | - | |||||||||||||||||||||||||
| 3345 | // Do not resize/move if not allowed. | - | ||||||||||||||||||||||||
| 3346 | d->currentOperation = d->getOperation(mouseEvent->pos()); | - | ||||||||||||||||||||||||
| 3347 | if ((d->isResizeOperation() && !d->resizeEnabled) || (d->isMoveOperation() && !d->moveEnabled))
| 0 | ||||||||||||||||||||||||
| 3348 | d->currentOperation = QMdiSubWindowPrivate::None; never executed: d->currentOperation = QMdiSubWindowPrivate::None; | 0 | ||||||||||||||||||||||||
| 3349 | d->updateCursor(); | - | ||||||||||||||||||||||||
| 3350 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3351 | - | |||||||||||||||||||||||||
| 3352 | /*! | - | ||||||||||||||||||||||||
| 3353 | \reimp | - | ||||||||||||||||||||||||
| 3354 | */ | - | ||||||||||||||||||||||||
| 3355 | void QMdiSubWindow::keyPressEvent(QKeyEvent *keyEvent) | - | ||||||||||||||||||||||||
| 3356 | { | - | ||||||||||||||||||||||||
| 3357 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3358 | if (!d->isInInteractiveMode || !parent()) {
| 0 | ||||||||||||||||||||||||
| 3359 | keyEvent->ignore(); | - | ||||||||||||||||||||||||
| 3360 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3361 | } | - | ||||||||||||||||||||||||
| 3362 | - | |||||||||||||||||||||||||
| 3363 | QPoint delta; | - | ||||||||||||||||||||||||
| 3364 | switch (keyEvent->key()) { | - | ||||||||||||||||||||||||
| 3365 | case Qt::Key_Right: never executed: case Qt::Key_Right: | 0 | ||||||||||||||||||||||||
| 3366 | if (keyEvent->modifiers() & Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||
| 3367 | delta = QPoint(d->keyboardPageStep, 0); never executed: delta = QPoint(d->keyboardPageStep, 0); | 0 | ||||||||||||||||||||||||
| 3368 | else | - | ||||||||||||||||||||||||
| 3369 | delta = QPoint(d->keyboardSingleStep, 0); never executed: delta = QPoint(d->keyboardSingleStep, 0); | 0 | ||||||||||||||||||||||||
| 3370 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3371 | case Qt::Key_Up: never executed: case Qt::Key_Up: | 0 | ||||||||||||||||||||||||
| 3372 | if (keyEvent->modifiers() & Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||
| 3373 | delta = QPoint(0, -d->keyboardPageStep); never executed: delta = QPoint(0, -d->keyboardPageStep); | 0 | ||||||||||||||||||||||||
| 3374 | else | - | ||||||||||||||||||||||||
| 3375 | delta = QPoint(0, -d->keyboardSingleStep); never executed: delta = QPoint(0, -d->keyboardSingleStep); | 0 | ||||||||||||||||||||||||
| 3376 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3377 | case Qt::Key_Left: never executed: case Qt::Key_Left: | 0 | ||||||||||||||||||||||||
| 3378 | if (keyEvent->modifiers() & Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||
| 3379 | delta = QPoint(-d->keyboardPageStep, 0); never executed: delta = QPoint(-d->keyboardPageStep, 0); | 0 | ||||||||||||||||||||||||
| 3380 | else | - | ||||||||||||||||||||||||
| 3381 | delta = QPoint(-d->keyboardSingleStep, 0); never executed: delta = QPoint(-d->keyboardSingleStep, 0); | 0 | ||||||||||||||||||||||||
| 3382 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3383 | case Qt::Key_Down: never executed: case Qt::Key_Down: | 0 | ||||||||||||||||||||||||
| 3384 | if (keyEvent->modifiers() & Qt::ShiftModifier)
| 0 | ||||||||||||||||||||||||
| 3385 | delta = QPoint(0, d->keyboardPageStep); never executed: delta = QPoint(0, d->keyboardPageStep); | 0 | ||||||||||||||||||||||||
| 3386 | else | - | ||||||||||||||||||||||||
| 3387 | delta = QPoint(0, d->keyboardSingleStep); never executed: delta = QPoint(0, d->keyboardSingleStep); | 0 | ||||||||||||||||||||||||
| 3388 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3389 | case Qt::Key_Escape: never executed: case Qt::Key_Escape: | 0 | ||||||||||||||||||||||||
| 3390 | case Qt::Key_Return: never executed: case Qt::Key_Return: | 0 | ||||||||||||||||||||||||
| 3391 | case Qt::Key_Enter: never executed: case Qt::Key_Enter: | 0 | ||||||||||||||||||||||||
| 3392 | d->leaveInteractiveMode(); | - | ||||||||||||||||||||||||
| 3393 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3394 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 3395 | keyEvent->ignore(); | - | ||||||||||||||||||||||||
| 3396 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3397 | } | - | ||||||||||||||||||||||||
| 3398 | - | |||||||||||||||||||||||||
| 3399 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||||||||
| 3400 | QPoint newPosition = parentWidget()->mapFromGlobal(cursor().pos() + delta); | - | ||||||||||||||||||||||||
| 3401 | QRect oldGeometry = | - | ||||||||||||||||||||||||
| 3402 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 3403 | d->isInRubberBandMode ? d->rubberBand->geometry() :
| 0 | ||||||||||||||||||||||||
| 3404 | #endif | - | ||||||||||||||||||||||||
| 3405 | geometry(); | - | ||||||||||||||||||||||||
| 3406 | d->setNewGeometry(newPosition); | - | ||||||||||||||||||||||||
| 3407 | QRect currentGeometry = | - | ||||||||||||||||||||||||
| 3408 | #ifndef QT_NO_RUBBERBAND | - | ||||||||||||||||||||||||
| 3409 | d->isInRubberBandMode ? d->rubberBand->geometry() :
| 0 | ||||||||||||||||||||||||
| 3410 | #endif | - | ||||||||||||||||||||||||
| 3411 | geometry(); | - | ||||||||||||||||||||||||
| 3412 | if (currentGeometry == oldGeometry)
| 0 | ||||||||||||||||||||||||
| 3413 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3414 | - | |||||||||||||||||||||||||
| 3415 | // Update cursor position | - | ||||||||||||||||||||||||
| 3416 | - | |||||||||||||||||||||||||
| 3417 | QPoint actualDelta; | - | ||||||||||||||||||||||||
| 3418 | if (d->isMoveOperation()) {
| 0 | ||||||||||||||||||||||||
| 3419 | actualDelta = QPoint(currentGeometry.x() - oldGeometry.x(), | - | ||||||||||||||||||||||||
| 3420 | currentGeometry.y() - oldGeometry.y()); | - | ||||||||||||||||||||||||
| 3421 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3422 | int dx = isLeftToRight() ? currentGeometry.width() - oldGeometry.width()
| 0 | ||||||||||||||||||||||||
| 3423 | : currentGeometry.x() - oldGeometry.x(); | - | ||||||||||||||||||||||||
| 3424 | actualDelta = QPoint(dx, currentGeometry.height() - oldGeometry.height()); | - | ||||||||||||||||||||||||
| 3425 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3426 | - | |||||||||||||||||||||||||
| 3427 | // Adjust in case we weren't able to move as long as wanted. | - | ||||||||||||||||||||||||
| 3428 | if (actualDelta != delta)
| 0 | ||||||||||||||||||||||||
| 3429 | newPosition += (actualDelta - delta); never executed: newPosition += (actualDelta - delta); | 0 | ||||||||||||||||||||||||
| 3430 | cursor().setPos(parentWidget()->mapToGlobal(newPosition)); | - | ||||||||||||||||||||||||
| 3431 | #endif | - | ||||||||||||||||||||||||
| 3432 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3433 | - | |||||||||||||||||||||||||
| 3434 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||
| 3435 | /*! | - | ||||||||||||||||||||||||
| 3436 | \reimp | - | ||||||||||||||||||||||||
| 3437 | */ | - | ||||||||||||||||||||||||
| 3438 | void QMdiSubWindow::contextMenuEvent(QContextMenuEvent *contextMenuEvent) | - | ||||||||||||||||||||||||
| 3439 | { | - | ||||||||||||||||||||||||
| 3440 | Q_D(QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3441 | if (!d->systemMenu) {
| 0 | ||||||||||||||||||||||||
| 3442 | contextMenuEvent->ignore(); | - | ||||||||||||||||||||||||
| 3443 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3444 | } | - | ||||||||||||||||||||||||
| 3445 | - | |||||||||||||||||||||||||
| 3446 | if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu
| 0 | ||||||||||||||||||||||||
| 3447 | || d->getRegion(QMdiSubWindowPrivate::Move).contains(contextMenuEvent->pos())) {
| 0 | ||||||||||||||||||||||||
| 3448 | d->systemMenu->exec(contextMenuEvent->globalPos()); | - | ||||||||||||||||||||||||
| 3449 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3450 | contextMenuEvent->ignore(); | - | ||||||||||||||||||||||||
| 3451 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3452 | } | - | ||||||||||||||||||||||||
| 3453 | #endif // QT_NO_CONTEXTMENU | - | ||||||||||||||||||||||||
| 3454 | - | |||||||||||||||||||||||||
| 3455 | /*! | - | ||||||||||||||||||||||||
| 3456 | \reimp | - | ||||||||||||||||||||||||
| 3457 | */ | - | ||||||||||||||||||||||||
| 3458 | void QMdiSubWindow::focusInEvent(QFocusEvent *focusInEvent) | - | ||||||||||||||||||||||||
| 3459 | { | - | ||||||||||||||||||||||||
| 3460 | d_func()->focusInReason = focusInEvent->reason(); | - | ||||||||||||||||||||||||
| 3461 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3462 | - | |||||||||||||||||||||||||
| 3463 | /*! | - | ||||||||||||||||||||||||
| 3464 | \reimp | - | ||||||||||||||||||||||||
| 3465 | */ | - | ||||||||||||||||||||||||
| 3466 | void QMdiSubWindow::focusOutEvent(QFocusEvent * /*focusOutEvent*/) | - | ||||||||||||||||||||||||
| 3467 | { | - | ||||||||||||||||||||||||
| 3468 | // To avoid update() in QWidget::focusOutEvent. | - | ||||||||||||||||||||||||
| 3469 | } | - | ||||||||||||||||||||||||
| 3470 | - | |||||||||||||||||||||||||
| 3471 | /*! | - | ||||||||||||||||||||||||
| 3472 | \reimp | - | ||||||||||||||||||||||||
| 3473 | */ | - | ||||||||||||||||||||||||
| 3474 | void QMdiSubWindow::childEvent(QChildEvent *childEvent) | - | ||||||||||||||||||||||||
| 3475 | { | - | ||||||||||||||||||||||||
| 3476 | if (childEvent->type() != QEvent::ChildPolished)
| 0 | ||||||||||||||||||||||||
| 3477 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3478 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 3479 | if (QSizeGrip *sizeGrip = qobject_cast<QSizeGrip *>(childEvent->child()))
| 0 | ||||||||||||||||||||||||
| 3480 | d_func()->setSizeGrip(sizeGrip); never executed: d_func()->setSizeGrip(sizeGrip); | 0 | ||||||||||||||||||||||||
| 3481 | #endif | - | ||||||||||||||||||||||||
| 3482 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3483 | - | |||||||||||||||||||||||||
| 3484 | /*! | - | ||||||||||||||||||||||||
| 3485 | \reimp | - | ||||||||||||||||||||||||
| 3486 | */ | - | ||||||||||||||||||||||||
| 3487 | QSize QMdiSubWindow::sizeHint() const | - | ||||||||||||||||||||||||
| 3488 | { | - | ||||||||||||||||||||||||
| 3489 | Q_D(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3490 | int margin, minWidth; | - | ||||||||||||||||||||||||
| 3491 | d->sizeParameters(&margin, &minWidth); | - | ||||||||||||||||||||||||
| 3492 | QSize size(2 * margin, d->titleBarHeight() + margin); | - | ||||||||||||||||||||||||
| 3493 | if (d->baseWidget && d->baseWidget->sizeHint().isValid())
| 0 | ||||||||||||||||||||||||
| 3494 | size += d->baseWidget->sizeHint(); never executed: size += d->baseWidget->sizeHint(); | 0 | ||||||||||||||||||||||||
| 3495 | return size.expandedTo(minimumSizeHint()); never executed: return size.expandedTo(minimumSizeHint()); | 0 | ||||||||||||||||||||||||
| 3496 | } | - | ||||||||||||||||||||||||
| 3497 | - | |||||||||||||||||||||||||
| 3498 | /*! | - | ||||||||||||||||||||||||
| 3499 | \reimp | - | ||||||||||||||||||||||||
| 3500 | */ | - | ||||||||||||||||||||||||
| 3501 | QSize QMdiSubWindow::minimumSizeHint() const | - | ||||||||||||||||||||||||
| 3502 | { | - | ||||||||||||||||||||||||
| 3503 | Q_D(const QMdiSubWindow); | - | ||||||||||||||||||||||||
| 3504 | if (isVisible())
| 0 | ||||||||||||||||||||||||
| 3505 | ensurePolished(); never executed: ensurePolished(); | 0 | ||||||||||||||||||||||||
| 3506 | - | |||||||||||||||||||||||||
| 3507 | // Minimized window. | - | ||||||||||||||||||||||||
| 3508 | if (parent() && isMinimized() && !isShaded())
| 0 | ||||||||||||||||||||||||
| 3509 | return d->iconSize(); never executed: return d->iconSize(); | 0 | ||||||||||||||||||||||||
| 3510 | - | |||||||||||||||||||||||||
| 3511 | // Calculate window decoration. | - | ||||||||||||||||||||||||
| 3512 | int margin, minWidth; | - | ||||||||||||||||||||||||
| 3513 | d->sizeParameters(&margin, &minWidth); | - | ||||||||||||||||||||||||
| 3514 | int decorationHeight = margin + d->titleBarHeight(); | - | ||||||||||||||||||||||||
| 3515 | int minHeight = decorationHeight; | - | ||||||||||||||||||||||||
| 3516 | - | |||||||||||||||||||||||||
| 3517 | // Shaded window. | - | ||||||||||||||||||||||||
| 3518 | if (parent() && isShaded())
| 0 | ||||||||||||||||||||||||
| 3519 | return QSize(qMax(minWidth, width()), d->titleBarHeight()); never executed: return QSize(qMax(minWidth, width()), d->titleBarHeight()); | 0 | ||||||||||||||||||||||||
| 3520 | - | |||||||||||||||||||||||||
| 3521 | // Content | - | ||||||||||||||||||||||||
| 3522 | if (layout()) {
| 0 | ||||||||||||||||||||||||
| 3523 | QSize minLayoutSize = layout()->minimumSize(); | - | ||||||||||||||||||||||||
| 3524 | if (minLayoutSize.isValid()) {
| 0 | ||||||||||||||||||||||||
| 3525 | minWidth = qMax(minWidth, minLayoutSize.width() + 2 * margin); | - | ||||||||||||||||||||||||
| 3526 | minHeight += minLayoutSize.height(); | - | ||||||||||||||||||||||||
| 3527 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3528 | } else if (d->baseWidget && d->baseWidget->isVisible()) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 3529 | QSize minBaseWidgetSize = d->baseWidget->minimumSizeHint(); | - | ||||||||||||||||||||||||
| 3530 | if (minBaseWidgetSize.isValid()) {
| 0 | ||||||||||||||||||||||||
| 3531 | minWidth = qMax(minWidth, minBaseWidgetSize.width() + 2 * margin); | - | ||||||||||||||||||||||||
| 3532 | minHeight += minBaseWidgetSize.height(); | - | ||||||||||||||||||||||||
| 3533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3534 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3535 | - | |||||||||||||||||||||||||
| 3536 | #ifndef QT_NO_SIZEGRIP | - | ||||||||||||||||||||||||
| 3537 | // SizeGrip | - | ||||||||||||||||||||||||
| 3538 | int sizeGripHeight = 0; | - | ||||||||||||||||||||||||
| 3539 | if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this)))
| 0 | ||||||||||||||||||||||||
| 3540 | sizeGripHeight = d->sizeGrip->height(); never executed: sizeGripHeight = d->sizeGrip->height(); | 0 | ||||||||||||||||||||||||
| 3541 | #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) | - | ||||||||||||||||||||||||
| 3542 | else if (parent() && qobject_cast<QMacStyle *>(style()) && !d->sizeGrip) | - | ||||||||||||||||||||||||
| 3543 | sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this); | - | ||||||||||||||||||||||||
| 3544 | #endif | - | ||||||||||||||||||||||||
| 3545 | minHeight = qMax(minHeight, decorationHeight + sizeGripHeight); | - | ||||||||||||||||||||||||
| 3546 | #endif | - | ||||||||||||||||||||||||
| 3547 | - | |||||||||||||||||||||||||
| 3548 | return QSize(minWidth, minHeight).expandedTo(QApplication::globalStrut()); never executed: return QSize(minWidth, minHeight).expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||||||||||||||
| 3549 | } | - | ||||||||||||||||||||||||
| 3550 | - | |||||||||||||||||||||||||
| 3551 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| 3552 | - | |||||||||||||||||||||||||
| 3553 | #include "moc_qmdisubwindow.cpp" | - | ||||||||||||||||||||||||
| 3554 | #include "qmdisubwindow.moc" | - | ||||||||||||||||||||||||
| 3555 | - | |||||||||||||||||||||||||
| 3556 | #endif //QT_NO_MDIAREA | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |