Bind MnemonicLabel’s “plain” label to buddy’s Accessible.name
This is to give a default name to form controls by default, like <label> does to <input> and <textarea> in HTML. Had to add a “plain” version of the label, with neither the <u> tag used in rich text or the ‘&’ in the “regular” label, otherwise orca would spell out these symbols.
This commit is contained in:
parent
f4affd9241
commit
9f181047ac
|
@ -22,6 +22,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Accessible.role: Accessible.Form
|
||||||
title: qsTr("Login")
|
title: qsTr("Login")
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|
|
@ -18,4 +18,10 @@ Label {
|
||||||
control.buddy.forceActiveFocus();
|
control.buddy.forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
property: "Accessible.name"
|
||||||
|
target: control.buddy
|
||||||
|
value: control.Mnemonic.plainLabel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ private:
|
||||||
MnemonicAttached::MnemonicAttached(QObject *parent)
|
MnemonicAttached::MnemonicAttached(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_label{}
|
, m_label{}
|
||||||
|
, m_plainLabel{}
|
||||||
, m_richTextLabel{}
|
, m_richTextLabel{}
|
||||||
, m_active{MnemonicEventFilter::instance().isAltPressed()}
|
, m_active{MnemonicEventFilter::instance().isAltPressed()}
|
||||||
{
|
{
|
||||||
|
@ -93,9 +94,15 @@ void MnemonicAttached::setLabel(const QString &label)
|
||||||
emit labelChanged();
|
emit labelChanged();
|
||||||
emit sequenceChanged();
|
emit sequenceChanged();
|
||||||
|
|
||||||
|
setPlainLabel(QString(m_label).remove('&'_L1));
|
||||||
updateRichText();
|
updateRichText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MnemonicAttached::plainLabel() const
|
||||||
|
{
|
||||||
|
return m_plainLabel;
|
||||||
|
}
|
||||||
|
|
||||||
QString MnemonicAttached::richTextLabel() const
|
QString MnemonicAttached::richTextLabel() const
|
||||||
{
|
{
|
||||||
return m_richTextLabel;
|
return m_richTextLabel;
|
||||||
|
@ -124,6 +131,15 @@ void MnemonicAttached::onAltReleased()
|
||||||
updateRichText();
|
updateRichText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MnemonicAttached::setPlainLabel(const QString &plain)
|
||||||
|
{
|
||||||
|
if (plain == m_plainLabel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_plainLabel = plain;
|
||||||
|
emit plainLabelChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void MnemonicAttached::updateRichText()
|
void MnemonicAttached::updateRichText()
|
||||||
{
|
{
|
||||||
QString richTextLabel;
|
QString richTextLabel;
|
||||||
|
|
|
@ -11,6 +11,7 @@ class MnemonicAttached : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged FINAL)
|
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged FINAL)
|
||||||
|
Q_PROPERTY(QString plainLabel READ plainLabel NOTIFY plainLabelChanged FINAL)
|
||||||
Q_PROPERTY(QString richTextLabel READ richTextLabel NOTIFY richTextLabelChanged FINAL)
|
Q_PROPERTY(QString richTextLabel READ richTextLabel NOTIFY richTextLabelChanged FINAL)
|
||||||
Q_PROPERTY(QKeySequence sequence READ sequence NOTIFY sequenceChanged FINAL)
|
Q_PROPERTY(QKeySequence sequence READ sequence NOTIFY sequenceChanged FINAL)
|
||||||
|
|
||||||
|
@ -25,6 +26,8 @@ public:
|
||||||
QString label() const;
|
QString label() const;
|
||||||
void setLabel(const QString &label);
|
void setLabel(const QString &label);
|
||||||
|
|
||||||
|
QString plainLabel() const;
|
||||||
|
|
||||||
QString richTextLabel() const;
|
QString richTextLabel() const;
|
||||||
|
|
||||||
QKeySequence sequence() const;
|
QKeySequence sequence() const;
|
||||||
|
@ -32,6 +35,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void enabledChanged();
|
void enabledChanged();
|
||||||
void labelChanged();
|
void labelChanged();
|
||||||
|
void plainLabelChanged();
|
||||||
void richTextLabelChanged();
|
void richTextLabelChanged();
|
||||||
void sequenceChanged();
|
void sequenceChanged();
|
||||||
|
|
||||||
|
@ -40,9 +44,11 @@ private slots:
|
||||||
void onAltReleased();
|
void onAltReleased();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setPlainLabel(const QString &plain);
|
||||||
void updateRichText();
|
void updateRichText();
|
||||||
|
|
||||||
QString m_label;
|
QString m_label;
|
||||||
|
QString m_plainLabel;
|
||||||
QString m_richTextLabel;
|
QString m_richTextLabel;
|
||||||
bool m_active;
|
bool m_active;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue