VirtualBox

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


Ignore:
Timestamp:
Jul 5, 2013 4:58:04 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Popup-center: Popup-pane 'show' animation.

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

Legend:

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

    r47014 r47016  
    3333                         bool fProposeAutoConfirmation)
    3434    : QWidget(pParent)
     35    , m_fPolished(false)
    3536    , m_iLayoutMargin(10), m_iLayoutSpacing(5)
    3637    , m_strMessage(strMessage), m_strDetails(strDetails)
    3738    , m_fProposeAutoConfirmation(fProposeAutoConfirmation)
    3839    , m_buttonDescriptions(buttonDescriptions)
     40    , m_fShown(false)
     41    , m_pShowAnimation(0)
    3942    , m_fHovered(false)
    4043    , m_iDefaultOpacity(180)
     
    9194}
    9295
     96void UIPopupPane::setMinimumSizeHint(const QSize &minimumSizeHint)
     97{
     98    /* Make sure the size-hint is changed: */
     99    if (m_minimumSizeHint == minimumSizeHint)
     100        return;
     101
     102    /* Assign new size-hint: */
     103    m_minimumSizeHint = minimumSizeHint;
     104
     105    /* Notify parent popup-stack: */
     106    emit sigSizeHintChanged();
     107}
     108
    93109void UIPopupPane::updateSizeHint()
    94110{
     
    119135    }
    120136
    121     /* Compose minimum size-hint: */
    122     m_minimumSizeHint = QSize(iMinimumWidthHint, iMinimumHeightHint);
     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();
    123145}
    124146
     
    152174}
    153175
     176void UIPopupPane::sltMarkAsShown()
     177{
     178    /* Mark popup-pane as 'shown': */
     179    m_fShown = true;
     180}
     181
    154182void UIPopupPane::sltAdjustGeometry()
    155183{
     
    212240void UIPopupPane::prepareAnimation()
    213241{
     242    /* Install 'show' animation for 'minimumSizeHint' property: */
     243    connect(this, SIGNAL(sigToShow()), this, SIGNAL(sigShow()), Qt::QueuedConnection);
     244    m_pShowAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "hiddenSizeHint", "shownSizeHint",
     245                                                             SIGNAL(sigShow()), SIGNAL(sigHide()));
     246    connect(m_pShowAnimation, SIGNAL(sigStateEnteredFinal()), this, SLOT(sltMarkAsShown()));
     247
    214248    /* Install 'hover' animation for 'opacity' property: */
    215249    UIAnimation::installPropertyAnimation(this, "opacity", "defaultOpacity", "hoveredOpacity",
     
    274308    /* Do not filter anything: */
    275309    return false;
     310}
     311
     312void UIPopupPane::showEvent(QShowEvent *pEvent)
     313{
     314    /* Call to base-class: */
     315    QWidget::showEvent(pEvent);
     316
     317    /* Polish border: */
     318    if (m_fPolished)
     319        return;
     320    m_fPolished = true;
     321
     322    /* Call to polish event: */
     323    polishEvent(pEvent);
     324}
     325
     326void UIPopupPane::polishEvent(QShowEvent*)
     327{
     328    /* Emit signal to start *show* animation: */
     329    emit sigToShow();
    276330}
    277331
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r47014 r47016  
    2727class UIPopupPaneTextPane;
    2828class UIPopupPaneButtonPane;
     29class UIAnimation;
    2930
    3031/* Popup-pane prototype: */
     
    3233{
    3334    Q_OBJECT;
     35    Q_PROPERTY(QSize hiddenSizeHint READ hiddenSizeHint);
     36    Q_PROPERTY(QSize shownSizeHint READ shownSizeHint);
     37    Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint WRITE setMinimumSizeHint);
    3438    Q_PROPERTY(int defaultOpacity READ defaultOpacity);
    3539    Q_PROPERTY(int hoveredOpacity READ hoveredOpacity);
     
    3741
    3842signals:
     43
     44    /* Notifiers: Show/hide stuff: */
     45    void sigToShow();
     46    void sigToHide();
     47    void sigShow();
     48    void sigHide();
    3949
    4050    /* Notifiers: Hover stuff: */
     
    6979    /* API: Layout stuff: */
    7080    QSize minimumSizeHint() const { return m_minimumSizeHint; }
     81    void setMinimumSizeHint(const QSize &minimumSizeHint);
    7182    void updateSizeHint();
    7283    void setDesiredWidth(int iWidth);
     
    7485
    7586private slots:
     87
     88    /* Handler: Show/hide stuff: */
     89    void sltMarkAsShown();
    7690
    7791    /* Handler: Layout stuff: */
     
    91105    bool eventFilter(QObject *pWatched, QEvent *pEvent);
    92106
    93     /* Handler: Event stuff: */
     107    /* Handlers: Event stuff: */
     108    void showEvent(QShowEvent *pEvent);
     109    void polishEvent(QShowEvent *pEvent);
    94110    void paintEvent(QPaintEvent *pEvent);
    95111
     
    101117    void done(int iResultCode);
    102118
     119    /* Property: Show/hide stuff: */
     120    QSize hiddenSizeHint() const { return m_hiddenSizeHint; }
     121    QSize shownSizeHint() const { return m_shownSizeHint; }
     122
    103123    /* Property: Hover stuff: */
    104124    int defaultOpacity() const { return m_iDefaultOpacity; }
     
    108128
    109129    /* Variables: General stuff: */
     130    bool m_fPolished;
    110131    const QString m_strId;
    111132    const int m_iLayoutMargin;
     
    121142    /* Variables: Button stuff: */
    122143    QMap<int, QString> m_buttonDescriptions;
     144
     145    /* Variables: Show/hide stuff: */
     146    bool m_fShown;
     147    UIAnimation *m_pShowAnimation;
     148    QSize m_hiddenSizeHint;
     149    QSize m_shownSizeHint;
    123150
    124151    /* Variables: Hover 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