| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qdockwidget.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||
| 40 | #include "qdockwidget.h" | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | #ifndef QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| 43 | #include <qaction.h> | - | ||||||||||||||||||||||||
| 44 | #include <qapplication.h> | - | ||||||||||||||||||||||||
| 45 | #include <qdesktopwidget.h> | - | ||||||||||||||||||||||||
| 46 | #include <qdrawutil.h> | - | ||||||||||||||||||||||||
| 47 | #include <qevent.h> | - | ||||||||||||||||||||||||
| 48 | #include <qfontmetrics.h> | - | ||||||||||||||||||||||||
| 49 | #include <qwindow.h> | - | ||||||||||||||||||||||||
| 50 | #include <qscreen.h> | - | ||||||||||||||||||||||||
| 51 | #include <qmainwindow.h> | - | ||||||||||||||||||||||||
| 52 | #include <qrubberband.h> | - | ||||||||||||||||||||||||
| 53 | #include <qstylepainter.h> | - | ||||||||||||||||||||||||
| 54 | #include <qtoolbutton.h> | - | ||||||||||||||||||||||||
| 55 | #include <qdebug.h> | - | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | #include <private/qwidgetresizehandler_p.h> | - | ||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | #include "qdockwidget_p.h" | - | ||||||||||||||||||||||||
| 60 | #include "qmainwindowlayout_p.h" | - | ||||||||||||||||||||||||
| 61 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||
| 62 | #include <private/qapplication_p.h> | - | ||||||||||||||||||||||||
| 63 | #include <private/qt_mac_p.h> | - | ||||||||||||||||||||||||
| 64 | #include <private/qmacstyle_mac_p.h> | - | ||||||||||||||||||||||||
| 65 | #endif | - | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp | - | ||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | // qmainwindow.cpp | - | ||||||||||||||||||||||||
| 72 | extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); | - | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidget *dock) | - | ||||||||||||||||||||||||
| 75 | { | - | ||||||||||||||||||||||||
| 76 | const QWidget *p = dock->parentWidget(); | - | ||||||||||||||||||||||||
| 77 | while (p) {
| 0 | ||||||||||||||||||||||||
| 78 | const QMainWindow *window = qobject_cast<const QMainWindow*>(p); | - | ||||||||||||||||||||||||
| 79 | if (window)
| 0 | ||||||||||||||||||||||||
| 80 | return qt_mainwindow_layout(window); never executed: return qt_mainwindow_layout(window); | 0 | ||||||||||||||||||||||||
| 81 | p = p->parentWidget(); | - | ||||||||||||||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 83 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||||||||
| 84 | } | - | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 | static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) | - | ||||||||||||||||||||||||
| 87 | { never executed: return (priv->features & feature) == feature; }return (priv->features & feature) == feature;never executed: return (priv->features & feature) == feature; | 0 | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | static inline bool hasFeature(const QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) | - | ||||||||||||||||||||||||
| 90 | { never executed: return (dockwidget->features() & feature) == feature; }return (dockwidget->features() & feature) == feature;never executed: return (dockwidget->features() & feature) == feature; | 0 | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||
| 93 | /* | - | ||||||||||||||||||||||||
| 94 | A Dock Window: | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | [+] is the float button | - | ||||||||||||||||||||||||
| 97 | [X] is the close button | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | +-------------------------------+ | - | ||||||||||||||||||||||||
| 100 | | Dock Window Title [+][X]| | - | ||||||||||||||||||||||||
| 101 | +-------------------------------+ | - | ||||||||||||||||||||||||
| 102 | | | | - | ||||||||||||||||||||||||
| 103 | | place to put the single | | - | ||||||||||||||||||||||||
| 104 | | QDockWidget child (this space | | - | ||||||||||||||||||||||||
| 105 | | does not yet have a name) | | - | ||||||||||||||||||||||||
| 106 | | | | - | ||||||||||||||||||||||||
| 107 | | | | - | ||||||||||||||||||||||||
| 108 | | | | - | ||||||||||||||||||||||||
| 109 | | | | - | ||||||||||||||||||||||||
| 110 | | | | - | ||||||||||||||||||||||||
| 111 | | | | - | ||||||||||||||||||||||||
| 112 | | | | - | ||||||||||||||||||||||||
| 113 | | | | - | ||||||||||||||||||||||||
| 114 | | | | - | ||||||||||||||||||||||||
| 115 | +-------------------------------+ | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | */ | - | ||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 120 | ** QDockWidgetTitleButton | - | ||||||||||||||||||||||||
| 121 | */ | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | class QDockWidgetTitleButton : public QAbstractButton | - | ||||||||||||||||||||||||
| 124 | { | - | ||||||||||||||||||||||||
| 125 | Q_OBJECT | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | public: | - | ||||||||||||||||||||||||
| 128 | QDockWidgetTitleButton(QDockWidget *dockWidget); | - | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | QSize sizeHint() const Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 131 | QSize minimumSizeHint() const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 132 | { return sizeHint(); } never executed: return sizeHint(); | 0 | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | void enterEvent(QEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 135 | void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 136 | void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; | - | ||||||||||||||||||||||||
| 137 | }; | - | ||||||||||||||||||||||||
| 138 | - | |||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | QDockWidgetTitleButton::QDockWidgetTitleButton(QDockWidget *dockWidget) | - | ||||||||||||||||||||||||
| 141 | : QAbstractButton(dockWidget) | - | ||||||||||||||||||||||||
| 142 | { | - | ||||||||||||||||||||||||
| 143 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||||||||||||||
| 144 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||
| 146 | QSize QDockWidgetTitleButton::sizeHint() const | - | ||||||||||||||||||||||||
| 147 | { | - | ||||||||||||||||||||||||
| 148 | ensurePolished(); | - | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this); | - | ||||||||||||||||||||||||
| 151 | if (!icon().isNull()) {
| 0 | ||||||||||||||||||||||||
| 152 | int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); | - | ||||||||||||||||||||||||
| 153 | QSize sz = icon().actualSize(QSize(iconSize, iconSize)); | - | ||||||||||||||||||||||||
| 154 | size += qMax(sz.width(), sz.height()); | - | ||||||||||||||||||||||||
| 155 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | return QSize(size, size); never executed: return QSize(size, size); | 0 | ||||||||||||||||||||||||
| 158 | } | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | void QDockWidgetTitleButton::enterEvent(QEvent *event) | - | ||||||||||||||||||||||||
| 161 | { | - | ||||||||||||||||||||||||
| 162 | if (isEnabled()) update(); never executed: update();
| 0 | ||||||||||||||||||||||||
| 163 | QAbstractButton::enterEvent(event); | - | ||||||||||||||||||||||||
| 164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | void QDockWidgetTitleButton::leaveEvent(QEvent *event) | - | ||||||||||||||||||||||||
| 167 | { | - | ||||||||||||||||||||||||
| 168 | if (isEnabled()) update(); never executed: update();
| 0 | ||||||||||||||||||||||||
| 169 | QAbstractButton::leaveEvent(event); | - | ||||||||||||||||||||||||
| 170 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | void QDockWidgetTitleButton::paintEvent(QPaintEvent *) | - | ||||||||||||||||||||||||
| 173 | { | - | ||||||||||||||||||||||||
| 174 | QPainter p(this); | - | ||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | QStyleOptionToolButton opt; | - | ||||||||||||||||||||||||
| 177 | opt.init(this); | - | ||||||||||||||||||||||||
| 178 | opt.state |= QStyle::State_AutoRaise; | - | ||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | if (style()->styleHint(QStyle::SH_DockWidget_ButtonsHaveFrame, 0, this))
| 0 | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | if (isEnabled() && underMouse() && !isChecked() && !isDown())
| 0 | ||||||||||||||||||||||||
| 183 | opt.state |= QStyle::State_Raised; never executed: opt.state |= QStyle::State_Raised; | 0 | ||||||||||||||||||||||||
| 184 | if (isChecked())
| 0 | ||||||||||||||||||||||||
| 185 | opt.state |= QStyle::State_On; never executed: opt.state |= QStyle::State_On; | 0 | ||||||||||||||||||||||||
| 186 | if (isDown())
| 0 | ||||||||||||||||||||||||
| 187 | opt.state |= QStyle::State_Sunken; never executed: opt.state |= QStyle::State_Sunken; | 0 | ||||||||||||||||||||||||
| 188 | style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); | - | ||||||||||||||||||||||||
| 189 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||
| 191 | opt.icon = icon(); | - | ||||||||||||||||||||||||
| 192 | opt.subControls = 0; | - | ||||||||||||||||||||||||
| 193 | opt.activeSubControls = 0; | - | ||||||||||||||||||||||||
| 194 | opt.features = QStyleOptionToolButton::None; | - | ||||||||||||||||||||||||
| 195 | opt.arrowType = Qt::NoArrow; | - | ||||||||||||||||||||||||
| 196 | int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); | - | ||||||||||||||||||||||||
| 197 | opt.iconSize = QSize(size, size); | - | ||||||||||||||||||||||||
| 198 | style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this); | - | ||||||||||||||||||||||||
| 199 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 202 | ** QDockWidgetLayout | - | ||||||||||||||||||||||||
| 203 | */ | - | ||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||
| 205 | QDockWidgetLayout::QDockWidgetLayout(QWidget *parent) | - | ||||||||||||||||||||||||
| 206 | : QLayout(parent), verticalTitleBar(false), item_list(RoleCount, 0) | - | ||||||||||||||||||||||||
| 207 | { | - | ||||||||||||||||||||||||
| 208 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | QDockWidgetLayout::~QDockWidgetLayout() | - | ||||||||||||||||||||||||
| 211 | { | - | ||||||||||||||||||||||||
| 212 | qDeleteAll(item_list); | - | ||||||||||||||||||||||||
| 213 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | /*! \internal | - | ||||||||||||||||||||||||
| 216 | Returns true if the dock widget managed by this layout should have a native | - | ||||||||||||||||||||||||
| 217 | window decoration or if Qt needs to draw it. | - | ||||||||||||||||||||||||
| 218 | */ | - | ||||||||||||||||||||||||
| 219 | bool QDockWidgetLayout::nativeWindowDeco() const | - | ||||||||||||||||||||||||
| 220 | { | - | ||||||||||||||||||||||||
| 221 | bool floating = parentWidget()->isWindow(); | - | ||||||||||||||||||||||||
| 222 | if (!floating && qobject_cast<QDockWidgetGroupWindow*>(parentWidget()->parentWidget()))
| 0 | ||||||||||||||||||||||||
| 223 | return wmSupportsNativeWindowDeco(); never executed: return wmSupportsNativeWindowDeco(); | 0 | ||||||||||||||||||||||||
| 224 | return nativeWindowDeco(floating); never executed: return nativeWindowDeco(floating); | 0 | ||||||||||||||||||||||||
| 225 | } | - | ||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||
| 227 | /*! \internal | - | ||||||||||||||||||||||||
| 228 | Returns true if the window manager can draw natively the windows decoration | - | ||||||||||||||||||||||||
| 229 | of a dock widget | - | ||||||||||||||||||||||||
| 230 | */ | - | ||||||||||||||||||||||||
| 231 | bool QDockWidgetLayout::wmSupportsNativeWindowDeco() | - | ||||||||||||||||||||||||
| 232 | { | - | ||||||||||||||||||||||||
| 233 | #if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID) | - | ||||||||||||||||||||||||
| 234 | return false; | - | ||||||||||||||||||||||||
| 235 | #else | - | ||||||||||||||||||||||||
| 236 | static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive); | - | ||||||||||||||||||||||||
| 237 | return !xcb; never executed: return !xcb; | 0 | ||||||||||||||||||||||||
| 238 | #endif | - | ||||||||||||||||||||||||
| 239 | } | - | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | /*! \internal | - | ||||||||||||||||||||||||
| 242 | Returns true if the dock widget managed by this layout should have a native | - | ||||||||||||||||||||||||
| 243 | window decoration or if Qt needs to draw it. The \a floating parameter | - | ||||||||||||||||||||||||
| 244 | overrides the floating current state of the dock widget. | - | ||||||||||||||||||||||||
| 245 | */ | - | ||||||||||||||||||||||||
| 246 | bool QDockWidgetLayout::nativeWindowDeco(bool floating) const | - | ||||||||||||||||||||||||
| 247 | { | - | ||||||||||||||||||||||||
| 248 | return wmSupportsNativeWindowDeco() && floating && item_list.at(QDockWidgetLayout::TitleBar) == 0; never executed: return wmSupportsNativeWindowDeco() && floating && item_list.at(QDockWidgetLayout::TitleBar) == 0; | 0 | ||||||||||||||||||||||||
| 249 | } | - | ||||||||||||||||||||||||
| 250 | - | |||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | void QDockWidgetLayout::addItem(QLayoutItem*) | - | ||||||||||||||||||||||||
| 253 | { | - | ||||||||||||||||||||||||
| 254 | qWarning("QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()"); | - | ||||||||||||||||||||||||
| 255 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 256 | } | - | ||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||
| 258 | QLayoutItem *QDockWidgetLayout::itemAt(int index) const | - | ||||||||||||||||||||||||
| 259 | { | - | ||||||||||||||||||||||||
| 260 | int cnt = 0; | - | ||||||||||||||||||||||||
| 261 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 262 | QLayoutItem *item = item_list.at(i); | - | ||||||||||||||||||||||||
| 263 | if (item == 0)
| 0 | ||||||||||||||||||||||||
| 264 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 265 | if (index == cnt++)
| 0 | ||||||||||||||||||||||||
| 266 | return item; never executed: return item; | 0 | ||||||||||||||||||||||||
| 267 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 268 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 269 | } | - | ||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | QLayoutItem *QDockWidgetLayout::takeAt(int index) | - | ||||||||||||||||||||||||
| 272 | { | - | ||||||||||||||||||||||||
| 273 | int j = 0; | - | ||||||||||||||||||||||||
| 274 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 275 | QLayoutItem *item = item_list.at(i); | - | ||||||||||||||||||||||||
| 276 | if (item == 0)
| 0 | ||||||||||||||||||||||||
| 277 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 278 | if (index == j) {
| 0 | ||||||||||||||||||||||||
| 279 | item_list[i] = 0; | - | ||||||||||||||||||||||||
| 280 | invalidate(); | - | ||||||||||||||||||||||||
| 281 | return item; never executed: return item; | 0 | ||||||||||||||||||||||||
| 282 | } | - | ||||||||||||||||||||||||
| 283 | ++j; | - | ||||||||||||||||||||||||
| 284 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 285 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | int QDockWidgetLayout::count() const | - | ||||||||||||||||||||||||
| 289 | { | - | ||||||||||||||||||||||||
| 290 | int result = 0; | - | ||||||||||||||||||||||||
| 291 | for (int i = 0; i < item_list.count(); ++i) {
| 0 | ||||||||||||||||||||||||
| 292 | if (item_list.at(i))
| 0 | ||||||||||||||||||||||||
| 293 | ++result; never executed: ++result; | 0 | ||||||||||||||||||||||||
| 294 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 295 | return result; never executed: return result; | 0 | ||||||||||||||||||||||||
| 296 | } | - | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) const | - | ||||||||||||||||||||||||
| 299 | { | - | ||||||||||||||||||||||||
| 300 | QSize result = content; | - | ||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | if (verticalTitleBar) {
| 0 | ||||||||||||||||||||||||
| 303 | result.setHeight(qMax(result.height(), minimumTitleWidth())); | - | ||||||||||||||||||||||||
| 304 | result.setWidth(qMax(content.width(), 0)); | - | ||||||||||||||||||||||||
| 305 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 306 | result.setHeight(qMax(result.height(), 0)); | - | ||||||||||||||||||||||||
| 307 | result.setWidth(qMax(content.width(), minimumTitleWidth())); | - | ||||||||||||||||||||||||
| 308 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); | - | ||||||||||||||||||||||||
| 311 | const bool nativeDeco = nativeWindowDeco(floating); | - | ||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | int fw = floating && !nativeDeco
| 0 | ||||||||||||||||||||||||
| 314 | ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w) | - | ||||||||||||||||||||||||
| 315 | : 0; | - | ||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||
| 317 | const int th = titleHeight(); | - | ||||||||||||||||||||||||
| 318 | if (!nativeDeco) {
| 0 | ||||||||||||||||||||||||
| 319 | if (verticalTitleBar)
| 0 | ||||||||||||||||||||||||
| 320 | result += QSize(th + 2*fw, 2*fw); never executed: result += QSize(th + 2*fw, 2*fw); | 0 | ||||||||||||||||||||||||
| 321 | else | - | ||||||||||||||||||||||||
| 322 | result += QSize(2*fw, th + 2*fw); never executed: result += QSize(2*fw, th + 2*fw); | 0 | ||||||||||||||||||||||||
| 323 | } | - | ||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | result.setHeight(qMin(result.height(), (int) QWIDGETSIZE_MAX)); | - | ||||||||||||||||||||||||
| 326 | result.setWidth(qMin(result.width(), (int) QWIDGETSIZE_MAX)); | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | if (content.width() < 0)
| 0 | ||||||||||||||||||||||||
| 329 | result.setWidth(-1); never executed: result.setWidth(-1); | 0 | ||||||||||||||||||||||||
| 330 | if (content.height() < 0)
| 0 | ||||||||||||||||||||||||
| 331 | result.setHeight(-1); never executed: result.setHeight(-1); | 0 | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | int left, top, right, bottom; | - | ||||||||||||||||||||||||
| 334 | w->getContentsMargins(&left, &top, &right, &bottom); | - | ||||||||||||||||||||||||
| 335 | //we need to subtract the contents margin (it will be added by the caller) | - | ||||||||||||||||||||||||
| 336 | QSize min = w->minimumSize() - QSize(left + right, top + bottom); | - | ||||||||||||||||||||||||
| 337 | QSize max = w->maximumSize() - QSize(left + right, top + bottom); | - | ||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | /* A floating dockwidget will automatically get its minimumSize set to the layout's | - | ||||||||||||||||||||||||
| 340 | minimum size + deco. We're *not* interested in this, we only take minimumSize() | - | ||||||||||||||||||||||||
| 341 | into account if the user set it herself. Otherwise we end up expanding the result | - | ||||||||||||||||||||||||
| 342 | of a calculation for a non-floating dock widget to a floating dock widget's | - | ||||||||||||||||||||||||
| 343 | minimum size + window decorations. */ | - | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | uint explicitMin = 0; | - | ||||||||||||||||||||||||
| 346 | uint explicitMax = 0; | - | ||||||||||||||||||||||||
| 347 | if (w->d_func()->extra != 0) {
| 0 | ||||||||||||||||||||||||
| 348 | explicitMin = w->d_func()->extra->explicitMinSize; | - | ||||||||||||||||||||||||
| 349 | explicitMax = w->d_func()->extra->explicitMaxSize; | - | ||||||||||||||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | if (!(explicitMin & Qt::Horizontal) || min.width() == 0)
| 0 | ||||||||||||||||||||||||
| 353 | min.setWidth(-1); never executed: min.setWidth(-1); | 0 | ||||||||||||||||||||||||
| 354 | if (!(explicitMin & Qt::Vertical) || min.height() == 0)
| 0 | ||||||||||||||||||||||||
| 355 | min.setHeight(-1); never executed: min.setHeight(-1); | 0 | ||||||||||||||||||||||||
| 356 | - | |||||||||||||||||||||||||
| 357 | if (!(explicitMax & Qt::Horizontal))
| 0 | ||||||||||||||||||||||||
| 358 | max.setWidth(QWIDGETSIZE_MAX); never executed: max.setWidth(((1<<24)-1)); | 0 | ||||||||||||||||||||||||
| 359 | if (!(explicitMax & Qt::Vertical))
| 0 | ||||||||||||||||||||||||
| 360 | max.setHeight(QWIDGETSIZE_MAX); never executed: max.setHeight(((1<<24)-1)); | 0 | ||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||
| 362 | return result.boundedTo(max).expandedTo(min); never executed: return result.boundedTo(max).expandedTo(min); | 0 | ||||||||||||||||||||||||
| 363 | } | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | QSize QDockWidgetLayout::sizeHint() const | - | ||||||||||||||||||||||||
| 366 | { | - | ||||||||||||||||||||||||
| 367 | QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); | - | ||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | QSize content(-1, -1); | - | ||||||||||||||||||||||||
| 370 | if (item_list[Content] != 0)
| 0 | ||||||||||||||||||||||||
| 371 | content = item_list[Content]->sizeHint(); never executed: content = item_list[Content]->sizeHint(); | 0 | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | return sizeFromContent(content, w->isFloating()); never executed: return sizeFromContent(content, w->isFloating()); | 0 | ||||||||||||||||||||||||
| 374 | } | - | ||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | QSize QDockWidgetLayout::maximumSize() const | - | ||||||||||||||||||||||||
| 377 | { | - | ||||||||||||||||||||||||
| 378 | if (item_list[Content] != 0) {
| 0 | ||||||||||||||||||||||||
| 379 | const QSize content = item_list[Content]->maximumSize(); | - | ||||||||||||||||||||||||
| 380 | return sizeFromContent(content, parentWidget()->isWindow()); never executed: return sizeFromContent(content, parentWidget()->isWindow()); | 0 | ||||||||||||||||||||||||
| 381 | } else { | - | ||||||||||||||||||||||||
| 382 | return parentWidget()->maximumSize(); never executed: return parentWidget()->maximumSize(); | 0 | ||||||||||||||||||||||||
| 383 | } | - | ||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | } | - | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | QSize QDockWidgetLayout::minimumSize() const | - | ||||||||||||||||||||||||
| 388 | { | - | ||||||||||||||||||||||||
| 389 | QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); | - | ||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | QSize content(0, 0); | - | ||||||||||||||||||||||||
| 392 | if (item_list[Content] != 0)
| 0 | ||||||||||||||||||||||||
| 393 | content = item_list[Content]->minimumSize(); never executed: content = item_list[Content]->minimumSize(); | 0 | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | return sizeFromContent(content, w->isFloating()); never executed: return sizeFromContent(content, w->isFloating()); | 0 | ||||||||||||||||||||||||
| 396 | } | - | ||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||
| 398 | QWidget *QDockWidgetLayout::widgetForRole(Role r) const | - | ||||||||||||||||||||||||
| 399 | { | - | ||||||||||||||||||||||||
| 400 | QLayoutItem *item = item_list.at(r); | - | ||||||||||||||||||||||||
| 401 | return item == 0 ? 0 : item->widget(); never executed: return item == 0 ? 0 : item->widget(); | 0 | ||||||||||||||||||||||||
| 402 | } | - | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | QLayoutItem *QDockWidgetLayout::itemForRole(Role r) const | - | ||||||||||||||||||||||||
| 405 | { | - | ||||||||||||||||||||||||
| 406 | return item_list.at(r); never executed: return item_list.at(r); | 0 | ||||||||||||||||||||||||
| 407 | } | - | ||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | void QDockWidgetLayout::setWidgetForRole(Role r, QWidget *w) | - | ||||||||||||||||||||||||
| 410 | { | - | ||||||||||||||||||||||||
| 411 | QWidget *old = widgetForRole(r); | - | ||||||||||||||||||||||||
| 412 | if (old != 0) {
| 0 | ||||||||||||||||||||||||
| 413 | old->hide(); | - | ||||||||||||||||||||||||
| 414 | removeWidget(old); | - | ||||||||||||||||||||||||
| 415 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | if (w != 0) {
| 0 | ||||||||||||||||||||||||
| 418 | addChildWidget(w); | - | ||||||||||||||||||||||||
| 419 | item_list[r] = new QWidgetItemV2(w); | - | ||||||||||||||||||||||||
| 420 | w->show(); | - | ||||||||||||||||||||||||
| 421 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 422 | item_list[r] = 0; | - | ||||||||||||||||||||||||
| 423 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 424 | - | |||||||||||||||||||||||||
| 425 | invalidate(); | - | ||||||||||||||||||||||||
| 426 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | static inline int pick(bool vertical, const QSize &size) | - | ||||||||||||||||||||||||
| 429 | { | - | ||||||||||||||||||||||||
| 430 | return vertical ? size.height() : size.width(); never executed: return vertical ? size.height() : size.width(); | 0 | ||||||||||||||||||||||||
| 431 | } | - | ||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | static inline int perp(bool vertical, const QSize &size) | - | ||||||||||||||||||||||||
| 434 | { | - | ||||||||||||||||||||||||
| 435 | return vertical ? size.width() : size.height(); never executed: return vertical ? size.width() : size.height(); | 0 | ||||||||||||||||||||||||
| 436 | } | - | ||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||
| 438 | int QDockWidgetLayout::minimumTitleWidth() const | - | ||||||||||||||||||||||||
| 439 | { | - | ||||||||||||||||||||||||
| 440 | QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); | - | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | if (QWidget *title = widgetForRole(TitleBar))
| 0 | ||||||||||||||||||||||||
| 443 | return pick(verticalTitleBar, title->minimumSizeHint()); never executed: return pick(verticalTitleBar, title->minimumSizeHint()); | 0 | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | QSize closeSize(0, 0); | - | ||||||||||||||||||||||||
| 446 | QSize floatSize(0, 0); | - | ||||||||||||||||||||||||
| 447 | if (hasFeature(q, QDockWidget::DockWidgetClosable)) {
| 0 | ||||||||||||||||||||||||
| 448 | if (QLayoutItem *item = item_list[CloseButton])
| 0 | ||||||||||||||||||||||||
| 449 | closeSize = item->widget()->sizeHint(); never executed: closeSize = item->widget()->sizeHint(); | 0 | ||||||||||||||||||||||||
| 450 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 451 | if (hasFeature(q, QDockWidget::DockWidgetFloatable)) {
| 0 | ||||||||||||||||||||||||
| 452 | if (QLayoutItem *item = item_list[FloatButton])
| 0 | ||||||||||||||||||||||||
| 453 | floatSize = item->widget()->sizeHint(); never executed: floatSize = item->widget()->sizeHint(); | 0 | ||||||||||||||||||||||||
| 454 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | int titleHeight = this->titleHeight(); | - | ||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); | - | ||||||||||||||||||||||||
| 459 | int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); | - | ||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||
| 461 | return pick(verticalTitleBar, closeSize) never executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw; | 0 | ||||||||||||||||||||||||
| 462 | + pick(verticalTitleBar, floatSize) never executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw; | 0 | ||||||||||||||||||||||||
| 463 | + titleHeight + 2*fw + 3*mw; never executed: return pick(verticalTitleBar, closeSize) + pick(verticalTitleBar, floatSize) + titleHeight + 2*fw + 3*mw; | 0 | ||||||||||||||||||||||||
| 464 | } | - | ||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | int QDockWidgetLayout::titleHeight() const | - | ||||||||||||||||||||||||
| 467 | { | - | ||||||||||||||||||||||||
| 468 | QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); | - | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | if (QWidget *title = widgetForRole(TitleBar))
| 0 | ||||||||||||||||||||||||
| 471 | return perp(verticalTitleBar, title->sizeHint()); never executed: return perp(verticalTitleBar, title->sizeHint()); | 0 | ||||||||||||||||||||||||
| 472 | - | |||||||||||||||||||||||||
| 473 | QSize closeSize(0, 0); | - | ||||||||||||||||||||||||
| 474 | QSize floatSize(0, 0); | - | ||||||||||||||||||||||||
| 475 | if (QLayoutItem *item = item_list[CloseButton])
| 0 | ||||||||||||||||||||||||
| 476 | closeSize = item->widget()->sizeHint(); never executed: closeSize = item->widget()->sizeHint(); | 0 | ||||||||||||||||||||||||
| 477 | if (QLayoutItem *item = item_list[FloatButton])
| 0 | ||||||||||||||||||||||||
| 478 | floatSize = item->widget()->sizeHint(); never executed: floatSize = item->widget()->sizeHint(); | 0 | ||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||
| 480 | int buttonHeight = qMax(perp(verticalTitleBar, closeSize), | - | ||||||||||||||||||||||||
| 481 | perp(verticalTitleBar, floatSize)); | - | ||||||||||||||||||||||||
| 482 | - | |||||||||||||||||||||||||
| 483 | QFontMetrics titleFontMetrics = q->fontMetrics(); | - | ||||||||||||||||||||||||
| 484 | int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); | - | ||||||||||||||||||||||||
| 485 | - | |||||||||||||||||||||||||
| 486 | return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw); never executed: return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw); | 0 | ||||||||||||||||||||||||
| 487 | } | - | ||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | void QDockWidgetLayout::setGeometry(const QRect &geometry) | - | ||||||||||||||||||||||||
| 490 | { | - | ||||||||||||||||||||||||
| 491 | QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); | - | ||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||
| 493 | bool nativeDeco = nativeWindowDeco(); | - | ||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||
| 495 | int fw = q->isFloating() && !nativeDeco
| 0 | ||||||||||||||||||||||||
| 496 | ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q) | - | ||||||||||||||||||||||||
| 497 | : 0; | - | ||||||||||||||||||||||||
| 498 | - | |||||||||||||||||||||||||
| 499 | if (nativeDeco) {
| 0 | ||||||||||||||||||||||||
| 500 | if (QLayoutItem *item = item_list[Content])
| 0 | ||||||||||||||||||||||||
| 501 | item->setGeometry(geometry); never executed: item->setGeometry(geometry); | 0 | ||||||||||||||||||||||||
| 502 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 503 | int titleHeight = this->titleHeight(); | - | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | if (verticalTitleBar) {
| 0 | ||||||||||||||||||||||||
| 506 | _titleArea = QRect(QPoint(fw, fw), | - | ||||||||||||||||||||||||
| 507 | QSize(titleHeight, geometry.height() - (fw * 2))); | - | ||||||||||||||||||||||||
| 508 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 509 | _titleArea = QRect(QPoint(fw, fw), | - | ||||||||||||||||||||||||
| 510 | QSize(geometry.width() - (fw * 2), titleHeight)); | - | ||||||||||||||||||||||||
| 511 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | if (QLayoutItem *item = item_list[TitleBar]) {
| 0 | ||||||||||||||||||||||||
| 514 | item->setGeometry(_titleArea); | - | ||||||||||||||||||||||||
| 515 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 516 | QStyleOptionDockWidget opt; | - | ||||||||||||||||||||||||
| 517 | q->initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||
| 519 | if (QLayoutItem *item = item_list[CloseButton]) {
| 0 | ||||||||||||||||||||||||
| 520 | if (!item->isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 521 | QRect r = q->style() | - | ||||||||||||||||||||||||
| 522 | ->subElementRect(QStyle::SE_DockWidgetCloseButton, | - | ||||||||||||||||||||||||
| 523 | &opt, q); | - | ||||||||||||||||||||||||
| 524 | if (!r.isNull())
| 0 | ||||||||||||||||||||||||
| 525 | item->setGeometry(r); never executed: item->setGeometry(r); | 0 | ||||||||||||||||||||||||
| 526 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 527 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||
| 529 | if (QLayoutItem *item = item_list[FloatButton]) {
| 0 | ||||||||||||||||||||||||
| 530 | if (!item->isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 531 | QRect r = q->style() | - | ||||||||||||||||||||||||
| 532 | ->subElementRect(QStyle::SE_DockWidgetFloatButton, | - | ||||||||||||||||||||||||
| 533 | &opt, q); | - | ||||||||||||||||||||||||
| 534 | if (!r.isNull())
| 0 | ||||||||||||||||||||||||
| 535 | item->setGeometry(r); never executed: item->setGeometry(r); | 0 | ||||||||||||||||||||||||
| 536 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 537 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 538 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 539 | - | |||||||||||||||||||||||||
| 540 | if (QLayoutItem *item = item_list[Content]) {
| 0 | ||||||||||||||||||||||||
| 541 | QRect r = geometry; | - | ||||||||||||||||||||||||
| 542 | if (verticalTitleBar) {
| 0 | ||||||||||||||||||||||||
| 543 | r.setLeft(_titleArea.right() + 1); | - | ||||||||||||||||||||||||
| 544 | r.adjust(0, fw, -fw, -fw); | - | ||||||||||||||||||||||||
| 545 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 546 | r.setTop(_titleArea.bottom() + 1); | - | ||||||||||||||||||||||||
| 547 | r.adjust(fw, 0, -fw, -fw); | - | ||||||||||||||||||||||||
| 548 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 549 | item->setGeometry(r); | - | ||||||||||||||||||||||||
| 550 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 551 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 552 | } | - | ||||||||||||||||||||||||
| 553 | - | |||||||||||||||||||||||||
| 554 | void QDockWidgetLayout::setVerticalTitleBar(bool b) | - | ||||||||||||||||||||||||
| 555 | { | - | ||||||||||||||||||||||||
| 556 | if (b == verticalTitleBar)
| 0 | ||||||||||||||||||||||||
| 557 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 558 | verticalTitleBar = b; | - | ||||||||||||||||||||||||
| 559 | invalidate(); | - | ||||||||||||||||||||||||
| 560 | parentWidget()->update(); | - | ||||||||||||||||||||||||
| 561 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 562 | - | |||||||||||||||||||||||||
| 563 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 564 | ** QDockWidgetItem | - | ||||||||||||||||||||||||
| 565 | */ | - | ||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||
| 567 | QDockWidgetItem::QDockWidgetItem(QDockWidget *dockWidget) | - | ||||||||||||||||||||||||
| 568 | : QWidgetItem(dockWidget) | - | ||||||||||||||||||||||||
| 569 | { | - | ||||||||||||||||||||||||
| 570 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 571 | - | |||||||||||||||||||||||||
| 572 | QSize QDockWidgetItem::minimumSize() const | - | ||||||||||||||||||||||||
| 573 | { | - | ||||||||||||||||||||||||
| 574 | QSize widgetMin(0, 0); | - | ||||||||||||||||||||||||
| 575 | if (QLayoutItem *item = dockWidgetChildItem())
| 0 | ||||||||||||||||||||||||
| 576 | widgetMin = item->minimumSize(); never executed: widgetMin = item->minimumSize(); | 0 | ||||||||||||||||||||||||
| 577 | return dockWidgetLayout()->sizeFromContent(widgetMin, false); never executed: return dockWidgetLayout()->sizeFromContent(widgetMin, false); | 0 | ||||||||||||||||||||||||
| 578 | } | - | ||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||
| 580 | QSize QDockWidgetItem::maximumSize() const | - | ||||||||||||||||||||||||
| 581 | { | - | ||||||||||||||||||||||||
| 582 | if (QLayoutItem *item = dockWidgetChildItem()) {
| 0 | ||||||||||||||||||||||||
| 583 | return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false); never executed: return dockWidgetLayout()->sizeFromContent(item->maximumSize(), false); | 0 | ||||||||||||||||||||||||
| 584 | } else { | - | ||||||||||||||||||||||||
| 585 | return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); never executed: return QSize(((1<<24)-1), ((1<<24)-1)); | 0 | ||||||||||||||||||||||||
| 586 | } | - | ||||||||||||||||||||||||
| 587 | } | - | ||||||||||||||||||||||||
| 588 | - | |||||||||||||||||||||||||
| 589 | - | |||||||||||||||||||||||||
| 590 | QSize QDockWidgetItem::sizeHint() const | - | ||||||||||||||||||||||||
| 591 | { | - | ||||||||||||||||||||||||
| 592 | if (QLayoutItem *item = dockWidgetChildItem()) {
| 0 | ||||||||||||||||||||||||
| 593 | return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false); never executed: return dockWidgetLayout()->sizeFromContent(item->sizeHint(), false); | 0 | ||||||||||||||||||||||||
| 594 | } else { | - | ||||||||||||||||||||||||
| 595 | return QWidgetItem::sizeHint(); never executed: return QWidgetItem::sizeHint(); | 0 | ||||||||||||||||||||||||
| 596 | } | - | ||||||||||||||||||||||||
| 597 | } | - | ||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | /****************************************************************************** | - | ||||||||||||||||||||||||
| 600 | ** QDockWidgetPrivate | - | ||||||||||||||||||||||||
| 601 | */ | - | ||||||||||||||||||||||||
| 602 | - | |||||||||||||||||||||||||
| 603 | void QDockWidgetPrivate::init() | - | ||||||||||||||||||||||||
| 604 | { | - | ||||||||||||||||||||||||
| 605 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 606 | - | |||||||||||||||||||||||||
| 607 | QDockWidgetLayout *layout = new QDockWidgetLayout(q); | - | ||||||||||||||||||||||||
| 608 | layout->setSizeConstraint(QLayout::SetMinAndMaxSize); | - | ||||||||||||||||||||||||
| 609 | - | |||||||||||||||||||||||||
| 610 | QAbstractButton *button = new QDockWidgetTitleButton(q); | - | ||||||||||||||||||||||||
| 611 | button->setObjectName(QLatin1String("qt_dockwidget_floatbutton")); | - | ||||||||||||||||||||||||
| 612 | QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_toggleTopLevel())); | - | ||||||||||||||||||||||||
| 613 | layout->setWidgetForRole(QDockWidgetLayout::FloatButton, button); | - | ||||||||||||||||||||||||
| 614 | - | |||||||||||||||||||||||||
| 615 | button = new QDockWidgetTitleButton(q); | - | ||||||||||||||||||||||||
| 616 | button->setObjectName(QLatin1String("qt_dockwidget_closebutton")); | - | ||||||||||||||||||||||||
| 617 | QObject::connect(button, SIGNAL(clicked()), q, SLOT(close())); | - | ||||||||||||||||||||||||
| 618 | layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button); | - | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 621 | toggleViewAction = new QAction(q); | - | ||||||||||||||||||||||||
| 622 | toggleViewAction->setCheckable(true); | - | ||||||||||||||||||||||||
| 623 | toggleViewAction->setMenuRole(QAction::NoRole); | - | ||||||||||||||||||||||||
| 624 | fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q); | - | ||||||||||||||||||||||||
| 625 | toggleViewAction->setText(fixedWindowTitle); | - | ||||||||||||||||||||||||
| 626 | QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), | - | ||||||||||||||||||||||||
| 627 | q, SLOT(_q_toggleView(bool))); | - | ||||||||||||||||||||||||
| 628 | #endif | - | ||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | updateButtons(); | - | ||||||||||||||||||||||||
| 631 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 632 | - | |||||||||||||||||||||||||
| 633 | /*! | - | ||||||||||||||||||||||||
| 634 | Initialize \a option with the values from this QDockWidget. This method | - | ||||||||||||||||||||||||
| 635 | is useful for subclasses when they need a QStyleOptionDockWidget, but don't want | - | ||||||||||||||||||||||||
| 636 | to fill in all the information themselves. | - | ||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||
| 638 | \sa QStyleOption::initFrom() | - | ||||||||||||||||||||||||
| 639 | */ | - | ||||||||||||||||||||||||
| 640 | void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const | - | ||||||||||||||||||||||||
| 641 | { | - | ||||||||||||||||||||||||
| 642 | Q_D(const QDockWidget); | - | ||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||
| 644 | if (!option)
| 0 | ||||||||||||||||||||||||
| 645 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 646 | QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout()); | - | ||||||||||||||||||||||||
| 647 | - | |||||||||||||||||||||||||
| 648 | QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent()); | - | ||||||||||||||||||||||||
| 649 | // If we are in a floating tab, init from the parent because the attributes and the geometry | - | ||||||||||||||||||||||||
| 650 | // of the title bar should be taken from the floating window. | - | ||||||||||||||||||||||||
| 651 | option->initFrom(floatingTab && !isFloating() ? parentWidget() : this); | - | ||||||||||||||||||||||||
| 652 | option->rect = dwlayout->titleArea(); | - | ||||||||||||||||||||||||
| 653 | option->title = d->fixedWindowTitle; | - | ||||||||||||||||||||||||
| 654 | option->closable = hasFeature(this, QDockWidget::DockWidgetClosable); | - | ||||||||||||||||||||||||
| 655 | option->movable = hasFeature(this, QDockWidget::DockWidgetMovable); | - | ||||||||||||||||||||||||
| 656 | option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable); | - | ||||||||||||||||||||||||
| 657 | - | |||||||||||||||||||||||||
| 658 | QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout()); | - | ||||||||||||||||||||||||
| 659 | option->verticalTitleBar = l->verticalTitleBar; | - | ||||||||||||||||||||||||
| 660 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | void QDockWidgetPrivate::_q_toggleView(bool b) | - | ||||||||||||||||||||||||
| 663 | { | - | ||||||||||||||||||||||||
| 664 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 665 | if (b == q->isHidden()) {
| 0 | ||||||||||||||||||||||||
| 666 | if (b)
| 0 | ||||||||||||||||||||||||
| 667 | q->show(); never executed: q->show(); | 0 | ||||||||||||||||||||||||
| 668 | else | - | ||||||||||||||||||||||||
| 669 | q->close(); never executed: q->close(); | 0 | ||||||||||||||||||||||||
| 670 | } | - | ||||||||||||||||||||||||
| 671 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 672 | - | |||||||||||||||||||||||||
| 673 | void QDockWidgetPrivate::updateButtons() | - | ||||||||||||||||||||||||
| 674 | { | - | ||||||||||||||||||||||||
| 675 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 676 | QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); | - | ||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||
| 678 | QStyleOptionDockWidget opt; | - | ||||||||||||||||||||||||
| 679 | q->initStyleOption(&opt); | - | ||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; | - | ||||||||||||||||||||||||
| 682 | bool nativeDeco = dwLayout->nativeWindowDeco(); | - | ||||||||||||||||||||||||
| 683 | bool hideButtons = nativeDeco || customTitleBar;
| 0 | ||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||
| 685 | bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable); | - | ||||||||||||||||||||||||
| 686 | bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable); | - | ||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | QAbstractButton *button | - | ||||||||||||||||||||||||
| 689 | = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton)); | - | ||||||||||||||||||||||||
| 690 | button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q)); | - | ||||||||||||||||||||||||
| 691 | button->setVisible(canFloat && !hideButtons); | - | ||||||||||||||||||||||||
| 692 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||
| 693 | //: Accessible name for button undocking a dock widget (floating state) | - | ||||||||||||||||||||||||
| 694 | button->setAccessibleName(QDockWidget::tr("Float")); | - | ||||||||||||||||||||||||
| 695 | button->setAccessibleDescription(QDockWidget::tr("Undocks and re-attaches the dock widget")); | - | ||||||||||||||||||||||||
| 696 | #endif | - | ||||||||||||||||||||||||
| 697 | button | - | ||||||||||||||||||||||||
| 698 | = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton)); | - | ||||||||||||||||||||||||
| 699 | button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q)); | - | ||||||||||||||||||||||||
| 700 | button->setVisible(canClose && !hideButtons); | - | ||||||||||||||||||||||||
| 701 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||||||||
| 702 | //: Accessible name for button closing a dock widget | - | ||||||||||||||||||||||||
| 703 | button->setAccessibleName(QDockWidget::tr("Close")); | - | ||||||||||||||||||||||||
| 704 | button->setAccessibleDescription(QDockWidget::tr("Closes the dock widget")); | - | ||||||||||||||||||||||||
| 705 | #endif | - | ||||||||||||||||||||||||
| 706 | q->setAttribute(Qt::WA_ContentsPropagated, | - | ||||||||||||||||||||||||
| 707 | (canFloat || canClose) && !hideButtons); | - | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | layout->invalidate(); | - | ||||||||||||||||||||||||
| 710 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||
| 712 | void QDockWidgetPrivate::_q_toggleTopLevel() | - | ||||||||||||||||||||||||
| 713 | { | - | ||||||||||||||||||||||||
| 714 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 715 | q->setFloating(!q->isFloating()); | - | ||||||||||||||||||||||||
| 716 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | /*! \internal | - | ||||||||||||||||||||||||
| 719 | Initialize the drag state structure and remember the position of the click. | - | ||||||||||||||||||||||||
| 720 | This is called when the mouse is pressed, but the dock is not yet dragged out. | - | ||||||||||||||||||||||||
| 721 | - | |||||||||||||||||||||||||
| 722 | \a nca specify that the event comes from NonClientAreaMouseButtonPress | - | ||||||||||||||||||||||||
| 723 | */ | - | ||||||||||||||||||||||||
| 724 | void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) | - | ||||||||||||||||||||||||
| 725 | { | - | ||||||||||||||||||||||||
| 726 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | if (state != 0)
| 0 | ||||||||||||||||||||||||
| 729 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 732 | Q_ASSERT(layout != 0); | - | ||||||||||||||||||||||||
| 733 | if (layout->pluggingWidget != 0) // the main window is animating a docking operation
| 0 | ||||||||||||||||||||||||
| 734 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 735 | - | |||||||||||||||||||||||||
| 736 | state = new QDockWidgetPrivate::DragState; | - | ||||||||||||||||||||||||
| 737 | state->pressPos = pos; | - | ||||||||||||||||||||||||
| 738 | state->dragging = false; | - | ||||||||||||||||||||||||
| 739 | state->widgetItem = 0; | - | ||||||||||||||||||||||||
| 740 | state->ownWidgetItem = false; | - | ||||||||||||||||||||||||
| 741 | state->nca = nca; | - | ||||||||||||||||||||||||
| 742 | state->ctrlDrag = false; | - | ||||||||||||||||||||||||
| 743 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||
| 745 | /*! \internal | - | ||||||||||||||||||||||||
| 746 | Actually start the drag and detach the dockwidget. | - | ||||||||||||||||||||||||
| 747 | The \a group parameter is true when we should potentially drag a group of | - | ||||||||||||||||||||||||
| 748 | tabbed widgets, and false if the dock widget should always be dragged | - | ||||||||||||||||||||||||
| 749 | alone. | - | ||||||||||||||||||||||||
| 750 | */ | - | ||||||||||||||||||||||||
| 751 | void QDockWidgetPrivate::startDrag(bool group) | - | ||||||||||||||||||||||||
| 752 | { | - | ||||||||||||||||||||||||
| 753 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | if (state == 0 || state->dragging)
| 0 | ||||||||||||||||||||||||
| 756 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 757 | - | |||||||||||||||||||||||||
| 758 | QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 759 | Q_ASSERT(layout != 0); | - | ||||||||||||||||||||||||
| 760 | - | |||||||||||||||||||||||||
| 761 | state->widgetItem = layout->unplug(q, group); | - | ||||||||||||||||||||||||
| 762 | if (state->widgetItem == 0) {
| 0 | ||||||||||||||||||||||||
| 763 | /* I have a QMainWindow parent, but I was never inserted with | - | ||||||||||||||||||||||||
| 764 | QMainWindow::addDockWidget, so the QMainWindowLayout has no | - | ||||||||||||||||||||||||
| 765 | widget item for me. :( I have to create it myself, and then | - | ||||||||||||||||||||||||
| 766 | delete it if I don't get dropped into a dock area. */ | - | ||||||||||||||||||||||||
| 767 | QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent); | - | ||||||||||||||||||||||||
| 768 | if (floatingTab && !q->isFloating())
| 0 | ||||||||||||||||||||||||
| 769 | state->widgetItem = new QDockWidgetGroupWindowItem(floatingTab); never executed: state->widgetItem = new QDockWidgetGroupWindowItem(floatingTab); | 0 | ||||||||||||||||||||||||
| 770 | else | - | ||||||||||||||||||||||||
| 771 | state->widgetItem = new QDockWidgetItem(q); never executed: state->widgetItem = new QDockWidgetItem(q); | 0 | ||||||||||||||||||||||||
| 772 | state->ownWidgetItem = true; | - | ||||||||||||||||||||||||
| 773 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 774 | - | |||||||||||||||||||||||||
| 775 | if (state->ctrlDrag)
| 0 | ||||||||||||||||||||||||
| 776 | layout->restore(); never executed: layout->restore(); | 0 | ||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||
| 778 | state->dragging = true; | - | ||||||||||||||||||||||||
| 779 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 780 | - | |||||||||||||||||||||||||
| 781 | /*! \internal | - | ||||||||||||||||||||||||
| 782 | Ends the drag end drop operation of the QDockWidget. | - | ||||||||||||||||||||||||
| 783 | The \a abort parameter specifies that it ends because of programmatic state | - | ||||||||||||||||||||||||
| 784 | reset rather than mouse release event. | - | ||||||||||||||||||||||||
| 785 | */ | - | ||||||||||||||||||||||||
| 786 | void QDockWidgetPrivate::endDrag(bool abort) | - | ||||||||||||||||||||||||
| 787 | { | - | ||||||||||||||||||||||||
| 788 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 789 | Q_ASSERT(state != 0); | - | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | q->releaseMouse(); | - | ||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||
| 793 | if (state->dragging) {
| 0 | ||||||||||||||||||||||||
| 794 | QMainWindowLayout *mwLayout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 795 | Q_ASSERT(mwLayout != 0); | - | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | if (abort || !mwLayout->plug(state->widgetItem)) {
| 0 | ||||||||||||||||||||||||
| 798 | if (hasFeature(this, QDockWidget::DockWidgetFloatable)) {
| 0 | ||||||||||||||||||||||||
| 799 | // This QDockWidget will now stay in the floating state. | - | ||||||||||||||||||||||||
| 800 | if (state->ownWidgetItem)
| 0 | ||||||||||||||||||||||||
| 801 | delete state->widgetItem; never executed: delete state->widgetItem; | 0 | ||||||||||||||||||||||||
| 802 | mwLayout->restore(); | - | ||||||||||||||||||||||||
| 803 | QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); | - | ||||||||||||||||||||||||
| 804 | if (!dwLayout->nativeWindowDeco()) {
| 0 | ||||||||||||||||||||||||
| 805 | // get rid of the X11BypassWindowManager window flag and activate the resizer | - | ||||||||||||||||||||||||
| 806 | Qt::WindowFlags flags = q->windowFlags(); | - | ||||||||||||||||||||||||
| 807 | flags &= ~Qt::X11BypassWindowManagerHint; | - | ||||||||||||||||||||||||
| 808 | q->setWindowFlags(flags); | - | ||||||||||||||||||||||||
| 809 | setResizerActive(q->isFloating()); | - | ||||||||||||||||||||||||
| 810 | q->show(); | - | ||||||||||||||||||||||||
| 811 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 812 | setResizerActive(false); | - | ||||||||||||||||||||||||
| 813 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 814 | if (q->isFloating()) // Might not be floating when dragging a QDockWidgetGroupWindow
| 0 | ||||||||||||||||||||||||
| 815 | undockedGeometry = q->geometry(); never executed: undockedGeometry = q->geometry(); | 0 | ||||||||||||||||||||||||
| 816 | q->activateWindow(); | - | ||||||||||||||||||||||||
| 817 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 818 | // The tab was not plugged back in the QMainWindow but the QDockWidget cannot | - | ||||||||||||||||||||||||
| 819 | // stay floating, revert to the previous state. | - | ||||||||||||||||||||||||
| 820 | mwLayout->revert(state->widgetItem); | - | ||||||||||||||||||||||||
| 821 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 822 | } | - | ||||||||||||||||||||||||
| 823 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 824 | delete state; | - | ||||||||||||||||||||||||
| 825 | state = 0; | - | ||||||||||||||||||||||||
| 826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||
| 828 | void QDockWidgetPrivate::setResizerActive(bool active) | - | ||||||||||||||||||||||||
| 829 | { | - | ||||||||||||||||||||||||
| 830 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 831 | if (active && !resizer) {
| 0 | ||||||||||||||||||||||||
| 832 | resizer = new QWidgetResizeHandler(q); | - | ||||||||||||||||||||||||
| 833 | resizer->setMovingEnabled(false); | - | ||||||||||||||||||||||||
| 834 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 835 | if (resizer)
| 0 | ||||||||||||||||||||||||
| 836 | resizer->setActive(QWidgetResizeHandler::Resize, active); never executed: resizer->setActive(QWidgetResizeHandler::Resize, active); | 0 | ||||||||||||||||||||||||
| 837 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||
| 839 | bool QDockWidgetPrivate::isAnimating() const | - | ||||||||||||||||||||||||
| 840 | { | - | ||||||||||||||||||||||||
| 841 | Q_Q(const QDockWidget); | - | ||||||||||||||||||||||||
| 842 | - | |||||||||||||||||||||||||
| 843 | QMainWindowLayout *mainWinLayout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 844 | if (mainWinLayout == 0)
| 0 | ||||||||||||||||||||||||
| 845 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 846 | - | |||||||||||||||||||||||||
| 847 | return (const void*)mainWinLayout->pluggingWidget == (const void*)q; never executed: return (const void*)mainWinLayout->pluggingWidget == (const void*)q; | 0 | ||||||||||||||||||||||||
| 848 | } | - | ||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||
| 850 | bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 851 | { | - | ||||||||||||||||||||||||
| 852 | #if !defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 853 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||
| 855 | QDockWidgetLayout *dwLayout | - | ||||||||||||||||||||||||
| 856 | = qobject_cast<QDockWidgetLayout*>(layout); | - | ||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | if (!dwLayout->nativeWindowDeco()) {
| 0 | ||||||||||||||||||||||||
| 859 | QRect titleArea = dwLayout->titleArea(); | - | ||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||
| 861 | QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent); | - | ||||||||||||||||||||||||
| 862 | - | |||||||||||||||||||||||||
| 863 | if (event->button() != Qt::LeftButton ||
| 0 | ||||||||||||||||||||||||
| 864 | !titleArea.contains(event->pos()) ||
| 0 | ||||||||||||||||||||||||
| 865 | // check if the tool window is movable... do nothing if it | - | ||||||||||||||||||||||||
| 866 | // is not (but allow moving if the window is floating) | - | ||||||||||||||||||||||||
| 867 | (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
| 0 | ||||||||||||||||||||||||
| 868 | (qobject_cast<QMainWindow*>(parent) == 0 && !floatingTab) ||
| 0 | ||||||||||||||||||||||||
| 869 | isAnimating() || state != 0) {
| 0 | ||||||||||||||||||||||||
| 870 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 871 | } | - | ||||||||||||||||||||||||
| 872 | - | |||||||||||||||||||||||||
| 873 | initDrag(event->pos(), false); | - | ||||||||||||||||||||||||
| 874 | - | |||||||||||||||||||||||||
| 875 | if (state)
| 0 | ||||||||||||||||||||||||
| 876 | state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier; never executed: state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;
| 0 | ||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||
| 878 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 879 | } | - | ||||||||||||||||||||||||
| 880 | - | |||||||||||||||||||||||||
| 881 | #endif // !defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 882 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 883 | } | - | ||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||
| 885 | bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 886 | { | - | ||||||||||||||||||||||||
| 887 | QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); | - | ||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||
| 889 | if (!dwLayout->nativeWindowDeco()) {
| 0 | ||||||||||||||||||||||||
| 890 | QRect titleArea = dwLayout->titleArea(); | - | ||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
| 0 | ||||||||||||||||||||||||
| 893 | hasFeature(this, QDockWidget::DockWidgetFloatable)) {
| 0 | ||||||||||||||||||||||||
| 894 | _q_toggleTopLevel(); | - | ||||||||||||||||||||||||
| 895 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 896 | } | - | ||||||||||||||||||||||||
| 897 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 898 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 899 | } | - | ||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||
| 901 | bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 902 | { | - | ||||||||||||||||||||||||
| 903 | bool ret = false; | - | ||||||||||||||||||||||||
| 904 | #if !defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 905 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 906 | - | |||||||||||||||||||||||||
| 907 | if (!state)
| 0 | ||||||||||||||||||||||||
| 908 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||
| 910 | QDockWidgetLayout *dwlayout | - | ||||||||||||||||||||||||
| 911 | = qobject_cast<QDockWidgetLayout *>(layout); | - | ||||||||||||||||||||||||
| 912 | QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 913 | if (!dwlayout->nativeWindowDeco()) {
| 0 | ||||||||||||||||||||||||
| 914 | if (!state->dragging
| 0 | ||||||||||||||||||||||||
| 915 | && mwlayout->pluggingWidget == 0
| 0 | ||||||||||||||||||||||||
| 916 | && (event->pos() - state->pressPos).manhattanLength()
| 0 | ||||||||||||||||||||||||
| 917 | > QApplication::startDragDistance()) {
| 0 | ||||||||||||||||||||||||
| 918 | startDrag(); | - | ||||||||||||||||||||||||
| 919 | #ifdef Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||||||||
| 920 | grabMouseWhileInWindow(); | - | ||||||||||||||||||||||||
| 921 | #else | - | ||||||||||||||||||||||||
| 922 | q->grabMouse(); | - | ||||||||||||||||||||||||
| 923 | #endif | - | ||||||||||||||||||||||||
| 924 | ret = true; | - | ||||||||||||||||||||||||
| 925 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 926 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||
| 928 | if (state->dragging && !state->nca) {
| 0 | ||||||||||||||||||||||||
| 929 | QPoint pos = event->globalPos() - state->pressPos; | - | ||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||
| 931 | QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(parent); | - | ||||||||||||||||||||||||
| 932 | if (floatingTab && !q->isFloating())
| 0 | ||||||||||||||||||||||||
| 933 | floatingTab->move(pos); never executed: floatingTab->move(pos); | 0 | ||||||||||||||||||||||||
| 934 | else | - | ||||||||||||||||||||||||
| 935 | q->move(pos); never executed: q->move(pos); | 0 | ||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | if (state && !state->ctrlDrag)
| 0 | ||||||||||||||||||||||||
| 938 | mwlayout->hover(state->widgetItem, event->globalPos()); never executed: mwlayout->hover(state->widgetItem, event->globalPos()); | 0 | ||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | ret = true; | - | ||||||||||||||||||||||||
| 941 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 942 | - | |||||||||||||||||||||||||
| 943 | #endif // !defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 944 | return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
| 945 | } | - | ||||||||||||||||||||||||
| 946 | - | |||||||||||||||||||||||||
| 947 | bool QDockWidgetPrivate::mouseReleaseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 948 | { | - | ||||||||||||||||||||||||
| 949 | #if !defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 950 | - | |||||||||||||||||||||||||
| 951 | if (event->button() == Qt::LeftButton && state && !state->nca) {
| 0 | ||||||||||||||||||||||||
| 952 | endDrag(); | - | ||||||||||||||||||||||||
| 953 | return true; //filter out the event never executed: return true; | 0 | ||||||||||||||||||||||||
| 954 | } | - | ||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||
| 956 | #endif // !defined(QT_NO_MAINWINDOW) | - | ||||||||||||||||||||||||
| 957 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
| 958 | } | - | ||||||||||||||||||||||||
| 959 | - | |||||||||||||||||||||||||
| 960 | void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) | - | ||||||||||||||||||||||||
| 961 | { | - | ||||||||||||||||||||||||
| 962 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 963 | - | |||||||||||||||||||||||||
| 964 | int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); | - | ||||||||||||||||||||||||
| 965 | - | |||||||||||||||||||||||||
| 966 | QWidget *tl = q->topLevelWidget(); | - | ||||||||||||||||||||||||
| 967 | QRect geo = tl->geometry(); | - | ||||||||||||||||||||||||
| 968 | QRect titleRect = tl->frameGeometry(); | - | ||||||||||||||||||||||||
| 969 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||
| 970 | if ((features & QDockWidget::DockWidgetVerticalTitleBar)) { | - | ||||||||||||||||||||||||
| 971 | titleRect.setTop(geo.top()); | - | ||||||||||||||||||||||||
| 972 | titleRect.setBottom(geo.bottom()); | - | ||||||||||||||||||||||||
| 973 | titleRect.setRight(geo.left() - 1); | - | ||||||||||||||||||||||||
| 974 | } else | - | ||||||||||||||||||||||||
| 975 | #endif | - | ||||||||||||||||||||||||
| 976 | { | - | ||||||||||||||||||||||||
| 977 | titleRect.setLeft(geo.left()); | - | ||||||||||||||||||||||||
| 978 | titleRect.setRight(geo.right()); | - | ||||||||||||||||||||||||
| 979 | titleRect.setBottom(geo.top() - 1); | - | ||||||||||||||||||||||||
| 980 | titleRect.adjust(0, fw, 0, 0); | - | ||||||||||||||||||||||||
| 981 | } | - | ||||||||||||||||||||||||
| 982 | - | |||||||||||||||||||||||||
| 983 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 984 | case QEvent::NonClientAreaMouseButtonPress: never executed: case QEvent::NonClientAreaMouseButtonPress: | 0 | ||||||||||||||||||||||||
| 985 | if (!titleRect.contains(event->globalPos()))
| 0 | ||||||||||||||||||||||||
| 986 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 987 | if (state != 0)
| 0 | ||||||||||||||||||||||||
| 988 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 989 | if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
| 0 | ||||||||||||||||||||||||
| 990 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 991 | if (isAnimating())
| 0 | ||||||||||||||||||||||||
| 992 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 993 | initDrag(event->pos(), true); | - | ||||||||||||||||||||||||
| 994 | if (state == 0)
| 0 | ||||||||||||||||||||||||
| 995 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 996 | state->ctrlDrag = event->modifiers() & Qt::ControlModifier; | - | ||||||||||||||||||||||||
| 997 | startDrag(); | - | ||||||||||||||||||||||||
| 998 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 999 | case QEvent::NonClientAreaMouseMove: never executed: case QEvent::NonClientAreaMouseMove: | 0 | ||||||||||||||||||||||||
| 1000 | if (state == 0 || !state->dragging)
| 0 | ||||||||||||||||||||||||
| 1001 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1002 | - | |||||||||||||||||||||||||
| 1003 | #ifndef Q_OS_MAC | - | ||||||||||||||||||||||||
| 1004 | if (state->nca) {
| 0 | ||||||||||||||||||||||||
| 1005 | endDrag(); | - | ||||||||||||||||||||||||
| 1006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | #endif | - | ||||||||||||||||||||||||
| 1008 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1009 | case QEvent::NonClientAreaMouseButtonRelease: never executed: case QEvent::NonClientAreaMouseButtonRelease: | 0 | ||||||||||||||||||||||||
| 1010 | #ifdef Q_OS_MAC | - | ||||||||||||||||||||||||
| 1011 | if (state) | - | ||||||||||||||||||||||||
| 1012 | endDrag(); | - | ||||||||||||||||||||||||
| 1013 | #endif | - | ||||||||||||||||||||||||
| 1014 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1015 | case QEvent::NonClientAreaMouseButtonDblClick: never executed: case QEvent::NonClientAreaMouseButtonDblClick: | 0 | ||||||||||||||||||||||||
| 1016 | _q_toggleTopLevel(); | - | ||||||||||||||||||||||||
| 1017 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1018 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1019 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1020 | } | - | ||||||||||||||||||||||||
| 1021 | } | - | ||||||||||||||||||||||||
| 1022 | - | |||||||||||||||||||||||||
| 1023 | /*! \internal | - | ||||||||||||||||||||||||
| 1024 | Called when the QDockWidget or the QDockWidgetGroupWindow is moved | - | ||||||||||||||||||||||||
| 1025 | */ | - | ||||||||||||||||||||||||
| 1026 | void QDockWidgetPrivate::moveEvent(QMoveEvent *event) | - | ||||||||||||||||||||||||
| 1027 | { | - | ||||||||||||||||||||||||
| 1028 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 1029 | - | |||||||||||||||||||||||||
| 1030 | if (state == 0 || !state->dragging || !state->nca)
| 0 | ||||||||||||||||||||||||
| 1031 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | if (!q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
| 0 | ||||||||||||||||||||||||
| 1034 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | // When the native window frame is being dragged, all we get is these mouse | - | ||||||||||||||||||||||||
| 1037 | // move events. | - | ||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||
| 1039 | if (state->ctrlDrag)
| 0 | ||||||||||||||||||||||||
| 1040 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 1043 | Q_ASSERT(layout != 0); | - | ||||||||||||||||||||||||
| 1044 | - | |||||||||||||||||||||||||
| 1045 | QPoint globalMousePos = event->pos() + state->pressPos; | - | ||||||||||||||||||||||||
| 1046 | layout->hover(state->widgetItem, globalMousePos); | - | ||||||||||||||||||||||||
| 1047 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1048 | - | |||||||||||||||||||||||||
| 1049 | void QDockWidgetPrivate::unplug(const QRect &rect) | - | ||||||||||||||||||||||||
| 1050 | { | - | ||||||||||||||||||||||||
| 1051 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 1052 | QRect r = rect; | - | ||||||||||||||||||||||||
| 1053 | r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); | - | ||||||||||||||||||||||||
| 1054 | QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); | - | ||||||||||||||||||||||||
| 1055 | if (dwLayout->nativeWindowDeco(true))
| 0 | ||||||||||||||||||||||||
| 1056 | r.adjust(0, dwLayout->titleHeight(), 0, 0); never executed: r.adjust(0, dwLayout->titleHeight(), 0, 0); | 0 | ||||||||||||||||||||||||
| 1057 | setWindowState(true, true, r); | - | ||||||||||||||||||||||||
| 1058 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1059 | - | |||||||||||||||||||||||||
| 1060 | void QDockWidgetPrivate::plug(const QRect &rect) | - | ||||||||||||||||||||||||
| 1061 | { | - | ||||||||||||||||||||||||
| 1062 | setWindowState(false, false, rect); | - | ||||||||||||||||||||||||
| 1063 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1064 | - | |||||||||||||||||||||||||
| 1065 | void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) | - | ||||||||||||||||||||||||
| 1066 | { | - | ||||||||||||||||||||||||
| 1067 | Q_Q(QDockWidget); | - | ||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||
| 1069 | if (!floating && parent) {
| 0 | ||||||||||||||||||||||||
| 1070 | QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 1071 | if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea
| 0 | ||||||||||||||||||||||||
| 1072 | && !qobject_cast<QDockWidgetGroupWindow *>(parent))
| 0 | ||||||||||||||||||||||||
| 1073 | return; // this dockwidget can't be redocked never executed: return; | 0 | ||||||||||||||||||||||||
| 1074 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1075 | - | |||||||||||||||||||||||||
| 1076 | bool wasFloating = q->isFloating(); | - | ||||||||||||||||||||||||
| 1077 | if (wasFloating) // Prevent repetitive unplugging from nested invocations (QTBUG-42818)
| 0 | ||||||||||||||||||||||||
| 1078 | unplug = false; never executed: unplug = false; | 0 | ||||||||||||||||||||||||
| 1079 | bool hidden = q->isHidden(); | - | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | if (q->isVisible())
| 0 | ||||||||||||||||||||||||
| 1082 | q->hide(); never executed: q->hide(); | 0 | ||||||||||||||||||||||||
| 1083 | - | |||||||||||||||||||||||||
| 1084 | Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
| 0 | ||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||
| 1086 | QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); | - | ||||||||||||||||||||||||
| 1087 | const bool nativeDeco = dwLayout->nativeWindowDeco(floating); | - | ||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||
| 1089 | if (nativeDeco) {
| 0 | ||||||||||||||||||||||||
| 1090 | flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; | - | ||||||||||||||||||||||||
| 1091 | if (hasFeature(this, QDockWidget::DockWidgetClosable))
| 0 | ||||||||||||||||||||||||
| 1092 | flags |= Qt::WindowCloseButtonHint; never executed: flags |= Qt::WindowCloseButtonHint; | 0 | ||||||||||||||||||||||||
| 1093 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1094 | flags |= Qt::FramelessWindowHint; | - | ||||||||||||||||||||||||
| 1095 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1096 | - | |||||||||||||||||||||||||
| 1097 | if (unplug)
| 0 | ||||||||||||||||||||||||
| 1098 | flags |= Qt::X11BypassWindowManagerHint; never executed: flags |= Qt::X11BypassWindowManagerHint; | 0 | ||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | q->setWindowFlags(flags); | - | ||||||||||||||||||||||||
| 1101 | - | |||||||||||||||||||||||||
| 1102 | - | |||||||||||||||||||||||||
| 1103 | if (!rect.isNull())
| 0 | ||||||||||||||||||||||||
| 1104 | q->setGeometry(rect); never executed: q->setGeometry(rect); | 0 | ||||||||||||||||||||||||
| 1105 | - | |||||||||||||||||||||||||
| 1106 | updateButtons(); | - | ||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | if (!hidden)
| 0 | ||||||||||||||||||||||||
| 1109 | q->show(); never executed: q->show(); | 0 | ||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | if (floating != wasFloating) {
| 0 | ||||||||||||||||||||||||
| 1112 | emit q->topLevelChanged(floating); | - | ||||||||||||||||||||||||
| 1113 | if (!floating && parent) {
| 0 | ||||||||||||||||||||||||
| 1114 | QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q); | - | ||||||||||||||||||||||||
| 1115 | if (mwlayout)
| 0 | ||||||||||||||||||||||||
| 1116 | emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); never executed: q->dockLocationChanged(mwlayout->dockWidgetArea(q)); | 0 | ||||||||||||||||||||||||
| 1117 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1118 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1119 | - | |||||||||||||||||||||||||
| 1120 | setResizerActive(!unplug && floating && !nativeDeco); | - | ||||||||||||||||||||||||
| 1121 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||
| 1123 | /*! | - | ||||||||||||||||||||||||
| 1124 | \class QDockWidget | - | ||||||||||||||||||||||||
| 1125 | - | |||||||||||||||||||||||||
| 1126 | \brief The QDockWidget class provides a widget that can be docked | - | ||||||||||||||||||||||||
| 1127 | inside a QMainWindow or floated as a top-level window on the | - | ||||||||||||||||||||||||
| 1128 | desktop. | - | ||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||
| 1130 | \ingroup mainwindow-classes | - | ||||||||||||||||||||||||
| 1131 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | QDockWidget provides the concept of dock widgets, also know as | - | ||||||||||||||||||||||||
| 1134 | tool palettes or utility windows. Dock windows are secondary | - | ||||||||||||||||||||||||
| 1135 | windows placed in the \e {dock widget area} around the | - | ||||||||||||||||||||||||
| 1136 | \l{QMainWindow::centralWidget()}{central widget} in a | - | ||||||||||||||||||||||||
| 1137 | QMainWindow. | - | ||||||||||||||||||||||||
| 1138 | - | |||||||||||||||||||||||||
| 1139 | \image mainwindow-docks.png | - | ||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | Dock windows can be moved inside their current area, moved into | - | ||||||||||||||||||||||||
| 1142 | new areas and floated (e.g., undocked) by the end-user. The | - | ||||||||||||||||||||||||
| 1143 | QDockWidget API allows the programmer to restrict the dock widgets | - | ||||||||||||||||||||||||
| 1144 | ability to move, float and close, as well as the areas in which | - | ||||||||||||||||||||||||
| 1145 | they can be placed. | - | ||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | \section1 Appearance | - | ||||||||||||||||||||||||
| 1148 | - | |||||||||||||||||||||||||
| 1149 | A QDockWidget consists of a title bar and the content area. The | - | ||||||||||||||||||||||||
| 1150 | title bar displays the dock widgets | - | ||||||||||||||||||||||||
| 1151 | \l{QWidget::windowTitle()}{window title}, | - | ||||||||||||||||||||||||
| 1152 | a \e float button and a \e close button. | - | ||||||||||||||||||||||||
| 1153 | Depending on the state of the QDockWidget, the \e float and \e | - | ||||||||||||||||||||||||
| 1154 | close buttons may be either disabled or not shown at all. | - | ||||||||||||||||||||||||
| 1155 | - | |||||||||||||||||||||||||
| 1156 | The visual appearance of the title bar and buttons is dependent | - | ||||||||||||||||||||||||
| 1157 | on the \l{QStyle}{style} in use. | - | ||||||||||||||||||||||||
| 1158 | - | |||||||||||||||||||||||||
| 1159 | A QDockWidget acts as a wrapper for its child widget, set with setWidget(). | - | ||||||||||||||||||||||||
| 1160 | Custom size hints, minimum and maximum sizes and size policies should be | - | ||||||||||||||||||||||||
| 1161 | implemented in the child widget. QDockWidget will respect them, adjusting | - | ||||||||||||||||||||||||
| 1162 | its own constraints to include the frame and title. Size constraints | - | ||||||||||||||||||||||||
| 1163 | should not be set on the QDockWidget itself, because they change depending | - | ||||||||||||||||||||||||
| 1164 | on whether it is docked; a docked QDockWidget has no frame and a smaller title | - | ||||||||||||||||||||||||
| 1165 | bar. | - | ||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | \sa QMainWindow, {Dock Widgets Example} | - | ||||||||||||||||||||||||
| 1168 | */ | - | ||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||
| 1170 | /*! | - | ||||||||||||||||||||||||
| 1171 | \enum QDockWidget::DockWidgetFeature | - | ||||||||||||||||||||||||
| 1172 | - | |||||||||||||||||||||||||
| 1173 | \value DockWidgetClosable The dock widget can be closed. On some systems the dock | - | ||||||||||||||||||||||||
| 1174 | widget always has a close button when it's floating | - | ||||||||||||||||||||||||
| 1175 | (for example on MacOS 10.5). | - | ||||||||||||||||||||||||
| 1176 | \value DockWidgetMovable The dock widget can be moved between docks | - | ||||||||||||||||||||||||
| 1177 | by the user. | - | ||||||||||||||||||||||||
| 1178 | \value DockWidgetFloatable The dock widget can be detached from the | - | ||||||||||||||||||||||||
| 1179 | main window, and floated as an independent | - | ||||||||||||||||||||||||
| 1180 | window. | - | ||||||||||||||||||||||||
| 1181 | \value DockWidgetVerticalTitleBar The dock widget displays a vertical title | - | ||||||||||||||||||||||||
| 1182 | bar on its left side. This can be used to | - | ||||||||||||||||||||||||
| 1183 | increase the amount of vertical space in | - | ||||||||||||||||||||||||
| 1184 | a QMainWindow. | - | ||||||||||||||||||||||||
| 1185 | \value AllDockWidgetFeatures (Deprecated) The dock widget can be closed, moved, | - | ||||||||||||||||||||||||
| 1186 | and floated. Since new features might be added in future | - | ||||||||||||||||||||||||
| 1187 | releases, the look and behavior of dock widgets might | - | ||||||||||||||||||||||||
| 1188 | change if you use this flag. Please specify individual | - | ||||||||||||||||||||||||
| 1189 | flags instead. | - | ||||||||||||||||||||||||
| 1190 | \value NoDockWidgetFeatures The dock widget cannot be closed, moved, | - | ||||||||||||||||||||||||
| 1191 | or floated. | - | ||||||||||||||||||||||||
| 1192 | - | |||||||||||||||||||||||||
| 1193 | \omitvalue DockWidgetFeatureMask | - | ||||||||||||||||||||||||
| 1194 | \omitvalue Reserved | - | ||||||||||||||||||||||||
| 1195 | */ | - | ||||||||||||||||||||||||
| 1196 | - | |||||||||||||||||||||||||
| 1197 | /*! | - | ||||||||||||||||||||||||
| 1198 | \property QDockWidget::windowTitle | - | ||||||||||||||||||||||||
| 1199 | \brief the dock widget title (caption) | - | ||||||||||||||||||||||||
| 1200 | - | |||||||||||||||||||||||||
| 1201 | By default, this property contains an empty string. | - | ||||||||||||||||||||||||
| 1202 | */ | - | ||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||
| 1204 | /*! | - | ||||||||||||||||||||||||
| 1205 | Constructs a QDockWidget with parent \a parent and window flags \a | - | ||||||||||||||||||||||||
| 1206 | flags. The dock widget will be placed in the left dock widget | - | ||||||||||||||||||||||||
| 1207 | area. | - | ||||||||||||||||||||||||
| 1208 | */ | - | ||||||||||||||||||||||||
| 1209 | QDockWidget::QDockWidget(QWidget *parent, Qt::WindowFlags flags) | - | ||||||||||||||||||||||||
| 1210 | : QWidget(*new QDockWidgetPrivate, parent, flags) | - | ||||||||||||||||||||||||
| 1211 | { | - | ||||||||||||||||||||||||
| 1212 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1213 | d->init(); | - | ||||||||||||||||||||||||
| 1214 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1215 | - | |||||||||||||||||||||||||
| 1216 | /*! | - | ||||||||||||||||||||||||
| 1217 | Constructs a QDockWidget with parent \a parent and window flags \a | - | ||||||||||||||||||||||||
| 1218 | flags. The dock widget will be placed in the left dock widget | - | ||||||||||||||||||||||||
| 1219 | area. | - | ||||||||||||||||||||||||
| 1220 | - | |||||||||||||||||||||||||
| 1221 | The window title is set to \a title. This title is used when the | - | ||||||||||||||||||||||||
| 1222 | QDockWidget is docked and undocked. It is also used in the context | - | ||||||||||||||||||||||||
| 1223 | menu provided by QMainWindow. | - | ||||||||||||||||||||||||
| 1224 | - | |||||||||||||||||||||||||
| 1225 | \sa setWindowTitle() | - | ||||||||||||||||||||||||
| 1226 | */ | - | ||||||||||||||||||||||||
| 1227 | QDockWidget::QDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) | - | ||||||||||||||||||||||||
| 1228 | : QWidget(*new QDockWidgetPrivate, parent, flags) | - | ||||||||||||||||||||||||
| 1229 | { | - | ||||||||||||||||||||||||
| 1230 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1231 | d->init(); | - | ||||||||||||||||||||||||
| 1232 | setWindowTitle(title); | - | ||||||||||||||||||||||||
| 1233 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||
| 1235 | /*! | - | ||||||||||||||||||||||||
| 1236 | Destroys the dock widget. | - | ||||||||||||||||||||||||
| 1237 | */ | - | ||||||||||||||||||||||||
| 1238 | QDockWidget::~QDockWidget() | - | ||||||||||||||||||||||||
| 1239 | { } | - | ||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||
| 1241 | /*! | - | ||||||||||||||||||||||||
| 1242 | Returns the widget for the dock widget. This function returns zero | - | ||||||||||||||||||||||||
| 1243 | if the widget has not been set. | - | ||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||
| 1245 | \sa setWidget() | - | ||||||||||||||||||||||||
| 1246 | */ | - | ||||||||||||||||||||||||
| 1247 | QWidget *QDockWidget::widget() const | - | ||||||||||||||||||||||||
| 1248 | { | - | ||||||||||||||||||||||||
| 1249 | QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1250 | return layout->widgetForRole(QDockWidgetLayout::Content); never executed: return layout->widgetForRole(QDockWidgetLayout::Content); | 0 | ||||||||||||||||||||||||
| 1251 | } | - | ||||||||||||||||||||||||
| 1252 | - | |||||||||||||||||||||||||
| 1253 | /*! | - | ||||||||||||||||||||||||
| 1254 | Sets the widget for the dock widget to \a widget. | - | ||||||||||||||||||||||||
| 1255 | - | |||||||||||||||||||||||||
| 1256 | If the dock widget is visible when \a widget is added, you must | - | ||||||||||||||||||||||||
| 1257 | \l{QWidget::}{show()} it explicitly. | - | ||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | Note that you must add the layout of the \a widget before you call | - | ||||||||||||||||||||||||
| 1260 | this function; if not, the \a widget will not be visible. | - | ||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | \sa widget() | - | ||||||||||||||||||||||||
| 1263 | */ | - | ||||||||||||||||||||||||
| 1264 | void QDockWidget::setWidget(QWidget *widget) | - | ||||||||||||||||||||||||
| 1265 | { | - | ||||||||||||||||||||||||
| 1266 | QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1267 | layout->setWidgetForRole(QDockWidgetLayout::Content, widget); | - | ||||||||||||||||||||||||
| 1268 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1269 | - | |||||||||||||||||||||||||
| 1270 | /*! | - | ||||||||||||||||||||||||
| 1271 | \property QDockWidget::features | - | ||||||||||||||||||||||||
| 1272 | \brief whether the dock widget is movable, closable, and floatable | - | ||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | By default, this property is set to a combination of DockWidgetClosable, | - | ||||||||||||||||||||||||
| 1275 | DockWidgetMovable and DockWidgetFloatable. | - | ||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | \sa DockWidgetFeature | - | ||||||||||||||||||||||||
| 1278 | */ | - | ||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | void QDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) | - | ||||||||||||||||||||||||
| 1281 | { | - | ||||||||||||||||||||||||
| 1282 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1283 | features &= DockWidgetFeatureMask; | - | ||||||||||||||||||||||||
| 1284 | if (d->features == features)
| 0 | ||||||||||||||||||||||||
| 1285 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1286 | const bool closableChanged = (d->features ^ features) & DockWidgetClosable; | - | ||||||||||||||||||||||||
| 1287 | d->features = features; | - | ||||||||||||||||||||||||
| 1288 | QDockWidgetLayout *layout | - | ||||||||||||||||||||||||
| 1289 | = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1290 | layout->setVerticalTitleBar(features & DockWidgetVerticalTitleBar); | - | ||||||||||||||||||||||||
| 1291 | d->updateButtons(); | - | ||||||||||||||||||||||||
| 1292 | d->toggleViewAction->setEnabled((d->features & DockWidgetClosable) == DockWidgetClosable); | - | ||||||||||||||||||||||||
| 1293 | emit featuresChanged(d->features); | - | ||||||||||||||||||||||||
| 1294 | update(); | - | ||||||||||||||||||||||||
| 1295 | if (closableChanged && layout->nativeWindowDeco()) {
| 0 | ||||||||||||||||||||||||
| 1296 | QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow *>(parent()); | - | ||||||||||||||||||||||||
| 1297 | if (floatingTab && !isFloating())
| 0 | ||||||||||||||||||||||||
| 1298 | floatingTab->adjustFlags(); never executed: floatingTab->adjustFlags(); | 0 | ||||||||||||||||||||||||
| 1299 | else | - | ||||||||||||||||||||||||
| 1300 | d->setWindowState(true /*floating*/, true /*unplug*/); //this ensures the native decoration is drawn never executed: d->setWindowState(true , true ); | 0 | ||||||||||||||||||||||||
| 1301 | } | - | ||||||||||||||||||||||||
| 1302 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1303 | - | |||||||||||||||||||||||||
| 1304 | QDockWidget::DockWidgetFeatures QDockWidget::features() const | - | ||||||||||||||||||||||||
| 1305 | { | - | ||||||||||||||||||||||||
| 1306 | Q_D(const QDockWidget); | - | ||||||||||||||||||||||||
| 1307 | return d->features; never executed: return d->features; | 0 | ||||||||||||||||||||||||
| 1308 | } | - | ||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | /*! | - | ||||||||||||||||||||||||
| 1311 | \property QDockWidget::floating | - | ||||||||||||||||||||||||
| 1312 | \brief whether the dock widget is floating | - | ||||||||||||||||||||||||
| 1313 | - | |||||||||||||||||||||||||
| 1314 | A floating dock widget is presented to the user as an independent | - | ||||||||||||||||||||||||
| 1315 | window "on top" of its parent QMainWindow, instead of being | - | ||||||||||||||||||||||||
| 1316 | docked in the QMainWindow. | - | ||||||||||||||||||||||||
| 1317 | - | |||||||||||||||||||||||||
| 1318 | By default, this property is \c true. | - | ||||||||||||||||||||||||
| 1319 | - | |||||||||||||||||||||||||
| 1320 | When this property changes, the \c {topLevelChanged()} signal is emitted. | - | ||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||
| 1322 | \sa isWindow(), topLevelChanged() | - | ||||||||||||||||||||||||
| 1323 | */ | - | ||||||||||||||||||||||||
| 1324 | void QDockWidget::setFloating(bool floating) | - | ||||||||||||||||||||||||
| 1325 | { | - | ||||||||||||||||||||||||
| 1326 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1327 | - | |||||||||||||||||||||||||
| 1328 | // the initial click of a double-click may have started a drag... | - | ||||||||||||||||||||||||
| 1329 | if (d->state != 0)
| 0 | ||||||||||||||||||||||||
| 1330 | d->endDrag(true); never executed: d->endDrag(true); | 0 | ||||||||||||||||||||||||
| 1331 | - | |||||||||||||||||||||||||
| 1332 | QRect r = d->undockedGeometry; | - | ||||||||||||||||||||||||
| 1333 | // Keep position when undocking for the first time. | - | ||||||||||||||||||||||||
| 1334 | if (floating && isVisible() && !r.isValid())
| 0 | ||||||||||||||||||||||||
| 1335 | r = QRect(mapToGlobal(QPoint(0, 0)), size()); never executed: r = QRect(mapToGlobal(QPoint(0, 0)), size()); | 0 | ||||||||||||||||||||||||
| 1336 | - | |||||||||||||||||||||||||
| 1337 | d->setWindowState(floating, false, floating ? r : QRect()); | - | ||||||||||||||||||||||||
| 1338 | - | |||||||||||||||||||||||||
| 1339 | if (floating && r.isNull()) {
| 0 | ||||||||||||||||||||||||
| 1340 | if (x() < 0 || y() < 0) //may happen if we have been hidden
| 0 | ||||||||||||||||||||||||
| 1341 | move(QPoint()); never executed: move(QPoint()); | 0 | ||||||||||||||||||||||||
| 1342 | setAttribute(Qt::WA_Moved, false); //we want it at the default position | - | ||||||||||||||||||||||||
| 1343 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1345 | - | |||||||||||||||||||||||||
| 1346 | /*! | - | ||||||||||||||||||||||||
| 1347 | \property QDockWidget::allowedAreas | - | ||||||||||||||||||||||||
| 1348 | \brief areas where the dock widget may be placed | - | ||||||||||||||||||||||||
| 1349 | - | |||||||||||||||||||||||||
| 1350 | The default is Qt::AllDockWidgetAreas. | - | ||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | \sa Qt::DockWidgetArea | - | ||||||||||||||||||||||||
| 1353 | */ | - | ||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||
| 1355 | void QDockWidget::setAllowedAreas(Qt::DockWidgetAreas areas) | - | ||||||||||||||||||||||||
| 1356 | { | - | ||||||||||||||||||||||||
| 1357 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1358 | areas &= Qt::DockWidgetArea_Mask; | - | ||||||||||||||||||||||||
| 1359 | if (areas == d->allowedAreas)
| 0 | ||||||||||||||||||||||||
| 1360 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1361 | d->allowedAreas = areas; | - | ||||||||||||||||||||||||
| 1362 | emit allowedAreasChanged(d->allowedAreas); | - | ||||||||||||||||||||||||
| 1363 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | Qt::DockWidgetAreas QDockWidget::allowedAreas() const | - | ||||||||||||||||||||||||
| 1366 | { | - | ||||||||||||||||||||||||
| 1367 | Q_D(const QDockWidget); | - | ||||||||||||||||||||||||
| 1368 | return d->allowedAreas; never executed: return d->allowedAreas; | 0 | ||||||||||||||||||||||||
| 1369 | } | - | ||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||
| 1371 | /*! | - | ||||||||||||||||||||||||
| 1372 | \fn bool QDockWidget::isAreaAllowed(Qt::DockWidgetArea area) const | - | ||||||||||||||||||||||||
| 1373 | - | |||||||||||||||||||||||||
| 1374 | Returns \c true if this dock widget can be placed in the given \a area; | - | ||||||||||||||||||||||||
| 1375 | otherwise returns \c false. | - | ||||||||||||||||||||||||
| 1376 | */ | - | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | /*! \reimp */ | - | ||||||||||||||||||||||||
| 1379 | void QDockWidget::changeEvent(QEvent *event) | - | ||||||||||||||||||||||||
| 1380 | { | - | ||||||||||||||||||||||||
| 1381 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1382 | QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1383 | - | |||||||||||||||||||||||||
| 1384 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 1385 | case QEvent::ModifiedChange: never executed: case QEvent::ModifiedChange: | 0 | ||||||||||||||||||||||||
| 1386 | case QEvent::WindowTitleChange: never executed: case QEvent::WindowTitleChange: | 0 | ||||||||||||||||||||||||
| 1387 | update(layout->titleArea()); | - | ||||||||||||||||||||||||
| 1388 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1389 | d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this); | - | ||||||||||||||||||||||||
| 1390 | d->toggleViewAction->setText(d->fixedWindowTitle); | - | ||||||||||||||||||||||||
| 1391 | #endif | - | ||||||||||||||||||||||||
| 1392 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1393 | { | - | ||||||||||||||||||||||||
| 1394 | if (QMainWindowLayout *winLayout = qt_mainwindow_layout_from_dock(this)) {
| 0 | ||||||||||||||||||||||||
| 1395 | if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
| 0 | ||||||||||||||||||||||||
| 1396 | info->updateTabBar(); never executed: info->updateTabBar(); | 0 | ||||||||||||||||||||||||
| 1397 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1398 | } | - | ||||||||||||||||||||||||
| 1399 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1400 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1401 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1402 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1403 | } | - | ||||||||||||||||||||||||
| 1404 | QWidget::changeEvent(event); | - | ||||||||||||||||||||||||
| 1405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1406 | - | |||||||||||||||||||||||||
| 1407 | /*! \reimp */ | - | ||||||||||||||||||||||||
| 1408 | void QDockWidget::closeEvent(QCloseEvent *event) | - | ||||||||||||||||||||||||
| 1409 | { | - | ||||||||||||||||||||||||
| 1410 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1411 | if (d->state)
| 0 | ||||||||||||||||||||||||
| 1412 | d->endDrag(true); never executed: d->endDrag(true); | 0 | ||||||||||||||||||||||||
| 1413 | QWidget::closeEvent(event); | - | ||||||||||||||||||||||||
| 1414 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||
| 1416 | /*! \reimp */ | - | ||||||||||||||||||||||||
| 1417 | void QDockWidget::paintEvent(QPaintEvent *event) | - | ||||||||||||||||||||||||
| 1418 | { | - | ||||||||||||||||||||||||
| 1419 | Q_UNUSED(event) | - | ||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||
| 1421 | QDockWidgetLayout *layout | - | ||||||||||||||||||||||||
| 1422 | = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1423 | bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; | - | ||||||||||||||||||||||||
| 1424 | bool nativeDeco = layout->nativeWindowDeco(); | - | ||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||
| 1426 | if (!nativeDeco && !customTitleBar) {
| 0 | ||||||||||||||||||||||||
| 1427 | QStylePainter p(this); | - | ||||||||||||||||||||||||
| 1428 | // ### Add PixelMetric to change spacers, so style may show border | - | ||||||||||||||||||||||||
| 1429 | // when not floating. | - | ||||||||||||||||||||||||
| 1430 | if (isFloating()) {
| 0 | ||||||||||||||||||||||||
| 1431 | QStyleOptionFrame framOpt; | - | ||||||||||||||||||||||||
| 1432 | framOpt.init(this); | - | ||||||||||||||||||||||||
| 1433 | p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt); | - | ||||||||||||||||||||||||
| 1434 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1435 | - | |||||||||||||||||||||||||
| 1436 | // Title must be painted after the frame, since the areas overlap, and | - | ||||||||||||||||||||||||
| 1437 | // the title may wish to extend out to all sides (eg. XP style) | - | ||||||||||||||||||||||||
| 1438 | QStyleOptionDockWidget titleOpt; | - | ||||||||||||||||||||||||
| 1439 | initStyleOption(&titleOpt); | - | ||||||||||||||||||||||||
| 1440 | p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt); | - | ||||||||||||||||||||||||
| 1441 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1442 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1443 | - | |||||||||||||||||||||||||
| 1444 | /*! \reimp */ | - | ||||||||||||||||||||||||
| 1445 | bool QDockWidget::event(QEvent *event) | - | ||||||||||||||||||||||||
| 1446 | { | - | ||||||||||||||||||||||||
| 1447 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1448 | - | |||||||||||||||||||||||||
| 1449 | QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); | - | ||||||||||||||||||||||||
| 1450 | QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(this); | - | ||||||||||||||||||||||||
| 1451 | - | |||||||||||||||||||||||||
| 1452 | switch (event->type()) { | - | ||||||||||||||||||||||||
| 1453 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1454 | case QEvent::Hide: never executed: case QEvent::Hide: | 0 | ||||||||||||||||||||||||
| 1455 | if (layout != 0)
| 0 | ||||||||||||||||||||||||
| 1456 | layout->keepSize(this); never executed: layout->keepSize(this); | 0 | ||||||||||||||||||||||||
| 1457 | d->toggleViewAction->setChecked(false); | - | ||||||||||||||||||||||||
| 1458 | emit visibilityChanged(false); | - | ||||||||||||||||||||||||
| 1459 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1460 | case QEvent::Show: { never executed: case QEvent::Show: | 0 | ||||||||||||||||||||||||
| 1461 | d->toggleViewAction->setChecked(true); | - | ||||||||||||||||||||||||
| 1462 | QPoint parentTopLeft(0, 0); | - | ||||||||||||||||||||||||
| 1463 | if (isWindow()) {
| 0 | ||||||||||||||||||||||||
| 1464 | if (const QWindow *window = windowHandle())
| 0 | ||||||||||||||||||||||||
| 1465 | parentTopLeft = window->screen()->availableVirtualGeometry().topLeft(); never executed: parentTopLeft = window->screen()->availableVirtualGeometry().topLeft(); | 0 | ||||||||||||||||||||||||
| 1466 | else | - | ||||||||||||||||||||||||
| 1467 | parentTopLeft = QGuiApplication::primaryScreen()->availableVirtualGeometry().topLeft(); never executed: parentTopLeft = QGuiApplication::primaryScreen()->availableVirtualGeometry().topLeft(); | 0 | ||||||||||||||||||||||||
| 1468 | } | - | ||||||||||||||||||||||||
| 1469 | emit visibilityChanged(geometry().right() >= parentTopLeft.x() && geometry().bottom() >= parentTopLeft.y()); | - | ||||||||||||||||||||||||
| 1470 | } | - | ||||||||||||||||||||||||
| 1471 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1472 | #endif | - | ||||||||||||||||||||||||
| 1473 | case QEvent::ApplicationLayoutDirectionChange: never executed: case QEvent::ApplicationLayoutDirectionChange: | 0 | ||||||||||||||||||||||||
| 1474 | case QEvent::LayoutDirectionChange: never executed: case QEvent::LayoutDirectionChange: | 0 | ||||||||||||||||||||||||
| 1475 | case QEvent::StyleChange: never executed: case QEvent::StyleChange: | 0 | ||||||||||||||||||||||||
| 1476 | case QEvent::ParentChange: never executed: case QEvent::ParentChange: | 0 | ||||||||||||||||||||||||
| 1477 | d->updateButtons(); | - | ||||||||||||||||||||||||
| 1478 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1479 | case QEvent::ZOrderChange: { never executed: case QEvent::ZOrderChange: | 0 | ||||||||||||||||||||||||
| 1480 | bool onTop = false; | - | ||||||||||||||||||||||||
| 1481 | if (win != 0) {
| 0 | ||||||||||||||||||||||||
| 1482 | const QObjectList &siblings = win->children(); | - | ||||||||||||||||||||||||
| 1483 | onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
| 0 | ||||||||||||||||||||||||
| 1484 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1485 | if (!isFloating() && layout != 0 && onTop)
| 0 | ||||||||||||||||||||||||
| 1486 | layout->raise(this); never executed: layout->raise(this); | 0 | ||||||||||||||||||||||||
| 1487 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1488 | } | - | ||||||||||||||||||||||||
| 1489 | case QEvent::WindowActivate: never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||||||||
| 1490 | case QEvent::WindowDeactivate: never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||||||||
| 1491 | update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea()); | - | ||||||||||||||||||||||||
| 1492 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1493 | case QEvent::ContextMenu: never executed: case QEvent::ContextMenu: | 0 | ||||||||||||||||||||||||
| 1494 | if (d->state) {
| 0 | ||||||||||||||||||||||||
| 1495 | event->accept(); | - | ||||||||||||||||||||||||
| 1496 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1497 | } | - | ||||||||||||||||||||||||
| 1498 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1499 | // return true after calling the handler since we don't want | - | ||||||||||||||||||||||||
| 1500 | // them to be passed onto the default handlers | - | ||||||||||||||||||||||||
| 1501 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||||||||
| 1502 | if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
| 0 | ||||||||||||||||||||||||
| 1503 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1504 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1505 | case QEvent::MouseButtonDblClick: never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||||||||||||||
| 1506 | if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
| 0 | ||||||||||||||||||||||||
| 1507 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1508 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1509 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||||||||
| 1510 | if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
| 0 | ||||||||||||||||||||||||
| 1511 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1512 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1513 | #ifdef Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||||||||
| 1514 | case QEvent::Leave: | - | ||||||||||||||||||||||||
| 1515 | if (d->state != 0 && d->state->dragging && !d->state->nca) { | - | ||||||||||||||||||||||||
| 1516 | // This is a workaround for loosing the mouse on Vista. | - | ||||||||||||||||||||||||
| 1517 | QPoint pos = QCursor::pos(); | - | ||||||||||||||||||||||||
| 1518 | QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, | - | ||||||||||||||||||||||||
| 1519 | QApplication::mouseButtons(), QApplication::keyboardModifiers()); | - | ||||||||||||||||||||||||
| 1520 | d->mouseMoveEvent(&fake); | - | ||||||||||||||||||||||||
| 1521 | } | - | ||||||||||||||||||||||||
| 1522 | break; | - | ||||||||||||||||||||||||
| 1523 | #endif | - | ||||||||||||||||||||||||
| 1524 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||||||||
| 1525 | if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
| 0 | ||||||||||||||||||||||||
| 1526 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1527 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1528 | case QEvent::NonClientAreaMouseMove: never executed: case QEvent::NonClientAreaMouseMove: | 0 | ||||||||||||||||||||||||
| 1529 | case QEvent::NonClientAreaMouseButtonPress: never executed: case QEvent::NonClientAreaMouseButtonPress: | 0 | ||||||||||||||||||||||||
| 1530 | case QEvent::NonClientAreaMouseButtonRelease: never executed: case QEvent::NonClientAreaMouseButtonRelease: | 0 | ||||||||||||||||||||||||
| 1531 | case QEvent::NonClientAreaMouseButtonDblClick: never executed: case QEvent::NonClientAreaMouseButtonDblClick: | 0 | ||||||||||||||||||||||||
| 1532 | d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event)); | - | ||||||||||||||||||||||||
| 1533 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
| 1534 | case QEvent::Move: never executed: case QEvent::Move: | 0 | ||||||||||||||||||||||||
| 1535 | d->moveEvent(static_cast<QMoveEvent*>(event)); | - | ||||||||||||||||||||||||
| 1536 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1537 | case QEvent::Resize: never executed: case QEvent::Resize: | 0 | ||||||||||||||||||||||||
| 1538 | // if the mainwindow is plugging us, we don't want to update undocked geometry | - | ||||||||||||||||||||||||
| 1539 | if (isFloating() && layout != 0 && layout->pluggingWidget != this)
| 0 | ||||||||||||||||||||||||
| 1540 | d->undockedGeometry = geometry(); never executed: d->undockedGeometry = geometry(); | 0 | ||||||||||||||||||||||||
| 1541 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1542 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 1543 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1544 | } | - | ||||||||||||||||||||||||
| 1545 | return QWidget::event(event); never executed: return QWidget::event(event); | 0 | ||||||||||||||||||||||||
| 1546 | } | - | ||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||
| 1548 | #ifndef QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1549 | /*! | - | ||||||||||||||||||||||||
| 1550 | Returns a checkable action that can be used to show or close this | - | ||||||||||||||||||||||||
| 1551 | dock widget. | - | ||||||||||||||||||||||||
| 1552 | - | |||||||||||||||||||||||||
| 1553 | The action's text is set to the dock widget's window title. | - | ||||||||||||||||||||||||
| 1554 | - | |||||||||||||||||||||||||
| 1555 | \sa QAction::text, QWidget::windowTitle | - | ||||||||||||||||||||||||
| 1556 | */ | - | ||||||||||||||||||||||||
| 1557 | QAction * QDockWidget::toggleViewAction() const | - | ||||||||||||||||||||||||
| 1558 | { | - | ||||||||||||||||||||||||
| 1559 | Q_D(const QDockWidget); | - | ||||||||||||||||||||||||
| 1560 | return d->toggleViewAction; never executed: return d->toggleViewAction; | 0 | ||||||||||||||||||||||||
| 1561 | } | - | ||||||||||||||||||||||||
| 1562 | #endif // QT_NO_ACTION | - | ||||||||||||||||||||||||
| 1563 | - | |||||||||||||||||||||||||
| 1564 | /*! | - | ||||||||||||||||||||||||
| 1565 | \fn void QDockWidget::featuresChanged(QDockWidget::DockWidgetFeatures features) | - | ||||||||||||||||||||||||
| 1566 | - | |||||||||||||||||||||||||
| 1567 | This signal is emitted when the \l features property changes. The | - | ||||||||||||||||||||||||
| 1568 | \a features parameter gives the new value of the property. | - | ||||||||||||||||||||||||
| 1569 | */ | - | ||||||||||||||||||||||||
| 1570 | - | |||||||||||||||||||||||||
| 1571 | /*! | - | ||||||||||||||||||||||||
| 1572 | \fn void QDockWidget::topLevelChanged(bool topLevel) | - | ||||||||||||||||||||||||
| 1573 | - | |||||||||||||||||||||||||
| 1574 | This signal is emitted when the \l floating property changes. | - | ||||||||||||||||||||||||
| 1575 | The \a topLevel parameter is true if the dock widget is now floating; | - | ||||||||||||||||||||||||
| 1576 | otherwise it is false. | - | ||||||||||||||||||||||||
| 1577 | - | |||||||||||||||||||||||||
| 1578 | \sa isWindow() | - | ||||||||||||||||||||||||
| 1579 | */ | - | ||||||||||||||||||||||||
| 1580 | - | |||||||||||||||||||||||||
| 1581 | /*! | - | ||||||||||||||||||||||||
| 1582 | \fn void QDockWidget::allowedAreasChanged(Qt::DockWidgetAreas allowedAreas) | - | ||||||||||||||||||||||||
| 1583 | - | |||||||||||||||||||||||||
| 1584 | This signal is emitted when the \l allowedAreas property changes. The | - | ||||||||||||||||||||||||
| 1585 | \a allowedAreas parameter gives the new value of the property. | - | ||||||||||||||||||||||||
| 1586 | */ | - | ||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||
| 1588 | /*! | - | ||||||||||||||||||||||||
| 1589 | \fn void QDockWidget::visibilityChanged(bool visible) | - | ||||||||||||||||||||||||
| 1590 | \since 4.3 | - | ||||||||||||||||||||||||
| 1591 | - | |||||||||||||||||||||||||
| 1592 | This signal is emitted when the dock widget becomes \a visible (or | - | ||||||||||||||||||||||||
| 1593 | invisible). This happens when the widget is hidden or shown, as | - | ||||||||||||||||||||||||
| 1594 | well as when it is docked in a tabbed dock area and its tab | - | ||||||||||||||||||||||||
| 1595 | becomes selected or unselected. | - | ||||||||||||||||||||||||
| 1596 | */ | - | ||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||
| 1598 | /*! | - | ||||||||||||||||||||||||
| 1599 | \fn void QDockWidget::dockLocationChanged(Qt::DockWidgetArea area) | - | ||||||||||||||||||||||||
| 1600 | \since 4.3 | - | ||||||||||||||||||||||||
| 1601 | - | |||||||||||||||||||||||||
| 1602 | This signal is emitted when the dock widget is moved to another | - | ||||||||||||||||||||||||
| 1603 | dock \a area, or is moved to a different location in its current | - | ||||||||||||||||||||||||
| 1604 | dock area. This happens when the dock widget is moved | - | ||||||||||||||||||||||||
| 1605 | programmatically or is dragged to a new location by the user. | - | ||||||||||||||||||||||||
| 1606 | */ | - | ||||||||||||||||||||||||
| 1607 | - | |||||||||||||||||||||||||
| 1608 | /*! | - | ||||||||||||||||||||||||
| 1609 | \since 4.3 | - | ||||||||||||||||||||||||
| 1610 | - | |||||||||||||||||||||||||
| 1611 | Sets an arbitrary \a widget as the dock widget's title bar. If \a widget | - | ||||||||||||||||||||||||
| 1612 | is 0, any custom title bar widget previously set on the dock widget is | - | ||||||||||||||||||||||||
| 1613 | removed, but not deleted, and the default title bar will be used | - | ||||||||||||||||||||||||
| 1614 | instead. | - | ||||||||||||||||||||||||
| 1615 | - | |||||||||||||||||||||||||
| 1616 | If a title bar widget is set, QDockWidget will not use native window | - | ||||||||||||||||||||||||
| 1617 | decorations when it is floated. | - | ||||||||||||||||||||||||
| 1618 | - | |||||||||||||||||||||||||
| 1619 | Here are some tips for implementing custom title bars: | - | ||||||||||||||||||||||||
| 1620 | - | |||||||||||||||||||||||||
| 1621 | \list | - | ||||||||||||||||||||||||
| 1622 | \li Mouse events that are not explicitly handled by the title bar widget | - | ||||||||||||||||||||||||
| 1623 | must be ignored by calling QMouseEvent::ignore(). These events then | - | ||||||||||||||||||||||||
| 1624 | propagate to the QDockWidget parent, which handles them in the usual | - | ||||||||||||||||||||||||
| 1625 | manner, moving when the title bar is dragged, docking and undocking | - | ||||||||||||||||||||||||
| 1626 | when it is double-clicked, etc. | - | ||||||||||||||||||||||||
| 1627 | - | |||||||||||||||||||||||||
| 1628 | \li When DockWidgetVerticalTitleBar is set on QDockWidget, the title | - | ||||||||||||||||||||||||
| 1629 | bar widget is repositioned accordingly. In resizeEvent(), the title | - | ||||||||||||||||||||||||
| 1630 | bar should check what orientation it should assume: | - | ||||||||||||||||||||||||
| 1631 | \snippet code/src_gui_widgets_qdockwidget.cpp 0 | - | ||||||||||||||||||||||||
| 1632 | - | |||||||||||||||||||||||||
| 1633 | \li The title bar widget must have a valid QWidget::sizeHint() and | - | ||||||||||||||||||||||||
| 1634 | QWidget::minimumSizeHint(). These functions should take into account | - | ||||||||||||||||||||||||
| 1635 | the current orientation of the title bar. | - | ||||||||||||||||||||||||
| 1636 | - | |||||||||||||||||||||||||
| 1637 | \li It is not possible to remove a title bar from a dock widget. However, | - | ||||||||||||||||||||||||
| 1638 | a similar effect can be achieved by setting a default constructed | - | ||||||||||||||||||||||||
| 1639 | QWidget as the title bar widget. | - | ||||||||||||||||||||||||
| 1640 | \endlist | - | ||||||||||||||||||||||||
| 1641 | - | |||||||||||||||||||||||||
| 1642 | Using qobject_cast() as shown above, the title bar widget has full access | - | ||||||||||||||||||||||||
| 1643 | to its parent QDockWidget. Hence it can perform such operations as docking | - | ||||||||||||||||||||||||
| 1644 | and hiding in response to user actions. | - | ||||||||||||||||||||||||
| 1645 | - | |||||||||||||||||||||||||
| 1646 | \sa titleBarWidget(), DockWidgetVerticalTitleBar | - | ||||||||||||||||||||||||
| 1647 | */ | - | ||||||||||||||||||||||||
| 1648 | - | |||||||||||||||||||||||||
| 1649 | void QDockWidget::setTitleBarWidget(QWidget *widget) | - | ||||||||||||||||||||||||
| 1650 | { | - | ||||||||||||||||||||||||
| 1651 | Q_D(QDockWidget); | - | ||||||||||||||||||||||||
| 1652 | QDockWidgetLayout *layout | - | ||||||||||||||||||||||||
| 1653 | = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1654 | layout->setWidgetForRole(QDockWidgetLayout::TitleBar, widget); | - | ||||||||||||||||||||||||
| 1655 | d->updateButtons(); | - | ||||||||||||||||||||||||
| 1656 | if (isWindow()) {
| 0 | ||||||||||||||||||||||||
| 1657 | //this ensures the native decoration is drawn | - | ||||||||||||||||||||||||
| 1658 | d->setWindowState(true /*floating*/, true /*unplug*/); | - | ||||||||||||||||||||||||
| 1659 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1660 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1661 | - | |||||||||||||||||||||||||
| 1662 | /*! | - | ||||||||||||||||||||||||
| 1663 | \since 4.3 | - | ||||||||||||||||||||||||
| 1664 | Returns the custom title bar widget set on the QDockWidget, or 0 if no | - | ||||||||||||||||||||||||
| 1665 | custom title bar has been set. | - | ||||||||||||||||||||||||
| 1666 | - | |||||||||||||||||||||||||
| 1667 | \sa setTitleBarWidget() | - | ||||||||||||||||||||||||
| 1668 | */ | - | ||||||||||||||||||||||||
| 1669 | - | |||||||||||||||||||||||||
| 1670 | QWidget *QDockWidget::titleBarWidget() const | - | ||||||||||||||||||||||||
| 1671 | { | - | ||||||||||||||||||||||||
| 1672 | QDockWidgetLayout *layout | - | ||||||||||||||||||||||||
| 1673 | = qobject_cast<QDockWidgetLayout*>(this->layout()); | - | ||||||||||||||||||||||||
| 1674 | return layout->widgetForRole(QDockWidgetLayout::TitleBar); never executed: return layout->widgetForRole(QDockWidgetLayout::TitleBar); | 0 | ||||||||||||||||||||||||
| 1675 | } | - | ||||||||||||||||||||||||
| 1676 | - | |||||||||||||||||||||||||
| 1677 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| 1678 | - | |||||||||||||||||||||||||
| 1679 | #include "qdockwidget.moc" | - | ||||||||||||||||||||||||
| 1680 | #include "moc_qdockwidget.cpp" | - | ||||||||||||||||||||||||
| 1681 | #include "moc_qdockwidget_p.cpp" | - | ||||||||||||||||||||||||
| 1682 | - | |||||||||||||||||||||||||
| 1683 | #endif // QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |