VirtualBox

Changeset 95661 in vbox


Ignore:
Timestamp:
Jul 15, 2022 11:06:18 AM (2 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: bugref:6899: Accessibility interface for QIRichTextLabel; Fixing small NLS quirk in settings whats-this / tool-tip handling.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIRichTextLabel.cpp

    r93995 r95661  
    1717
    1818/* Qt includes: */
     19#include <QAccessibleWidget>
    1920#include <QtMath>
    2021#include <QUrl>
     
    2425#include "QIRichTextLabel.h"
    2526
     27/* Other VBox includes: */
     28#include "iprt/assert.h"
     29
     30/* Forward declarations: */
     31class QIRichTextLabel;
     32
     33
     34/** QAccessibleObject extension used as an accessibility interface for QIRichTextLabel. */
     35class UIAccessibilityInterfaceForQIRichTextLabel : public QAccessibleWidget
     36{
     37public:
     38
     39    /** Returns an accessibility interface for passed @a strClassname and @a pObject. */
     40    static QAccessibleInterface *pFactory(const QString &strClassname, QObject *pObject)
     41    {
     42        /* Creating QIRichTextLabel accessibility interface: */
     43        if (pObject && strClassname == QLatin1String("QIRichTextLabel"))
     44            return new UIAccessibilityInterfaceForQIRichTextLabel(qobject_cast<QWidget*>(pObject));
     45
     46        /* Null by default: */
     47        return 0;
     48    }
     49
     50    /** Constructs an accessibility interface passing @a pWidget to the base-class. */
     51    UIAccessibilityInterfaceForQIRichTextLabel(QWidget *pWidget)
     52        : QAccessibleWidget(pWidget, QAccessible::StaticText)
     53    {}
     54
     55    /** Returns a text for the passed @a enmTextRole. */
     56    virtual QString text(QAccessible::Text enmTextRole) const RT_OVERRIDE;
     57
     58private:
     59
     60    /** Returns corresponding QIRichTextLabel. */
     61    QIRichTextLabel *label() const;
     62};
     63
     64
     65/*********************************************************************************************************************************
     66*   Class UIAccessibilityInterfaceForQIRichTextLabel implementation.                                                             *
     67*********************************************************************************************************************************/
     68
     69QString UIAccessibilityInterfaceForQIRichTextLabel::text(QAccessible::Text enmTextRole) const
     70{
     71    /* Make sure label still alive: */
     72    AssertPtrReturn(label(), QString());
     73
     74    /* Return the description: */
     75    if (enmTextRole == QAccessible::Description)
     76        return label()->plainText();
     77
     78    /* Null-string by default: */
     79    return QString();
     80}
     81
     82QIRichTextLabel *UIAccessibilityInterfaceForQIRichTextLabel::label() const
     83{
     84    return qobject_cast<QIRichTextLabel*>(widget());
     85}
     86
     87
     88/*********************************************************************************************************************************
     89*   Class QIRichTextLabel implementation.                                                                                        *
     90*********************************************************************************************************************************/
    2691
    2792QIRichTextLabel::QIRichTextLabel(QWidget *pParent)
     
    3095    , m_iMinimumTextWidth(0)
    3196{
     97    /* Install QIRichTextLabel accessibility interface factory: */
     98    QAccessible::installFactory(UIAccessibilityInterfaceForQIRichTextLabel::pFactory);
     99
    32100    /* Configure self: */
    33101    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     
    74142}
    75143
     144QString QIRichTextLabel::plainText() const
     145{
     146    return m_pTextBrowser->toPlainText();
     147}
     148
    76149void QIRichTextLabel::registerImage(const QImage &image, const QString &strName)
    77150{
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIRichTextLabel.h

    r93115 r95661  
    4747    /** Returns text. */
    4848    QString text() const;
     49    /** Returns plain text. */
     50    QString plainText() const;
    4951
    5052    /** Registers @a image under a passed @a strName. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r94064 r95661  
    590590
    591591    if (pWhatsThisWidget && !strWhatsThisText.isEmpty())
    592         pWhatsThisWidget->setToolTip(QString("<qt>%1</qt>").arg(strWhatsThisText));
     592        pWhatsThisWidget->setToolTip(strWhatsThisText);
    593593}
    594594
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