VirtualBox

Changeset 104630 in vbox


Ignore:
Timestamp:
May 14, 2024 2:00:10 PM (7 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10672: Accessibility fixes for Runtime UI; Providing UIMachineView with own accessibility interface wrapping underlying graphical canvas.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r104393 r104630  
    2828/* Qt includes: */
    2929#include <QAbstractNativeEventFilter>
     30#include <QAccessibleWidget>
    3031#include <QApplication>
    3132#include <QBitmap>
     
    4243#include "UIDesktopWidgetWatchdog.h"
    4344#include "UIExtraDataManager.h"
     45#include "UIFrameBuffer.h"
     46#include "UIKeyboardHandler.h"
    4447#include "UILoggingDefs.h"
    4548#include "UIMachine.h"
     
    5154#include "UIMachineViewSeamless.h"
    5255#include "UIMachineViewScale.h"
     56#include "UIMouseHandler.h"
    5357#include "UINotificationCenter.h"
    54 #include "UIKeyboardHandler.h"
    55 #include "UIMouseHandler.h"
    56 #include "UIFrameBuffer.h"
     58#include "UITranslationEventListener.h"
    5759#ifdef VBOX_WS_MAC
    5860# include "UICocoaApplication.h"
     
    102104# define DNDDEBUG(x)
    103105#endif
     106
     107
     108/** QAccessibleWidget extension used as an accessibility interface for Machine-view. */
     109class UIAccessibilityInterfaceForUIMachineView : public QAccessibleWidget
     110{
     111public:
     112
     113    /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
     114    static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject)
     115    {
     116        /* Creating Machine-view accessibility interface: */
     117        if (pObject && strClassname == QLatin1String("UIMachineView"))
     118            return new UIAccessibilityInterfaceForUIMachineView(qobject_cast<QWidget*>(pObject));
     119
     120        /* Null by default: */
     121        return 0;
     122    }
     123
     124    /** Constructs an accessibility interface passing @a pWidget to the base-class. */
     125    UIAccessibilityInterfaceForUIMachineView(QWidget *pWidget)
     126        : QAccessibleWidget(pWidget, QAccessible::Canvas)
     127    {}
     128
     129    /** Returns the number of children. */
     130    virtual int childCount() const RT_OVERRIDE
     131    {
     132        /* Make sure view still alive: */
     133        AssertPtrReturn(view(), 0);
     134
     135        /* Zero by default: */
     136        return 0;
     137    }
     138
     139    /** Returns the child with the passed @a iIndex. */
     140    virtual QAccessibleInterface *child(int iIndex) const RT_OVERRIDE
     141    {
     142        /* Make sure view still alive: */
     143        AssertPtrReturn(view(), 0);
     144        /* Make sure index is valid: */
     145        AssertReturn(iIndex >= 0 && iIndex < childCount(), 0);
     146
     147        /* Null by default: */
     148        return 0;
     149    }
     150
     151    /** Returns the index of passed @a pChild. */
     152    virtual int indexOfChild(const QAccessibleInterface *pChild) const RT_OVERRIDE
     153    {
     154        /* Make sure view still alive: */
     155        AssertPtrReturn(view(), -1);
     156        /* Make sure child is valid: */
     157        AssertReturn(pChild, -1);
     158
     159        /* -1 by default: */
     160        return -1;;
     161    }
     162
     163    /** Returns a text for the passed @a enmTextRole. */
     164    virtual QString text(QAccessible::Text enmTextRole) const RT_OVERRIDE
     165    {
     166        /* Make sure view still alive: */
     167        AssertPtrReturn(view(), QString());
     168
     169        /* Gather suitable text: */
     170        Q_UNUSED(enmTextRole);
     171        QString strText = view()->toolTip();
     172        if (strText.isEmpty())
     173            strText = view()->whatsThis();
     174        return strText;
     175    }
     176
     177private:
     178
     179    /** Returns corresponding Machine-view. */
     180    UIMachineView *view() const { return qobject_cast<UIMachineView*>(widget()); }
     181};
    104182
    105183
     
    11451223}
    11461224
     1225void UIMachineView::sltRetranslateUI()
     1226{
     1227    setWhatsThis(tr("Holds the graphical canvas containing guest screen contents."));
     1228}
     1229
    11471230UIMachineView::UIMachineView(UIMachineWindow *pMachineWindow, ulong uScreenId)
    11481231    : QAbstractScrollArea(pMachineWindow->centralWidget())
     
    11581241    , m_pNativeEventFilter(0)
    11591242{
     1243    /* Install Machine-view accessibility interface factory: */
     1244    QAccessible::installFactory(UIAccessibilityInterfaceForUIMachineView::pFactory);
    11601245}
    11611246
     
    13211406    /* UICommon connections: */
    13221407    connect(&uiCommon(), &UICommon::sigAskToDetachCOM, this, &UIMachineView::sltDetachCOM);
     1408
    13231409    /* Desktop resolution change (e.g. monitor hotplug): */
    13241410    connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenResized,
    13251411            this, &UIMachineView::sltDesktopResized);
     1412
    13261413    /* Scale-factor change: */
    13271414    connect(gEDataManager, &UIExtraDataManager::sigScaleFactorChange,
     
    13301417    connect(gEDataManager, &UIExtraDataManager::sigScalingOptimizationTypeChange,
    13311418            this, &UIMachineView::sltHandleScalingOptimizationChange);
     1419
    13321420    /* Action-pool connections: */
    13331421    UIActionPoolRuntime *pActionPoolRuntime = qobject_cast<UIActionPoolRuntime*>(actionPool());
     
    13391427                this, &UIMachineView::sltHandleActionTriggerViewScreenResize);
    13401428    }
     1429
     1430    /* Translate initially: */
     1431    connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
     1432            this, &UIMachineView::sltRetranslateUI);
     1433    sltRetranslateUI();
    13411434}
    13421435
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r103988 r104630  
    234234    void sltDetachCOM();
    235235
     236    /** Handles translation event. */
     237    void sltRetranslateUI();
     238
    236239protected:
    237240
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