⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q3dockwindow.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        horHandle->hide();        verHandle->hide();        if (moveEnabled)            titleBar->show();        else            titleBar->hide();        titleBar->updateGui();        hHandleTop->hide();        vHandleLeft->hide();        hHandleBottom->hide();        vHandleRight->hide();        setLineWidth(2);        widgetResizeHandler->setActive(isResizeEnabled());    } else {        hbox->setMargin(0);        titleBar->hide();        if (orientation() == Qt::Horizontal) {            horHandle->hide();            if (moveEnabled)                verHandle->show();            else                verHandle->hide();#ifdef Q_WS_MAC            if(horHandle->mousePressed) {                horHandle->mousePressed = false;                verHandle->mousePressed = true;                verHandle->grabMouse();            }#endif            verHandle->updateGui();        } else {            if (moveEnabled)                horHandle->show();            else                horHandle->hide();            horHandle->updateGui();#ifdef Q_WS_MAC            if(verHandle->mousePressed) {                verHandle->mousePressed = false;                horHandle->mousePressed = true;                horHandle->grabMouse();            }#endif            verHandle->hide();        }        if (isResizeEnabled()) {            if (orientation() == Qt::Horizontal) {                hHandleBottom->raise();                hHandleTop->raise();            } else {                vHandleRight->raise();                vHandleLeft->raise();            }            if (area()) {                if (orientation() == Qt::Horizontal) {                    if (area()->handlePosition() == Q3DockArea::Normal) {                        hHandleBottom->show();                        hHandleTop->hide();                    } else {                        hHandleTop->show();                        hHandleBottom->hide();                    }                    if (!area()->isLastDockWindow(this))                        vHandleRight->show();                    else                        vHandleRight->hide();                    vHandleLeft->hide();                } else {                    if ((area()->handlePosition() == Q3DockArea::Normal) != QApplication::reverseLayout()) {                        vHandleRight->show();                        vHandleLeft->hide();                    } else {                        vHandleLeft->show();                        vHandleRight->hide();                    }                    if (!area()->isLastDockWindow(this))                        hHandleBottom->show();                    else                        hHandleBottom->hide();                    hHandleTop->hide();                }            }        }#ifndef Q_OS_TEMP        if (moveEnabled)            setLineWidth(1);        else            setLineWidth(0);#endif        widgetResizeHandler->setActive(false);    }}void Q3DockWindow::updatePosition(const QPoint &globalPos){    if (curPlace == OutsideDock && state == InDock)        lastSize = size();    bool doAdjustSize = curPlace != state && state == OutsideDock;    bool doUpdate = true;    bool doOrientationChange = true;    if (state != curPlace && state == InDock) {        doUpdate = false;        curPlace = state;        updateGui();        QApplication::sendPostedEvents();    }    Qt::Orientation oo = orientation();    if (state == InDock) {        if (tmpDockArea) {            bool differentDocks = false;            if (dockArea && dockArea != tmpDockArea) {                differentDocks = true;                delete (Q3DockArea::DockWindowData*)dockWindowData;                dockWindowData = dockArea->dockWindowData(this);                dockArea->removeDockWindow(this, false, false);            }            dockArea = tmpDockArea;            if (differentDocks) {                if (doUpdate) {                    doUpdate = false;                    curPlace = state;                    updateGui();                }                emit orientationChanged(tmpDockArea->orientation());                doOrientationChange = false;            } else {                updateGui();            }            dockArea->moveDockWindow(this, globalPos, currRect, startOrientation != oo);        }    } else {        if (dockArea) {            Q3MainWindow *mw = (Q3MainWindow*)dockArea->parentWidget();            if (qobject_cast<Q3MainWindow*>(mw) &&                 (!mw->isDockEnabled(Qt::DockTornOff) ||                   !mw->isDockEnabled(this, Qt::DockTornOff)))                return;            delete (Q3DockArea::DockWindowData*)dockWindowData;            dockWindowData = dockArea->dockWindowData(this);            dockArea->removeDockWindow(this, true,                startOrientation != Qt::Horizontal && qobject_cast<Q3ToolBar*>(this));        }        dockArea = 0;        QPoint topLeft = currRect.topLeft();        QRect screen = qApp->desktop()->availableGeometry(topLeft);        if (!screen.contains(topLeft)) {            topLeft.setY(qMax(topLeft.y(), screen.top()));            topLeft.setY(qMin(topLeft.y(), screen.bottom()-height()));            topLeft.setX(qMax(topLeft.x(), screen.left()));            topLeft.setX(qMin(topLeft.x(), screen.right()-width()));        }        move(topLeft);    }    if (curPlace == InDock && state == OutsideDock && !qobject_cast<Q3ToolBar*>(this)) {        if (lastSize != QSize(-1, -1))            resize(lastSize);    }    if (doUpdate) {        curPlace = state;        updateGui();    }    if (doOrientationChange)        emit orientationChanged(orientation());    tmpDockArea = 0;    if (doAdjustSize) {        QApplication::sendPostedEvents(this, QEvent::LayoutHint);        if (qobject_cast<Q3ToolBar*>(this))            adjustSize();        if (lastSize == QSize(-1, -1))            setAttribute(Qt::WA_Resized, false); // Ensures size is recalculated (non-opaque).        show();        if (parentWidget() && isWindow())            parentWidget()->setActiveWindow();    }    emit placeChanged(curPlace);}/*!    Sets the dock window's main widget to \a w.    \sa boxLayout()*/void Q3DockWindow::setWidget(QWidget *w){    wid = w;    boxLayout()->addWidget(w);    updateGui();}/*!    Returns the dock window's main widget.    \sa setWidget()*/QWidget *Q3DockWindow::widget() const{    return wid;}void Q3DockWindow::startRectDraw(const QPoint &so, bool drawRect){    state = place();    if (rubberBand)        endRectDraw(!opaque);    rubberBand = new QRubberBand(QRubberBand::Rectangle);    currRect = QRect(realWidgetPos(this), size());    if (drawRect) {        rubberBand->setGeometry(currRect);    }    startOrientation = orientation();    startOffset = mapFromGlobal(so);    rubberBand->show();}void Q3DockWindow::endRectDraw(bool){    delete rubberBand;    rubberBand = 0;}/*!  \reimp*/void Q3DockWindow::drawFrame(QPainter *p){    if (place() == InDock) {        Q3Frame::drawFrame(p);        return;    }    QStyleOptionFrame opt;    opt.rect = rect();    opt.palette = palette();    opt.state = QStyle::State_None;    if (titleBar->isActive())        opt.state |= QStyle::State_Active;    opt.lineWidth = lineWidth();    opt.midLineWidth = midLineWidth();    style()->drawPrimitive(QStyle::PE_FrameWindow, &opt, p, this);}/*!  \reimp*/void Q3DockWindow::drawContents(QPainter *p){    // This is only used by the PocketPC style. We probably need to revist later.    QStyleOption opt(0, QStyleOption::SO_Default);    opt.init(this);    if (titleBar->isActive())        opt.state |= QStyle::State_Active;    style()->drawControl(QStyle::CE_Q3DockWindowEmptyArea, &opt, p, this);}/*!    \property Q3DockWindow::resizeEnabled    \brief whether the dock window is resizeable    A resizeable dock window can be resized using splitter-like    handles inside a dock area and like every other top level window    when floating.    A dock window is both horizontally and vertically stretchable if    you call setResizeEnabled(true).    This property is false by default.    \sa setVerticallyStretchable() setHorizontallyStretchable()*/void Q3DockWindow::setResizeEnabled(bool b){    resizeEnabled = b;    updateGui();}/*!    \property Q3DockWindow::movingEnabled    \brief whether the user can move the dock window within the dock    area, move the dock window to another dock area, or float the dock    window.    This property is true by default.*/void Q3DockWindow::setMovingEnabled(bool b){    moveEnabled = b;    updateGui();}bool Q3DockWindow::isResizeEnabled() const{    return resizeEnabled;}bool Q3DockWindow::isMovingEnabled() const{    return moveEnabled;}/*!    \property Q3DockWindow::closeMode    \brief the close mode of a dock window    Defines when (if ever) the dock window has a close button. The    choices are \c Never, \c Docked (i.e. only when docked), \c    Undocked (only when undocked, i.e. floated) or \c Always.    The default is \c Never.*/void Q3DockWindow::setCloseMode(int m){    cMode = m;    if (place() == InDock) {        horHandle->updateGui();        verHandle->updateGui();    } else {        titleBar->updateGui();    }}/*!    Returns true if the dock window has a close button; otherwise    returns false. The result depends on the dock window's \l Place    and its \l CloseMode.    \sa setCloseMode()*/bool Q3DockWindow::isCloseEnabled() const{    return  ((cMode & Docked) == Docked && place() == InDock ||              (cMode & Undocked) == Undocked && place() == OutsideDock);}int Q3DockWindow::closeMode() const{    return cMode;}/*!    \property Q3DockWindow::horizontallyStretchable    \brief whether the dock window is horizontally stretchable.    A dock window is horizontally stretchable if you call    setHorizontallyStretchable(true) or setResizeEnabled(true).    \warning Stretchability is broken. You must call    setResizeEnabled(true) to get proper behavior and even then    Q3DockWindow does not limit stretchablilty.    \sa setResizeEnabled()*/void Q3DockWindow::setHorizontallyStretchable(bool b){    stretchable[Qt::Horizontal] = b;}/*!    \property Q3DockWindow::verticallyStretchable    \brief whether the dock window is vertically stretchable.    A dock window is vertically stretchable if you call    setVerticallyStretchable(true) or setResizeEnabled(true).    \sa setResizeEnabled()    \warning Stretchability is broken. You must call    setResizeEnabled(true) to get proper behavior and even then    Q3DockWindow does not limit stretchablilty.*/void Q3DockWindow::setVerticallyStretchable(bool b){    stretchable[Qt::Vertical] = b;}bool Q3DockWindow::isHorizontallyStretchable() const{    return isResizeEnabled() || stretchable[Qt::Horizontal];}bool Q3DockWindow::isVerticallyStretchable() const{    return isResizeEnabled() || stretchable[Qt::Vertical];}/*!    \property Q3DockWindow::stretchable    \brief whether the dock window is stretchable in the current    orientation()    This property can be set using setHorizontallyStretchable() and    setVerticallyStretchable(), or with setResizeEnabled().    \warning Stretchability is broken. You must call    setResizeEnabled(true) to get proper behavior and even then    Q3DockWindow does not limit stretchablilty.    \sa setResizeEnabled()*/bool Q3DockWindow::isStretchable() const{    if (orientation() == Qt::Horizontal)        return isHorizontallyStretchable();    return isVerticallyStretchable();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -