VirtualBox

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


Ignore:
Timestamp:
Aug 17, 2012 12:21:30 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Toggle animation for details-view elements.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r42827 r42856  
    9494void UIGDetailsElement::close()
    9595{
    96     m_pButton->setToggled(false, false);
     96    m_pButton->setToggled(false);
    9797}
    9898
    9999void UIGDetailsElement::open()
    100100{
    101     m_pButton->setToggled(true, false);
     101    m_pButton->setToggled(true);
    102102}
    103103
     
    134134}
    135135
     136void UIGDetailsElement::markAnimationFinished()
     137{
     138    m_fAnimationRunning = false;
     139}
     140
     141void UIGDetailsElement::sltToggleButtonClicked()
     142{
     143    emit sigToggleElement(m_type, closed());
     144}
     145
    136146void UIGDetailsElement::sltElementToggleStart()
    137147{
     
    144154    /* Toggle element state: */
    145155    m_fClosed = !m_fClosed;
    146     /* Relayout model: */
    147     model()->updateLayout();
    148     update();
    149156}
    150157
    151158void UIGDetailsElement::sltElementToggleFinish(bool fToggled)
    152159{
    153     /* Mark animation stopped: */
    154     m_fAnimationRunning = false;
    155 
    156160    /* Update toggle-state: */
    157161    m_fClosed = !fToggled;
    158     /* Relayout model: */
    159     model()->updateLayout();
    160     update();
     162
     163    /* Notify about finishing: */
     164    emit sigToggleElementFinished();
    161165}
    162166
     
    443447    /* Setup toggle-button: */
    444448    m_pButton = new UIGraphicsRotatorButton(this, "additionalHeight", !m_fClosed, true /* reflected */);
     449    m_pButton->setAutoHandleButtonClick(false);
     450    connect(m_pButton, SIGNAL(sigButtonClicked()), this, SLOT(sltToggleButtonClicked()));
    445451    connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltElementToggleStart()));
    446452    connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool)));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r42827 r42856  
    5757    void sigHoverLeave();
    5858
    59     /* Notifier: Toggle stuff: */
     59    /* Notifiers: Toggle stuff: */
    6060    void sigToggleElement(DetailsElementType type, bool fToggled);
     61    void sigToggleElementFinished();
    6162
    6263    /* Notifier: Link-click stuff: */
     
    9091    virtual void updateAppearance() = 0;
    9192
     93    /* API: Animation stuff: */
     94    void markAnimationFinished();
     95
    9296protected slots:
    9397
    94     /* Handlers: Collapse/expand stuff: */
     98    /* Handlers: Toggle stuff: */
     99    void sltToggleButtonClicked();
    95100    void sltElementToggleStart();
    96101    void sltElementToggleFinish(bool fToggled);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp

    r42734 r42856  
    4040    , m_pScene(0)
    4141    , m_pRoot(0)
     42    , m_pAnimationCallback(0)
    4243{
    4344    /* Prepare scene: */
     
    4647    /* Prepare root: */
    4748    prepareRoot();
     49
     50    /* Register meta-type: */
     51    qRegisterMetaType<DetailsElementType>();
    4852}
    4953
     
    97101void UIGDetailsModel::sltToggleElements(DetailsElementType type, bool fToggled)
    98102{
     103    /* Make sure not started yet: */
     104    if (m_pAnimationCallback)
     105        return;
     106    /* Prepare/configure animation callback: */
     107    m_pAnimationCallback = new UIGDetailsElementAnimationCallback(this, type, fToggled);
     108    connect(m_pAnimationCallback, SIGNAL(sigAllAnimationFinished(DetailsElementType, bool)),
     109            this, SLOT(sltToggleAnimationFinished(DetailsElementType, bool)), Qt::QueuedConnection);
    99110    /* For each the set of the group: */
    100111    foreach (UIGDetailsItem *pSetItem, m_pRoot->items())
     
    109120            {
    110121                if (fToggled && pElement->closed())
     122                {
     123                    m_pAnimationCallback->addNotifier(pElement);
    111124                    pElement->open();
     125                }
    112126                else if (!fToggled && pElement->opened())
     127                {
     128                    m_pAnimationCallback->addNotifier(pElement);
    113129                    pElement->close();
     130                }
    114131            }
    115132        }
    116133    }
     134    /* Update layout: */
     135    updateLayout();
     136}
     137
     138void UIGDetailsModel::sltToggleAnimationFinished(DetailsElementType type, bool fToggled)
     139{
     140    /* Cleanup animation callback: */
     141    delete m_pAnimationCallback;
     142    m_pAnimationCallback = 0;
     143
     144    /* Mark animation finished: */
     145    foreach (UIGDetailsItem *pSetItem, m_pRoot->items())
     146    {
     147        foreach (UIGDetailsItem *pElementItem, pSetItem->items())
     148        {
     149            UIGDetailsElement *pElement = pElementItem->toElement();
     150            if (pElement->elementType() == type)
     151                pElement->markAnimationFinished();
     152        }
     153    }
     154    /* Update layout: */
     155    updateLayout();
    117156
    118157    /* Update details settings: */
     
    246285}
    247286
     287UIGDetailsElementAnimationCallback::UIGDetailsElementAnimationCallback(QObject *pParent, DetailsElementType type, bool fToggled)
     288    : QObject(pParent)
     289    , m_type(type)
     290    , m_fToggled(fToggled)
     291{
     292}
     293
     294void UIGDetailsElementAnimationCallback::addNotifier(UIGDetailsItem *pItem)
     295{
     296    /* Connect notifier: */
     297    connect(pItem, SIGNAL(sigToggleElementFinished()), this, SLOT(sltAnimationFinished()));
     298    /* Remember notifier: */
     299    m_notifiers << pItem;
     300}
     301
     302void UIGDetailsElementAnimationCallback::sltAnimationFinished()
     303{
     304    /* Determine notifier: */
     305    UIGDetailsItem *pItem = qobject_cast<UIGDetailsItem*>(sender());
     306    /* Disconnect notifier: */
     307    disconnect(pItem, SIGNAL(sigToggleElementFinished()), this, SLOT(sltAnimationFinished()));
     308    /* Remove notifier: */
     309    m_notifiers.removeAll(pItem);
     310    /* Check if we finished: */
     311    if (m_notifiers.isEmpty())
     312        emit sigAllAnimationFinished(m_type, m_fToggled);
     313}
     314
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h

    r42734 r42856  
    3939class UIGDetailsGroup;
    4040class UIVMItem;
     41class UIGDetailsElementAnimationCallback;
     42class UIGDetailsItem;
    4143
    4244/* Graphics selector model: */
     
    7880    /* Handler: Toggle stuff: */
    7981    void sltToggleElements(DetailsElementType type, bool fToggled);
     82    void sltToggleAnimationFinished(DetailsElementType type, bool fToggled);
    8083
    8184    /* Handler: Context-menu stuff: */
     
    118121    QGraphicsScene *m_pScene;
    119122    UIGDetailsGroup *m_pRoot;
     123    UIGDetailsElementAnimationCallback *m_pAnimationCallback;
     124};
     125
     126/* Details-element animation callback: */
     127class UIGDetailsElementAnimationCallback : public QObject
     128{
     129    Q_OBJECT;
     130
     131signals:
     132
     133    /* Notifier: Complete stuff: */
     134    void sigAllAnimationFinished(DetailsElementType type, bool fToggled);
     135
     136public:
     137
     138    /* Constructor: */
     139    UIGDetailsElementAnimationCallback(QObject *pParent, DetailsElementType type, bool fToggled);
     140
     141    /* API: Notifiers stuff: */
     142    void addNotifier(UIGDetailsItem *pItem);
     143
     144private slots:
     145
     146    /* Handler: Progress stuff: */
     147    void sltAnimationFinished();
     148
     149private:
     150
     151    /* Variables: */
     152    QList<UIGDetailsItem*> m_notifiers;
     153    DetailsElementType m_type;
     154    bool m_fToggled;
    120155};
    121156
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsRotatorButton.cpp

    r42795 r42856  
    4242    , m_pBackwardSubordinateAnimation(0)
    4343{
     44    /* Configure: */
     45    setAutoHandleButtonClick(true);
     46
    4447    /* Create state machine: */
    4548    m_pAnimationMachine = new QStateMachine(this);
     
    107110}
    108111
     112void UIGraphicsRotatorButton::setAutoHandleButtonClick(bool fEnabled)
     113{
     114    /* Disconnect button-click signal: */
     115    disconnect(this, SIGNAL(sigButtonClicked()), this, SLOT(sltButtonClicked()));
     116    if (fEnabled)
     117    {
     118        /* Connect button-click signal: */
     119        connect(this, SIGNAL(sigButtonClicked()), this, SLOT(sltButtonClicked()));
     120    }
     121}
     122
    109123void UIGraphicsRotatorButton::setToggled(bool fToggled, bool fAnimated /* = true */)
    110124{
     
    159173    return m_pForwardSubordinateAnimation->state() == QAbstractAnimation::Running ||
    160174           m_pBackwardSubordinateAnimation->state() == QAbstractAnimation::Running;
     175}
     176
     177void UIGraphicsRotatorButton::sltButtonClicked()
     178{
     179    /* Toggle state: */
     180    switch (state())
     181    {
     182        case UIGraphicsRotatorButtonState_Default: setToggled(true); break;
     183        case UIGraphicsRotatorButtonState_Rotated: setToggled(false); break;
     184        default: break;
     185    }
    161186}
    162187
     
    172197}
    173198
    174 void UIGraphicsRotatorButton::mousePressEvent(QGraphicsSceneMouseEvent*)
    175 {
    176     /* Toggle state: */
    177     switch (state())
    178     {
    179         case UIGraphicsRotatorButtonState_Default: setToggled(true); break;
    180         case UIGraphicsRotatorButtonState_Rotated: setToggled(false); break;
    181         default: break;
    182     }
    183 }
    184 
    185 void UIGraphicsRotatorButton::mouseReleaseEvent(QGraphicsSceneMouseEvent*)
    186 {
    187     /* Do nothing (do NOT propagate to parent!)... */
    188 }
    189 
    190199void UIGraphicsRotatorButton::updateRotationState()
    191200{
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsRotatorButton.h

    r42526 r42856  
    6262                            int iAnimationDuration = 300);
    6363
     64    /* API: Button-click stuff: */
     65    void setAutoHandleButtonClick(bool fEnabled);
     66
    6467    /* API: Toggle stuff: */
    6568    void setToggled(bool fToggled, bool fAnimated = true);
     
    6972    bool isAnimationRunning() const;
    7073
     74protected slots:
     75
     76    /* Handler: Button-click stuff: */
     77    void sltButtonClicked();
     78
    7179protected:
    7280
    7381    /* Helpers: Update stuff: */
    7482    void refresh();
    75 
    76     /* Mouse-buttons handler: */
    77     void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
    78     void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent);
    7983
    8084private:
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