| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qmainwindow.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | class QMainWindowPrivate : public QWidgetPrivate | - | ||||||||||||
| 9 | { | - | ||||||||||||
| 10 | inline QMainWindow* q_func() { return static_cast<QMainWindow *>(q_ptr); } inline const QMainWindow* q_func() const { return static_cast<const QMainWindow *>(q_ptr); } friend class QMainWindow; | - | ||||||||||||
| 11 | public: | - | ||||||||||||
| 12 | inline QMainWindowPrivate() | - | ||||||||||||
| 13 | : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) | - | ||||||||||||
| 14 | , hasOldCursor(false) , cursorAdjusted(false) | - | ||||||||||||
| 15 | - | |||||||||||||
| 16 | { } | - | ||||||||||||
| 17 | QMainWindowLayout *layout; | - | ||||||||||||
| 18 | QSize iconSize; | - | ||||||||||||
| 19 | bool explicitIconSize; | - | ||||||||||||
| 20 | Qt::ToolButtonStyle toolButtonStyle; | - | ||||||||||||
| 21 | - | |||||||||||||
| 22 | - | |||||||||||||
| 23 | - | |||||||||||||
| 24 | - | |||||||||||||
| 25 | - | |||||||||||||
| 26 | - | |||||||||||||
| 27 | - | |||||||||||||
| 28 | void init(); | - | ||||||||||||
| 29 | QList<int> hoverSeparator; | - | ||||||||||||
| 30 | QPoint hoverPos; | - | ||||||||||||
| 31 | - | |||||||||||||
| 32 | - | |||||||||||||
| 33 | QCursor separatorCursor(const QList<int> &path) const; | - | ||||||||||||
| 34 | void adjustCursor(const QPoint &pos); | - | ||||||||||||
| 35 | QCursor oldCursor; | - | ||||||||||||
| 36 | QCursor adjustedCursor; | - | ||||||||||||
| 37 | uint hasOldCursor : 1; | - | ||||||||||||
| 38 | uint cursorAdjusted : 1; | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | - | |||||||||||||
| 41 | static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) | - | ||||||||||||
| 42 | { | - | ||||||||||||
| 43 | return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); | - | ||||||||||||
| 44 | } | - | ||||||||||||
| 45 | }; | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) | - | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | return QMainWindowPrivate::mainWindowLayout(mainWindow); | - | ||||||||||||
| 50 | } | - | ||||||||||||
| 51 | void QMainWindowPrivate::init() | - | ||||||||||||
| 52 | { | - | ||||||||||||
| 53 | QMainWindow * const q = q_func(); | - | ||||||||||||
| 54 | layout = new QMainWindowLayout(q, 0); | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | - | |||||||||||||
| 57 | const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); | - | ||||||||||||
| 58 | iconSize = QSize(metric, metric); | - | ||||||||||||
| 59 | q->setAttribute(Qt::WA_Hover); | - | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | QMainWindow::QMainWindow(QWidget *parent, Qt::WindowFlags flags) | - | ||||||||||||
| 62 | : QWidget(*(new QMainWindowPrivate()), parent, flags | Qt::Window) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | d_func()->init(); | - | ||||||||||||
| 65 | } | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | - | |||||||||||||
| 68 | - | |||||||||||||
| 69 | - | |||||||||||||
| 70 | - | |||||||||||||
| 71 | QMainWindow::~QMainWindow() | - | ||||||||||||
| 72 | { } | - | ||||||||||||
| 73 | void QMainWindow::setDockOptions(DockOptions opt) | - | ||||||||||||
| 74 | { | - | ||||||||||||
| 75 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 76 | d->layout->setDockOptions(opt); | - | ||||||||||||
| 77 | } | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | QMainWindow::DockOptions QMainWindow::dockOptions() const | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | const QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 82 | return d->layout->dockOptions; | - | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | QSize QMainWindow::iconSize() const | - | ||||||||||||
| 86 | { return d_func()->iconSize; } | - | ||||||||||||
| 87 | - | |||||||||||||
| 88 | void QMainWindow::setIconSize(const QSize &iconSize) | - | ||||||||||||
| 89 | { | - | ||||||||||||
| 90 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 91 | QSize sz = iconSize; | - | ||||||||||||
| 92 | if (!sz.isValid()) { | - | ||||||||||||
| 93 | const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); | - | ||||||||||||
| 94 | sz = QSize(metric, metric); | - | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | if (d->iconSize != sz) { | - | ||||||||||||
| 97 | d->iconSize = sz; | - | ||||||||||||
| 98 | iconSizeChanged(d->iconSize); | - | ||||||||||||
| 99 | } | - | ||||||||||||
| 100 | d->explicitIconSize = iconSize.isValid(); | - | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | Qt::ToolButtonStyle QMainWindow::toolButtonStyle() const | - | ||||||||||||
| 103 | { return d_func()->toolButtonStyle; } | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) | - | ||||||||||||
| 106 | { | - | ||||||||||||
| 107 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 108 | if (d->toolButtonStyle == toolButtonStyle) | - | ||||||||||||
| 109 | return; | - | ||||||||||||
| 110 | d->toolButtonStyle = toolButtonStyle; | - | ||||||||||||
| 111 | toolButtonStyleChanged(d->toolButtonStyle); | - | ||||||||||||
| 112 | } | - | ||||||||||||
| 113 | QMenuBar *QMainWindow::menuBar() const | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); | - | ||||||||||||
| 116 | if (!menuBar) { | - | ||||||||||||
| 117 | QMainWindow *self = const_cast<QMainWindow *>(this); | - | ||||||||||||
| 118 | menuBar = new QMenuBar(self); | - | ||||||||||||
| 119 | self->setMenuBar(menuBar); | - | ||||||||||||
| 120 | } | - | ||||||||||||
| 121 | return menuBar; | - | ||||||||||||
| 122 | } | - | ||||||||||||
| 123 | void QMainWindow::setMenuBar(QMenuBar *menuBar) | - | ||||||||||||
| 124 | { | - | ||||||||||||
| 125 | QLayout *topLayout = layout(); | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 | QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); | - | ||||||||||||
| 130 | if (menuBar) { | - | ||||||||||||
| 131 | - | |||||||||||||
| 132 | QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner); | - | ||||||||||||
| 133 | if (cornerWidget) | - | ||||||||||||
| 134 | menuBar->setCornerWidget(cornerWidget, Qt::TopLeftCorner); | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | cornerWidget = oldMenuBar->cornerWidget(Qt::TopRightCorner); | - | ||||||||||||
| 137 | if (cornerWidget) | - | ||||||||||||
| 138 | menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner); | - | ||||||||||||
| 139 | } | - | ||||||||||||
| 140 | oldMenuBar->hide(); | - | ||||||||||||
| 141 | oldMenuBar->deleteLater(); | - | ||||||||||||
| 142 | } | - | ||||||||||||
| 143 | topLayout->setMenuBar(menuBar); | - | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | - | |||||||||||||
| 147 | - | |||||||||||||
| 148 | - | |||||||||||||
| 149 | - | |||||||||||||
| 150 | - | |||||||||||||
| 151 | - | |||||||||||||
| 152 | QWidget *QMainWindow::menuWidget() const | - | ||||||||||||
| 153 | { | - | ||||||||||||
| 154 | QWidget *menuBar = d_func()->layout->menuBar(); | - | ||||||||||||
| 155 | return menuBar; | - | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | void QMainWindow::setMenuWidget(QWidget *menuBar) | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 160 | if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { | - | ||||||||||||
| 161 | d->layout->menuBar()->hide(); | - | ||||||||||||
| 162 | d->layout->menuBar()->deleteLater(); | - | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | d->layout->setMenuBar(menuBar); | - | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | QStatusBar *QMainWindow::statusBar() const | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | QStatusBar *statusbar = d_func()->layout->statusBar(); | - | ||||||||||||
| 169 | if (!statusbar) { | - | ||||||||||||
| 170 | QMainWindow *self = const_cast<QMainWindow *>(this); | - | ||||||||||||
| 171 | statusbar = new QStatusBar(self); | - | ||||||||||||
| 172 | statusbar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | - | ||||||||||||
| 173 | self->setStatusBar(statusbar); | - | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | return statusbar; | - | ||||||||||||
| 176 | } | - | ||||||||||||
| 177 | void QMainWindow::setStatusBar(QStatusBar *statusbar) | - | ||||||||||||
| 178 | { | - | ||||||||||||
| 179 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 180 | if (d->layout->statusBar() && d->layout->statusBar() != statusbar) { | - | ||||||||||||
| 181 | d->layout->statusBar()->hide(); | - | ||||||||||||
| 182 | d->layout->statusBar()->deleteLater(); | - | ||||||||||||
| 183 | } | - | ||||||||||||
| 184 | d->layout->setStatusBar(statusbar); | - | ||||||||||||
| 185 | } | - | ||||||||||||
| 186 | QWidget *QMainWindow::centralWidget() const | - | ||||||||||||
| 187 | { return d_func()->layout->centralWidget(); } | - | ||||||||||||
| 188 | void QMainWindow::setCentralWidget(QWidget *widget) | - | ||||||||||||
| 189 | { | - | ||||||||||||
| 190 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 191 | if (d->layout->centralWidget() && d->layout->centralWidget() != widget) { | - | ||||||||||||
| 192 | d->layout->centralWidget()->hide(); | - | ||||||||||||
| 193 | d->layout->centralWidget()->deleteLater(); | - | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | d->layout->setCentralWidget(widget); | - | ||||||||||||
| 196 | } | - | ||||||||||||
| 197 | QWidget *QMainWindow::takeCentralWidget() | - | ||||||||||||
| 198 | { | - | ||||||||||||
| 199 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 200 | QWidget *oldcentralwidget = d->layout->centralWidget(); | - | ||||||||||||
| 201 | if (oldcentralwidget) { | - | ||||||||||||
| 202 | oldcentralwidget->setParent(0); | - | ||||||||||||
| 203 | d->layout->setCentralWidget(0); | - | ||||||||||||
| 204 | } | - | ||||||||||||
| 205 | return oldcentralwidget; | - | ||||||||||||
| 206 | } | - | ||||||||||||
| 207 | void QMainWindow::setCorner(Qt::Corner corner, Qt::DockWidgetArea area) | - | ||||||||||||
| 208 | { | - | ||||||||||||
| 209 | bool valid = false; | - | ||||||||||||
| 210 | switch (corner) { | - | ||||||||||||
| 211 | case never executed: Qt::TopLeftCorner:case Qt::TopLeftCorner:never executed: case Qt::TopLeftCorner: | 0 | ||||||||||||
| 212 | valid = (area == Qt::TopDockWidgetArea
| 0 | ||||||||||||
| 213 | break; never executed: break; | 0 | ||||||||||||
| 214 | case never executed: Qt::TopRightCorner:case Qt::TopRightCorner:never executed: case Qt::TopRightCorner: | 0 | ||||||||||||
| 215 | valid = (area == Qt::TopDockWidgetArea
| 0 | ||||||||||||
| 216 | break; never executed: break; | 0 | ||||||||||||
| 217 | case never executed: Qt::BottomLeftCorner:case Qt::BottomLeftCorner:never executed: case Qt::BottomLeftCorner: | 0 | ||||||||||||
| 218 | valid = (area == Qt::BottomDockWidgetArea
| 0 | ||||||||||||
| 219 | break; never executed: break; | 0 | ||||||||||||
| 220 | case never executed: Qt::BottomRightCorner:case Qt::BottomRightCorner:never executed: case Qt::BottomRightCorner: | 0 | ||||||||||||
| 221 | valid = (area == Qt::BottomDockWidgetArea
| 0 | ||||||||||||
| 222 | break; never executed: break; | 0 | ||||||||||||
| 223 | } | - | ||||||||||||
| 224 | if (!(__builtin_expect(!!(!
| 0 | ||||||||||||
| 225 | QMessageLogger(__FILE__, 699705, __PRETTY_FUNCTION__).warning("QMainWindow::setCorner(): 'area' is not valid for 'corner'"); never executed: QMessageLogger(__FILE__, 705, __PRETTY_FUNCTION__).warning("QMainWindow::setCorner(): 'area' is not valid for 'corner'"); | 0 | ||||||||||||
| 226 | else | - | ||||||||||||
| 227 | d_func()->layout->setCorner(corner, area); never executed: d_func()->layout->setCorner(corner, area); | 0 | ||||||||||||
| 228 | } | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | - | |||||||||||||
| 231 | - | |||||||||||||
| 232 | - | |||||||||||||
| 233 | - | |||||||||||||
| 234 | - | |||||||||||||
| 235 | - | |||||||||||||
| 236 | Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const | - | ||||||||||||
| 237 | { return d_func()->layout->corner(corner); } | - | ||||||||||||
| 238 | - | |||||||||||||
| 239 | - | |||||||||||||
| 240 | - | |||||||||||||
| 241 | - | |||||||||||||
| 242 | static bool checkToolBarArea(Qt::ToolBarArea area, const char *where) | - | ||||||||||||
| 243 | { | - | ||||||||||||
| 244 | switch (area) { | - | ||||||||||||
| 245 | case Qt::LeftToolBarArea: | - | ||||||||||||
| 246 | case Qt::RightToolBarArea: | - | ||||||||||||
| 247 | case Qt::TopToolBarArea: | - | ||||||||||||
| 248 | case Qt::BottomToolBarArea: | - | ||||||||||||
| 249 | return true; | - | ||||||||||||
| 250 | default: | - | ||||||||||||
| 251 | break; | - | ||||||||||||
| 252 | } | - | ||||||||||||
| 253 | QMessageLogger(__FILE__, 727733, __PRETTY_FUNCTION__).warning("%s: invalid 'area' argument", where); | - | ||||||||||||
| 254 | return false; | - | ||||||||||||
| 255 | } | - | ||||||||||||
| 256 | - | |||||||||||||
| 257 | - | |||||||||||||
| 258 | - | |||||||||||||
| 259 | - | |||||||||||||
| 260 | - | |||||||||||||
| 261 | void QMainWindow::addToolBarBreak(Qt::ToolBarArea area) | - | ||||||||||||
| 262 | { | - | ||||||||||||
| 263 | if (!checkToolBarArea(area, "QMainWindow::addToolBarBreak")) | - | ||||||||||||
| 264 | return; | - | ||||||||||||
| 265 | d_func()->layout->addToolBarBreak(area); | - | ||||||||||||
| 266 | } | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | - | |||||||||||||
| 269 | - | |||||||||||||
| 270 | - | |||||||||||||
| 271 | void QMainWindow::insertToolBarBreak(QToolBar *before) | - | ||||||||||||
| 272 | { d_func()->layout->insertToolBarBreak(before); } | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | - | |||||||||||||
| 275 | - | |||||||||||||
| 276 | - | |||||||||||||
| 277 | - | |||||||||||||
| 278 | void QMainWindow::removeToolBarBreak(QToolBar *before) | - | ||||||||||||
| 279 | { | - | ||||||||||||
| 280 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 281 | d->layout->removeToolBarBreak(before); | - | ||||||||||||
| 282 | } | - | ||||||||||||
| 283 | void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar) | - | ||||||||||||
| 284 | { | - | ||||||||||||
| 285 | if (!checkToolBarArea(area, "QMainWindow::addToolBar")) | - | ||||||||||||
| 286 | return; | - | ||||||||||||
| 287 | - | |||||||||||||
| 288 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 289 | - | |||||||||||||
| 290 | disconnect(this, qFlagLocation("2""iconSizeChanged(QSize)" "\0" __FILE__ ":" "773""779"), | - | ||||||||||||
| 291 | toolbar, qFlagLocation("1""_q_updateIconSize(QSize)" "\0" __FILE__ ":" "774""780")); | - | ||||||||||||
| 292 | disconnect(this, qFlagLocation("2""toolButtonStyleChanged(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "775""781"), | - | ||||||||||||
| 293 | toolbar, qFlagLocation("1""_q_updateToolButtonStyle(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "776""782")); | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | if(toolbar->d_func()->state && toolbar->d_func()->state->dragging) { | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | - | |||||||||||||
| 298 | bool animated = isAnimated(); | - | ||||||||||||
| 299 | setAnimated(false); | - | ||||||||||||
| 300 | - | |||||||||||||
| 301 | toolbar->d_func()->endDrag(); | - | ||||||||||||
| 302 | - | |||||||||||||
| 303 | setAnimated(animated); | - | ||||||||||||
| 304 | - | |||||||||||||
| 305 | } | - | ||||||||||||
| 306 | - | |||||||||||||
| 307 | if (!d->layout->usesHIToolBar(toolbar)) { | - | ||||||||||||
| 308 | d->layout->removeWidget(toolbar); | - | ||||||||||||
| 309 | } else { | - | ||||||||||||
| 310 | d->layout->removeToolBar(toolbar); | - | ||||||||||||
| 311 | } | - | ||||||||||||
| 312 | - | |||||||||||||
| 313 | toolbar->d_func()->_q_updateIconSize(d->iconSize); | - | ||||||||||||
| 314 | toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); | - | ||||||||||||
| 315 | connect(this, qFlagLocation("2""iconSizeChanged(QSize)" "\0" __FILE__ ":" "798""804"), | - | ||||||||||||
| 316 | toolbar, qFlagLocation("1""_q_updateIconSize(QSize)" "\0" __FILE__ ":" "799""805")); | - | ||||||||||||
| 317 | connect(this, qFlagLocation("2""toolButtonStyleChanged(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "800""806"), | - | ||||||||||||
| 318 | toolbar, qFlagLocation("1""_q_updateToolButtonStyle(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "801""807")); | - | ||||||||||||
| 319 | - | |||||||||||||
| 320 | d->layout->addToolBar(area, toolbar); | - | ||||||||||||
| 321 | } | - | ||||||||||||
| 322 | - | |||||||||||||
| 323 | - | |||||||||||||
| 324 | - | |||||||||||||
| 325 | - | |||||||||||||
| 326 | void QMainWindow::addToolBar(QToolBar *toolbar) | - | ||||||||||||
| 327 | { addToolBar(Qt::TopToolBarArea, toolbar); } | - | ||||||||||||
| 328 | QToolBar *QMainWindow::addToolBar(const QString &title) | - | ||||||||||||
| 329 | { | - | ||||||||||||
| 330 | QToolBar *toolBar = new QToolBar(this); | - | ||||||||||||
| 331 | toolBar->setWindowTitle(title); | - | ||||||||||||
| 332 | addToolBar(toolBar); | - | ||||||||||||
| 333 | return toolBar; | - | ||||||||||||
| 334 | } | - | ||||||||||||
| 335 | void QMainWindow::insertToolBar(QToolBar *before, QToolBar *toolbar) | - | ||||||||||||
| 336 | { | - | ||||||||||||
| 337 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | d->layout->removeToolBar(toolbar); | - | ||||||||||||
| 340 | - | |||||||||||||
| 341 | toolbar->d_func()->_q_updateIconSize(d->iconSize); | - | ||||||||||||
| 342 | toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); | - | ||||||||||||
| 343 | connect(this, qFlagLocation("2""iconSizeChanged(QSize)" "\0" __FILE__ ":" "844""850"), | - | ||||||||||||
| 344 | toolbar, qFlagLocation("1""_q_updateIconSize(QSize)" "\0" __FILE__ ":" "845""851")); | - | ||||||||||||
| 345 | connect(this, qFlagLocation("2""toolButtonStyleChanged(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "846""852"), | - | ||||||||||||
| 346 | toolbar, qFlagLocation("1""_q_updateToolButtonStyle(Qt::ToolButtonStyle)" "\0" __FILE__ ":" "847""853")); | - | ||||||||||||
| 347 | - | |||||||||||||
| 348 | d->layout->insertToolBar(before, toolbar); | - | ||||||||||||
| 349 | } | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | - | |||||||||||||
| 352 | - | |||||||||||||
| 353 | - | |||||||||||||
| 354 | - | |||||||||||||
| 355 | void QMainWindow::removeToolBar(QToolBar *toolbar) | - | ||||||||||||
| 356 | { | - | ||||||||||||
| 357 | if (toolbar) { | - | ||||||||||||
| 358 | d_func()->layout->removeToolBar(toolbar); | - | ||||||||||||
| 359 | toolbar->hide(); | - | ||||||||||||
| 360 | } | - | ||||||||||||
| 361 | } | - | ||||||||||||
| 362 | Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const | - | ||||||||||||
| 363 | { return d_func()->layout->toolBarArea(toolbar); } | - | ||||||||||||
| 364 | bool QMainWindow::toolBarBreak(QToolBar *toolbar) const | - | ||||||||||||
| 365 | { | - | ||||||||||||
| 366 | return d_func()->layout->toolBarBreak(toolbar); | - | ||||||||||||
| 367 | } | - | ||||||||||||
| 368 | bool QMainWindow::isAnimated() const | - | ||||||||||||
| 369 | { | - | ||||||||||||
| 370 | const QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 371 | return d->layout->dockOptions & AnimatedDocks; | - | ||||||||||||
| 372 | } | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | void QMainWindow::setAnimated(bool enabled) | - | ||||||||||||
| 375 | { | - | ||||||||||||
| 376 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 377 | - | |||||||||||||
| 378 | DockOptions opts = d->layout->dockOptions; | - | ||||||||||||
| if (enabled) | ||||||||||||||
| opts |= AnimatedDocks; | ||||||||||||||
| 379 | elseopts&= ~.setFlag(AnimatedDocks;, enabled); | - | ||||||||||||
| 380 | - | |||||||||||||
| 381 | d->layout->setDockOptions(opts); | - | ||||||||||||
| 382 | } never executed: end of block | 0 | ||||||||||||
| 383 | bool QMainWindow::isDockNestingEnabled() const | - | ||||||||||||
| 384 | { | - | ||||||||||||
| 385 | const QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 386 | return d->layout->dockOptions & AllowNestedDocks; | - | ||||||||||||
| 387 | } | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | void QMainWindow::setDockNestingEnabled(bool enabled) | - | ||||||||||||
| 390 | { | - | ||||||||||||
| 391 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 392 | - | |||||||||||||
| 393 | DockOptions opts = d->layout->dockOptions; | - | ||||||||||||
| if (enabled) | ||||||||||||||
| opts |= AllowNestedDocks; | ||||||||||||||
| 394 | elseopts&= ~.setFlag(AllowNestedDocks;, enabled); | - | ||||||||||||
| 395 | - | |||||||||||||
| 396 | d->layout->setDockOptions(opts); | - | ||||||||||||
| 397 | } never executed: end of block | 0 | ||||||||||||
| 398 | static bool checkDockWidgetArea(Qt::DockWidgetArea area, const char *where) | - | ||||||||||||
| 399 | { | - | ||||||||||||
| 400 | switch (area) { | - | ||||||||||||
| 401 | case Qt::LeftDockWidgetArea: | - | ||||||||||||
| 402 | case Qt::RightDockWidgetArea: | - | ||||||||||||
| 403 | case Qt::TopDockWidgetArea: | - | ||||||||||||
| 404 | case Qt::BottomDockWidgetArea: | - | ||||||||||||
| 405 | return true; | - | ||||||||||||
| 406 | default: | - | ||||||||||||
| 407 | break; | - | ||||||||||||
| 408 | } | - | ||||||||||||
| 409 | QMessageLogger(__FILE__, 1004, __PRETTY_FUNCTION__).warning("%s: invalid 'area' argument", where); | - | ||||||||||||
| 410 | return false; | - | ||||||||||||
| 411 | } | - | ||||||||||||
| 412 | bool QMainWindow::documentMode() const | - | ||||||||||||
| 413 | { | - | ||||||||||||
| 414 | return d_func()->layout->documentMode(); | - | ||||||||||||
| 415 | } | - | ||||||||||||
| 416 | - | |||||||||||||
| 417 | void QMainWindow::setDocumentMode(bool enabled) | - | ||||||||||||
| 418 | { | - | ||||||||||||
| 419 | d_func()->layout->setDocumentMode(enabled); | - | ||||||||||||
| 420 | } | - | ||||||||||||
| 421 | QTabWidget::TabShape QMainWindow::tabShape() const | - | ||||||||||||
| 422 | { | - | ||||||||||||
| 423 | return d_func()->layout->tabShape(); | - | ||||||||||||
| 424 | } | - | ||||||||||||
| 425 | - | |||||||||||||
| 426 | void QMainWindow::setTabShape(QTabWidget::TabShape tabShape) | - | ||||||||||||
| 427 | { | - | ||||||||||||
| 428 | d_func()->layout->setTabShape(tabShape); | - | ||||||||||||
| 429 | } | - | ||||||||||||
| 430 | QTabWidget::TabPosition QMainWindow::tabPosition(Qt::DockWidgetArea area) const | - | ||||||||||||
| 431 | { | - | ||||||||||||
| 432 | if (!checkDockWidgetArea(area, "QMainWindow::tabPosition")) | - | ||||||||||||
| 433 | return QTabWidget::South; | - | ||||||||||||
| 434 | return d_func()->layout->tabPosition(area); | - | ||||||||||||
| 435 | } | - | ||||||||||||
| 436 | void QMainWindow::setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition) | - | ||||||||||||
| 437 | { | - | ||||||||||||
| 438 | d_func()->layout->setTabPosition(areas, tabPosition); | - | ||||||||||||
| 439 | } | - | ||||||||||||
| 440 | - | |||||||||||||
| 441 | - | |||||||||||||
| 442 | - | |||||||||||||
| 443 | - | |||||||||||||
| 444 | - | |||||||||||||
| 445 | void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget) | - | ||||||||||||
| 446 | { | - | ||||||||||||
| 447 | if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) | - | ||||||||||||
| 448 | return; | - | ||||||||||||
| 449 | - | |||||||||||||
| 450 | Qt::Orientation orientation = Qt::Vertical; | - | ||||||||||||
| 451 | switch (area) { | - | ||||||||||||
| 452 | case Qt::TopDockWidgetArea: | - | ||||||||||||
| 453 | case Qt::BottomDockWidgetArea: | - | ||||||||||||
| 454 | orientation = Qt::Horizontal; | - | ||||||||||||
| 455 | break; | - | ||||||||||||
| 456 | default: | - | ||||||||||||
| 457 | break; | - | ||||||||||||
| 458 | } | - | ||||||||||||
| 459 | d_func()->layout->removeWidget(dockwidget); | - | ||||||||||||
| 460 | addDockWidget(area, dockwidget, orientation); | - | ||||||||||||
| 461 | } | - | ||||||||||||
| 462 | bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget) | - | ||||||||||||
| 463 | { | - | ||||||||||||
| 464 | return d_func()->layout->restoreDockWidget(dockwidget); | - | ||||||||||||
| 465 | } | - | ||||||||||||
| 466 | - | |||||||||||||
| 467 | - | |||||||||||||
| 468 | - | |||||||||||||
| 469 | - | |||||||||||||
| 470 | - | |||||||||||||
| 471 | void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget, | - | ||||||||||||
| 472 | Qt::Orientation orientation) | - | ||||||||||||
| 473 | { | - | ||||||||||||
| 474 | if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) | - | ||||||||||||
| 475 | return; | - | ||||||||||||
| 476 | - | |||||||||||||
| 477 | - | |||||||||||||
| 478 | d_func()->layout->addDockWidget(area, dockwidget, orientation); | - | ||||||||||||
| 479 | } | - | ||||||||||||
| 480 | void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, | - | ||||||||||||
| 481 | Qt::Orientation orientation) | - | ||||||||||||
| 482 | { | - | ||||||||||||
| 483 | d_func()->layout->splitDockWidget(after, dockwidget, orientation); | - | ||||||||||||
| 484 | } | - | ||||||||||||
| 485 | void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) | - | ||||||||||||
| 486 | { | - | ||||||||||||
| 487 | d_func()->layout->tabifyDockWidget(first, second); | - | ||||||||||||
| 488 | } | - | ||||||||||||
| 489 | QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const | - | ||||||||||||
| 490 | { | - | ||||||||||||
| 491 | QList<QDockWidget*> ret; | - | ||||||||||||
| 492 | - | |||||||||||||
| 493 | - | |||||||||||||
| 494 | - | |||||||||||||
| 495 | const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); | - | ||||||||||||
| 496 | if (info && info->tabbed && info->tabBar) { | - | ||||||||||||
| 497 | for(int i = 0; i < info->item_list.count(); ++i) { | - | ||||||||||||
| 498 | const QDockAreaLayoutItem &item = info->item_list.at(i); | - | ||||||||||||
| 499 | if (item.widgetItem) { | - | ||||||||||||
| 500 | if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) { | - | ||||||||||||
| 501 | if (dock != dockwidget) { | - | ||||||||||||
| 502 | ret += dock; | - | ||||||||||||
| 503 | } | - | ||||||||||||
| 504 | } | - | ||||||||||||
| 505 | } | - | ||||||||||||
| 506 | } | - | ||||||||||||
| 507 | } | - | ||||||||||||
| 508 | - | |||||||||||||
| 509 | return ret; | - | ||||||||||||
| 510 | } | - | ||||||||||||
| 511 | - | |||||||||||||
| 512 | - | |||||||||||||
| 513 | - | |||||||||||||
| 514 | - | |||||||||||||
| 515 | - | |||||||||||||
| 516 | - | |||||||||||||
| 517 | void QMainWindow::removeDockWidget(QDockWidget *dockwidget) | - | ||||||||||||
| 518 | { | - | ||||||||||||
| 519 | if (dockwidget) { | - | ||||||||||||
| 520 | d_func()->layout->removeWidget(dockwidget); | - | ||||||||||||
| 521 | dockwidget->hide(); | - | ||||||||||||
| 522 | } | - | ||||||||||||
| 523 | } | - | ||||||||||||
| 524 | Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const | - | ||||||||||||
| 525 | { return d_func()->layout->dockWidgetArea(dockwidget); } | - | ||||||||||||
| 526 | void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks, | - | ||||||||||||
| 527 | const QList<int> &sizes, Qt::Orientation orientation) | - | ||||||||||||
| 528 | { | - | ||||||||||||
| 529 | d_func()->layout->layoutState.dockAreaLayout.resizeDocks(docks, sizes, orientation); | - | ||||||||||||
| 530 | d_func()->layout->invalidate(); | - | ||||||||||||
| 531 | } | - | ||||||||||||
| 532 | QByteArray QMainWindow::saveState(int version) const | - | ||||||||||||
| 533 | { | - | ||||||||||||
| 534 | QByteArray data; | - | ||||||||||||
| 535 | QDataStream stream(&data, QIODevice::WriteOnly); | - | ||||||||||||
| 536 | stream << QMainWindowLayout::VersionMarker; | - | ||||||||||||
| 537 | stream << version; | - | ||||||||||||
| 538 | d_func()->layout->saveState(stream); | - | ||||||||||||
| 539 | return data; | - | ||||||||||||
| 540 | } | - | ||||||||||||
| 541 | bool QMainWindow::restoreState(const QByteArray &state, int version) | - | ||||||||||||
| 542 | { | - | ||||||||||||
| 543 | if (state.isEmpty()) | - | ||||||||||||
| 544 | return false; | - | ||||||||||||
| 545 | QByteArray sd = state; | - | ||||||||||||
| 546 | QDataStream stream(&sd, QIODevice::ReadOnly); | - | ||||||||||||
| 547 | int marker, v; | - | ||||||||||||
| 548 | stream >> marker; | - | ||||||||||||
| 549 | stream >> v; | - | ||||||||||||
| 550 | if (stream.status() != QDataStream::Ok || marker != QMainWindowLayout::VersionMarker || v != version) | - | ||||||||||||
| 551 | return false; | - | ||||||||||||
| 552 | bool restored = d_func()->layout->restoreState(stream); | - | ||||||||||||
| 553 | return restored; | - | ||||||||||||
| 554 | } | - | ||||||||||||
| 555 | - | |||||||||||||
| 556 | - | |||||||||||||
| 557 | QCursor QMainWindowPrivate::separatorCursor(const QList<int> &path) const | - | ||||||||||||
| 558 | { | - | ||||||||||||
| 559 | QDockAreaLayoutInfo *info = layout->layoutState.dockAreaLayout.info(path); | - | ||||||||||||
| 560 | ((!(info != 0)) ? qt_assert("info != 0",__FILE__,1339) : qt_noop()); | - | ||||||||||||
| 561 | if (path.size() == 1) { | - | ||||||||||||
| 562 | - | |||||||||||||
| 563 | switch (path.first()) { | - | ||||||||||||
| 564 | case QInternal::LeftDock: | - | ||||||||||||
| 565 | case QInternal::RightDock: | - | ||||||||||||
| 566 | return Qt::SplitHCursor; | - | ||||||||||||
| 567 | case QInternal::TopDock: | - | ||||||||||||
| 568 | case QInternal::BottomDock: | - | ||||||||||||
| 569 | return Qt::SplitVCursor; | - | ||||||||||||
| 570 | default: | - | ||||||||||||
| 571 | break; | - | ||||||||||||
| 572 | } | - | ||||||||||||
| 573 | } | - | ||||||||||||
| 574 | - | |||||||||||||
| 575 | - | |||||||||||||
| 576 | - | |||||||||||||
| 577 | return info->o == Qt::Horizontal | - | ||||||||||||
| 578 | ? Qt::SplitHCursor : Qt::SplitVCursor; | - | ||||||||||||
| 579 | } | - | ||||||||||||
| 580 | - | |||||||||||||
| 581 | void QMainWindowPrivate::adjustCursor(const QPoint &pos) | - | ||||||||||||
| 582 | { | - | ||||||||||||
| 583 | QMainWindow * const q = q_func(); | - | ||||||||||||
| 584 | - | |||||||||||||
| 585 | hoverPos = pos; | - | ||||||||||||
| 586 | - | |||||||||||||
| 587 | if (pos == QPoint(0, 0)) { | - | ||||||||||||
| 588 | if (!hoverSeparator.isEmpty()) | - | ||||||||||||
| 589 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - | ||||||||||||
| 590 | hoverSeparator.clear(); | - | ||||||||||||
| 591 | - | |||||||||||||
| 592 | if (cursorAdjusted) { | - | ||||||||||||
| 593 | cursorAdjusted = false; | - | ||||||||||||
| 594 | if (hasOldCursor) | - | ||||||||||||
| 595 | q->setCursor(oldCursor); | - | ||||||||||||
| 596 | else | - | ||||||||||||
| 597 | q->unsetCursor(); | - | ||||||||||||
| 598 | } | - | ||||||||||||
| 599 | } else if (layout->movingSeparator.isEmpty()) { | - | ||||||||||||
| 600 | QList<int> pathToSeparator | - | ||||||||||||
| 601 | = layout->layoutState.dockAreaLayout.findSeparator(pos); | - | ||||||||||||
| 602 | - | |||||||||||||
| 603 | if (pathToSeparator != hoverSeparator) { | - | ||||||||||||
| 604 | if (!hoverSeparator.isEmpty()) | - | ||||||||||||
| 605 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - | ||||||||||||
| 606 | - | |||||||||||||
| 607 | hoverSeparator = pathToSeparator; | - | ||||||||||||
| 608 | - | |||||||||||||
| 609 | if (hoverSeparator.isEmpty()) { | - | ||||||||||||
| 610 | if (cursorAdjusted) { | - | ||||||||||||
| 611 | cursorAdjusted = false; | - | ||||||||||||
| 612 | if (hasOldCursor) | - | ||||||||||||
| 613 | q->setCursor(oldCursor); | - | ||||||||||||
| 614 | else | - | ||||||||||||
| 615 | q->unsetCursor(); | - | ||||||||||||
| 616 | } | - | ||||||||||||
| 617 | } else { | - | ||||||||||||
| 618 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - | ||||||||||||
| 619 | if (!cursorAdjusted) { | - | ||||||||||||
| 620 | oldCursor = q->cursor(); | - | ||||||||||||
| 621 | hasOldCursor = q->testAttribute(Qt::WA_SetCursor); | - | ||||||||||||
| 622 | } | - | ||||||||||||
| 623 | adjustedCursor = separatorCursor(hoverSeparator); | - | ||||||||||||
| 624 | q->setCursor(adjustedCursor); | - | ||||||||||||
| 625 | cursorAdjusted = true; | - | ||||||||||||
| 626 | } | - | ||||||||||||
| 627 | } | - | ||||||||||||
| 628 | } | - | ||||||||||||
| 629 | } | - | ||||||||||||
| 630 | - | |||||||||||||
| 631 | - | |||||||||||||
| 632 | - | |||||||||||||
| 633 | bool QMainWindow::event(QEvent *event) | - | ||||||||||||
| 634 | { | - | ||||||||||||
| 635 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 636 | switch (event->type()) { | - | ||||||||||||
| 637 | - | |||||||||||||
| 638 | - | |||||||||||||
| 639 | case QEvent::Paint: { | - | ||||||||||||
| 640 | QPainter p(this); | - | ||||||||||||
| 641 | QRegion r = static_cast<QPaintEvent*>(event)->region(); | - | ||||||||||||
| 642 | d->layout->layoutState.dockAreaLayout.paintSeparators(&p, this, r, d->hoverPos); | - | ||||||||||||
| 643 | break; | - | ||||||||||||
| 644 | } | - | ||||||||||||
| 645 | - | |||||||||||||
| 646 | - | |||||||||||||
| 647 | case QEvent::HoverMove: { | - | ||||||||||||
| 648 | d->adjustCursor(static_cast<QHoverEvent*>(event)->pos()); | - | ||||||||||||
| 649 | break; | - | ||||||||||||
| 650 | } | - | ||||||||||||
| 651 | - | |||||||||||||
| 652 | - | |||||||||||||
| 653 | - | |||||||||||||
| 654 | case QEvent::HoverEnter: | - | ||||||||||||
| 655 | return true; | - | ||||||||||||
| 656 | case QEvent::HoverLeave: | - | ||||||||||||
| 657 | d->adjustCursor(QPoint(0, 0)); | - | ||||||||||||
| 658 | return true; | - | ||||||||||||
| 659 | case QEvent::ShortcutOverride: | - | ||||||||||||
| 660 | d->adjustCursor(QPoint(0, 0)); | - | ||||||||||||
| 661 | break; | - | ||||||||||||
| 662 | - | |||||||||||||
| 663 | - | |||||||||||||
| 664 | case QEvent::MouseButtonPress: { | - | ||||||||||||
| 665 | QMouseEvent *e = static_cast<QMouseEvent*>(event); | - | ||||||||||||
| 666 | if (e->button() == Qt::LeftButton && d->layout->startSeparatorMove(e->pos())) { | - | ||||||||||||
| 667 | - | |||||||||||||
| 668 | e->accept(); | - | ||||||||||||
| 669 | return true; | - | ||||||||||||
| 670 | } | - | ||||||||||||
| 671 | break; | - | ||||||||||||
| 672 | } | - | ||||||||||||
| 673 | - | |||||||||||||
| 674 | case QEvent::MouseMove: { | - | ||||||||||||
| 675 | QMouseEvent *e = static_cast<QMouseEvent*>(event); | - | ||||||||||||
| 676 | - | |||||||||||||
| 677 | - | |||||||||||||
| 678 | d->adjustCursor(e->pos()); | - | ||||||||||||
| 679 | - | |||||||||||||
| 680 | if (e->buttons() & Qt::LeftButton) { | - | ||||||||||||
| 681 | if (d->layout->separatorMove(e->pos())) { | - | ||||||||||||
| 682 | - | |||||||||||||
| 683 | e->accept(); | - | ||||||||||||
| 684 | return true; | - | ||||||||||||
| 685 | } | - | ||||||||||||
| 686 | } | - | ||||||||||||
| 687 | - | |||||||||||||
| 688 | break; | - | ||||||||||||
| 689 | } | - | ||||||||||||
| 690 | - | |||||||||||||
| 691 | case QEvent::MouseButtonRelease: { | - | ||||||||||||
| 692 | QMouseEvent *e = static_cast<QMouseEvent*>(event); | - | ||||||||||||
| 693 | if (d->layout->endSeparatorMove(e->pos())) { | - | ||||||||||||
| 694 | - | |||||||||||||
| 695 | e->accept(); | - | ||||||||||||
| 696 | return true; | - | ||||||||||||
| 697 | } | - | ||||||||||||
| 698 | break; | - | ||||||||||||
| 699 | } | - | ||||||||||||
| 700 | - | |||||||||||||
| 701 | - | |||||||||||||
| 702 | - | |||||||||||||
| 703 | - | |||||||||||||
| 704 | case QEvent::ToolBarChange: { | - | ||||||||||||
| 705 | d->layout->toggleToolBarsVisible(); | - | ||||||||||||
| 706 | return true; | - | ||||||||||||
| 707 | } | - | ||||||||||||
| 708 | - | |||||||||||||
| 709 | - | |||||||||||||
| 710 | - | |||||||||||||
| 711 | case QEvent::StatusTip: | - | ||||||||||||
| 712 | - | |||||||||||||
| 713 | if (QStatusBar *sb = d->layout->statusBar()) | - | ||||||||||||
| 714 | sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip()); | - | ||||||||||||
| 715 | else | - | ||||||||||||
| 716 | - | |||||||||||||
| 717 | static_cast<QStatusTipEvent*>(event)->ignore(); | - | ||||||||||||
| 718 | return true; | - | ||||||||||||
| 719 | - | |||||||||||||
| 720 | - | |||||||||||||
| 721 | case QEvent::StyleChange: | - | ||||||||||||
| 722 | - | |||||||||||||
| 723 | d->layout->layoutState.dockAreaLayout.styleChangedEvent(); | - | ||||||||||||
| 724 | - | |||||||||||||
| 725 | if (!d->explicitIconSize) | - | ||||||||||||
| 726 | setIconSize(QSize()); | - | ||||||||||||
| 727 | break; | - | ||||||||||||
| 728 | case QEvent::CursorChange: | - | ||||||||||||
| 729 | - | |||||||||||||
| 730 | - | |||||||||||||
| 731 | - | |||||||||||||
| 732 | if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) { | - | ||||||||||||
| 733 | d->oldCursor = cursor(); | - | ||||||||||||
| 734 | d->hasOldCursor = testAttribute(Qt::WA_SetCursor); | - | ||||||||||||
| 735 | - | |||||||||||||
| 736 | - | |||||||||||||
| 737 | setCursor(d->adjustedCursor); | - | ||||||||||||
| 738 | } | - | ||||||||||||
| 739 | break; | - | ||||||||||||
| 740 | - | |||||||||||||
| 741 | default: | - | ||||||||||||
| 742 | break; | - | ||||||||||||
| 743 | } | - | ||||||||||||
| 744 | - | |||||||||||||
| 745 | return QWidget::event(event); | - | ||||||||||||
| 746 | } | - | ||||||||||||
| 747 | void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) | - | ||||||||||||
| 748 | { | - | ||||||||||||
| 749 | (void)set; | - | ||||||||||||
| 750 | - | |||||||||||||
| 751 | } | - | ||||||||||||
| 752 | - | |||||||||||||
| 753 | bool QMainWindow::unifiedTitleAndToolBarOnMac() const | - | ||||||||||||
| 754 | { | - | ||||||||||||
| 755 | - | |||||||||||||
| 756 | - | |||||||||||||
| 757 | - | |||||||||||||
| 758 | - | |||||||||||||
| 759 | - | |||||||||||||
| 760 | - | |||||||||||||
| 761 | return false; | - | ||||||||||||
| 762 | } | - | ||||||||||||
| 763 | - | |||||||||||||
| 764 | - | |||||||||||||
| 765 | - | |||||||||||||
| 766 | - | |||||||||||||
| 767 | - | |||||||||||||
| 768 | - | |||||||||||||
| 769 | bool QMainWindow::isSeparator(const QPoint &pos) const | - | ||||||||||||
| 770 | { | - | ||||||||||||
| 771 | - | |||||||||||||
| 772 | const QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 773 | return !d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty(); | - | ||||||||||||
| 774 | - | |||||||||||||
| 775 | - | |||||||||||||
| 776 | - | |||||||||||||
| 777 | - | |||||||||||||
| 778 | } | - | ||||||||||||
| 779 | - | |||||||||||||
| 780 | - | |||||||||||||
| 781 | - | |||||||||||||
| 782 | - | |||||||||||||
| 783 | - | |||||||||||||
| 784 | void QMainWindow::contextMenuEvent(QContextMenuEvent *event) | - | ||||||||||||
| 785 | { | - | ||||||||||||
| 786 | event->ignore(); | - | ||||||||||||
| 787 | - | |||||||||||||
| 788 | - | |||||||||||||
| 789 | QWidget *child = childAt(event->pos()); | - | ||||||||||||
| 790 | while (child && child != this) { | - | ||||||||||||
| 791 | - | |||||||||||||
| 792 | if (QMenuBar *mb = qobject_cast<QMenuBar *>(child)) { | - | ||||||||||||
| 793 | if (mb->parentWidget() != this) | - | ||||||||||||
| 794 | return; | - | ||||||||||||
| 795 | break; | - | ||||||||||||
| 796 | } | - | ||||||||||||
| 797 | - | |||||||||||||
| 798 | - | |||||||||||||
| 799 | if (QDockWidget *dw = qobject_cast<QDockWidget *>(child)) { | - | ||||||||||||
| 800 | if (dw->parentWidget() != this) | - | ||||||||||||
| 801 | return; | - | ||||||||||||
| 802 | if (dw->widget() | - | ||||||||||||
| 803 | && dw->widget()->geometry().contains(child->mapFrom(this, event->pos()))) { | - | ||||||||||||
| 804 | - | |||||||||||||
| 805 | return; | - | ||||||||||||
| 806 | } | - | ||||||||||||
| 807 | break; | - | ||||||||||||
| 808 | } | - | ||||||||||||
| 809 | - | |||||||||||||
| 810 | - | |||||||||||||
| 811 | if (QToolBar *tb = qobject_cast<QToolBar *>(child)) { | - | ||||||||||||
| 812 | if (tb->parentWidget() != this) | - | ||||||||||||
| 813 | return; | - | ||||||||||||
| 814 | break; | - | ||||||||||||
| 815 | } | - | ||||||||||||
| 816 | - | |||||||||||||
| 817 | child = child->parentWidget(); | - | ||||||||||||
| 818 | } | - | ||||||||||||
| 819 | if (child == this) | - | ||||||||||||
| 820 | return; | - | ||||||||||||
| 821 | - | |||||||||||||
| 822 | - | |||||||||||||
| 823 | QMenu *popup = createPopupMenu(); | - | ||||||||||||
| 824 | if (popup) { | - | ||||||||||||
| 825 | if (!popup->isEmpty()) { | - | ||||||||||||
| 826 | popup->setAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||
| 827 | popup->popup(event->globalPos()); | - | ||||||||||||
| 828 | event->accept(); | - | ||||||||||||
| 829 | } else { | - | ||||||||||||
| 830 | delete popup; | - | ||||||||||||
| 831 | } | - | ||||||||||||
| 832 | } | - | ||||||||||||
| 833 | - | |||||||||||||
| 834 | } | - | ||||||||||||
| 835 | QMenu *QMainWindow::createPopupMenu() | - | ||||||||||||
| 836 | { | - | ||||||||||||
| 837 | QMainWindowPrivate * const d = d_func(); | - | ||||||||||||
| 838 | QMenu *menu = 0; | - | ||||||||||||
| 839 | - | |||||||||||||
| 840 | QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>(); | - | ||||||||||||
| 841 | if (dockwidgets.size()) { | - | ||||||||||||
| 842 | menu = new QMenu(this); | - | ||||||||||||
| 843 | for (int i = 0; i < dockwidgets.size(); ++i) { | - | ||||||||||||
| 844 | QDockWidget *dockWidget = dockwidgets.at(i); | - | ||||||||||||
| 845 | - | |||||||||||||
| 846 | if (dockWidget->parentWidget() == this) { | - | ||||||||||||
| 847 | if (d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) | - | ||||||||||||
| 848 | continue; | - | ||||||||||||
| 849 | } else if (QDockWidgetGroupWindow *dwgw = | - | ||||||||||||
| 850 | qobject_cast<QDockWidgetGroupWindow *>(dockWidget->parentWidget())) { | - | ||||||||||||
| 851 | if (dwgw->parentWidget() != this) | - | ||||||||||||
| 852 | continue; | - | ||||||||||||
| 853 | if (dwgw->layoutInfo()->indexOf(dockWidget).isEmpty()) | - | ||||||||||||
| 854 | continue; | - | ||||||||||||
| 855 | } else { | - | ||||||||||||
| 856 | continue; | - | ||||||||||||
| 857 | } | - | ||||||||||||
| 858 | menu->addAction(dockwidgets.at(i)->toggleViewAction()); | - | ||||||||||||
| 859 | } | - | ||||||||||||
| 860 | menu->addSeparator(); | - | ||||||||||||
| 861 | } | - | ||||||||||||
| 862 | - | |||||||||||||
| 863 | - | |||||||||||||
| 864 | QList<QToolBar *> toolbars = findChildren<QToolBar *>(); | - | ||||||||||||
| 865 | if (toolbars.size()) { | - | ||||||||||||
| 866 | if (!menu) | - | ||||||||||||
| 867 | menu = new QMenu(this); | - | ||||||||||||
| 868 | for (int i = 0; i < toolbars.size(); ++i) { | - | ||||||||||||
| 869 | QToolBar *toolBar = toolbars.at(i); | - | ||||||||||||
| 870 | if (toolBar->parentWidget() == this | - | ||||||||||||
| 871 | && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty())) { | - | ||||||||||||
| 872 | menu->addAction(toolbars.at(i)->toggleViewAction()); | - | ||||||||||||
| 873 | } | - | ||||||||||||
| 874 | } | - | ||||||||||||
| 875 | } | - | ||||||||||||
| 876 | - | |||||||||||||
| 877 | (void)d;; | - | ||||||||||||
| 878 | return menu; | - | ||||||||||||
| 879 | } | - | ||||||||||||
| 880 | - | |||||||||||||
| 881 | - | |||||||||||||
| 882 | - | |||||||||||||
| 883 | - | |||||||||||||
| Switch to Source code | Preprocessed file |