VirtualBox

Changeset 64100 in vbox


Ignore:
Timestamp:
Sep 29, 2016 5:09:16 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111055
Message:

FE/Qt: bugref:6899: Accessibility support (step 63): Settings: Basic tab-widget selector accessibility interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSelector.cpp

    r64091 r64100  
    2121
    2222/* Qt includes: */
     23# include <QAccessibleWidget>
    2324# include <QAction>
    2425# include <QHeaderView>
    2526# include <QLayout>
    2627# include <QTabWidget>
     28# include <QToolButton>
    2729
    2830/* GUI includes: */
     
    3537
    3638#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     39
     40
     41/** QAccessibleWidget extension used as an accessibility interface for UIToolBar. */
     42class UIAccessibilityInterfaceForUIToolBarButton : public QAccessibleWidget
     43{
     44public:
     45
     46    /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
     47    static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject)
     48    {
     49        /* Creating segmented-button accessibility interface: */
     50        if (   pObject
     51            && strClassname == QLatin1String("QToolButton")
     52            && pObject->property("Belongs to") == "UISettingsSelectorToolBar")
     53            return new UIAccessibilityInterfaceForUIToolBarButton(qobject_cast<QWidget*>(pObject));
     54
     55        /* Null by default: */
     56        return 0;
     57    }
     58
     59    /** Constructs an accessibility interface passing @a pWidget to the base-class. */
     60    UIAccessibilityInterfaceForUIToolBarButton(QWidget *pWidget)
     61        : QAccessibleWidget(pWidget, QAccessible::RadioButton)
     62    {}
     63
     64    virtual QAccessible::State state() const
     65    {
     66        /* Prepare the button state: */
     67        QAccessible::State state;
     68
     69        /* Make sure button still alive: */
     70        AssertPtrReturn(button(), state);
     71
     72        /* Compose the button state: */
     73        state.checkable = button()->isCheckable();
     74        state.checked = button()->isChecked();
     75
     76        /* Return the segment state: */
     77        return state;
     78    }
     79
     80private:
     81
     82    /** Returns corresponding segmented-button. */
     83    QToolButton *button() const { return qobject_cast<QToolButton*>(widget()); }
     84};
    3785
    3886
     
    439487    , m_pActionGroup(0)
    440488{
     489    /* Install tool-bar button accessibility interface factory: */
     490    QAccessible::installFactory(UIAccessibilityInterfaceForUIToolBarButton::pFactory);
     491
    441492    /* Prepare the toolbar: */
    442493    m_pToolBar = new UIToolBar(pParent);
     
    489540        m_pActionGroup->addAction(pItem->action());
    490541        m_pToolBar->addAction(pItem->action());
     542        m_pToolBar->widgetForAction(pItem->action())
     543            ->setProperty("Belongs to", "UISettingsSelectorToolBar");
    491544        pPage->setContentsMargins(0, 0, 0, 0);
    492545        pPage->layout()->setContentsMargins(0, 0, 0, 0);
     
    498551        m_pActionGroup->addAction(pItem->action());
    499552        m_pToolBar->addAction(pItem->action());
     553        m_pToolBar->widgetForAction(pItem->action())
     554            ->setProperty("Belongs to", "UISettingsSelectorToolBar");
    500555        QITabWidget *pTabWidget = new QITabWidget();
    501556        pTabWidget->setIconSize(QSize(16, 16));
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