예제 #1
0
파일: qdockwidget.cpp 프로젝트: phen89/rtqt
/*! \reimp */
void QDockWidget::changeEvent(QEvent *event)
{
    Q_D(QDockWidget);
    QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());

    switch (event->type()) {
    case QEvent::ModifiedChange:
    case QEvent::WindowTitleChange:
        update(layout->titleArea());
#ifndef QT_NO_ACTION
        d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this);
        d->toggleViewAction->setText(d->fixedWindowTitle);
#endif
#ifndef QT_NO_TABBAR
        {
            QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
            if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
                if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
                    info->updateTabBar();
            }
        }
#endif // QT_NO_TABBAR
        break;
    default:
        break;
    }
    QWidget::changeEvent(event);
}
예제 #2
0
파일: qdockwidget.cpp 프로젝트: phen89/rtqt
bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
{
#if !defined(QT_NO_MAINWINDOW)
    Q_Q(QDockWidget);

    QDockWidgetLayout *dwLayout
        = qobject_cast<QDockWidgetLayout*>(layout);

    if (!dwLayout->nativeWindowDeco()) {
        QRect titleArea = dwLayout->titleArea();

        if (event->button() != Qt::LeftButton ||
            !titleArea.contains(event->pos()) ||
            // check if the tool window is movable... do nothing if it
            // is not (but allow moving if the window is floating)
            (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
            qobject_cast<QMainWindow*>(parent) == 0 ||
            isAnimating() || state != 0) {
            return false;
        }

        initDrag(event->pos(), false);

        if (state)
            state->ctrlDrag = hasFeature(this, QDockWidget::DockWidgetFloatable) && event->modifiers() & Qt::ControlModifier;

        return true;
    }

#endif // !defined(QT_NO_MAINWINDOW)
    return false;
}
예제 #3
0
void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
    if (state != 0)
        return;

    Q_Q(QDockWidget);
    QMainWindow *win = qobject_cast<QMainWindow*>(parent);
    Q_ASSERT(win != 0);
    QMainWindowLayout *layout = qt_mainwindow_layout(win);
    Q_ASSERT(layout != 0);
    if (layout->pluggingWidget != 0) // the main window is animating a docking operation
        return;

    state = new QDockWidgetPrivate::DragState;
    state->dragging = false;
    state->widgetItem = 0;
    state->ownWidgetItem = false;
    state->nca = nca;
    state->ctrlDrag = false;

    if (!q->isFloating()) {
        // When dragging the widget out of the docking area,
        // use the middle of title area as pressPos
        QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(q->layout());
        Q_ASSERT(dwlayout != 0);
        int width = undockedGeometry.isNull() ? q->width() : undockedGeometry.width();
        state->pressPos.setY(dwlayout->titleArea().height() / 2);
        state->pressPos.setX(width / 2);
    } else {
        state->pressPos = pos;
    }
}
예제 #4
0
파일: qdockwidget.cpp 프로젝트: phen89/rtqt
bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
{
    QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);

    if (!dwLayout->nativeWindowDeco()) {
        QRect titleArea = dwLayout->titleArea();

        if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
            hasFeature(this, QDockWidget::DockWidgetFloatable)) {
            _q_toggleTopLevel();
            return true;
        }
    }
    return false;
}
예제 #5
0
void QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
{
    Q_Q(QDockWidget);

    QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());

    if (!layout->nativeWindowDeco()) {
        QRect titleArea = layout->titleArea();

        if (event->button() != Qt::LeftButton)
            return;
        if (!titleArea.contains(event->pos()))
            return;
        if (!::hasFeature(q, QDockWidget::DockWidgetFloatable))
            return;
        _q_toggleTopLevel();
    }
}
예제 #6
0
/*!
    \property QDockWidget::floating
    \brief whether the dock widget is floating

    A floating dock widget is presented to the user as an independent
    window "on top" of its parent QMainWindow, instead of being
    docked in the QMainWindow.

    \sa isWindow()
*/
void QDockWidget::setFloating(bool floating)
{
    Q_D(QDockWidget);

    // the initial click of a double-click may have started a drag...
    if (d->state != 0)
        d->endDrag(true);

    QRect r = d->undockedGeometry;

    if (floating && r.isNull()) {
        QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
        QRect titleArea = layout->titleArea();
        int h = layout->verticalTitleBar ? titleArea.width() : titleArea.height();
        QPoint p = mapToGlobal(QPoint(h, h));
        r = QRect(p, size());
    }

    d->setWindowState(floating, false, floating ? r : QRect());
}
예제 #7
0
파일: qdockwidget.cpp 프로젝트: phen89/rtqt
/*!
    Initialize \a option with the values from this QDockWidget. This method
    is useful for subclasses when they need a QStyleOptionDockWidget, but don't want
    to fill in all the information themselves.

    \sa QStyleOption::initFrom()
*/
void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
{
    Q_D(const QDockWidget);

    if (!option)
        return;
    QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(layout());

    option->initFrom(this);
    option->rect = dwlayout->titleArea();
    option->title = d->fixedWindowTitle;
    option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
    option->movable = hasFeature(this, QDockWidget::DockWidgetMovable);
    option->floatable = hasFeature(this, QDockWidget::DockWidgetFloatable);

    QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(layout());
    QStyleOptionDockWidgetV2 *v2
        = qstyleoption_cast<QStyleOptionDockWidgetV2*>(option);
    if (v2 != 0)
        v2->verticalTitleBar = l->verticalTitleBar;
}
예제 #8
0
void QDockWidgetPrivate::mousePressEvent(QMouseEvent *event)
{
#if !defined(QT_NO_MAINWINDOW)
    Q_Q(QDockWidget);

    QDockWidgetLayout *layout
        = qobject_cast<QDockWidgetLayout*>(q->layout());

    if (!layout->nativeWindowDeco()) {
        QRect titleArea = layout->titleArea();

        if (event->button() != Qt::LeftButton)
            return;
        if (!titleArea.contains(event->pos()))
            return;
        // check if the tool window is movable... do nothing if it is not
        if (!::hasFeature(q, QDockWidget::DockWidgetMovable))
            return;

        if (qobject_cast<QMainWindow*>(q->parentWidget()) == 0)
            return;

        if (isAnimating())
            return;

        if (state != 0)
            return;

        initDrag(event->pos(), false);

        if (state == 0)
            return;

        state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
    }

#endif // !defined(QT_NO_MAINWINDOW)
}