void QToolBarPrivate::endDrag() { Q_Q(QToolBar); Q_ASSERT(state != 0); q->releaseMouse(); if (state->dragging) { QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); Q_ASSERT(layout != 0); if (!layout->plug(state->widgetItem)) { if (q->isFloatable()) { layout->restore(); #if defined(Q_WS_X11) || defined(Q_WS_MAC) setWindowState(true); // gets rid of the X11BypassWindowManager window flag // and activates the resizer #endif q->activateWindow(); } else { layout->revert(state->widgetItem); } } } delete state; state = 0; }
void QDockWidgetPrivate::startDrag() { Q_Q(QDockWidget); if (state == 0 || state->dragging) return; QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); state->widgetItem = layout->unplug(q); if (state->widgetItem == 0) { /* I have a QMainWindow parent, but I was never inserted with QMainWindow::addDockWidget, so the QMainWindowLayout has no widget item for me. :( I have to create it myself, and then delete it if I don't get dropped into a dock area. */ state->widgetItem = new QDockWidgetItem(q); state->ownWidgetItem = true; } if (state->ctrlDrag) layout->restore(); state->dragging = true; }
/*! \internal */ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const { Q_D(const QToolBar); if (!option) return; option->initFrom(this); if (orientation() == Qt::Horizontal) option->state |= QStyle::State_Horizontal; option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this); option->features = d->layout->movable() ? QStyleOptionToolBar::Movable : QStyleOptionToolBar::None; // if the tool bar is not in a QMainWindow, this will make the painting right option->toolBarArea = Qt::NoToolBarArea; // Add more styleoptions if the toolbar has been added to a mainwindow. QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget()); if (!mainWindow) return; QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(mainWindow->layout()); Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()", "QMainWindow->layout() != QMainWindowLayout"); layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this)); }
void QToolBarPrivate::startDrag(bool moving) { Q_Q(QToolBar); Q_ASSERT(state != 0); if ((moving && state->moving) || state->dragging) return; QMainWindow *win = qobject_cast<QMainWindow*>(parent); Q_ASSERT(win != 0); QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); Q_ASSERT(layout != 0); if (!moving) { state->widgetItem = layout->unplug(q); #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) if (q->isWindow()) { setWindowState(true, true); //set it to floating } #endif Q_ASSERT(state->widgetItem != 0); } state->dragging = !moving; state->moving = moving; }
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) { Q_Q(QDockWidget); if (!floating && parent) { QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) return; // this dockwidget can't be redocked } bool wasFloating = q->isFloating(); bool hidden = q->isHidden(); if (q->isVisible()) q->hide(); Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); const bool nativeDeco = dwLayout->nativeWindowDeco(floating); if (nativeDeco) { flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; if (hasFeature(this, QDockWidget::DockWidgetClosable)) flags |= Qt::WindowCloseButtonHint; } else { flags |= Qt::FramelessWindowHint; } if (unplug) flags |= Qt::X11BypassWindowManagerHint; q->setWindowFlags(flags); #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) { ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0); } #endif if (!rect.isNull()) q->setGeometry(rect); updateButtons(); if (!hidden) q->show(); if (floating != wasFloating) { emit q->topLevelChanged(floating); if (!floating && parent) { QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); } } resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco); }
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) { Q_Q(QDockWidget); if (!floating && parent) { QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) return; // this dockwidget can't be redocked } bool wasFloating = q->isFloating(); bool hidden = q->isHidden(); if (q->isVisible()) q->hide(); Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); const bool nativeDeco = dwLayout->nativeWindowDeco(floating); if (nativeDeco) { flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; if (hasFeature(this, QDockWidget::DockWidgetClosable)) flags |= Qt::WindowCloseButtonHint; } else { flags |= Qt::FramelessWindowHint; } if (unplug) flags |= Qt::X11BypassWindowManagerHint; q->setWindowFlags(flags); if (!rect.isNull()) q->setGeometry(rect); updateButtons(); if (!hidden) q->show(); if (floating != wasFloating) { emit q->topLevelChanged(floating); if (!floating && parent) { QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); } } if (floating && nativeDeco) if (const QWindow *window = q->windowHandle()) if (QPlatformWindow *platformWindow = window->handle()) platformWindow->setFrameStrutEventsEnabled(true); resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco); }
void QDockWidgetPrivate::moveEvent(QMoveEvent *event) { Q_Q(QDockWidget); if (state == 0 || !state->dragging || !state->nca || !q->isWindow()) return; // When the native window frame is being dragged, all we get is these mouse // move events. if (state->ctrlDrag) return; QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); QPoint globalMousePos = event->pos() + state->pressPos; layout->hover(state->widgetItem, globalMousePos); }
bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) { bool ret = false; #if !defined(QT_NO_MAINWINDOW) Q_Q(QDockWidget); if (!state) return ret; QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout); QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout()); if (!dwlayout->nativeWindowDeco()) { if (!state->dragging && mwlayout->pluggingWidget == 0 && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { startDrag(); #ifdef Q_OS_WIN grabMouseWhileInWindow(); #else q->grabMouse(); #endif ret = true; } } if (state->dragging && !state->nca) { QPoint pos = event->globalPos() - state->pressPos; q->move(pos); if (!state->ctrlDrag) mwlayout->hover(state->widgetItem, event->globalPos()); ret = true; } #endif // !defined(QT_NO_MAINWINDOW) return ret; }
void QToolBarPrivate::startDrag(bool moving) { Q_Q(QToolBar); Q_ASSERT(state != 0); if ((moving && state->moving) || state->dragging) return; QMainWindow *win = qobject_cast<QMainWindow*>(parent); Q_ASSERT(win != 0); QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (!moving) { state->widgetItem = layout->unplug(q); Q_ASSERT(state->widgetItem != 0); } state->dragging = !moving; state->moving = moving; }
void QDockWidgetPrivate::endDrag(bool abort) { Q_Q(QDockWidget); Q_ASSERT(state != 0); q->releaseMouse(); if (state->dragging) { QMainWindowLayout *mwLayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); Q_ASSERT(mwLayout != 0); if (abort || !mwLayout->plug(state->widgetItem)) { if (hasFeature(this, QDockWidget::DockWidgetFloatable)) { if (state->ownWidgetItem) delete state->widgetItem; mwLayout->restore(); #ifdef Q_WS_X11 // get rid of the X11BypassWindowManager window flag and activate the resizer Qt::WindowFlags flags = q->windowFlags(); flags &= ~Qt::X11BypassWindowManagerHint; q->setWindowFlags(flags); resizer->setActive(QWidgetResizeHandler::Resize, true); q->show(); #else QDockWidgetLayout *myLayout = qobject_cast<QDockWidgetLayout*>(layout); resizer->setActive(QWidgetResizeHandler::Resize, myLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0); #endif undockedGeometry = q->geometry(); q->activateWindow(); } else { mwLayout->revert(state->widgetItem); } } } delete state; state = 0; }
void QRasterWindowSurface::setGeometry(const QRect &rect) { QWindowSurface::setGeometry(rect); Q_D(QRasterWindowSurface); d->inSetGeometry = true; if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height()) { #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN)) #ifndef Q_WS_WIN if (d_ptr->translucentBackground) #else if (!qt_widget_private(window())->isOpaque) #endif prepareBuffer(QImage::Format_ARGB32_Premultiplied, window()); else #endif prepareBuffer(QNativeImage::systemFormat(), window()); } d->inSetGeometry = false; #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) QMainWindow* mWindow = qobject_cast<QMainWindow*>(window()); if (mWindow) { QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout()); QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList; for (int i = 0; i < toolbarList.size(); ++i) { QToolBar* toolbar = toolbarList.at(i); if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) { QWidget* tbWidget = (QWidget*) toolbar; if (tbWidget->d_func()->unifiedSurface) { tbWidget->d_func()->unifiedSurface->setGeometry(rect); } } } } #endif // Q_WS_MAC && QT_MAC_USE_COCOA }
void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) { Q_Q(QDockWidget); int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q); QRect geo = q->geometry(); QRect titleRect = q->frameGeometry(); #ifdef Q_WS_MAC if ((features & QDockWidget::DockWidgetVerticalTitleBar)) { titleRect.setTop(geo.top()); titleRect.setBottom(geo.bottom()); titleRect.setRight(geo.left() - 1); } else #endif { titleRect.setLeft(geo.left()); titleRect.setRight(geo.right()); titleRect.setBottom(geo.top() - 1); titleRect.adjust(0, fw, 0, 0); } switch (event->type()) { case QEvent::NonClientAreaMouseButtonPress: if (!titleRect.contains(event->globalPos())) break; if (state != 0) break; if (qobject_cast<QMainWindow*>(parent) == 0) break; if (isAnimating()) break; initDrag(event->pos(), true); if (state == 0) break; #ifdef Q_WS_WIN // On Windows, NCA mouse events don't contain modifier info state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000; #else state->ctrlDrag = event->modifiers() & Qt::ControlModifier; #endif startDrag(); break; case QEvent::NonClientAreaMouseMove: if (state == 0 || !state->dragging) break; if (state->nca) { endDrag(); } #ifdef Q_OS_MAC else { // workaround for lack of mouse-grab on Mac QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); q->move(event->globalPos() - state->pressPos); if (!state->ctrlDrag) layout->hover(state->widgetItem, event->globalPos()); } #endif break; case QEvent::NonClientAreaMouseButtonRelease: #ifdef Q_OS_MAC if (state) endDrag(); #endif break; case QEvent::NonClientAreaMouseButtonDblClick: _q_toggleTopLevel(); break; default: break; } }
/*! \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); }
void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget) { QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout()); if (mlayout) mlayout->updateUnifiedToolbarOffset(); }
/*! \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); }
bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) { Q_Q(QToolBar); if (!state) { #ifdef Q_WS_MAC if (!macWindowDragging) return false; QWidget *w = q->window(); const QPoint delta = event->pos() - macWindowDragPressPosition; w->move(w->pos() + delta); return true; #endif return false; } QMainWindow *win = qobject_cast<QMainWindow*>(parent); if (win == 0) return true; QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); Q_ASSERT(layout != 0); if (layout->pluggingWidget == 0 && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) { const bool wasDragging = state->dragging; const bool moving = !q->isWindow() && (orientation == Qt::Vertical ? event->x() >= 0 && event->x() < q->width() : event->y() >= 0 && event->y() < q->height()); startDrag(moving); if (!moving && !wasDragging) { #ifdef Q_OS_WIN grabMouseWhileInWindow(); #else q->grabMouse(); #endif } } if (state->dragging) { QPoint pos = event->globalPos(); // if we are right-to-left, we move so as to keep the right edge the same distance // from the mouse if (q->isLeftToRight()) pos -= state->pressPos; else pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y()); q->move(pos); layout->hover(state->widgetItem, event->globalPos()); } else if (state->moving) { const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos); int pos = 0; QPoint delta = event->globalPos() - globalPressPos; if (orientation == Qt::Vertical) { pos = q->y() + delta.y(); } else { if (q->isRightToLeft()) { pos = win->width() - q->width() - q->x() - delta.x(); } else { pos = q->x() + delta.x(); } } layout->moveToolBar(q, pos); } return true; }
/*! \reimp */ bool QToolBar::event(QEvent *event) { Q_D(QToolBar); switch (event->type()) { case QEvent::Timer: if (d->waitForPopupTimer.timerId() == static_cast<QTimerEvent*>(event)->timerId()) { QWidget *w = QApplication::activePopupWidget(); if (!waitForPopup(this, w)) { d->waitForPopupTimer.stop(); if (!this->underMouse()) d->layout->setExpanded(false); } } break; case QEvent::Hide: if (!isHidden()) break; // fallthrough intended case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); emit visibilityChanged(event->type() == QEvent::Show); #if defined(Q_WS_MAC) if (toolbarInUnifiedToolBar(this)) { // I can static_cast because I did the qobject_cast in the if above, therefore // we must have a QMainWindowLayout here. QMainWindowLayout *mwLayout = static_cast<QMainWindowLayout *>(parentWidget()->layout()); mwLayout->fixSizeInUnifiedToolbar(this); mwLayout->syncUnifiedToolbarVisibility(); } # if !defined(QT_MAC_USE_COCOA) // Fall through case QEvent::LayoutRequest: { // There's currently no way to invalidate the size and let // HIToolbar know about it. This forces a re-check. int earlyResult = -1; if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget())) { bool needUpdate = true; if (event->type() == QEvent::LayoutRequest) { QSize oldSizeHint = sizeHint(); earlyResult = QWidget::event(event) ? 1 : 0; needUpdate = oldSizeHint != sizeHint(); } if (needUpdate) { OSWindowRef windowRef = qt_mac_window_for(mainWindow); if (toolbarInUnifiedToolBar(this) && macWindowToolbarIsVisible(windowRef)) { DisableScreenUpdates(); macWindowToolbarShow(this, false); macWindowToolbarShow(this, true); EnableScreenUpdates(); } } if (earlyResult != -1) return earlyResult; } } # endif // !QT_MAC_USE_COCOA #endif // Q_WS_MAC break; case QEvent::ParentChange: d->layout->checkUsePopupMenu(); #if defined(Q_WS_MAC) if (parentWidget() && parentWidget()->isWindow()) qt_mac_updateToolBarButtonHint(parentWidget()); #endif break; case QEvent::MouseButtonPress: { if (d->mousePressEvent(static_cast<QMouseEvent*>(event))) return true; break; } case QEvent::MouseButtonRelease: if (d->mouseReleaseEvent(static_cast<QMouseEvent*>(event))) return true; break; case QEvent::HoverEnter: case QEvent::HoverLeave: // there's nothing special to do here and we don't want to update the whole widget return true; case QEvent::HoverMove: { #ifndef QT_NO_CURSOR QHoverEvent *e = static_cast<QHoverEvent*>(event); QStyleOptionToolBar opt; initStyleOption(&opt); if (style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, this).contains(e->pos())) setCursor(Qt::SizeAllCursor); else unsetCursor(); #endif break; } case QEvent::MouseMove: if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event))) return true; break; #ifdef Q_WS_WINCE case QEvent::ContextMenu: { QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event); QWidget* child = childAt(contextMenuEvent->pos()); QAbstractButton* button = qobject_cast<QAbstractButton*>(child); if (button) button->setDown(false); } break; #endif case QEvent::Leave: if (d->state != 0 && d->state->dragging) { #ifdef Q_OS_WIN // 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); #endif } else { if (!d->layout->expanded) break; QWidget *w = QApplication::activePopupWidget(); if (waitForPopup(this, w)) { d->waitForPopupTimer.start(POPUP_TIMER_INTERVAL, this); break; } d->waitForPopupTimer.stop(); d->layout->setExpanded(false); break; } default: break; } return QWidget::event(event); }