void QDockWidgetPrivate::updateButtons() { Q_Q(QDockWidget); QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); QStyleOptionDockWidget opt; q->initStyleOption(&opt); bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; bool nativeDeco = dwLayout->nativeWindowDeco(); bool hideButtons = nativeDeco || customTitleBar; bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable); bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable); QAbstractButton *button = qobject_cast<QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::FloatButton)); button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q)); button->setVisible(canFloat && !hideButtons); button = qobject_cast <QAbstractButton*>(dwLayout->widgetForRole(QDockWidgetLayout::CloseButton)); button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q)); button->setVisible(canClose && !hideButtons); q->setAttribute(Qt::WA_ContentsPropagated, (canFloat || canClose) && !hideButtons); layout->invalidate(); }
/*! \reimp */ void QDockWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; bool nativeDeco = layout->nativeWindowDeco(); if (!nativeDeco && !customTitleBar) { QStylePainter p(this); // ### Add PixelMetric to change spacers, so style may show border // when not floating. if (isFloating()) { QStyleOptionFrame framOpt; framOpt.init(this); p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt); } // Title must be painted after the frame, since the areas overlap, and // the title may wish to extend out to all sides (eg. XP style) QStyleOptionDockWidgetV2 titleOpt; initStyleOption(&titleOpt); p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt); } }
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; }
QWidget *QDockWidget::titleBarWidget() const { QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); return layout->widgetForRole(QDockWidgetLayout::TitleBar); }
/*! Returns the widget for the dock widget. This function returns zero if the widget has not been set. \sa setWidget() */ QWidget *QDockWidget::widget() const { QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); return layout->widgetForRole(QDockWidgetLayout::Content); }