VirtualBox

Changeset 52402 in vbox


Ignore:
Timestamp:
Aug 18, 2014 6:38:06 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95564
Message:

FE/Qt: Runtime UI: Sliding tool-bar: Top/bottom position support.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISlidingToolBar.cpp

    r52389 r52402  
    2929#endif /* Q_WS_MAC */
    3030
    31 UISlidingToolBar::UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget)
     31UISlidingToolBar::UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position position)
    3232    : QWidget(pParentWidget, Qt::Tool | Qt::FramelessWindowHint)
     33    , m_position(position)
    3334    , m_parentRect(pParentWidget->geometry())
    3435    , m_indentRect(pIndentWidget->geometry())
     
    128129void UISlidingToolBar::prepareGeometry()
    129130{
    130     /* Prepare geometry based on parent and mdi-sub-window size-hints: */
     131    /* Prepare geometry based on parent and mdi-sub-window size-hints,
     132     * But move mdi-sub-window to initial position: */
    131133    const QSize sh = m_pEmbeddedWidget->sizeHint();
    132     setGeometry(m_parentRect.x(), m_parentRect.y() + m_parentRect.height() - m_indentRect.height() - sh.height(),
    133                 qMax(m_parentRect.width(), sh.width()), sh.height());
    134     /* But move mdi-sub-window to initial position: */
    135     m_pEmbeddedWidget->setGeometry(0, sh.height(), qMax(width(), sh.width()), sh.height());
     134    switch (m_position)
     135    {
     136        case Position_Top:
     137        {
     138            setGeometry(m_parentRect.x(), m_parentRect.y()                         + m_indentRect.height(),
     139                        qMax(m_parentRect.width(), sh.width()), sh.height());
     140            m_pEmbeddedWidget->setGeometry(0, -sh.height(), qMax(width(), sh.width()), sh.height());
     141            break;
     142        }
     143        case Position_Bottom:
     144        {
     145            setGeometry(m_parentRect.x(), m_parentRect.y() + m_parentRect.height() - m_indentRect.height() - sh.height(),
     146                        qMax(m_parentRect.width(), sh.width()), sh.height());
     147            m_pEmbeddedWidget->setGeometry(0,  sh.height(), qMax(width(), sh.width()), sh.height());
     148            break;
     149        }
     150    }
    136151
    137152#ifdef Q_WS_X11
     
    171186    /* Adjust geometry based on parent and mdi-sub-window size-hints: */
    172187    const QSize sh = m_pEmbeddedWidget->sizeHint();
    173     setGeometry(m_parentRect.x(), m_parentRect.y() + m_parentRect.height() - m_indentRect.height() - sh.height(),
    174                 qMax(m_parentRect.width(), sh.width()), sh.height());
     188    switch (m_position)
     189    {
     190        case Position_Top:
     191        {
     192            setGeometry(m_parentRect.x(), m_parentRect.y()                         + m_indentRect.height(),
     193                        qMax(m_parentRect.width(), sh.width()), sh.height());
     194            break;
     195        }
     196        case Position_Bottom:
     197        {
     198            setGeometry(m_parentRect.x(), m_parentRect.y() + m_parentRect.height() - m_indentRect.height() - sh.height(),
     199                        qMax(m_parentRect.width(), sh.width()), sh.height());
     200            break;
     201        }
     202    }
    175203    /* And move mdi-sub-window to corresponding position: */
    176204    m_pEmbeddedWidget->setGeometry(0, 0, qMax(width(), sh.width()), sh.height());
     
    195223    /* Recalculate mdi-sub-window geometry animation boundaries based on size-hint: */
    196224    const QSize sh = m_pEmbeddedWidget->sizeHint();
    197     m_startWidgetGeometry = QRect(0, sh.height(), qMax(width(), sh.width()), sh.height());
    198     m_finalWidgetGeometry = QRect(0,           0, qMax(width(), sh.width()), sh.height());
     225    switch (m_position)
     226    {
     227        case Position_Top:    m_startWidgetGeometry = QRect(0, -sh.height(), qMax(width(), sh.width()), sh.height()); break;
     228        case Position_Bottom: m_startWidgetGeometry = QRect(0,  sh.height(), qMax(width(), sh.width()), sh.height()); break;
     229    }
     230    m_finalWidgetGeometry = QRect(0, 0, qMax(width(), sh.width()), sh.height());
    199231    m_pAnimation->update();
    200232}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISlidingToolBar.h

    r52389 r52402  
    4747public:
    4848
     49    /** Possible positions. */
     50    enum Position
     51    {
     52        Position_Top,
     53        Position_Bottom
     54    };
     55
    4956    /** Constructor, passes @a pParentWidget to the QWidget constructor.
    5057      * @param pParentWidget is used to get parent-widget geoemtry,
    5158      * @param pIndentWidget is used to get indent-widget geometry,
    5259      * @param pChildWidget  brings child-widget to be injected into tool-bar. */
    53     UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget);
     60    UISlidingToolBar(QWidget *pParentWidget, QWidget *pIndentWidget, QWidget *pChildWidget, Position position);
    5461
    5562private slots:
     
    98105    /** @name Geometry
    99106      * @{ */
     107        /** Holds the tool-bar position. */
     108        const Position m_position;
    100109        /** Holds the cached parent-widget geometry. */
    101110        QRect m_parentRect;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIStatusBarEditorWindow.cpp

    r52389 r52402  
    118118public:
    119119
    120     /** Constructor, passes @a pParent to the QWidget constructor.
    121       * @param rect is used to define initial cached parent geometry.
    122       * @param statusBarRect is used to define initial cached status-bar geometry. */
     120    /** Constructor, passes @a pParent to the QWidget constructor. */
    123121    UIStatusBarEditorWidget(QWidget *pParent = 0);
    124122
     
    445443    connect(gEDataManager, SIGNAL(sigStatusBarConfigurationChange()),
    446444            this, SLOT(sltHandleConfigurationChange()));
     445
    447446    /* Update status buttons: */
    448447    updateStatusButtons();
     
    546545    }
    547546
     547    /* Paint shape/shadow: */
     548    painter.fillRect(QRect(5, 5, width() - 5 * 2, height() - 5), color0); // background
     549    painter.fillRect(QRect(0,           0, 5, 5), grad1); // left corner
     550    painter.fillRect(QRect(width() - 5, 0, 5, 5), grad2); // right corner
     551    painter.fillRect(QRect(5, 0, width() - 5 * 2, 5), grad3); // bottom line
     552    painter.fillRect(QRect(0,           5, 5, height() - 5), grad4); // left line
     553    painter.fillRect(QRect(width() - 5, 5, 5, height() - 5), grad5); // right line
     554
     555#if defined(Q_WS_WIN) || defined(Q_WS_X11)
    548556    /* Paint frames: */
    549     painter.fillRect(QRect(5, 5, width() - 5 * 2, height() - 5), color0);
    550     painter.fillRect(QRect(0, 0, 5, 5), grad1);
    551     painter.fillRect(QRect(width() - 5, 0, 5, 5), grad2);
    552     painter.fillRect(QRect(5, 0, width() - 5 * 2, 5), grad3);
    553     painter.fillRect(QRect(0, 5, 5, height() - 5), grad4);
    554     painter.fillRect(QRect(width() - 5, 5, 5, height() - 5), grad5);
    555 #if defined(Q_WS_WIN) || defined(Q_WS_X11)
    556557    painter.save();
    557558    painter.setPen(color3);
     
    695696
    696697UIStatusBarEditorWindow::UIStatusBarEditorWindow(UIMachineWindow *pParent)
    697     : UISlidingToolBar(pParent, pParent->statusBar(), new UIStatusBarEditorWidget)
     698    : UISlidingToolBar(pParent, pParent->statusBar(), new UIStatusBarEditorWidget, UISlidingToolBar::Position_Bottom)
    698699{
    699700}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette