VirtualBox

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


Ignore:
Timestamp:
May 17, 2021 2:58:15 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10003: Reworking Details pane; Make updateLayout() public again!

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

Legend:

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

    r89100 r89101  
    204204}
    205205
     206void UIDetailsElement::updateLayout()
     207{
     208    /* Prepare variables: */
     209    QSize size = geometry().size().toSize();
     210    int iMargin = data(ElementData_Margin).toInt();
     211
     212    /* Layout button: */
     213    int iButtonWidth = m_buttonSize.width();
     214    int iButtonHeight = m_buttonSize.height();
     215    int iButtonX = size.width() - 2 * iMargin - iButtonWidth;
     216    int iButtonY = iButtonHeight == m_iMinimumHeaderHeight ? iMargin :
     217                   iMargin + (m_iMinimumHeaderHeight - iButtonHeight) / 2;
     218    m_pButton->setPos(iButtonX, iButtonY);
     219
     220    /* If closed: */
     221    if (isClosed())
     222    {
     223        /* Hide text-pane if still visible: */
     224        if (m_pTextPane->isVisible())
     225            m_pTextPane->hide();
     226    }
     227    /* If opened: */
     228    else
     229    {
     230        /* Layout text-pane: */
     231        int iTextPaneX = 2 * iMargin;
     232        int iTextPaneY = iMargin + m_iMinimumHeaderHeight + 2 * iMargin;
     233        m_pTextPane->setPos(iTextPaneX, iTextPaneY);
     234        m_pTextPane->resize(size.width() - 4 * iMargin,
     235                            size.height() - 4 * iMargin - m_iMinimumHeaderHeight);
     236        /* Show text-pane if still invisible and animation finished: */
     237        if (!m_pTextPane->isVisible() && !isAnimationRunning())
     238            m_pTextPane->show();
     239    }
     240}
     241
    206242int UIDetailsElement::minimumWidthHint() const
    207243{
     
    385421{
    386422    AssertMsgFailed(("Details element do NOT support children!"));
    387 }
    388 
    389 void UIDetailsElement::updateLayout()
    390 {
    391     /* Prepare variables: */
    392     QSize size = geometry().size().toSize();
    393     int iMargin = data(ElementData_Margin).toInt();
    394 
    395     /* Layout button: */
    396     int iButtonWidth = m_buttonSize.width();
    397     int iButtonHeight = m_buttonSize.height();
    398     int iButtonX = size.width() - 2 * iMargin - iButtonWidth;
    399     int iButtonY = iButtonHeight == m_iMinimumHeaderHeight ? iMargin :
    400                    iMargin + (m_iMinimumHeaderHeight - iButtonHeight) / 2;
    401     m_pButton->setPos(iButtonX, iButtonY);
    402 
    403     /* If closed: */
    404     if (isClosed())
    405     {
    406         /* Hide text-pane if still visible: */
    407         if (m_pTextPane->isVisible())
    408             m_pTextPane->hide();
    409     }
    410     /* If opened: */
    411     else
    412     {
    413         /* Layout text-pane: */
    414         int iTextPaneX = 2 * iMargin;
    415         int iTextPaneY = iMargin + m_iMinimumHeaderHeight + 2 * iMargin;
    416         m_pTextPane->setPos(iTextPaneX, iTextPaneY);
    417         m_pTextPane->resize(size.width() - 4 * iMargin,
    418                             size.height() - 4 * iMargin - m_iMinimumHeaderHeight);
    419         /* Show text-pane if still invisible and animation finished: */
    420         if (!m_pTextPane->isVisible() && !isAnimationRunning())
    421             m_pTextPane->show();
    422     }
    423423}
    424424
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.h

    r89100 r89101  
    112112    /** @name Layout stuff.
    113113      * @{ */
     114        /** Updates layout. */
     115        virtual void updateLayout() /* override */;
     116
    114117        /** Returns minimum width-hint. */
    115118        virtual int minimumWidthHint() const /* override */;
     
    197200    /** @name Layout stuff.
    198201      * @{ */
    199         /** Updates layout. */
    200         virtual void updateLayout() /* override */;
    201 
    202202        /** Returns minimum width-hint for @a fClosed element. */
    203203        virtual int minimumHeightHintForElement(bool fClosed) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElements.cpp

    r83719 r89101  
    139139}
    140140
     141void UIDetailsElementPreview::updateLayout()
     142{
     143    /* Call to base-class: */
     144    UIDetailsElement::updateLayout();
     145
     146    /* Show/hide preview: */
     147    if (isClosed() && m_pPreview->isVisible())
     148        m_pPreview->hide();
     149    if (isOpened() && !m_pPreview->isVisible() && !isAnimationRunning())
     150        m_pPreview->show();
     151
     152    /* And update preview layout itself: */
     153    const int iMargin = data(ElementData_Margin).toInt();
     154    m_pPreview->setPos(iMargin, 2 * iMargin + minimumHeaderHeight());
     155    m_pPreview->resize(m_pPreview->minimumSizeHint());
     156}
     157
    141158void UIDetailsElementPreview::sltPreviewSizeHintChanged()
    142159{
     
    202219}
    203220
    204 void UIDetailsElementPreview::updateLayout()
    205 {
    206     /* Call to base-class: */
    207     UIDetailsElement::updateLayout();
    208 
    209     /* Show/hide preview: */
    210     if (isClosed() && m_pPreview->isVisible())
    211         m_pPreview->hide();
    212     if (isOpened() && !m_pPreview->isVisible() && !isAnimationRunning())
    213         m_pPreview->show();
    214 
    215     /* And update preview layout itself: */
    216     const int iMargin = data(ElementData_Margin).toInt();
    217     m_pPreview->setPos(iMargin, 2 * iMargin + minimumHeaderHeight());
    218     m_pPreview->resize(m_pPreview->minimumSizeHint());
    219 }
    220 
    221221void UIDetailsElementPreview::updateAppearance()
    222222{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElements.h

    r83719 r89101  
    9191    UIDetailsElementPreview(UIDetailsSet *pParent, bool fOpened);
    9292
     93    /** Updates layout. */
     94    virtual void updateLayout() /* override */;
     95
    9396private slots:
    9497
     
    107110      *                be calculated for the closed element. */
    108111    int minimumHeightHintForElement(bool fClosed) const;
    109     /** Updates layout. */
    110     void updateLayout();
    111112
    112113    /** Updates appearance. */
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