VirtualBox

Changeset 47031 in vbox


Ignore:
Timestamp:
Jul 8, 2013 10:30:00 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
87064
Message:

FE/Qt: Popup-center: Cumulative patch to popup-pane and popup-pane-text-pane for more wise encapsulation and layout stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp

    r47030 r47031  
    5353void UIPopupPane::setMessage(const QString &strMessage)
    5454{
    55     /* Make sure somthing changed: */
     55    /* Make sure the message has changed: */
    5656    if (m_strMessage == strMessage)
    5757        return;
     
    6464void UIPopupPane::setDetails(const QString &strDetails)
    6565{
    66     /* Make sure somthing changed: */
     66    /* Make sure the details has changed: */
    6767    if (m_strDetails == strDetails)
    6868        return;
     
    7474void UIPopupPane::setProposeAutoConfirmation(bool fPropose)
    7575{
    76     /* Make sure something changed: */
     76    /* Make sure the auto-confirmation-proposal has changed: */
    7777    if (m_fProposeAutoConfirmation == fPropose)
    7878        return;
    7979
    80     /* Fetch new auto-confirmation proposal: */
     80    /* Fetch new auto-confirmation-proposal: */
    8181    m_fProposeAutoConfirmation = fPropose;
    8282    m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation);
     
    9696void UIPopupPane::setMinimumSizeHint(const QSize &minimumSizeHint)
    9797{
    98     /* Make sure the size-hint is changed: */
     98    /* Make sure the size-hint has changed: */
    9999    if (m_minimumSizeHint == minimumSizeHint)
    100100        return;
    101101
    102     /* Assign new size-hint: */
     102    /* Fetch new size-hint: */
    103103    m_minimumSizeHint = minimumSizeHint;
    104104
    105105    /* Notify parent popup-stack: */
    106106    emit sigSizeHintChanged();
    107 }
    108 
    109 void UIPopupPane::updateSizeHint()
    110 {
    111     /* Calculate minimum width-hint: */
    112     int iMinimumWidthHint = 0;
    113     {
    114         /* Take into account layout: */
    115         iMinimumWidthHint += 2 * m_iLayoutMargin;
    116         {
    117             /* Take into account widgets: */
    118             iMinimumWidthHint += m_pTextPane->minimumSizeHint().width();
    119             iMinimumWidthHint += m_iLayoutSpacing;
    120             iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width();
    121         }
    122     }
    123 
    124     /* Calculate minimum height-hint: */
    125     int iMinimumHeightHint = 0;
    126     {
    127         /* Take into account layout: */
    128         iMinimumHeightHint += 2 * m_iLayoutMargin;
    129         {
    130             /* Take into account widgets: */
    131             const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height();
    132             const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height();
    133             iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight);
    134         }
    135     }
    136 
    137     /* Compose minimum size-hints: */
    138     m_hiddenSizeHint = QSize(iMinimumWidthHint, 1);
    139     m_shownSizeHint = QSize(iMinimumWidthHint, iMinimumHeightHint);
    140     m_minimumSizeHint = m_fShown ? m_shownSizeHint : m_hiddenSizeHint;
    141 
    142     /* Update 'show/hide' animation: */
    143     if (m_pShowAnimation)
    144         m_pShowAnimation->update();
    145107}
    146108
     
    180142}
    181143
    182 void UIPopupPane::sltAdjustGeometry()
    183 {
    184     /* Update size-hint: */
    185     updateSizeHint();
     144void UIPopupPane::sltUpdateSizeHint()
     145{
     146    /* Calculate minimum width-hint: */
     147    int iMinimumWidthHint = 0;
     148    {
     149        /* Take into account layout: */
     150        iMinimumWidthHint += 2 * m_iLayoutMargin;
     151        {
     152            /* Take into account widgets: */
     153            iMinimumWidthHint += m_pTextPane->minimumSizeHint().width();
     154            iMinimumWidthHint += m_iLayoutSpacing;
     155            iMinimumWidthHint += m_pButtonPane->minimumSizeHint().width();
     156        }
     157    }
     158
     159    /* Calculate minimum height-hint: */
     160    int iMinimumHeightHint = 0;
     161    {
     162        /* Take into account layout: */
     163        iMinimumHeightHint += 2 * m_iLayoutMargin;
     164        {
     165            /* Take into account widgets: */
     166            const int iTextPaneHeight = m_pTextPane->minimumSizeHint().height();
     167            const int iButtonBoxHeight = m_pButtonPane->minimumSizeHint().height();
     168            iMinimumHeightHint += qMax(iTextPaneHeight, iButtonBoxHeight);
     169        }
     170    }
     171
     172    /* Compose minimum size-hints: */
     173    m_hiddenSizeHint = QSize(iMinimumWidthHint, 1);
     174    m_shownSizeHint = QSize(iMinimumWidthHint, iMinimumHeightHint);
     175    m_minimumSizeHint = m_fShown ? m_shownSizeHint : m_hiddenSizeHint;
     176
     177    /* Update 'show/hide' animation: */
     178    if (m_pShowAnimation)
     179        m_pShowAnimation->update();
    186180
    187181    /* Notify parent popup-stack: */
     
    202196    prepareAnimation();
    203197
    204     /* Adjust geometry: */
    205     sltAdjustGeometry();
     198    /* Update size-hint: */
     199    sltUpdateSizeHint();
    206200}
    207201
     
    212206
    213207    /* Create message-label: */
    214     m_pTextPane = new UIPopupPaneTextPane(this);
     208    m_pTextPane = new UIPopupPaneTextPane(this, m_strMessage, m_fProposeAutoConfirmation);
    215209    {
    216210        /* Prepare label: */
    217         connect(m_pTextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry()));
     211        connect(m_pTextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint()));
    218212        m_pTextPane->installEventFilter(this);
    219         m_pTextPane->setText(m_strMessage);
    220         m_pTextPane->setProposeAutoConfirmation(m_fProposeAutoConfirmation);
    221213    }
    222214
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r47016 r47031  
    8080    QSize minimumSizeHint() const { return m_minimumSizeHint; }
    8181    void setMinimumSizeHint(const QSize &minimumSizeHint);
    82     void updateSizeHint();
    8382    void setDesiredWidth(int iWidth);
    8483    void layoutContent();
     
    9089
    9190    /* Handler: Layout stuff: */
    92     void sltAdjustGeometry();
     91    void sltUpdateSizeHint();
    9392
    9493    /* Handler: Button stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.cpp

    r47012 r47031  
    2626#include "UIAnimationFramework.h"
    2727
    28 UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent /*= 0*/)
     28UIPopupPaneTextPane::UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fProposeAutoConfirmation)
    2929    : QIWithRetranslateUI<QWidget>(pParent)
    3030    , m_iLayoutMargin(0)
    3131    , m_iLayoutSpacing(10)
     32    , m_strText(strText)
    3233    , m_pLabel(0)
    3334    , m_iDesiredLabelWidth(-1)
    3435    , m_pAutoConfirmCheckBox(0)
    35     , m_fProposeAutoConfirmation(false)
     36    , m_fProposeAutoConfirmation(fProposeAutoConfirmation)
    3637    , m_fFocused(false)
    3738    , m_pAnimation(0)
     
    4344void UIPopupPaneTextPane::setText(const QString &strText)
    4445{
    45     /* Make sure the text is changed: */
     46    /* Make sure the text has changed: */
    4647    if (m_pLabel->text() == strText)
    4748        return;
    48     /* Update the pane for the new text: */
    49     m_pLabel->setText(strText);
     49
     50    /* Fetch new text: */
     51    m_strText = strText;
     52    m_pLabel->setText(m_strText);
     53
     54    /* Update size-hint: */
    5055    updateSizeHint();
    5156}
     
    5358void UIPopupPaneTextPane::setDesiredWidth(int iDesiredWidth)
    5459{
    55     /* Make sure the desired-width is changed: */
     60    /* Make sure the desired-width has changed: */
    5661    if (m_iDesiredLabelWidth == iDesiredWidth)
    5762        return;
    58     /* Update the pane for the new desired-width: */
     63
     64    /* Fetch new desired-width: */
    5965    m_iDesiredLabelWidth = iDesiredWidth;
     66
     67    /* Update size-hint: */
    6068    updateSizeHint();
    6169}
     
    6371void UIPopupPaneTextPane::setProposeAutoConfirmation(bool fPropose)
    6472{
    65     /* Make sure the auto-confirmation-proposal is changed: */
     73    /* Make sure the auto-confirmation-proposal has changed: */
    6674    if (m_fProposeAutoConfirmation == fPropose)
    6775        return;
    68     /* Update the pane for the new auto-confirmation-proposal: */
     76
     77    /* Fetch new auto-confirmation-proposal: */
    6978    m_fProposeAutoConfirmation = fPropose;
     79
     80    /* Update size-hint: */
    7081    updateSizeHint();
    7182}
     
    95106void UIPopupPaneTextPane::setMinimumSizeHint(const QSize &minimumSizeHint)
    96107{
    97     /* Make sure the size-hint is changed: */
     108    /* Make sure the size-hint has changed: */
    98109    if (m_minimumSizeHint == minimumSizeHint)
    99110        return;
    100     /* Assign new size-hint: */
     111
     112    /* Fetch new size-hint: */
    101113    m_minimumSizeHint = minimumSizeHint;
     114
    102115    /* Notify parent popup-pane: */
    103116    emit sigSizeHintChanged();
     
    111124    const int iLabelWidth = m_labelSizeHint.width();
    112125    const int iLabelHeight = m_labelSizeHint.height();
     126
    113127    /* Label: */
    114128    m_pLabel->move(m_iLayoutMargin, m_iLayoutMargin);
     
    165179void UIPopupPaneTextPane::prepare()
    166180{
    167     /* Propagate parent signals: */
    168     connect(parent(), SIGNAL(sigFocusEnter()), this, SLOT(sltFocusEnter()));
    169     connect(parent(), SIGNAL(sigFocusLeave()), this, SLOT(sltFocusLeave()));
    170181    /* Prepare content: */
    171182    prepareContent();
    172     /* Install geometry animation for 'minimumSizeHint' property: */
    173     m_pAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint",
    174                                                          SIGNAL(sigFocusEnter()), SIGNAL(sigFocusLeave()));
     183    /* Prepare animation: */
     184    prepareAnimation();
     185
     186    /* Update size-hint: */
     187    updateSizeHint();
    175188}
    176189
     
    190203        m_pLabel->setWordWrap(true);
    191204        m_pLabel->setFocusPolicy(Qt::NoFocus);
    192     }
     205        m_pLabel->setText(m_strText);
     206    }
     207
    193208    /* Create check-box: */
    194209    m_pAutoConfirmCheckBox = new QCheckBox(this);
     
    204219        m_pAutoConfirmCheckBox->setFocusPolicy(Qt::NoFocus);
    205220    }
     221
    206222    /* Translate UI finally: */
    207223    retranslateUi();
     224}
     225
     226void UIPopupPaneTextPane::prepareAnimation()
     227{
     228    /* Propagate parent signals: */
     229    connect(parent(), SIGNAL(sigFocusEnter()), this, SLOT(sltFocusEnter()));
     230    connect(parent(), SIGNAL(sigFocusLeave()), this, SLOT(sltFocusLeave()));
     231    /* Install geometry animation for 'minimumSizeHint' property: */
     232    m_pAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint",
     233                                                         SIGNAL(sigFocusEnter()), SIGNAL(sigFocusLeave()));
    208234}
    209235
     
    243269
    244270    /* Update animation: */
    245     m_pAnimation->update();
    246 }
    247 
     271    if (m_pAnimation)
     272        m_pAnimation->update();
     273
     274    /* Notify parent popup-pane: */
     275    emit sigSizeHintChanged();
     276}
     277
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.h

    r47012 r47031  
    5151
    5252    /* Constructor: */
    53     UIPopupPaneTextPane(QWidget *pParent = 0);
     53    UIPopupPaneTextPane(QWidget *pParent, const QString &strText, bool fProposeAutoConfirmation);
    5454
    5555    /* API: Text stuff: */
     
    8080    void prepare();
    8181    void prepareContent();
     82    void prepareAnimation();
    8283
    8384    /* Helper: Translate stuff: */
     
    101102
    102103    /* Variables: Widget stuff: */
     104    QString m_strText;
    103105    QLabel *m_pLabel;
    104106    int m_iDesiredLabelWidth;
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