VirtualBox

Changeset 47644 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 9, 2013 1:40:03 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Popup-center: Support for popup-stack orientation (top/bottom) setting.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp

    r47626 r47644  
    125125    AssertPtrReturnVoid(pParent);
    126126
    127     /* Composing corresponding popup-stack: */
     127    /* Composing corresponding popup-stack ID: */
    128128    const QString strPopupStackID(popupStackID(pParent));
    129129
     
    141141                newStackType == UIPopupStackType_Separate ? "separate window" : "embedded widget"));
    142142    stackType = newStackType;
     143}
     144
     145void UIPopupCenter::setPopupStackOrientation(QWidget *pParent, UIPopupStackOrientation newStackOrientation)
     146{
     147    /* Make sure parent is set! */
     148    AssertPtrReturnVoid(pParent);
     149
     150    /* Composing corresponding popup-stack ID: */
     151    const QString strPopupStackID(popupStackID(pParent));
     152
     153    /* Looking for current popup-stack orientation, create if it doesn't exists: */
     154    UIPopupStackOrientation &stackOrientation = m_stackOrientations[strPopupStackID];
     155
     156    /* Make sure stack-orientation has changed: */
     157    if (stackOrientation == newStackOrientation)
     158        return;
     159
     160    /* Remember new stack orientation: */
     161    LogRelFlow(("UIPopupCenter::setPopupStackType: Changing orientation of popup-stack with ID = '%s' from '%s' to '%s'.\n",
     162                strPopupStackID.toAscii().constData(),
     163                stackOrientation == UIPopupStackOrientation_Top ? "top oriented" : "bottom oriented",
     164                newStackOrientation == UIPopupStackOrientation_Top ? "top oriented" : "bottom oriented"));
     165    stackOrientation = newStackOrientation;
     166
     167    /* Update orientation for popup-stack if it currently exists: */
     168    if (m_stacks.contains(strPopupStackID))
     169        m_stacks[strPopupStackID]->setOrientation(stackOrientation);
    143170}
    144171
     
    245272    {
    246273        /* Create new one: */
    247         pPopupStack = m_stacks[strPopupStackID] = new UIPopupStack(strPopupStackID);
     274        pPopupStack = m_stacks[strPopupStackID] = new UIPopupStack(strPopupStackID, m_stackOrientations[strPopupStackID]);
    248275        /* Attach popup-stack connections: */
    249276        connect(pPopupStack, SIGNAL(sigPopupPaneDone(QString, int)), this, SLOT(sltPopupPaneDone(QString, int)));
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h

    r47615 r47644  
    3636};
    3737
     38/* Popup-stack orientations: */
     39enum UIPopupStackOrientation
     40{
     41    UIPopupStackOrientation_Top,
     42    UIPopupStackOrientation_Bottom
     43};
     44
    3845/* Popup-center singleton: */
    3946class UIPopupCenter: public QObject
     
    5663    void hidePopupStack(QWidget *pParent);
    5764    void setPopupStackType(QWidget *pParent, UIPopupStackType newStackType);
     65    void setPopupStackOrientation(QWidget *pParent, UIPopupStackOrientation newStackOrientation);
    5866
    5967    /* API: Main message function.
     
    130138    /* Variables: Popup-stack stuff: */
    131139    QMap<QString, UIPopupStackType> m_stackTypes;
     140    QMap<QString, UIPopupStackOrientation> m_stackOrientations;
    132141    QMap<QString, QPointer<UIPopupStack> > m_stacks;
    133142
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp

    r47523 r47644  
    3030#include "UIPopupStackViewport.h"
    3131
    32 UIPopupStack::UIPopupStack(const QString &strID)
     32UIPopupStack::UIPopupStack(const QString &strID, UIPopupStackOrientation orientation)
    3333    : m_strID(strID)
     34    , m_orientation(orientation)
    3435    , m_pScrollArea(0)
    3536    , m_pScrollViewport(0)
     
    7475    /* Redirect request to viewport: */
    7576    m_pScrollViewport->recallPopupPane(strPopupPaneID);
     77}
     78
     79void UIPopupStack::setOrientation(UIPopupStackOrientation orientation)
     80{
     81    /* Make sure orientation has changed: */
     82    if (m_orientation == orientation)
     83        return;
     84
     85    /* Update orientation: */
     86    m_orientation = orientation;
     87    sltAdjustGeometry();
    7688}
    7789
     
    104116    /* Read parent geometry: */
    105117    QRect geo(parentWidget()->geometry());
    106 
    107     /* Determine origin: */
    108     bool fIsWindow = isWindow();
    109     int iX = fIsWindow ? geo.x() : 0;
    110     int iY = fIsWindow ? geo.y() : 0;
    111     /* Add menu-bar height: */
    112     iY += m_iParentMenuBarHeight;
    113118
    114119    /* Determine size: */
     
    128133        /* Compare minimum and current height: */
    129134        iHeight = qMin(iHeight, iMinimumHeight);
     135    }
     136
     137    /* Determine origin: */
     138    int iX = 0;
     139    int iY = 0;
     140    /* Shift for top-level window: */
     141    if (isWindow())
     142    {
     143        iX += geo.x();
     144        iY += geo.y();
     145    }
     146    switch (m_orientation)
     147    {
     148        case UIPopupStackOrientation_Top:
     149        {
     150            /* Just add menu-bar height: */
     151            iY += m_iParentMenuBarHeight;
     152            break;
     153        }
     154        case UIPopupStackOrientation_Bottom:
     155        {
     156            /* Shift to bottom: */
     157            iY += (geo.height() - iHeight);
     158            /* And subtract status-bar height: */
     159            iY -= m_iParentStatusBarHeight;
     160            break;
     161        }
    130162    }
    131163
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h

    r47523 r47644  
    2424#include <QMap>
    2525
     26/* GUI includes: */
     27#include "UIPopupCenter.h"
     28
    2629/* Forward declaration: */
    2730class QVBoxLayout;
     
    4851
    4952    /* Constructor: */
    50     UIPopupStack(const QString &strID);
     53    UIPopupStack(const QString &strID, UIPopupStackOrientation orientation);
    5154
    5255    /* API: Popup-pane stuff: */
     
    5962                         const QString &strMessage, const QString &strDetails);
    6063    void recallPopupPane(const QString &strPopupPaneID);
     64    void setOrientation(UIPopupStackOrientation orientation);
    6165
    6266    /* API: Parent stuff: */
     
    9498    /* Variable: General stuff: */
    9599    QString m_strID;
     100    UIPopupStackOrientation m_orientation;
    96101
    97102    /* Variables: Widget stuff: */
Note: See TracChangeset for help on using the changeset viewer.

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