VirtualBox

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


Ignore:
Timestamp:
Aug 22, 2018 6:27:21 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Rework sliding animation to use more convenient UISlidingAnimation instead of UISlidingWidget.

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

Legend:

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

    r73799 r73846  
    2222/* Qt includes: */
    2323# include <QHBoxLayout>
     24# include <QStackedWidget>
    2425# include <QStyle>
    2526# include <QVBoxLayout>
     
    3334# include "UIVirtualBoxManager.h"
    3435# include "UIVirtualBoxManagerWidget.h"
    35 # include "UISlidingWidget.h"
    3636# include "UITabBar.h"
    3737# include "UIToolBar.h"
     
    4848    : m_fPolished(false)
    4949    , m_pActionPool(pParent->actionPool())
    50     , m_pSlidingWidget(0)
    5150    , m_pSplitter(0)
    5251    , m_pToolBar(0)
    5352    , m_pToolbarTools(0)
    5453    , m_pPaneChooser(0)
     54    , m_pStackedWidget(0)
     55    , m_pPaneToolsGlobal(0)
    5556    , m_pPaneToolsMachine(0)
    56     , m_pPaneToolsGlobal(0)
     57    , m_pSlidingAnimation(0)
    5758{
    5859    prepare();
     
    237238    /* If global item is selected and we are on machine tools pane => switch to global tools pane: */
    238239    if (   isGlobalItemSelected()
    239         && m_pSlidingWidget->state() == UISlidingWidget::State_Start)
    240     {
    241         m_pSlidingWidget->moveForward();
    242         m_pToolbarTools->switchToTabBar(UIToolbarTools::TabBarType_Global);
     240        && m_pStackedWidget->currentWidget() != m_pPaneToolsGlobal)
     241    {
     242        m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal); // rendering w/a
     243        m_pStackedWidget->setCurrentWidget(m_pSlidingAnimation);
     244        m_pSlidingAnimation->animate(SlidingDirection_Reverse);
    243245    }
    244246
     
    247249    /* If machine or group item is selected and we are on global tools pane => switch to machine tools pane: */
    248250    if (   (isMachineItemSelected() || isGroupItemSelected())
    249         && m_pSlidingWidget->state() == UISlidingWidget::State_Final)
    250     {
    251         m_pSlidingWidget->moveBackward();
    252         m_pToolbarTools->switchToTabBar(UIToolbarTools::TabBarType_Machine);
     251        && m_pStackedWidget->currentWidget() != m_pPaneToolsMachine)
     252    {
     253        m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine); // rendering w/a
     254        m_pStackedWidget->setCurrentWidget(m_pSlidingAnimation);
     255        m_pSlidingAnimation->animate(SlidingDirection_Forward);
    253256    }
    254257
     
    312315}
    313316
     317void UIVirtualBoxManagerWidget::sltHandleSlidingAnimationComplete(SlidingDirection enmDirection)
     318{
     319    switch (enmDirection)
     320    {
     321        case SlidingDirection_Forward:
     322        {
     323            m_pToolbarTools->switchToTabBar(UIToolbarTools::TabBarType_Machine);
     324            m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine);
     325            break;
     326        }
     327        case SlidingDirection_Reverse:
     328        {
     329            m_pToolbarTools->switchToTabBar(UIToolbarTools::TabBarType_Global);
     330            m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal);
     331            break;
     332        }
     333    }
     334}
     335
    314336void UIVirtualBoxManagerWidget::sltHandleToolOpenedMachine(ToolTypeMachine enmType)
    315337{
     
    467489                    }
    468490
    469                     /* Create sliding-widget: */
    470                     m_pSlidingWidget = new UISlidingWidget(Qt::Vertical);
    471                     if (m_pSlidingWidget)
     491                    /* Create stacked-widget: */
     492                    m_pStackedWidget = new QStackedWidget;
     493                    if (m_pStackedWidget)
    472494                    {
     495                        /* Create Global Tools-pane: */
     496                        m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool());
     497                        if (m_pPaneToolsGlobal)
     498                        {
     499                            /* Add into stack: */
     500                            m_pStackedWidget->addWidget(m_pPaneToolsGlobal);
     501                        }
     502
    473503                        /* Create Machine Tools-pane: */
    474504                        m_pPaneToolsMachine = new UIToolPaneMachine(actionPool());
    475                         /* Create Global Tools-pane: */
    476                         m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool());
    477 
    478                         /* Add left/right widgets into sliding widget: */
    479                         m_pSlidingWidget->setWidgets(m_pPaneToolsMachine, m_pPaneToolsGlobal);
     505                        if (m_pPaneToolsMachine)
     506                        {
     507                            /* Add into stack: */
     508                            m_pStackedWidget->addWidget(m_pPaneToolsMachine);
     509                        }
     510
     511                        /* Create sliding-widget: */
     512                        m_pSlidingAnimation = new UISlidingAnimation(Qt::Vertical, true);
     513                        if (m_pSlidingAnimation)
     514                        {
     515                            /* Add first/second widgets into sliding animation: */
     516                            m_pSlidingAnimation->setWidgets(m_pPaneToolsGlobal, m_pPaneToolsMachine);
     517                            connect(m_pSlidingAnimation, &UISlidingAnimation::sigAnimationComplete,
     518                                    this, &UIVirtualBoxManagerWidget::sltHandleSlidingAnimationComplete);
     519
     520                            /* Add into stack: */
     521                            m_pStackedWidget->addWidget(m_pSlidingAnimation);
     522                        }
     523
     524                        /* Make Machine Tools pane active initially: */
     525                        m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine);
    480526
    481527                        /* Add into layout: */
    482                         pLayoutRight->addWidget(m_pSlidingWidget, 1);
     528                        pLayoutRight->addWidget(m_pStackedWidget, 1);
    483529                    }
    484530                }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r73780 r73846  
    2424/* GUI includes: */
    2525#include "QIWithRetranslateUI.h"
     26#include "UISlidingAnimation.h"
    2627#include "UIToolPaneGlobal.h"
    2728#include "UIToolPaneMachine.h"
    2829
    2930/* Forward declarations: */
     31class QStackedWidget;
    3032class QISplitter;
    3133class UIActionPool;
    3234class UIChooser;
    33 class UISlidingWidget;
    3435class UITabBar;
    3536class UIToolBar;
     
    137138        /** Handles signal about Chooser-pane index change the default way. */
    138139        void sltHandleChooserPaneIndexChangeDefault() { sltHandleChooserPaneIndexChange(); }
     140
     141        /** Handles sliding animation complete signal.
     142          * @param  enmDirection  Brings which direction was animation finished for. */
     143        void sltHandleSlidingAnimationComplete(SlidingDirection enmDirection);
    139144    /** @} */
    140145
     
    182187    UIActionPool *m_pActionPool;
    183188
    184     /** Holds the sliding-widget isntance. */
    185     UISlidingWidget *m_pSlidingWidget;
    186 
    187189    /** Holds the central splitter instance. */
    188190    QISplitter *m_pSplitter;
     
    200202
    201203    /** Holds the Chooser-pane instance. */
    202     UIChooser         *m_pPaneChooser;
     204    UIChooser          *m_pPaneChooser;
     205    /** Holds the stacked-widget. */
     206    QStackedWidget     *m_pStackedWidget;
     207    /** Holds the Global Tools-pane instance. */
     208    UIToolPaneGlobal   *m_pPaneToolsGlobal;
    203209    /** Holds the Machine Tools-pane instance. */
    204     UIToolPaneMachine *m_pPaneToolsMachine;
    205     /** Holds the Global Tools-pane instance. */
    206     UIToolPaneGlobal  *m_pPaneToolsGlobal;
     210    UIToolPaneMachine  *m_pPaneToolsMachine;
     211    /** Holds the sliding-animation widget instance. */
     212    UISlidingAnimation *m_pSlidingAnimation;
    207213};
    208214
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