/*! \reimp */ bool QDockWidget::event(QEvent *event) { Q_D(QDockWidget); QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); QMainWindowLayout *layout = qt_mainwindow_layout(win); switch (event->type()) { #ifndef QT_NO_ACTION case QEvent::Hide: if (layout != 0) layout->keepSize(this); d->toggleViewAction->setChecked(false); emit visibilityChanged(false); break; case QEvent::Show: d->toggleViewAction->setChecked(true); emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0); break; #endif case QEvent::ApplicationLayoutDirectionChange: case QEvent::LayoutDirectionChange: case QEvent::StyleChange: case QEvent::ParentChange: d->updateButtons(); break; case QEvent::ZOrderChange: { bool onTop = false; if (win != 0) { const QObjectList &siblings = win->children(); onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; } if (!isFloating() && layout != 0 && onTop) layout->raise(this); break; } case QEvent::WindowActivate: case QEvent::WindowDeactivate: update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea()); break; case QEvent::ContextMenu: if (d->state) { event->accept(); return true; } break; // return true after calling the handler since we don't want // them to be passed onto the default handlers case QEvent::MouseButtonPress: if (d->mousePressEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::MouseButtonDblClick: if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::MouseMove: if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event))) return true; break; #ifdef Q_OS_WIN case QEvent::Leave: if (d->state != 0 && d->state->dragging && !d->state->nca) { // This is a workaround for loosing the mouse on Vista. QPoint pos = QCursor::pos(); QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton, QApplication::mouseButtons(), QApplication::keyboardModifiers()); d->mouseMoveEvent(&fake); } break; #endif case QEvent::MouseButtonRelease: if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::NonClientAreaMouseMove: case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonRelease: case QEvent::NonClientAreaMouseButtonDblClick: d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event)); return true; case QEvent::Move: d->moveEvent(static_cast<QMoveEvent*>(event)); break; case QEvent::Resize: // if the mainwindow is plugging us, we don't want to update undocked geometry if (isFloating() && layout != 0 && layout->pluggingWidget != this) d->undockedGeometry = geometry(); break; default: break; } return QWidget::event(event); }
/*! \reimp */ bool QDockWidget::event(QEvent *event) { Q_D(QDockWidget); QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); QMainWindowLayout *layout = qt_mainwindow_layout(win); switch (event->type()) { #ifndef QT_NO_ACTION case QEvent::Hide: if (layout != 0) layout->keepSize(this); d->toggleViewAction->setChecked(false); emit visibilityChanged(false); break; case QEvent::Show: { d->toggleViewAction->setChecked(true); const QPoint parentTopLeft = isWindow() ? QApplication::desktop()->availableGeometry(this).topLeft() : QPoint(0, 0); emit visibilityChanged(geometry().right() >= parentTopLeft.x() && geometry().bottom() >= parentTopLeft.y()); } break; #endif case QEvent::ApplicationLayoutDirectionChange: case QEvent::LayoutDirectionChange: case QEvent::StyleChange: case QEvent::ParentChange: d->updateButtons(); break; case QEvent::ZOrderChange: { bool onTop = false; if (win != 0) { const QObjectList &siblings = win->children(); onTop = siblings.count() > 0 && siblings.last() == (QObject*)this; } if (!isFloating() && layout != 0 && onTop) layout->raise(this); break; } case QEvent::WindowActivate: case QEvent::WindowDeactivate: update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea()); break; case QEvent::ContextMenu: if (d->state) { event->accept(); return true; } break; // return true after calling the handler since we don't want // them to be passed onto the default handlers case QEvent::MouseButtonPress: if (d->mousePressEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::MouseButtonDblClick: if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::MouseMove: if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::MouseButtonRelease: if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event))) return true; break; case QEvent::NonClientAreaMouseMove: case QEvent::NonClientAreaMouseButtonPress: case QEvent::NonClientAreaMouseButtonRelease: case QEvent::NonClientAreaMouseButtonDblClick: d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event)); return true; case QEvent::Move: d->moveEvent(static_cast<QMoveEvent*>(event)); break; case QEvent::Resize: // if the mainwindow is plugging us, we don't want to update undocked geometry if (isFloating() && layout != 0 && layout->pluggingWidget != this) d->undockedGeometry = geometry(); break; default: break; } return QWidget::event(event); }