VirtualBox

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


Ignore:
Timestamp:
Jan 9, 2017 1:17:26 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 158): Basic accessibility interface for UIStatusBarEditorWidget.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r64659 r65204  
    13641364}
    13651365
     1366/* QString <= IndicatorType: */
     1367template<> QString toString(const IndicatorType &indicatorType)
     1368{
     1369    QString strResult;
     1370    switch (indicatorType)
     1371    {
     1372        case IndicatorType_HardDisks:     strResult = QApplication::translate("VBoxGlobal", "Hard Disks", "IndicatorType"); break;
     1373        case IndicatorType_OpticalDisks:  strResult = QApplication::translate("VBoxGlobal", "Optical Disks", "IndicatorType"); break;
     1374        case IndicatorType_FloppyDisks:   strResult = QApplication::translate("VBoxGlobal", "Floppy Disks", "IndicatorType"); break;
     1375        case IndicatorType_Network:       strResult = QApplication::translate("VBoxGlobal", "Network", "IndicatorType"); break;
     1376        case IndicatorType_USB:           strResult = QApplication::translate("VBoxGlobal", "USB", "IndicatorType"); break;
     1377        case IndicatorType_SharedFolders: strResult = QApplication::translate("VBoxGlobal", "Shared Folders", "IndicatorType"); break;
     1378        case IndicatorType_Display:       strResult = QApplication::translate("VBoxGlobal", "Display", "IndicatorType"); break;
     1379        case IndicatorType_VideoCapture:  strResult = QApplication::translate("VBoxGlobal", "Video Capture", "IndicatorType"); break;
     1380        case IndicatorType_Features:      strResult = QApplication::translate("VBoxGlobal", "Features", "IndicatorType"); break;
     1381        case IndicatorType_Mouse:         strResult = QApplication::translate("VBoxGlobal", "Mouse", "IndicatorType"); break;
     1382        case IndicatorType_Keyboard:      strResult = QApplication::translate("VBoxGlobal", "Keyboard", "IndicatorType"); break;
     1383        default:
     1384        {
     1385            AssertMsgFailed(("No text for indicator type=%d", indicatorType));
     1386            break;
     1387        }
     1388    }
     1389    return strResult;
     1390}
     1391
    13661392/* QIcon <= IndicatorType: */
    13671393template<> QIcon toIcon(const IndicatorType &indicatorType)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIStatusBarEditorWindow.cpp

    r65203 r65204  
    2121
    2222/* Qt includes: */
     23# include <QAccessibleWidget>
    2324# include <QStylePainter>
    2425# include <QStyleOption>
     
    113114};
    114115
     116
     117/** QAccessibleWidget extension used as an accessibility interface for UIStatusBarEditor buttons. */
     118class UIAccessibilityInterfaceForUIStatusBarEditorButton : public QAccessibleWidget
     119{
     120public:
     121
     122    /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
     123    static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject);
     124
     125    /** Constructs an accessibility interface passing @a pWidget to the base-class. */
     126    UIAccessibilityInterfaceForUIStatusBarEditorButton(QWidget *pWidget);
     127
     128    /** Returns a text for the passed @a enmTextRole. */
     129    virtual QString text(QAccessible::Text enmTextRole) const /* override */;
     130
     131    /** Returns the state. */
     132    virtual QAccessible::State state() const /* override */;
     133
     134private:
     135
     136    /** Returns corresponding toolbar button. */
     137    UIStatusBarEditorButton *button() const { return qobject_cast<UIStatusBarEditorButton*>(widget()); }
     138};
     139
     140
     141/*********************************************************************************************************************************
     142*   Class UIAccessibilityInterfaceForUIStatusBarEditorButton implementation.                                                     *
     143*********************************************************************************************************************************/
     144
     145/* static */
     146QAccessibleInterface *UIAccessibilityInterfaceForUIStatusBarEditorButton::pFactory(const QString &strClassname, QObject *pObject)
     147{
     148    /* Creating toolbar button accessibility interface: */
     149    if (   pObject
     150        && strClassname == QLatin1String("UIStatusBarEditorButton"))
     151        return new UIAccessibilityInterfaceForUIStatusBarEditorButton(qobject_cast<QWidget*>(pObject));
     152
     153    /* Null by default: */
     154    return 0;
     155}
     156
     157UIAccessibilityInterfaceForUIStatusBarEditorButton::UIAccessibilityInterfaceForUIStatusBarEditorButton(QWidget *pWidget)
     158    : QAccessibleWidget(pWidget, QAccessible::CheckBox)
     159{
     160}
     161
     162QString UIAccessibilityInterfaceForUIStatusBarEditorButton::text(QAccessible::Text /* enmTextRole */) const
     163{
     164    /* Make sure view still alive: */
     165    AssertPtrReturn(button(), QString());
     166
     167    /* Return view tool-tip: */
     168    return gpConverter->toString(button()->type());
     169}
     170
     171QAccessible::State UIAccessibilityInterfaceForUIStatusBarEditorButton::state() const /* override */
     172{
     173    /* Prepare the button state: */
     174    QAccessible::State state;
     175
     176    /* Make sure button still alive: */
     177    AssertPtrReturn(button(), state);
     178
     179    /* Compose the button state: */
     180    state.checkable = true;
     181    state.checked = button()->isChecked();
     182
     183    /* Return the button state: */
     184    return state;
     185}
     186
     187
     188
     189/*********************************************************************************************************************************
     190*   Class UIStatusBarEditorButton implementation.                                                                                *
     191*********************************************************************************************************************************/
    115192
    116193/* static */
     
    402479    if (m_strMachineID.isEmpty())
    403480        return;
     481
     482    /* Install tool-bar button accessibility interface factory: */
     483    QAccessible::installFactory(UIAccessibilityInterfaceForUIStatusBarEditorButton::pFactory);
    404484
    405485    /* Track D&D events: */
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