VirtualBox

Changeset 63697 in vbox


Ignore:
Timestamp:
Sep 2, 2016 1:02:50 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: Accessibility support (step 3): Selector UI: Basic Chooser-view accessibility interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserView.cpp

    r63696 r63697  
    2222/* Qt includes: */
    2323# include <QScrollBar>
     24# include <QAccessibleWidget>
    2425
    2526/* GUI includes: */
    2627# include "UIGChooser.h"
     28# include "UIGChooserModel.h"
    2729# include "UIGChooserView.h"
    2830# include "UIGChooserItem.h"
    2931
     32/* Other VBox includes: */
     33# include <iprt/assert.h>
     34
    3035#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     36
     37
     38/** QAccessibleWidget extension used as an accessibility interface for Chooser-view. */
     39class UIAccessibilityInterfaceForUIGChooserView : public QAccessibleWidget
     40{
     41public:
     42
     43    /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
     44    static QAccessibleInterface* pFactory(const QString &strClassname, QObject *pObject)
     45    {
     46        /* Creating Chooser-view accessibility interface: */
     47        if (pObject && strClassname == QLatin1String("UIGChooserView"))
     48            return new UIAccessibilityInterfaceForUIGChooserView(qobject_cast<QWidget*>(pObject));
     49
     50        /* Null by default: */
     51        return 0;
     52    }
     53
     54    /** Constructs an accessibility interface passing @a pWidget to the base-class. */
     55    UIAccessibilityInterfaceForUIGChooserView(QWidget *pWidget)
     56        : QAccessibleWidget(pWidget, QAccessible::List)
     57    {}
     58
     59    /** Returns the number of children. */
     60    virtual int childCount() const /* override */
     61    {
     62        /* Make sure view still alive: */
     63        AssertPtrReturn(view(), 0);
     64
     65        /* Return the number of children: */
     66        return view()->chooser()->model()->root()->items().size();
     67    }
     68
     69    /** Returns the child with the passed @a iIndex. */
     70    virtual QAccessibleInterface *child(int iIndex) const /* override */
     71    {
     72        /* Make sure view still alive: */
     73        AssertPtrReturn(view(), 0);
     74
     75        /* Make sure index is valid: */
     76        if (iIndex < childCount())
     77            return QAccessible::queryAccessibleInterface(view()->chooser()->model()->root()->items().at(iIndex));
     78
     79        /* Null by default: */
     80        return 0;
     81    }
     82
     83    /** Returns a text for the passed @a enmTextRole. */
     84    virtual QString text(QAccessible::Text enmTextRole) const /* override */
     85    {
     86        /* Make sure view still alive: */
     87        AssertPtrReturn(view(), QString());
     88
     89        /* Return view tool-tip: */
     90        Q_UNUSED(enmTextRole);
     91        return view()->toolTip();
     92    }
     93
     94private:
     95
     96    /** Returns corresponding Chooser-view. */
     97    UIGChooserView* view() const { return qobject_cast<UIGChooserView*>(widget()); }
     98};
    3199
    32100
     
    37105    , m_iMinimumHeightHint(0)
    38106{
     107    /* Install Chooser-view accessibility interface factory: */
     108    QAccessible::installFactory(UIAccessibilityInterfaceForUIGChooserView::pFactory);
     109
    39110    /* Setup frame: */
    40111    setFrameShape(QFrame::NoFrame);
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