| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | #include "qmainwindow.h" | - |
| 43 | #include "qmainwindowlayout_p.h" | - |
| 44 | | - |
| 45 | #ifndef QT_NO_MAINWINDOW | - |
| 46 | | - |
| 47 | #include "qdockwidget.h" | - |
| 48 | #include "qtoolbar.h" | - |
| 49 | | - |
| 50 | #include <qapplication.h> | - |
| 51 | #include <qmenubar.h> | - |
| 52 | #include <qstatusbar.h> | - |
| 53 | #include <qevent.h> | - |
| 54 | #include <qstyle.h> | - |
| 55 | #include <qdebug.h> | - |
| 56 | #include <qpainter.h> | - |
| 57 | | - |
| 58 | #include <private/qwidget_p.h> | - |
| 59 | #include "qtoolbar_p.h" | - |
| 60 | #include "qwidgetanimator_p.h" | - |
| 61 | #ifdef Q_OS_OSX | - |
| 62 | #include <qpa/qplatformnativeinterface.h> | - |
| 63 | #endif | - |
| 64 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
| 65 | #include <private/qt_mac_p.h> | - |
| 66 | #include <private/qt_cocoa_helpers_mac_p.h> | - |
| 67 | QT_BEGIN_NAMESPACE | - |
| 68 | extern OSWindowRef qt_mac_window_for(const QWidget *); | - |
| 69 | QT_END_NAMESPACE | - |
| 70 | #endif | - |
| 71 | | - |
| 72 | QT_BEGIN_NAMESPACE | - |
| 73 | | - |
| 74 | class QMainWindowPrivate : public QWidgetPrivate | - |
| 75 | { | - |
| 76 | Q_DECLARE_PUBLIC(QMainWindow) | - |
| 77 | public: | - |
| 78 | inline QMainWindowPrivate() | - |
| 79 | : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) | - |
| 80 | #ifdef Q_OS_OSX | - |
| 81 | , useUnifiedToolBar(false) | - |
| 82 | #endif | - |
| 83 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
| 84 | , useHIToolBar(false) | - |
| 85 | , activateUnifiedToolbarAfterFullScreen(false) | - |
| 86 | #endif | - |
| 87 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
| 88 | , hasOldCursor(false) , cursorAdjusted(false) | - |
| 89 | #endif | - |
| 90 | { } | - |
| 91 | QMainWindowLayout *layout; | - |
| 92 | QSize iconSize; | - |
| 93 | bool explicitIconSize; | - |
| 94 | Qt::ToolButtonStyle toolButtonStyle; | - |
| 95 | #ifdef Q_OS_OSX | - |
| 96 | bool useUnifiedToolBar; | - |
| 97 | #endif | - |
| 98 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
| 99 | bool useHIToolBar; | - |
| 100 | bool activateUnifiedToolbarAfterFullScreen; | - |
| 101 | #endif | - |
| 102 | void init(); | - |
| 103 | QList<int> hoverSeparator; | - |
| 104 | QPoint hoverPos; | - |
| 105 | | - |
| 106 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
| 107 | QCursor separatorCursor(const QList<int> &path) const; | - |
| 108 | void adjustCursor(const QPoint &pos); | - |
| 109 | QCursor oldCursor; | - |
| 110 | QCursor adjustedCursor; | - |
| 111 | uint hasOldCursor : 1; | - |
| 112 | uint cursorAdjusted : 1; | - |
| 113 | #endif | - |
| 114 | | - |
| 115 | static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) | - |
| 116 | { | - |
| 117 | return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); | - |
| 118 | } | - |
| 119 | }; | - |
| 120 | | - |
| 121 | QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) | - |
| 122 | { | - |
| 123 | return QMainWindowPrivate::mainWindowLayout(mainWindow); | - |
| 124 | } | - |
| 125 | | - |
| 126 | #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS | - |
| 127 | Q_WIDGETS_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget) | - |
| 128 | { | - |
| 129 | QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout()); | - |
| 130 | Q_ASSERT(topLayout); | - |
| 131 | | - |
| 132 | int row = 0; | - |
| 133 | int column = 0; | - |
| 134 | | - |
| 135 | switch (area) { | - |
| 136 | case Qt::LeftDockWidgetArea: | - |
| 137 | row = 1; | - |
| 138 | column = 0; | - |
| 139 | break; | - |
| 140 | case Qt::TopDockWidgetArea: | - |
| 141 | row = 0; | - |
| 142 | column = 1; | - |
| 143 | break; | - |
| 144 | case Qt::BottomDockWidgetArea: | - |
| 145 | row = 2; | - |
| 146 | column = 1; | - |
| 147 | break; | - |
| 148 | case Qt::RightDockWidgetArea: | - |
| 149 | row = 1; | - |
| 150 | column = 2; | - |
| 151 | break; | - |
| 152 | default: | - |
| 153 | Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area"); | - |
| 154 | return; | - |
| 155 | } | - |
| 156 | | - |
| 157 | if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column)) | - |
| 158 | delete oldItem->widget(); | - |
| 159 | topLayout->addWidget(widget, row, column); | - |
| 160 | } | - |
| 161 | #endif | - |
| 162 | | - |
| 163 | void QMainWindowPrivate::init() | - |
| 164 | { | - |
| 165 | Q_Q(QMainWindow); | - |
| 166 | | - |
| 167 | #ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS | - |
| 168 | QGridLayout *topLayout = new QGridLayout(q); | - |
| 169 | topLayout->setContentsMargins(0, 0, 0, 0); | - |
| 170 | | - |
| 171 | layout = new QMainWindowLayout(q, topLayout); | - |
| 172 | | - |
| 173 | topLayout->addItem(layout, 1, 1); | - |
| 174 | #else | - |
| 175 | layout = new QMainWindowLayout(q, 0); | - |
| 176 | #endif | - |
| 177 | | - |
| 178 | const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); | - |
| 179 | iconSize = QSize(metric, metric); | - |
| 180 | q->setAttribute(Qt::WA_Hover); | - |
| 181 | } | - |
| 182 | | - |
| 183 | | - |
| 184 | | - |
| 185 | | - |
| 186 | | - |
| 187 | | - |
| 188 | | - |
| 189 | | - |
| 190 | | - |
| 191 | | - |
| 192 | | - |
| 193 | | - |
| 194 | | - |
| 195 | | - |
| 196 | | - |
| 197 | | - |
| 198 | | - |
| 199 | | - |
| 200 | | - |
| 201 | | - |
| 202 | | - |
| 203 | | - |
| 204 | | - |
| 205 | | - |
| 206 | | - |
| 207 | | - |
| 208 | | - |
| 209 | | - |
| 210 | | - |
| 211 | | - |
| 212 | | - |
| 213 | | - |
| 214 | | - |
| 215 | | - |
| 216 | | - |
| 217 | | - |
| 218 | | - |
| 219 | | - |
| 220 | | - |
| 221 | | - |
| 222 | | - |
| 223 | | - |
| 224 | | - |
| 225 | | - |
| 226 | | - |
| 227 | | - |
| 228 | | - |
| 229 | | - |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | | - |
| 234 | | - |
| 235 | | - |
| 236 | | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | | - |
| 241 | | - |
| 242 | | - |
| 243 | | - |
| 244 | | - |
| 245 | | - |
| 246 | | - |
| 247 | | - |
| 248 | | - |
| 249 | | - |
| 250 | | - |
| 251 | | - |
| 252 | | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | | - |
| 257 | | - |
| 258 | | - |
| 259 | | - |
| 260 | | - |
| 261 | | - |
| 262 | | - |
| 263 | | - |
| 264 | | - |
| 265 | | - |
| 266 | | - |
| 267 | | - |
| 268 | | - |
| 269 | | - |
| 270 | | - |
| 271 | | - |
| 272 | | - |
| 273 | | - |
| 274 | | - |
| 275 | | - |
| 276 | | - |
| 277 | | - |
| 278 | | - |
| 279 | | - |
| 280 | | - |
| 281 | | - |
| 282 | | - |
| 283 | | - |
| 284 | | - |
| 285 | | - |
| 286 | | - |
| 287 | | - |
| 288 | | - |
| 289 | | - |
| 290 | | - |
| 291 | | - |
| 292 | | - |
| 293 | | - |
| 294 | | - |
| 295 | | - |
| 296 | | - |
| 297 | | - |
| 298 | | - |
| 299 | | - |
| 300 | | - |
| 301 | | - |
| 302 | | - |
| 303 | | - |
| 304 | | - |
| 305 | | - |
| 306 | | - |
| 307 | | - |
| 308 | | - |
| 309 | | - |
| 310 | | - |
| 311 | | - |
| 312 | | - |
| 313 | | - |
| 314 | | - |
| 315 | | - |
| 316 | | - |
| 317 | | - |
| 318 | | - |
| 319 | | - |
| 320 | | - |
| 321 | | - |
| 322 | | - |
| 323 | | - |
| 324 | | - |
| 325 | | - |
| 326 | | - |
| 327 | | - |
| 328 | | - |
| 329 | | - |
| 330 | | - |
| 331 | | - |
| 332 | | - |
| 333 | | - |
| 334 | | - |
| 335 | | - |
| 336 | | - |
| 337 | | - |
| 338 | | - |
| 339 | | - |
| 340 | | - |
| 341 | | - |
| 342 | | - |
| 343 | | - |
| 344 | | - |
| 345 | | - |
| 346 | | - |
| 347 | | - |
| 348 | | - |
| 349 | | - |
| 350 | | - |
| 351 | | - |
| 352 | | - |
| 353 | | - |
| 354 | | - |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | | - |
| 360 | | - |
| 361 | | - |
| 362 | | - |
| 363 | | - |
| 364 | | - |
| 365 | | - |
| 366 | | - |
| 367 | | - |
| 368 | | - |
| 369 | | - |
| 370 | | - |
| 371 | | - |
| 372 | | - |
| 373 | | - |
| 374 | | - |
| 375 | | - |
| 376 | | - |
| 377 | | - |
| 378 | | - |
| 379 | | - |
| 380 | | - |
| 381 | | - |
| 382 | | - |
| 383 | | - |
| 384 | | - |
| 385 | | - |
| 386 | | - |
| 387 | QMainWindow::QMainWindow(QWidget *parent, Qt::WindowFlags flags) | - |
| 388 | : QWidget(*(new QMainWindowPrivate()), parent, flags | Qt::Window) | - |
| 389 | { | - |
| 390 | d_func()->init(); | - |
| 391 | } | - |
| 392 | | - |
| 393 | | - |
| 394 | | - |
| 395 | | - |
| 396 | | - |
| 397 | QMainWindow::~QMainWindow() | - |
| 398 | { } | - |
| 399 | | - |
| 400 | | - |
| 401 | | - |
| 402 | | - |
| 403 | | - |
| 404 | | - |
| 405 | | - |
| 406 | | - |
| 407 | | - |
| 408 | | - |
| 409 | | - |
| 410 | | - |
| 411 | | - |
| 412 | | - |
| 413 | | - |
| 414 | | - |
| 415 | | - |
| 416 | | - |
| 417 | | - |
| 418 | | - |
| 419 | | - |
| 420 | | - |
| 421 | | - |
| 422 | | - |
| 423 | | - |
| 424 | | - |
| 425 | | - |
| 426 | | - |
| 427 | | - |
| 428 | | - |
| 429 | | - |
| 430 | | - |
| 431 | | - |
| 432 | | - |
| 433 | | - |
| 434 | | - |
| 435 | | - |
| 436 | | - |
| 437 | | - |
| 438 | | - |
| 439 | | - |
| 440 | | - |
| 441 | | - |
| 442 | | - |
| 443 | | - |
| 444 | | - |
| 445 | | - |
| 446 | | - |
| 447 | | - |
| 448 | | - |
| 449 | | - |
| 450 | | - |
| 451 | | - |
| 452 | | - |
| 453 | | - |
| 454 | | - |
| 455 | void QMainWindow::setDockOptions(DockOptions opt) | - |
| 456 | { | - |
| 457 | Q_D(QMainWindow); | - |
| 458 | d->layout->setDockOptions(opt); | - |
| 459 | } | - |
| 460 | | - |
| 461 | QMainWindow::DockOptions QMainWindow::dockOptions() const | - |
| 462 | { | - |
| 463 | Q_D(const QMainWindow); | - |
| 464 | return d->layout->dockOptions; | - |
| 465 | } | - |
| 466 | | - |
| 467 | QSize QMainWindow::iconSize() const | - |
| 468 | { return d_func()->iconSize; } | - |
| 469 | | - |
| 470 | void QMainWindow::setIconSize(const QSize &iconSize) | - |
| 471 | { | - |
| 472 | Q_D(QMainWindow); | - |
| 473 | QSize sz = iconSize; | - |
| 474 | if (!sz.isValid()) { | - |
| 475 | const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this); | - |
| 476 | sz = QSize(metric, metric); | - |
| 477 | } | - |
| 478 | if (d->iconSize != sz) { | - |
| 479 | d->iconSize = sz; | - |
| 480 | emit iconSizeChanged(d->iconSize); | - |
| 481 | } | - |
| 482 | d->explicitIconSize = iconSize.isValid(); | - |
| 483 | } | - |
| 484 | | - |
| 485 | | - |
| 486 | | - |
| 487 | | - |
| 488 | | - |
| 489 | | - |
| 490 | | - |
| 491 | | - |
| 492 | | - |
| 493 | | - |
| 494 | | - |
| 495 | Qt::ToolButtonStyle QMainWindow::toolButtonStyle() const | - |
| 496 | { return d_func()->toolButtonStyle; } | - |
| 497 | | - |
| 498 | void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) | - |
| 499 | { | - |
| 500 | Q_D(QMainWindow); | - |
| 501 | if (d->toolButtonStyle == toolButtonStyle) | - |
| 502 | return; | - |
| 503 | d->toolButtonStyle = toolButtonStyle; | - |
| 504 | emit toolButtonStyleChanged(d->toolButtonStyle); | - |
| 505 | } | - |
| 506 | | - |
| 507 | #ifndef QT_NO_MENUBAR | - |
| 508 | | - |
| 509 | | - |
| 510 | | - |
| 511 | | - |
| 512 | | - |
| 513 | | - |
| 514 | | - |
| 515 | | - |
| 516 | | - |
| 517 | | - |
| 518 | | - |
| 519 | | - |
| 520 | | - |
| 521 | | - |
| 522 | | - |
| 523 | QMenuBar *QMainWindow::menuBar() const | - |
| 524 | { | - |
| 525 | QMenuBar *menuBar = qobject_cast<QMenuBar *>(layout()->menuBar()); | - |
| 526 | if (!menuBar) { | - |
| 527 | QMainWindow *self = const_cast<QMainWindow *>(this); | - |
| 528 | menuBar = new QMenuBar(self); | - |
| 529 | self->setMenuBar(menuBar); | - |
| 530 | } | - |
| 531 | return menuBar; | - |
| 532 | } | - |
| 533 | | - |
| 534 | | - |
| 535 | | - |
| 536 | | - |
| 537 | | - |
| 538 | | - |
| 539 | | - |
| 540 | | - |
| 541 | | - |
| 542 | void QMainWindow::setMenuBar(QMenuBar *menuBar) | - |
| 543 | { | - |
| 544 | QLayout *topLayout = layout(); | - |
| 545 | | - |
| 546 | if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { | - |
| 547 | | - |
| 548 | QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); | - |
| 549 | if (menuBar) { | - |
| 550 | | - |
| 551 | QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner); | - |
| 552 | if (cornerWidget) | - |
| 553 | menuBar->setCornerWidget(cornerWidget, Qt::TopLeftCorner); | - |
| 554 | | - |
| 555 | cornerWidget = oldMenuBar->cornerWidget(Qt::TopRightCorner); | - |
| 556 | if (cornerWidget) | - |
| 557 | menuBar->setCornerWidget(cornerWidget, Qt::TopRightCorner); | - |
| 558 | } | - |
| 559 | oldMenuBar->hide(); | - |
| 560 | oldMenuBar->deleteLater(); | - |
| 561 | } | - |
| 562 | topLayout->setMenuBar(menuBar); | - |
| 563 | } | - |
| 564 | | - |
| 565 | | - |
| 566 | | - |
| 567 | | - |
| 568 | | - |
| 569 | | - |
| 570 | | - |
| 571 | QWidget *QMainWindow::menuWidget() const | - |
| 572 | { | - |
| 573 | QWidget *menuBar = d_func()->layout->menuBar(); | - |
| 574 | return menuBar; | - |
| 575 | } | - |
| 576 | | - |
| 577 | | - |
| 578 | | - |
| 579 | | - |
| 580 | | - |
| 581 | | - |
| 582 | | - |
| 583 | | - |
| 584 | | - |
| 585 | void QMainWindow::setMenuWidget(QWidget *menuBar) | - |
| 586 | { | - |
| 587 | Q_D(QMainWindow); | - |
| 588 | if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { | - |
| 589 | d->layout->menuBar()->hide(); | - |
| 590 | d->layout->menuBar()->deleteLater(); | - |
| 591 | } | - |
| 592 | d->layout->setMenuBar(menuBar); | - |
| 593 | } | - |
| 594 | #endif // QT_NO_MENUBAR | - |
| 595 | | - |
| 596 | #ifndef QT_NO_STATUSBAR | - |
| 597 | | - |
| 598 | | - |
| 599 | | - |
| 600 | | - |
| 601 | | - |
| 602 | | - |
| 603 | QStatusBar *QMainWindow::statusBar() const | - |
| 604 | { | - |
| 605 | QStatusBar *statusbar = d_func()->layout->statusBar(); | - |
| 606 | if (!statusbar) { | - |
| 607 | QMainWindow *self = const_cast<QMainWindow *>(this); | - |
| 608 | statusbar = new QStatusBar(self); | - |
| 609 | statusbar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); | - |
| 610 | self->setStatusBar(statusbar); | - |
| 611 | } | - |
| 612 | return statusbar; | - |
| 613 | } | - |
| 614 | | - |
| 615 | | - |
| 616 | | - |
| 617 | | - |
| 618 | | - |
| 619 | | - |
| 620 | | - |
| 621 | | - |
| 622 | | - |
| 623 | | - |
| 624 | void QMainWindow::setStatusBar(QStatusBar *statusbar) | - |
| 625 | { | - |
| 626 | Q_D(QMainWindow); | - |
| 627 | if (d->layout->statusBar() && d->layout->statusBar() != statusbar) { | - |
| 628 | d->layout->statusBar()->hide(); | - |
| 629 | d->layout->statusBar()->deleteLater(); | - |
| 630 | } | - |
| 631 | d->layout->setStatusBar(statusbar); | - |
| 632 | } | - |
| 633 | #endif // QT_NO_STATUSBAR | - |
| 634 | | - |
| 635 | | - |
| 636 | | - |
| 637 | | - |
| 638 | | - |
| 639 | | - |
| 640 | | - |
| 641 | QWidget *QMainWindow::centralWidget() const | - |
| 642 | { return d_func()->layout->centralWidget(); } | - |
| 643 | | - |
| 644 | | - |
| 645 | | - |
| 646 | | - |
| 647 | | - |
| 648 | | - |
| 649 | | - |
| 650 | | - |
| 651 | | - |
| 652 | void QMainWindow::setCentralWidget(QWidget *widget) | - |
| 653 | { | - |
| 654 | Q_D(QMainWindow); | - |
| 655 | if (d->layout->centralWidget() && d->layout->centralWidget() != widget) { | - |
| 656 | d->layout->centralWidget()->hide(); | - |
| 657 | d->layout->centralWidget()->deleteLater(); | - |
| 658 | } | - |
| 659 | d->layout->setCentralWidget(widget); | - |
| 660 | } | - |
| 661 | | - |
| 662 | | - |
| 663 | | - |
| 664 | | - |
| 665 | | - |
| 666 | | - |
| 667 | | - |
| 668 | | - |
| 669 | QWidget *QMainWindow::takeCentralWidget() | - |
| 670 | { | - |
| 671 | Q_D(QMainWindow); | - |
| 672 | QWidget *oldcentralwidget = d->layout->centralWidget(); | - |
| 673 | if (oldcentralwidget) { | - |
| 674 | oldcentralwidget->setParent(0); | - |
| 675 | d->layout->setCentralWidget(0); | - |
| 676 | } | - |
| 677 | return oldcentralwidget; | - |
| 678 | } | - |
| 679 | | - |
| 680 | #ifndef QT_NO_DOCKWIDGET | - |
| 681 | | - |
| 682 | | - |
| 683 | | - |
| 684 | | - |
| 685 | | - |
| 686 | | - |
| 687 | void QMainWindow::setCorner(Qt::Corner corner, Qt::DockWidgetArea area) | - |
| 688 | { | - |
| 689 | bool valid = false; | - |
| 690 | switch (corner) { | - |
| 691 | case Qt::TopLeftCorner: never executed: case Qt::TopLeftCorner: | 0 |
| 692 | valid = (area == Qt::TopDockWidgetArea || area == Qt::LeftDockWidgetArea);| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 693 | break; never executed: break; | 0 |
| 694 | case Qt::TopRightCorner: never executed: case Qt::TopRightCorner: | 0 |
| 695 | valid = (area == Qt::TopDockWidgetArea || area == Qt::RightDockWidgetArea);| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 696 | break; never executed: break; | 0 |
| 697 | case Qt::BottomLeftCorner: never executed: case Qt::BottomLeftCorner: | 0 |
| 698 | valid = (area == Qt::BottomDockWidgetArea || area == Qt::LeftDockWidgetArea);| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 699 | break; never executed: break; | 0 |
| 700 | case Qt::BottomRightCorner: never executed: case Qt::BottomRightCorner: | 0 |
| 701 | valid = (area == Qt::BottomDockWidgetArea || area == Qt::RightDockWidgetArea);| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 702 | break; never executed: break; | 0 |
| 703 | } | - |
| 704 | if (Q_UNLIKELY(!valid)))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 705 | qWarning("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 |
| 706 | else | - |
| 707 | d_func()->layout->setCorner(corner, area); never executed: d_func()->layout->setCorner(corner, area); | 0 |
| 708 | } | - |
| 709 | | - |
| 710 | | - |
| 711 | | - |
| 712 | | - |
| 713 | | - |
| 714 | | - |
| 715 | | - |
| 716 | Qt::DockWidgetArea QMainWindow::corner(Qt::Corner corner) const | - |
| 717 | { return d_func()->layout->corner(corner); } | - |
| 718 | #endif | - |
| 719 | | - |
| 720 | #ifndef QT_NO_TOOLBAR | - |
| 721 | | - |
| 722 | static bool checkToolBarArea(Qt::ToolBarArea area, const char *where) | - |
| 723 | { | - |
| 724 | switch (area) { | - |
| 725 | case Qt::LeftToolBarArea: | - |
| 726 | case Qt::RightToolBarArea: | - |
| 727 | case Qt::TopToolBarArea: | - |
| 728 | case Qt::BottomToolBarArea: | - |
| 729 | return true; | - |
| 730 | default: | - |
| 731 | break; | - |
| 732 | } | - |
| 733 | qWarning("%s: invalid 'area' argument", where); | - |
| 734 | return false; | - |
| 735 | } | - |
| 736 | | - |
| 737 | | - |
| 738 | | - |
| 739 | | - |
| 740 | | - |
| 741 | void QMainWindow::addToolBarBreak(Qt::ToolBarArea area) | - |
| 742 | { | - |
| 743 | if (!checkToolBarArea(area, "QMainWindow::addToolBarBreak")) | - |
| 744 | return; | - |
| 745 | d_func()->layout->addToolBarBreak(area); | - |
| 746 | } | - |
| 747 | | - |
| 748 | | - |
| 749 | | - |
| 750 | | - |
| 751 | void QMainWindow::insertToolBarBreak(QToolBar *before) | - |
| 752 | { d_func()->layout->insertToolBarBreak(before); } | - |
| 753 | | - |
| 754 | | - |
| 755 | | - |
| 756 | | - |
| 757 | | - |
| 758 | void QMainWindow::removeToolBarBreak(QToolBar *before) | - |
| 759 | { | - |
| 760 | Q_D(QMainWindow); | - |
| 761 | d->layout->removeToolBarBreak(before); | - |
| 762 | } | - |
| 763 | | - |
| 764 | | - |
| 765 | | - |
| 766 | | - |
| 767 | | - |
| 768 | | - |
| 769 | | - |
| 770 | | - |
| 771 | | - |
| 772 | void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar) | - |
| 773 | { | - |
| 774 | if (!checkToolBarArea(area, "QMainWindow::addToolBar")) | - |
| 775 | return; | - |
| 776 | | - |
| 777 | Q_D(QMainWindow); | - |
| 778 | | - |
| 779 | disconnect(this, SIGNAL(iconSizeChanged(QSize)), | - |
| 780 | toolbar, SLOT(_q_updateIconSize(QSize))); | - |
| 781 | disconnect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), | - |
| 782 | toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); | - |
| 783 | | - |
| 784 | if(toolbar->d_func()->state && toolbar->d_func()->state->dragging) { | - |
| 785 | | - |
| 786 | #ifndef QT_NO_DOCKWIDGET | - |
| 787 | bool animated = isAnimated(); | - |
| 788 | setAnimated(false); | - |
| 789 | #endif | - |
| 790 | toolbar->d_func()->endDrag(); | - |
| 791 | #ifndef QT_NO_DOCKWIDGET | - |
| 792 | setAnimated(animated); | - |
| 793 | #endif | - |
| 794 | } | - |
| 795 | | - |
| 796 | if (!d->layout->usesHIToolBar(toolbar)) { | - |
| 797 | d->layout->removeWidget(toolbar); | - |
| 798 | } else { | - |
| 799 | d->layout->removeToolBar(toolbar); | - |
| 800 | } | - |
| 801 | | - |
| 802 | toolbar->d_func()->_q_updateIconSize(d->iconSize); | - |
| 803 | toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); | - |
| 804 | connect(this, SIGNAL(iconSizeChanged(QSize)), | - |
| 805 | toolbar, SLOT(_q_updateIconSize(QSize))); | - |
| 806 | connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), | - |
| 807 | toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); | - |
| 808 | | - |
| 809 | d->layout->addToolBar(area, toolbar); | - |
| 810 | } | - |
| 811 | | - |
| 812 | | - |
| 813 | | - |
| 814 | | - |
| 815 | void QMainWindow::addToolBar(QToolBar *toolbar) | - |
| 816 | { addToolBar(Qt::TopToolBarArea, toolbar); } | - |
| 817 | | - |
| 818 | | - |
| 819 | | - |
| 820 | | - |
| 821 | | - |
| 822 | | - |
| 823 | | - |
| 824 | | - |
| 825 | | - |
| 826 | QToolBar *QMainWindow::addToolBar(const QString &title) | - |
| 827 | { | - |
| 828 | QToolBar *toolBar = new QToolBar(this); | - |
| 829 | toolBar->setWindowTitle(title); | - |
| 830 | addToolBar(toolBar); | - |
| 831 | return toolBar; | - |
| 832 | } | - |
| 833 | | - |
| 834 | | - |
| 835 | | - |
| 836 | | - |
| 837 | | - |
| 838 | | - |
| 839 | | - |
| 840 | | - |
| 841 | | - |
| 842 | void QMainWindow::insertToolBar(QToolBar *before, QToolBar *toolbar) | - |
| 843 | { | - |
| 844 | Q_D(QMainWindow); | - |
| 845 | | - |
| 846 | d->layout->removeToolBar(toolbar); | - |
| 847 | | - |
| 848 | toolbar->d_func()->_q_updateIconSize(d->iconSize); | - |
| 849 | toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); | - |
| 850 | connect(this, SIGNAL(iconSizeChanged(QSize)), | - |
| 851 | toolbar, SLOT(_q_updateIconSize(QSize))); | - |
| 852 | connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), | - |
| 853 | toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); | - |
| 854 | | - |
| 855 | d->layout->insertToolBar(before, toolbar); | - |
| 856 | } | - |
| 857 | | - |
| 858 | | - |
| 859 | | - |
| 860 | | - |
| 861 | | - |
| 862 | void QMainWindow::removeToolBar(QToolBar *toolbar) | - |
| 863 | { | - |
| 864 | if (toolbar) { | - |
| 865 | d_func()->layout->removeToolBar(toolbar); | - |
| 866 | toolbar->hide(); | - |
| 867 | } | - |
| 868 | } | - |
| 869 | | - |
| 870 | | - |
| 871 | | - |
| 872 | | - |
| 873 | | - |
| 874 | | - |
| 875 | | - |
| 876 | | - |
| 877 | Qt::ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar) const | - |
| 878 | { return d_func()->layout->toolBarArea(toolbar); } | - |
| 879 | | - |
| 880 | | - |
| 881 | | - |
| 882 | | - |
| 883 | | - |
| 884 | | - |
| 885 | | - |
| 886 | | - |
| 887 | bool QMainWindow::toolBarBreak(QToolBar *toolbar) const | - |
| 888 | { | - |
| 889 | return d_func()->layout->toolBarBreak(toolbar); | - |
| 890 | } | - |
| 891 | | - |
| 892 | #endif // QT_NO_TOOLBAR | - |
| 893 | | - |
| 894 | #ifndef QT_NO_DOCKWIDGET | - |
| 895 | | - |
| 896 | | - |
| 897 | | - |
| 898 | | - |
| 899 | | - |
| 900 | | - |
| 901 | | - |
| 902 | | - |
| 903 | | - |
| 904 | | - |
| 905 | | - |
| 906 | | - |
| 907 | | - |
| 908 | | - |
| 909 | | - |
| 910 | | - |
| 911 | | - |
| 912 | | - |
| 913 | | - |
| 914 | | - |
| 915 | | - |
| 916 | bool QMainWindow::isAnimated() const | - |
| 917 | { | - |
| 918 | Q_D(const QMainWindow); | - |
| 919 | return d->layout->dockOptions & AnimatedDocks; | - |
| 920 | } | - |
| 921 | | - |
| 922 | void QMainWindow::setAnimated(bool enabled) | - |
| 923 | { | - |
| 924 | Q_D(QMainWindow); | - |
| 925 | | - |
| 926 | DockOptions opts = d->layout->dockOptions; | - |
| if (enabled) | |
| opts |= AnimatedDocks; | |
| 927 | elseopts&= ~.setFlag(AnimatedDocks;, enabled); | - |
| 928 | | - |
| 929 | d->layout->setDockOptions(opts); | - |
| 930 | } never executed: end of block | 0 |
| 931 | | - |
| 932 | | - |
| 933 | | - |
| 934 | | - |
| 935 | | - |
| 936 | | - |
| 937 | | - |
| 938 | | - |
| 939 | | - |
| 940 | | - |
| 941 | | - |
| 942 | | - |
| 943 | | - |
| 944 | | - |
| 945 | | - |
| 946 | | - |
| 947 | | - |
| 948 | | - |
| 949 | | - |
| 950 | | - |
| 951 | | - |
| 952 | bool QMainWindow::isDockNestingEnabled() const | - |
| 953 | { | - |
| 954 | Q_D(const QMainWindow); | - |
| 955 | return d->layout->dockOptions & AllowNestedDocks; | - |
| 956 | } | - |
| 957 | | - |
| 958 | void QMainWindow::setDockNestingEnabled(bool enabled) | - |
| 959 | { | - |
| 960 | Q_D(QMainWindow); | - |
| 961 | | - |
| 962 | DockOptions opts = d->layout->dockOptions; | - |
| if (enabled) | |
| opts |= AllowNestedDocks; | |
| 963 | elseopts&= ~.setFlag(AllowNestedDocks;, enabled); | - |
| 964 | | - |
| 965 | d->layout->setDockOptions(opts); | - |
| 966 | } never executed: end of block | 0 |
| 967 | | - |
| 968 | #if 0 | - |
| 969 | | - |
| 970 | | - |
| 971 | | - |
| 972 | | - |
| 973 | | - |
| 974 | | - |
| 975 | | - |
| 976 | | - |
| 977 | | - |
| 978 | | - |
| 979 | | - |
| 980 | | - |
| 981 | | - |
| 982 | bool QMainWindow::verticalTabsEnabled() const | - |
| 983 | { | - |
| 984 | return d_func()->layout->verticalTabsEnabled(); | - |
| 985 | } | - |
| 986 | | - |
| 987 | void QMainWindow::setVerticalTabsEnabled(bool enabled) | - |
| 988 | { | - |
| 989 | d_func()->layout->setVerticalTabsEnabled(enabled); | - |
| 990 | } | - |
| 991 | #endif | - |
| 992 | | - |
| 993 | static bool checkDockWidgetArea(Qt::DockWidgetArea area, const char *where) | - |
| 994 | { | - |
| 995 | switch (area) { | - |
| 996 | case Qt::LeftDockWidgetArea: | - |
| 997 | case Qt::RightDockWidgetArea: | - |
| 998 | case Qt::TopDockWidgetArea: | - |
| 999 | case Qt::BottomDockWidgetArea: | - |
| 1000 | return true; | - |
| 1001 | default: | - |
| 1002 | break; | - |
| 1003 | } | - |
| 1004 | qWarning("%s: invalid 'area' argument", where); | - |
| 1005 | return false; | - |
| 1006 | } | - |
| 1007 | | - |
| 1008 | #ifndef QT_NO_TABBAR | - |
| 1009 | | - |
| 1010 | | - |
| 1011 | | - |
| 1012 | | - |
| 1013 | | - |
| 1014 | | - |
| 1015 | | - |
| 1016 | | - |
| 1017 | | - |
| 1018 | bool QMainWindow::documentMode() const | - |
| 1019 | { | - |
| 1020 | return d_func()->layout->documentMode(); | - |
| 1021 | } | - |
| 1022 | | - |
| 1023 | void QMainWindow::setDocumentMode(bool enabled) | - |
| 1024 | { | - |
| 1025 | d_func()->layout->setDocumentMode(enabled); | - |
| 1026 | } | - |
| 1027 | #endif // QT_NO_TABBAR | - |
| 1028 | | - |
| 1029 | #ifndef QT_NO_TABWIDGET | - |
| 1030 | | - |
| 1031 | | - |
| 1032 | | - |
| 1033 | | - |
| 1034 | | - |
| 1035 | | - |
| 1036 | | - |
| 1037 | | - |
| 1038 | | - |
| 1039 | QTabWidget::TabShape QMainWindow::tabShape() const | - |
| 1040 | { | - |
| 1041 | return d_func()->layout->tabShape(); | - |
| 1042 | } | - |
| 1043 | | - |
| 1044 | void QMainWindow::setTabShape(QTabWidget::TabShape tabShape) | - |
| 1045 | { | - |
| 1046 | d_func()->layout->setTabShape(tabShape); | - |
| 1047 | } | - |
| 1048 | | - |
| 1049 | | - |
| 1050 | | - |
| 1051 | | - |
| 1052 | | - |
| 1053 | | - |
| 1054 | | - |
| 1055 | | - |
| 1056 | | - |
| 1057 | | - |
| 1058 | | - |
| 1059 | QTabWidget::TabPosition QMainWindow::tabPosition(Qt::DockWidgetArea area) const | - |
| 1060 | { | - |
| 1061 | if (!checkDockWidgetArea(area, "QMainWindow::tabPosition")) | - |
| 1062 | return QTabWidget::South; | - |
| 1063 | return d_func()->layout->tabPosition(area); | - |
| 1064 | } | - |
| 1065 | | - |
| 1066 | | - |
| 1067 | | - |
| 1068 | | - |
| 1069 | | - |
| 1070 | | - |
| 1071 | | - |
| 1072 | | - |
| 1073 | | - |
| 1074 | | - |
| 1075 | | - |
| 1076 | | - |
| 1077 | void QMainWindow::setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition) | - |
| 1078 | { | - |
| 1079 | d_func()->layout->setTabPosition(areas, tabPosition); | - |
| 1080 | } | - |
| 1081 | #endif // QT_NO_TABWIDGET | - |
| 1082 | | - |
| 1083 | | - |
| 1084 | | - |
| 1085 | | - |
| 1086 | void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget) | - |
| 1087 | { | - |
| 1088 | if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) | - |
| 1089 | return; | - |
| 1090 | | - |
| 1091 | Qt::Orientation orientation = Qt::Vertical; | - |
| 1092 | switch (area) { | - |
| 1093 | case Qt::TopDockWidgetArea: | - |
| 1094 | case Qt::BottomDockWidgetArea: | - |
| 1095 | orientation = Qt::Horizontal; | - |
| 1096 | break; | - |
| 1097 | default: | - |
| 1098 | break; | - |
| 1099 | } | - |
| 1100 | d_func()->layout->removeWidget(dockwidget); | - |
| 1101 | addDockWidget(area, dockwidget, orientation); | - |
| 1102 | | - |
| 1103 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support | - |
| 1104 | QMacAutoReleasePool pool; | - |
| 1105 | extern bool qt_mac_is_macdrawer(const QWidget *); | - |
| 1106 | if (qt_mac_is_macdrawer(dockwidget)) { | - |
| 1107 | extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); | - |
| 1108 | window()->createWinId(); | - |
| 1109 | dockwidget->window()->createWinId(); | - |
| 1110 | qt_mac_set_drawer_preferred_edge(dockwidget, area); | - |
| 1111 | if (dockwidget->isVisible()) { | - |
| 1112 | dockwidget->hide(); | - |
| 1113 | dockwidget->show(); | - |
| 1114 | } | - |
| 1115 | } | - |
| 1116 | #endif | - |
| 1117 | } | - |
| 1118 | | - |
| 1119 | | - |
| 1120 | | - |
| 1121 | | - |
| 1122 | | - |
| 1123 | | - |
| 1124 | | - |
| 1125 | | - |
| 1126 | | - |
| 1127 | bool QMainWindow::restoreDockWidget(QDockWidget *dockwidget) | - |
| 1128 | { | - |
| 1129 | return d_func()->layout->restoreDockWidget(dockwidget); | - |
| 1130 | } | - |
| 1131 | | - |
| 1132 | | - |
| 1133 | | - |
| 1134 | | - |
| 1135 | | - |
| 1136 | void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget, | - |
| 1137 | Qt::Orientation orientation) | - |
| 1138 | { | - |
| 1139 | if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) | - |
| 1140 | return; | - |
| 1141 | | - |
| 1142 | | - |
| 1143 | d_func()->layout->addDockWidget(area, dockwidget, orientation); | - |
| 1144 | } | - |
| 1145 | | - |
| 1146 | | - |
| 1147 | | - |
| 1148 | | - |
| 1149 | | - |
| 1150 | | - |
| 1151 | | - |
| 1152 | | - |
| 1153 | | - |
| 1154 | | - |
| 1155 | | - |
| 1156 | | - |
| 1157 | | - |
| 1158 | | - |
| 1159 | | - |
| 1160 | | - |
| 1161 | | - |
| 1162 | | - |
| 1163 | | - |
| 1164 | | - |
| 1165 | | - |
| 1166 | | - |
| 1167 | void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, | - |
| 1168 | Qt::Orientation orientation) | - |
| 1169 | { | - |
| 1170 | d_func()->layout->splitDockWidget(after, dockwidget, orientation); | - |
| 1171 | } | - |
| 1172 | | - |
| 1173 | | - |
| 1174 | | - |
| 1175 | | - |
| 1176 | | - |
| 1177 | | - |
| 1178 | | - |
| 1179 | | - |
| 1180 | | - |
| 1181 | void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second) | - |
| 1182 | { | - |
| 1183 | d_func()->layout->tabifyDockWidget(first, second); | - |
| 1184 | } | - |
| 1185 | | - |
| 1186 | | - |
| 1187 | | - |
| 1188 | | - |
| 1189 | | - |
| 1190 | | - |
| 1191 | | - |
| 1192 | | - |
| 1193 | | - |
| 1194 | | - |
| 1195 | | - |
| 1196 | QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const | - |
| 1197 | { | - |
| 1198 | QList<QDockWidget*> ret; | - |
| 1199 | #if defined(QT_NO_TABBAR) | - |
| 1200 | Q_UNUSED(dockwidget); | - |
| 1201 | #else | - |
| 1202 | const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget); | - |
| 1203 | if (info && info->tabbed && info->tabBar) { | - |
| 1204 | for(int i = 0; i < info->item_list.count(); ++i) { | - |
| 1205 | const QDockAreaLayoutItem &item = info->item_list.at(i); | - |
| 1206 | if (item.widgetItem) { | - |
| 1207 | if (QDockWidget *dock = qobject_cast<QDockWidget*>(item.widgetItem->widget())) { | - |
| 1208 | if (dock != dockwidget) { | - |
| 1209 | ret += dock; | - |
| 1210 | } | - |
| 1211 | } | - |
| 1212 | } | - |
| 1213 | } | - |
| 1214 | } | - |
| 1215 | #endif | - |
| 1216 | return ret; | - |
| 1217 | } | - |
| 1218 | | - |
| 1219 | | - |
| 1220 | | - |
| 1221 | | - |
| 1222 | | - |
| 1223 | | - |
| 1224 | void QMainWindow::removeDockWidget(QDockWidget *dockwidget) | - |
| 1225 | { | - |
| 1226 | if (dockwidget) { | - |
| 1227 | d_func()->layout->removeWidget(dockwidget); | - |
| 1228 | dockwidget->hide(); | - |
| 1229 | } | - |
| 1230 | } | - |
| 1231 | | - |
| 1232 | | - |
| 1233 | | - |
| 1234 | | - |
| 1235 | | - |
| 1236 | | - |
| 1237 | | - |
| 1238 | | - |
| 1239 | Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const | - |
| 1240 | { return d_func()->layout->dockWidgetArea(dockwidget); } | - |
| 1241 | | - |
| 1242 | | - |
| 1243 | | - |
| 1244 | | - |
| 1245 | | - |
| 1246 | | - |
| 1247 | | - |
| 1248 | | - |
| 1249 | | - |
| 1250 | | - |
| 1251 | | - |
| 1252 | | - |
| 1253 | | - |
| 1254 | | - |
| 1255 | | - |
| 1256 | | - |
| 1257 | | - |
| 1258 | | - |
| 1259 | | - |
| 1260 | | - |
| 1261 | | - |
| 1262 | | - |
| 1263 | void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks, | - |
| 1264 | const QList<int> &sizes, Qt::Orientation orientation) | - |
| 1265 | { | - |
| 1266 | d_func()->layout->layoutState.dockAreaLayout.resizeDocks(docks, sizes, orientation); | - |
| 1267 | d_func()->layout->invalidate(); | - |
| 1268 | } | - |
| 1269 | | - |
| 1270 | | - |
| 1271 | #endif // QT_NO_DOCKWIDGET | - |
| 1272 | | - |
| 1273 | | - |
| 1274 | | - |
| 1275 | | - |
| 1276 | | - |
| 1277 | | - |
| 1278 | | - |
| 1279 | | - |
| 1280 | | - |
| 1281 | | - |
| 1282 | | - |
| 1283 | | - |
| 1284 | | - |
| 1285 | | - |
| 1286 | | - |
| 1287 | | - |
| 1288 | | - |
| 1289 | | - |
| 1290 | | - |
| 1291 | | - |
| 1292 | | - |
| 1293 | | - |
| 1294 | QByteArray QMainWindow::saveState(int version) const | - |
| 1295 | { | - |
| 1296 | QByteArray data; | - |
| 1297 | QDataStream stream(&data, QIODevice::WriteOnly); | - |
| 1298 | stream << QMainWindowLayout::VersionMarker; | - |
| 1299 | stream << version; | - |
| 1300 | d_func()->layout->saveState(stream); | - |
| 1301 | return data; | - |
| 1302 | } | - |
| 1303 | | - |
| 1304 | | - |
| 1305 | | - |
| 1306 | | - |
| 1307 | | - |
| 1308 | | - |
| 1309 | | - |
| 1310 | | - |
| 1311 | | - |
| 1312 | | - |
| 1313 | | - |
| 1314 | | - |
| 1315 | | - |
| 1316 | | - |
| 1317 | | - |
| 1318 | | - |
| 1319 | | - |
| 1320 | bool QMainWindow::restoreState(const QByteArray &state, int version) | - |
| 1321 | { | - |
| 1322 | if (state.isEmpty()) | - |
| 1323 | return false; | - |
| 1324 | QByteArray sd = state; | - |
| 1325 | QDataStream stream(&sd, QIODevice::ReadOnly); | - |
| 1326 | int marker, v; | - |
| 1327 | stream >> marker; | - |
| 1328 | stream >> v; | - |
| 1329 | if (stream.status() != QDataStream::Ok || marker != QMainWindowLayout::VersionMarker || v != version) | - |
| 1330 | return false; | - |
| 1331 | bool restored = d_func()->layout->restoreState(stream); | - |
| 1332 | return restored; | - |
| 1333 | } | - |
| 1334 | | - |
| 1335 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
| 1336 | QCursor QMainWindowPrivate::separatorCursor(const QList<int> &path) const | - |
| 1337 | { | - |
| 1338 | QDockAreaLayoutInfo *info = layout->layoutState.dockAreaLayout.info(path); | - |
| 1339 | Q_ASSERT(info != 0); | - |
| 1340 | if (path.size() == 1) { | - |
| 1341 | | - |
| 1342 | switch (path.first()) { | - |
| 1343 | case QInternal::LeftDock: | - |
| 1344 | case QInternal::RightDock: | - |
| 1345 | return Qt::SplitHCursor; | - |
| 1346 | case QInternal::TopDock: | - |
| 1347 | case QInternal::BottomDock: | - |
| 1348 | return Qt::SplitVCursor; | - |
| 1349 | default: | - |
| 1350 | break; | - |
| 1351 | } | - |
| 1352 | } | - |
| 1353 | | - |
| 1354 | | - |
| 1355 | | - |
| 1356 | return info->o == Qt::Horizontal | - |
| 1357 | ? Qt::SplitHCursor : Qt::SplitVCursor; | - |
| 1358 | } | - |
| 1359 | | - |
| 1360 | void QMainWindowPrivate::adjustCursor(const QPoint &pos) | - |
| 1361 | { | - |
| 1362 | Q_Q(QMainWindow); | - |
| 1363 | | - |
| 1364 | hoverPos = pos; | - |
| 1365 | | - |
| 1366 | if (pos == QPoint(0, 0)) { | - |
| 1367 | if (!hoverSeparator.isEmpty()) | - |
| 1368 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - |
| 1369 | hoverSeparator.clear(); | - |
| 1370 | | - |
| 1371 | if (cursorAdjusted) { | - |
| 1372 | cursorAdjusted = false; | - |
| 1373 | if (hasOldCursor) | - |
| 1374 | q->setCursor(oldCursor); | - |
| 1375 | else | - |
| 1376 | q->unsetCursor(); | - |
| 1377 | } | - |
| 1378 | } else if (layout->movingSeparator.isEmpty()) { | - |
| 1379 | QList<int> pathToSeparator | - |
| 1380 | = layout->layoutState.dockAreaLayout.findSeparator(pos); | - |
| 1381 | | - |
| 1382 | if (pathToSeparator != hoverSeparator) { | - |
| 1383 | if (!hoverSeparator.isEmpty()) | - |
| 1384 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - |
| 1385 | | - |
| 1386 | hoverSeparator = pathToSeparator; | - |
| 1387 | | - |
| 1388 | if (hoverSeparator.isEmpty()) { | - |
| 1389 | if (cursorAdjusted) { | - |
| 1390 | cursorAdjusted = false; | - |
| 1391 | if (hasOldCursor) | - |
| 1392 | q->setCursor(oldCursor); | - |
| 1393 | else | - |
| 1394 | q->unsetCursor(); | - |
| 1395 | } | - |
| 1396 | } else { | - |
| 1397 | q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator)); | - |
| 1398 | if (!cursorAdjusted) { | - |
| 1399 | oldCursor = q->cursor(); | - |
| 1400 | hasOldCursor = q->testAttribute(Qt::WA_SetCursor); | - |
| 1401 | } | - |
| 1402 | adjustedCursor = separatorCursor(hoverSeparator); | - |
| 1403 | q->setCursor(adjustedCursor); | - |
| 1404 | cursorAdjusted = true; | - |
| 1405 | } | - |
| 1406 | } | - |
| 1407 | } | - |
| 1408 | } | - |
| 1409 | #endif | - |
| 1410 | | - |
| 1411 | | - |
| 1412 | bool QMainWindow::event(QEvent *event) | - |
| 1413 | { | - |
| 1414 | Q_D(QMainWindow); | - |
| 1415 | switch (event->type()) { | - |
| 1416 | | - |
| 1417 | #ifndef QT_NO_DOCKWIDGET | - |
| 1418 | case QEvent::Paint: { | - |
| 1419 | QPainter p(this); | - |
| 1420 | QRegion r = static_cast<QPaintEvent*>(event)->region(); | - |
| 1421 | d->layout->layoutState.dockAreaLayout.paintSeparators(&p, this, r, d->hoverPos); | - |
| 1422 | break; | - |
| 1423 | } | - |
| 1424 | | - |
| 1425 | #ifndef QT_NO_CURSOR | - |
| 1426 | case QEvent::HoverMove: { | - |
| 1427 | d->adjustCursor(static_cast<QHoverEvent*>(event)->pos()); | - |
| 1428 | break; | - |
| 1429 | } | - |
| 1430 | | - |
| 1431 | | - |
| 1432 | | - |
| 1433 | case QEvent::HoverEnter: | - |
| 1434 | return true; | - |
| 1435 | case QEvent::HoverLeave: | - |
| 1436 | d->adjustCursor(QPoint(0, 0)); | - |
| 1437 | return true; | - |
| 1438 | case QEvent::ShortcutOverride: | - |
| 1439 | d->adjustCursor(QPoint(0, 0)); | - |
| 1440 | break; | - |
| 1441 | #endif // QT_NO_CURSOR | - |
| 1442 | | - |
| 1443 | case QEvent::MouseButtonPress: { | - |
| 1444 | QMouseEvent *e = static_cast<QMouseEvent*>(event); | - |
| 1445 | if (e->button() == Qt::LeftButton && d->layout->startSeparatorMove(e->pos())) { | - |
| 1446 | | - |
| 1447 | e->accept(); | - |
| 1448 | return true; | - |
| 1449 | } | - |
| 1450 | break; | - |
| 1451 | } | - |
| 1452 | | - |
| 1453 | case QEvent::MouseMove: { | - |
| 1454 | QMouseEvent *e = static_cast<QMouseEvent*>(event); | - |
| 1455 | | - |
| 1456 | #ifndef QT_NO_CURSOR | - |
| 1457 | d->adjustCursor(e->pos()); | - |
| 1458 | #endif | - |
| 1459 | if (e->buttons() & Qt::LeftButton) { | - |
| 1460 | if (d->layout->separatorMove(e->pos())) { | - |
| 1461 | | - |
| 1462 | e->accept(); | - |
| 1463 | return true; | - |
| 1464 | } | - |
| 1465 | } | - |
| 1466 | | - |
| 1467 | break; | - |
| 1468 | } | - |
| 1469 | | - |
| 1470 | case QEvent::MouseButtonRelease: { | - |
| 1471 | QMouseEvent *e = static_cast<QMouseEvent*>(event); | - |
| 1472 | if (d->layout->endSeparatorMove(e->pos())) { | - |
| 1473 | | - |
| 1474 | e->accept(); | - |
| 1475 | return true; | - |
| 1476 | } | - |
| 1477 | break; | - |
| 1478 | } | - |
| 1479 | | - |
| 1480 | #endif | - |
| 1481 | | - |
| 1482 | #ifndef QT_NO_TOOLBAR | - |
| 1483 | case QEvent::ToolBarChange: { | - |
| 1484 | d->layout->toggleToolBarsVisible(); | - |
| 1485 | return true; | - |
| 1486 | } | - |
| 1487 | #endif | - |
| 1488 | | - |
| 1489 | #ifndef QT_NO_STATUSTIP | - |
| 1490 | case QEvent::StatusTip: | - |
| 1491 | #ifndef QT_NO_STATUSBAR | - |
| 1492 | if (QStatusBar *sb = d->layout->statusBar()) | - |
| 1493 | sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip()); | - |
| 1494 | else | - |
| 1495 | #endif | - |
| 1496 | static_cast<QStatusTipEvent*>(event)->ignore(); | - |
| 1497 | return true; | - |
| 1498 | #endif // QT_NO_STATUSTIP | - |
| 1499 | | - |
| 1500 | case QEvent::StyleChange: | - |
| 1501 | #ifndef QT_NO_DOCKWIDGET | - |
| 1502 | d->layout->layoutState.dockAreaLayout.styleChangedEvent(); | - |
| 1503 | #endif | - |
| 1504 | if (!d->explicitIconSize) | - |
| 1505 | setIconSize(QSize()); | - |
| 1506 | break; | - |
| 1507 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
| 1508 | case QEvent::Show: | - |
| 1509 | if (unifiedTitleAndToolBarOnMac()) | - |
| 1510 | d->layout->syncUnifiedToolbarVisibility(); | - |
| 1511 | d->layout->blockVisiblityCheck = false; | - |
| 1512 | break; | - |
| 1513 | case QEvent::WindowStateChange: | - |
| 1514 | { | - |
| 1515 | if (isHidden()) { | - |
| 1516 | | - |
| 1517 | d->layout->blockVisiblityCheck = true; | - |
| 1518 | } | - |
| 1519 | | - |
| 1520 | QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event); | - |
| 1521 | if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) { | - |
| 1522 | d->layout->updateHIToolBarStatus(); | - |
| 1523 | } | - |
| 1524 | } | - |
| 1525 | break; | - |
| 1526 | #endif // Q_DEAD_CODE_FROM_QT4_MAC | - |
| 1527 | #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) | - |
| 1528 | case QEvent::CursorChange: | - |
| 1529 | | - |
| 1530 | | - |
| 1531 | | - |
| 1532 | if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) { | - |
| 1533 | d->oldCursor = cursor(); | - |
| 1534 | d->hasOldCursor = testAttribute(Qt::WA_SetCursor); | - |
| 1535 | | - |
| 1536 | | - |
| 1537 | setCursor(d->adjustedCursor); | - |
| 1538 | } | - |
| 1539 | break; | - |
| 1540 | #endif | - |
| 1541 | default: | - |
| 1542 | break; | - |
| 1543 | } | - |
| 1544 | | - |
| 1545 | return QWidget::event(event); | - |
| 1546 | } | - |
| 1547 | | - |
| 1548 | #ifndef QT_NO_TOOLBAR | - |
| 1549 | | - |
| 1550 | | - |
| 1551 | | - |
| 1552 | | - |
| 1553 | | - |
| 1554 | | - |
| 1555 | | - |
| 1556 | | - |
| 1557 | | - |
| 1558 | | - |
| 1559 | | - |
| 1560 | | - |
| 1561 | | - |
| 1562 | void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) | - |
| 1563 | { | - |
| 1564 | #ifdef Q_OS_OSX | - |
| 1565 | Q_D(QMainWindow); | - |
| 1566 | if (isWindow()) { | - |
| 1567 | d->useUnifiedToolBar = set; | - |
| 1568 | createWinId(); | - |
| 1569 | | - |
| 1570 | QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); | - |
| 1571 | QPlatformNativeInterface::NativeResourceForIntegrationFunction function = | - |
| 1572 | nativeInterface->nativeResourceFunctionForIntegration("setContentBorderEnabled"); | - |
| 1573 | if (!function) | - |
| 1574 | return; | - |
| 1575 | | - |
| 1576 | typedef void (*SetContentBorderEnabledFunction)(QWindow *window, bool enable); | - |
| 1577 | (reinterpret_cast<SetContentBorderEnabledFunction>(function))(window()->windowHandle(), set); | - |
| 1578 | update(); | - |
| 1579 | } | - |
| 1580 | #endif | - |
| 1581 | | - |
| 1582 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
| 1583 | Q_D(QMainWindow); | - |
| 1584 | if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3) | - |
| 1585 | return; | - |
| 1586 | | - |
| 1587 | d->useHIToolBar = set; | - |
| 1588 | createWinId(); | - |
| 1589 | | - |
| 1590 | | - |
| 1591 | if (windowSurface() && set) { | - |
| 1592 | d->layout->unifiedSurface = new QUnifiedToolbarSurface(this); | - |
| 1593 | } | - |
| 1594 | | - |
| 1595 | d->layout->updateHIToolBarStatus(); | - |
| 1596 | | - |
| 1597 | | - |
| 1598 | if (windowSurface() && !set) { | - |
| 1599 | if (d->layout->unifiedSurface) { | - |
| 1600 | delete d->layout->unifiedSurface; | - |
| 1601 | d->layout->unifiedSurface = 0; | - |
| 1602 | } | - |
| 1603 | } | - |
| 1604 | | - |
| 1605 | | - |
| 1606 | d->macUpdateOpaqueSizeGrip(); | - |
| 1607 | #else | - |
| 1608 | Q_UNUSED(set) | - |
| 1609 | #endif | - |
| 1610 | } | - |
| 1611 | | - |
| 1612 | bool QMainWindow::unifiedTitleAndToolBarOnMac() const | - |
| 1613 | { | - |
| 1614 | #ifdef Q_OS_OSX | - |
| 1615 | return d_func()->useUnifiedToolBar; | - |
| 1616 | #endif | - |
| 1617 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - |
| 1618 | return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint); | - |
| 1619 | #endif | - |
| 1620 | return false; | - |
| 1621 | } | - |
| 1622 | | - |
| 1623 | #endif // QT_NO_TOOLBAR | - |
| 1624 | | - |
| 1625 | | - |
| 1626 | | - |
| 1627 | | - |
| 1628 | bool QMainWindow::isSeparator(const QPoint &pos) const | - |
| 1629 | { | - |
| 1630 | #ifndef QT_NO_DOCKWIDGET | - |
| 1631 | Q_D(const QMainWindow); | - |
| 1632 | return !d->layout->layoutState.dockAreaLayout.findSeparator(pos).isEmpty(); | - |
| 1633 | #else | - |
| 1634 | Q_UNUSED(pos); | - |
| 1635 | return false; | - |
| 1636 | #endif | - |
| 1637 | } | - |
| 1638 | | - |
| 1639 | #ifndef QT_NO_CONTEXTMENU | - |
| 1640 | | - |
| 1641 | | - |
| 1642 | | - |
| 1643 | void QMainWindow::contextMenuEvent(QContextMenuEvent *event) | - |
| 1644 | { | - |
| 1645 | event->ignore(); | - |
| 1646 | | - |
| 1647 | | - |
| 1648 | QWidget *child = childAt(event->pos()); | - |
| 1649 | while (child && child != this) { | - |
| 1650 | #ifndef QT_NO_MENUBAR | - |
| 1651 | if (QMenuBar *mb = qobject_cast<QMenuBar *>(child)) { | - |
| 1652 | if (mb->parentWidget() != this) | - |
| 1653 | return; | - |
| 1654 | break; | - |
| 1655 | } | - |
| 1656 | #endif | - |
| 1657 | #ifndef QT_NO_DOCKWIDGET | - |
| 1658 | if (QDockWidget *dw = qobject_cast<QDockWidget *>(child)) { | - |
| 1659 | if (dw->parentWidget() != this) | - |
| 1660 | return; | - |
| 1661 | if (dw->widget() | - |
| 1662 | && dw->widget()->geometry().contains(child->mapFrom(this, event->pos()))) { | - |
| 1663 | | - |
| 1664 | return; | - |
| 1665 | } | - |
| 1666 | break; | - |
| 1667 | } | - |
| 1668 | #endif // QT_NO_DOCKWIDGET | - |
| 1669 | #ifndef QT_NO_TOOLBAR | - |
| 1670 | if (QToolBar *tb = qobject_cast<QToolBar *>(child)) { | - |
| 1671 | if (tb->parentWidget() != this) | - |
| 1672 | return; | - |
| 1673 | break; | - |
| 1674 | } | - |
| 1675 | #endif | - |
| 1676 | child = child->parentWidget(); | - |
| 1677 | } | - |
| 1678 | if (child == this) | - |
| 1679 | return; | - |
| 1680 | | - |
| 1681 | #ifndef QT_NO_MENU | - |
| 1682 | QMenu *popup = createPopupMenu(); | - |
| 1683 | if (popup) { | - |
| 1684 | if (!popup->isEmpty()) { | - |
| 1685 | popup->setAttribute(Qt::WA_DeleteOnClose); | - |
| 1686 | popup->popup(event->globalPos()); | - |
| 1687 | event->accept(); | - |
| 1688 | } else { | - |
| 1689 | delete popup; | - |
| 1690 | } | - |
| 1691 | } | - |
| 1692 | #endif | - |
| 1693 | } | - |
| 1694 | #endif // QT_NO_CONTEXTMENU | - |
| 1695 | | - |
| 1696 | #ifndef QT_NO_MENU | - |
| 1697 | | - |
| 1698 | | - |
| 1699 | | - |
| 1700 | | - |
| 1701 | | - |
| 1702 | | - |
| 1703 | | - |
| 1704 | | - |
| 1705 | | - |
| 1706 | | - |
| 1707 | | - |
| 1708 | | - |
| 1709 | | - |
| 1710 | | - |
| 1711 | | - |
| 1712 | QMenu *QMainWindow::createPopupMenu() | - |
| 1713 | { | - |
| 1714 | Q_D(QMainWindow); | - |
| 1715 | QMenu *menu = 0; | - |
| 1716 | #ifndef QT_NO_DOCKWIDGET | - |
| 1717 | QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>(); | - |
| 1718 | if (dockwidgets.size()) { | - |
| 1719 | menu = new QMenu(this); | - |
| 1720 | for (int i = 0; i < dockwidgets.size(); ++i) { | - |
| 1721 | QDockWidget *dockWidget = dockwidgets.at(i); | - |
| 1722 | | - |
| 1723 | if (dockWidget->parentWidget() == this) { | - |
| 1724 | if (d->layout->layoutState.dockAreaLayout.indexOf(dockWidget).isEmpty()) | - |
| 1725 | continue; | - |
| 1726 | } else if (QDockWidgetGroupWindow *dwgw = | - |
| 1727 | qobject_cast<QDockWidgetGroupWindow *>(dockWidget->parentWidget())) { | - |
| 1728 | if (dwgw->parentWidget() != this) | - |
| 1729 | continue; | - |
| 1730 | if (dwgw->layoutInfo()->indexOf(dockWidget).isEmpty()) | - |
| 1731 | continue; | - |
| 1732 | } else { | - |
| 1733 | continue; | - |
| 1734 | } | - |
| 1735 | menu->addAction(dockwidgets.at(i)->toggleViewAction()); | - |
| 1736 | } | - |
| 1737 | menu->addSeparator(); | - |
| 1738 | } | - |
| 1739 | #endif // QT_NO_DOCKWIDGET | - |
| 1740 | #ifndef QT_NO_TOOLBAR | - |
| 1741 | QList<QToolBar *> toolbars = findChildren<QToolBar *>(); | - |
| 1742 | if (toolbars.size()) { | - |
| 1743 | if (!menu) | - |
| 1744 | menu = new QMenu(this); | - |
| 1745 | for (int i = 0; i < toolbars.size(); ++i) { | - |
| 1746 | QToolBar *toolBar = toolbars.at(i); | - |
| 1747 | if (toolBar->parentWidget() == this | - |
| 1748 | && (!d->layout->layoutState.toolBarAreaLayout.indexOf(toolBar).isEmpty())) { | - |
| 1749 | menu->addAction(toolbars.at(i)->toggleViewAction()); | - |
| 1750 | } | - |
| 1751 | } | - |
| 1752 | } | - |
| 1753 | #endif | - |
| 1754 | Q_UNUSED(d); | - |
| 1755 | return menu; | - |
| 1756 | } | - |
| 1757 | #endif // QT_NO_MENU | - |
| 1758 | | - |
| 1759 | QT_END_NAMESPACE | - |
| 1760 | | - |
| 1761 | #include "moc_qmainwindow.cpp" | - |
| 1762 | | - |
| 1763 | #endif // QT_NO_MAINWINDOW | - |
| | |