VirtualBox

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


Ignore:
Timestamp:
Sep 7, 2018 11:16:21 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Chooser pane re-styling: Adjust global item to have a height of main toolbar.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r74108 r74138  
    550550{
    551551    /* Tool-bar connections: */
     552    connect(m_pToolBar, &UIToolBar::sigResized,
     553            m_pPaneChooser, &UIChooser::sltHandleToolbarResize);
    552554    connect(m_pToolBar, &UIToolBar::customContextMenuRequested,
    553555            this, &UIVirtualBoxManagerWidget::sltHandleContextMenuRequest);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp

    r74085 r74138  
    112112}
    113113
     114void UIChooser::sltHandleToolbarResize(const QSize &newSize)
     115{
     116    /* Pass height to a model: */
     117    model()->setGlobalItemHeightHint(newSize.height());
     118}
     119
    114120void UIChooser::preparePalette()
    115121{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r73631 r74138  
    8282    bool isGroupSavingInProgress() const;
    8383
     84public slots:
     85
     86    /** Handles toolbar resize to @a newSize. */
     87    void sltHandleToolbarResize(const QSize &newSize);
     88
    8489private:
    8590
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp

    r73954 r74138  
    4343    , m_iMinimumNameWidth(0)
    4444    , m_iMaximumNameWidth(0)
     45    , m_iHeightHint(0)
    4546{
    4647    /* Prepare: */
     
    118119}
    119120
     121void UIChooserItemGlobal::setHeightHint(int iHint)
     122{
     123    /* Remember a new hint: */
     124    m_iHeightHint = iHint;
     125
     126    /* Update geometry and the model layout: */
     127    updateGeometry();
     128    model()->updateLayout();
     129}
     130
    120131void UIChooserItemGlobal::retranslateUi()
    121132{
     
    290301{
    291302    /* Prepare variables: */
    292     int iMargin = data(GlobalItemData_Margin).toInt();
    293     int iSpacing = data(GlobalItemData_Spacing).toInt();
     303    const int iMargin = data(GlobalItemData_Margin).toInt();
     304    const int iSpacing = data(GlobalItemData_Spacing).toInt();
    294305
    295306    /* Calculating proposed width: */
     
    298309    /* Two margins: */
    299310    iProposedWidth += 2 * iMargin;
    300     /* And global-item content to take into account: */
     311    /* And global-item content width: */
    301312    iProposedWidth += (m_pixmapSize.width() +
    302313                       iSpacing +
     
    310321{
    311322    /* Prepare variables: */
    312     int iMargin = data(GlobalItemData_Margin).toInt();
     323    const int iMargin = data(GlobalItemData_Margin).toInt();
    313324
    314325    /* Calculating proposed height: */
    315326    int iProposedHeight = 0;
    316327
    317     /* Two margins: */
    318     iProposedHeight += 2 * iMargin;
    319     /* And global-item content to take into account: */
    320     iProposedHeight += qMax(m_pixmapSize.height(), m_visibleNameSize.height());
     328    /* Global-item content height: */
     329    const int iContentHeight = qMax(m_pixmapSize.height(), m_visibleNameSize.height());
     330
     331    /* If we have height hint: */
     332    if (m_iHeightHint)
     333    {
     334        /* Take the largest value between height hint and content height: */
     335        iProposedHeight += qMax(m_iHeightHint, iContentHeight);
     336    }
     337    /* Otherwise: */
     338    else
     339    {
     340        /* Two margins: */
     341        iProposedHeight += 2 * iMargin;
     342        /* And content height: */
     343        iProposedHeight += iContentHeight;
     344    }
    321345
    322346    /* Return result: */
     
    391415    {
    392416        /* Layout hints: */
    393         case GlobalItemData_Margin: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 4;
     417        case GlobalItemData_Margin:  return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 3 * 2;
    394418        case GlobalItemData_Spacing: return QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) / 2;
    395419
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h

    r73954 r74138  
    4646    virtual ~UIChooserItemGlobal() /* override */;
    4747
     48    /** @name Layout stuff.
     49      * @{ */
     50        /** Defines height @a iHint. */
     51        void setHeightHint(int iHint);
     52    /** @} */
     53
    4854protected:
    4955
     
    243249        /** Holds maximum name width. */
    244250        int  m_iMaximumNameWidth;
     251
     252        /** Holds the height hint. */
     253        int  m_iHeightHint;
    245254    /** @} */
    246255};
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r73927 r74138  
    189189    /* Make sure root-item is shown: */
    190190    root()->show();
     191}
     192
     193void UIChooserModel::setGlobalItemHeightHint(int iHint)
     194{
     195    /* Walk thrugh all the items of navigation list: */
     196    foreach (UIChooserItem *pItem, navigationList())
     197    {
     198        /* And for each global item: */
     199        if (pItem->type() == UIChooserItemType_Global)
     200        {
     201            /* Apply the height hint we have: */
     202            UIChooserItemGlobal *pGlobalItem = pItem->toGlobalItem();
     203            if (pGlobalItem)
     204                pGlobalItem->setHeightHint(iHint);
     205        }
     206    }
    191207}
    192208
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r73631 r74138  
    103103    /* API: Layout stuff: */
    104104    void updateLayout();
     105    /** Defines global item height @a iHint. */
     106    void setGlobalItemHeightHint(int iHint);
    105107
    106108    /* API: Navigation 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