VirtualBox

Changeset 63928 in vbox


Ignore:
Timestamp:
Sep 21, 2016 4:07:54 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110812
Message:

FE/Qt: bugref:6899: Accessibility support (step 46): Selector UI: Moving segmented-button from UIVMDesktop to UISelectorWindow where it really belongs to.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r63926 r63928  
    5555# include "UISelectorWindow.h"
    5656# include "UISettingsDialogSpecific.h"
     57# include "UISpacerWidgets.h"
     58# include "UISpecialControls.h"
    5759# include "UIToolBar.h"
    5860# include "UIVMLogViewer.h"
     
    121123#endif /* !VBOX_WS_MAC */
    122124    , m_pToolBar(0)
     125    , m_pSegmentedButton(0)
    123126    , m_pContainerDetails(0)
    124127    , m_pPaneChooser(0)
     
    202205            statusBar()->hide();
    203206    }
    204 }
    205 
    206 void UISelectorWindow::sltHandleDetailsContainerIndexChange(int iIndex)
    207 {
    208     if (iIndex)
    209         m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);
    210     else
    211         m_pContainerDetails->setCurrentWidget(m_pPaneDetails);
    212207}
    213208
     
    10431038}
    10441039
     1040void UISelectorWindow::sltHandleSegmentedButtonSwitch(int iSegment)
     1041{
     1042    /* Get current item: */
     1043    const UIVMItem *pItem = currentItem();
     1044
     1045    /* If current item exists & accessible: */
     1046    if (pItem && pItem->accessible())
     1047    {
     1048        /* Raise the required widget: */
     1049        switch (iSegment)
     1050        {
     1051            case SegmentType_Details:
     1052            {
     1053                /* Raise the details pane: */
     1054                m_pContainerDetails->setCurrentWidget(m_pPaneDetails);
     1055                break;
     1056            }
     1057            case SegmentType_Snapshots:
     1058            {
     1059                /* Raise the desktop pane which contains snapshot pane for now: */
     1060                m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);
     1061                break;
     1062            }
     1063            default:
     1064                break;
     1065        }
     1066        /* And pass the request to desktop pane afterwards: */
     1067        m_pPaneDesktop->setWidgetIndex(iSegment);
     1068    }
     1069    else
     1070    {
     1071        /* Raise the desktop pane which contains text/error details: */
     1072        m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);
     1073        /* And pass the request to desktop pane afterwards: */
     1074        m_pPaneDesktop->setWidgetIndex(SegmentType_Details);
     1075    }
     1076}
     1077
     1078void UISelectorWindow::sltPerformSegmentedButtonSwitch(int iSegment)
     1079{
     1080    m_pSegmentedButton->animateClick(iSegment);
     1081}
     1082
    10451083UIVMItem* UISelectorWindow::currentItem() const
    10461084{
     
    10551093void UISelectorWindow::updateSnapshots(UIVMItem *pItem, const CMachine &comMachine)
    10561094{
    1057     /* Redirect call to Desktop-pane: */
    1058     m_pPaneDesktop->updateSnapshots(pItem, comMachine);
     1095    /* Update segmented-button text: */
     1096    // TODO: Bring that NLS to "&Snapshots" / "&Snapshots (%1)" form
     1097    //       as translator should be able to translate whole sentence.
     1098    //       And move it from UIVMDesktop to UISelectorWindow context.
     1099    QString strName = QApplication::translate("UIVMDesktop", "&Snapshots");
     1100    if (pItem)
     1101    {
     1102        /* Append the snapshot count (if any): */
     1103        const ULONG count = pItem->snapshotCount();
     1104        if (count)
     1105            strName += QString(" (%1)").arg(count);
     1106    }
     1107    m_pSegmentedButton->setTitle(SegmentType_Snapshots, strName);
     1108
     1109    /* Update snapshot pane availability: */
     1110    if (comMachine.isNotNull())
     1111        m_pSegmentedButton->setEnabled(SegmentType_Snapshots, true);
     1112    else
     1113        lockSnapshots();
     1114
     1115    /* Redirect call to Desktop-pane finally: */
     1116    m_pPaneDesktop->updateSnapshots(comMachine);
    10591117}
    10601118
    10611119void UISelectorWindow::lockSnapshots()
    10621120{
    1063     /* Redirect call to Desktop-pane: */
    1064     m_pPaneDesktop->lockSnapshots();
     1121    /* First switch to details pane: */
     1122    sltPerformSegmentedButtonSwitchToDetails();
     1123    /* Then lock the snapshot pane: */
     1124    m_pSegmentedButton->setEnabled(SegmentType_Snapshots, false);
    10651125}
    10661126
     
    10791139    setWindowTitle(strTitle);
    10801140
     1141    /* Translate segmented-button: */
     1142    // TODO: Move that NLS from UIVMDesktop to UISelectorWindow context.
     1143    m_pSegmentedButton->setTitle(SegmentType_Details, QApplication::translate("UIVMDesktop", "&Details"));
     1144
    10811145    /* Make sure details and snapshot panes are updated: */
    10821146    sltHandleChooserPaneIndexChange();
     
    12431307    qApp->installEventFilter(this);
    12441308#endif /* VBOX_WS_MAC */
     1309
     1310//#ifdef VBOX_WS_MAC
     1311//    /* Cocoa stuff should be async..
     1312//     * Do not ask me why but otherwise
     1313//     * it conflicts with native handlers. */
     1314//    QMetaObject::invokeMethod(this, "sltPerformSegmentedButtonSwitchToDetails", Qt::QueuedConnection);
     1315//#else /* !VBOX_WS_MAC */
     1316    sltPerformSegmentedButtonSwitchToDetails();
     1317//#endif /* !VBOX_WS_MAC */
    12451318}
    12461319
     
    16891762    m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow));
    16901763
     1764    /* Create/add horizontal spacer widget to align subsequent controls right: */
     1765    m_pToolBar->addWidget(new UIHorizontalSpacerWidget(this));
     1766
     1767    /* Create/add segmented-button: */
     1768    m_pSegmentedButton = new UITexturedSegmentedButton(this, 2);
     1769    m_pSegmentedButton->setIcon(SegmentType_Details, UIIconPool::iconSet(":/vm_settings_16px.png",
     1770                                                                         ":/vm_settings_disabled_16px.png"));
     1771    m_pSegmentedButton->setIcon(SegmentType_Snapshots, UIIconPool::iconSet(":/snapshot_take_16px.png",
     1772                                                                           ":/snapshot_take_disabled_16px.png"));
     1773    m_pToolBar->addWidget(m_pSegmentedButton);
     1774
     1775    /* Create/add horizontal spacer widget of fixed size for the beta label: */
     1776    QWidget *pSpace = new QWidget(this);
     1777    if (vboxGlobal().isBeta())
     1778        pSpace->setFixedSize(28, 1);
     1779    else
     1780        pSpace->setFixedSize(10, 1);
     1781    m_pToolBar->addWidget(pSpace);
     1782
     1783#ifdef VBOX_WS_MAC
     1784    /* Update toolbar on Mac OS X: */
     1785    m_pToolBar->updateLayout();
     1786#endif /* VBOX_WS_MAC */
     1787
    16911788    /* Prepare graphics VM list: */
    16921789    m_pPaneChooser = new UIGChooser(this);
     
    17001797
    17011798    /* Prepare details and snapshots tabs: */
    1702     m_pPaneDesktop = new UIVMDesktop(m_pToolBar, actionPool()->action(UIActionIndexST_M_Group_S_Refresh), this);
     1799    m_pPaneDesktop = new UIVMDesktop(actionPool()->action(UIActionIndexST_M_Group_S_Refresh), this);
    17031800
    17041801    /* Crate container: */
     
    18231920#endif /* VBOX_WS_MAC */
    18241921
     1922    /* Segmented-button connections: */
     1923    connect(m_pSegmentedButton, SIGNAL(clicked(int)), this, SLOT(sltHandleSegmentedButtonSwitch(int)));
     1924
    18251925    /* VM desktop connections: */
    1826     connect(m_pPaneDesktop, SIGNAL(sigCurrentChanged(int)), this, SLOT(sltHandleDetailsContainerIndexChange(int)));
    18271926    connect(m_pPaneDetails, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),
    18281927            this, SLOT(sltOpenMachineSettingsDialog(const QString&, const QString&, const QString&)));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r63926 r63928  
    4040class QMenu;
    4141class QStackedWidget;
     42class UITexturedSegmentedButton;
    4243
    4344/** Singleton QIMainWindow extension
     
    4647{
    4748    Q_OBJECT;
     49
     50    /** Segmented-button segment types. */
     51    enum SegmentType
     52    {
     53        SegmentType_Details   = 0,
     54        SegmentType_Snapshots
     55    };
    4856
    4957public:
     
    7886    /** Handles selector-window context-menu call for passed @a position. */
    7987    void sltShowSelectorWindowContextMenu(const QPoint &position);
    80 
    81     /** Handles signal about Details-container @a iIndex change. */
    82     void sltHandleDetailsContainerIndexChange(int iIndex);
    8388
    8489    /** Handles signal about Chooser-pane index change.
     
    177182    /** @} */
    178183
     184    /** @name Segmented-button stuff.
     185      * @{ */
     186        /** Handles segmented-button switch. */
     187        void sltHandleSegmentedButtonSwitch(int iSegment);
     188        /** Performs segmented-button switch. */
     189        void sltPerformSegmentedButtonSwitch(int iSegment);
     190        /** Performs segmented-button switch to details pane. */
     191        void sltPerformSegmentedButtonSwitchToDetails() { sltPerformSegmentedButtonSwitch(SegmentType_Details); }
     192    /** @} */
     193
    179194private:
    180195
     
    299314    UIToolBar *m_pToolBar;
    300315
     316    /** Holds the segmented-button instance. */
     317    UITexturedSegmentedButton *m_pSegmentedButton;
     318
    301319    /** Holds the Details-container instance. */
    302320    QStackedWidget *m_pContainerDetails;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp

    r63925 r63928  
    3131# include "UIBar.h"
    3232# include "UIIconPool.h"
    33 # include "UISpacerWidgets.h"
    34 # include "UISpecialControls.h"
    3533# include "UIVMDesktop.h"
    3634# include "UIVMItem.h"
     
    220218}
    221219
    222 UIVMDesktop::UIVMDesktop(UIToolBar *pToolBar, QAction *pRefreshAction, QWidget *pParent)
     220UIVMDesktop::UIVMDesktop(QAction *pRefreshAction, QWidget *pParent)
    223221    : QIWithRetranslateUI<QWidget>(pParent)
    224222{
    225     /* Create container: */
    226     QWidget *pContainer = new QWidget;
    227     {
    228         /* Create layout: */
    229         QHBoxLayout *pLayout = new QHBoxLayout(pContainer);
    230         {
    231             /* Configure layout: */
    232             pLayout->setContentsMargins(0, 0, 0, 0);
    233             /* Create segmented-button: */
    234             m_pHeaderBtn = new UITexturedSegmentedButton(pContainer, 2);
    235             {
    236                 /* Configure segmented-button: */
    237                 m_pHeaderBtn->setIcon(SegmentType_Details, UIIconPool::iconSet(":/vm_settings_16px.png",
    238                                                                                ":/vm_settings_disabled_16px.png"));
    239                 m_pHeaderBtn->setIcon(SegmentType_Snapshots, UIIconPool::iconSet(":/snapshot_take_16px.png",
    240                                                                                  ":/snapshot_take_disabled_16px.png"));
    241                 /* Add segmented-buttons into layout: */
    242                 pLayout->addWidget(m_pHeaderBtn);
    243             }
    244         }
    245     }
    246 
    247 #ifdef VBOX_WS_MAC
    248     /* Cocoa stuff should be async...
    249      * Do not ask me why but otherwise
    250      * it conflicts with native handlers. */
    251     QTimer::singleShot(0, this, SLOT(sltInit()));
    252 #else /* !VBOX_WS_MAC */
    253     sltInit();
    254 #endif /* !VBOX_WS_MAC */
    255 
    256223    /* Prepare main layout: */
    257224    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    258225    pMainLayout->setContentsMargins(0, 0, 0, 0);
    259 
    260     /* The header to select the different pages.
    261      * Has different styles on the different platforms. */
    262     if (pToolBar)
    263     {
    264         pToolBar->addWidget(new UIHorizontalSpacerWidget(this));
    265         pToolBar->addWidget(pContainer);
    266         QWidget *pSpace = new QWidget(this);
    267         /* We need a little bit more space for the beta label. */
    268         if (vboxGlobal().isBeta())
    269             pSpace->setFixedSize(28, 1);
    270         else
    271             pSpace->setFixedSize(10, 1);
    272         pToolBar->addWidget(pSpace);
    273 #ifdef VBOX_WS_MAC
    274         pToolBar->updateLayout();
    275 #endif /* VBOX_WS_MAC */
    276     }
    277     else
    278     {
    279         UIBar *pBar = new UIBar(this);
    280         pBar->setContentWidget(pContainer);
    281         pMainLayout->addWidget(pBar);
    282     }
    283226
    284227    /* Create desktop pane: */
     
    294237    m_pStackedLayout->addWidget(m_pSnapshotsPane);
    295238
    296     /* Connect the header buttons with the stack layout: */
    297     connect(m_pHeaderBtn, SIGNAL(clicked(int)), m_pStackedLayout, SLOT(setCurrentIndex(int)));
    298     connect(m_pStackedLayout, SIGNAL(currentChanged(int)), this, SIGNAL(sigCurrentChanged(int)));
    299 
    300239    /* Translate finally: */
    301240    retranslateUi();
     
    322261}
    323262
    324 void UIVMDesktop::updateSnapshots(UIVMItem *pVMItem, const CMachine &comMachine)
    325 {
    326     /* Update snapshot segment name: */
    327     QString strName = tr("&Snapshots");
    328     if (pVMItem)
    329     {
    330         const ULONG count = pVMItem->snapshotCount();
    331         if (count)
    332             strName += QString(" (%1)").arg(count);
    333     }
    334     m_pHeaderBtn->setTitle(SegmentType_Snapshots, strName);
    335 
    336     /* Update segmented-button availability: */
    337     if (comMachine.isNotNull())
    338         m_pHeaderBtn->setEnabled(SegmentType_Snapshots, true);
    339     else
    340         lockSnapshots();
    341 
    342     /* Update snapshot pane: */
     263void UIVMDesktop::updateSnapshots(const CMachine &comMachine)
     264{
    343265    m_pSnapshotsPane->setMachine(comMachine);
    344266}
    345267
    346 void UIVMDesktop::lockSnapshots()
    347 {
    348     m_pHeaderBtn->animateClick(SegmentType_Details);
    349     m_pHeaderBtn->setEnabled(SegmentType_Snapshots, false);
    350 }
    351 
    352 void UIVMDesktop::sltInit()
    353 {
    354     m_pHeaderBtn->animateClick(0);
    355 }
    356 
    357268void UIVMDesktop::retranslateUi()
    358269{
    359     m_pHeaderBtn->setTitle(SegmentType_Details, tr("&Details"));
    360270}
    361271
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.h

    r63924 r63928  
    3030class CMachine;
    3131class UIVMDesktopPrivate;
    32 class UITexturedSegmentedButton;
    3332class UIVMItem;
    3433class UISnapshotPane;
     
    4544    Q_OBJECT;
    4645
    47     /** Segmented-button segment types. */
    48     enum SegmentType
    49     {
    50         SegmentType_Details   = 0,
    51         SegmentType_Snapshots
    52     };
    53 
    54 signals:
    55 
    56     /* Notifier: Current widget stuff: */
    57     void sigCurrentChanged(int iWidgetIndex);
    58 
    5946public:
    6047
    6148    /* Constructor: */
    62     UIVMDesktop(UIToolBar *pToolBar, QAction *pRefreshAction, QWidget *pParent);
     49    UIVMDesktop(QAction *pRefreshAction, QWidget *pParent);
    6350
    6451    /** Returns current widget index. */
     
    7057    void updateDetailsText(const QString &strText);
    7158    void updateDetailsError(const QString &strError);
    72     void updateSnapshots(UIVMItem *pVMItem, const CMachine& machine);
    73     void lockSnapshots();
    74 
    75 private slots:
    76 
    77     /** Initialization handler. */
    78     void sltInit();
     59    void updateSnapshots(const CMachine &comMachine);
    7960
    8061private:
     
    8566    /* Variables: */
    8667    QStackedLayout *m_pStackedLayout;
    87     UITexturedSegmentedButton *m_pHeaderBtn;
    8868    UIVMDesktopPrivate *m_pDesktopPrivate;
    8969    UISnapshotPane *m_pSnapshotsPane;
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