Hide "invalid" accessibility interfaces.

Those with a null object pointer and those with a
null rect.

Change-Id: I40e0c435ee768fc8c58098fec131eb65e89d76f2
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
Morten Johan Sørvig 2013-04-16 15:26:38 +02:00 committed by The Qt Project
parent cbde509965
commit a7fd8696dd
3 changed files with 32 additions and 3 deletions

View File

@ -253,9 +253,21 @@ void AccessibilitySceneManager::updateItemFlags(QGraphicsRectItem *item, QAccess
}
}
if (m_optionsWidget->hideNullObjectItems()) {
if (interface->object() == 0) {
shouldShow = false;
}
}
if (m_optionsWidget->hideNullRectItems()) {
if (interface->rect().isNull()) {
shouldShow = false;
}
}
item->setVisible(shouldShow);
if (interface->object() == m_selectedObject)
if (interface->object() && interface->object() == m_selectedObject)
item->setBrush(QColor(Qt::yellow));
else
item->setBrush(QColor(Qt::white));
@ -392,7 +404,7 @@ void AccessibilitySceneManager::addGraphicsItems(AccessibilitySceneManager::Tree
graphicsItem->setRect(0, 0, m_treeItemWidth, m_treeItemHeight);
graphicsItem->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
if (item.object == m_selectedObject)
if (item.object && item.object == m_selectedObject)
graphicsItem->setBrush(QColor(Qt::yellow));
else
graphicsItem->setBrush(QColor(Qt::white));

View File

@ -77,6 +77,18 @@ public:
m_hidePaneItems->setChecked(true);
connect(m_hidePaneItems, SIGNAL(toggled(bool)), SIGNAL(optionsChanged()));
m_hideNullObjectItems = new QCheckBox(this);
m_layout->addWidget(m_hideNullObjectItems);
m_hideNullObjectItems->setText("Hide Items with a null QObject pointer");
m_hideNullObjectItems->setChecked(true);
connect(m_hideNullObjectItems, SIGNAL(toggled(bool)), SIGNAL(optionsChanged()));
m_hideNullRectItems = new QCheckBox(this);
m_layout->addWidget(m_hideNullRectItems);
m_hideNullRectItems->setText("Hide Items with a null rect");
m_hideNullRectItems->setChecked(true);
connect(m_hideNullRectItems, SIGNAL(toggled(bool)), SIGNAL(optionsChanged()));
m_enableTextToSpeach = new QCheckBox(this);
m_layout->addWidget(m_enableTextToSpeach);
m_enableTextToSpeach->setText("Enable Text To Speech");
@ -96,6 +108,8 @@ public:
bool hideInvisibleItems() { return m_hideInvisibleItems->isChecked(); }
bool hideOffscreenItems() { return m_hideOffscreenItems->isChecked(); }
bool hidePaneItems() { return m_hidePaneItems->isChecked(); }
bool hideNullObjectItems() { return m_hideNullObjectItems->isChecked(); }
bool hideNullRectItems() { return m_hideNullRectItems->isChecked(); }
bool enableTextToSpeach() { return m_enableTextToSpeach->isChecked(); }
signals:
void optionsChanged();
@ -109,6 +123,8 @@ private:
QCheckBox *m_hideInvisibleItems;
QCheckBox *m_hideOffscreenItems;
QCheckBox *m_hidePaneItems;
QCheckBox *m_hideNullObjectItems;
QCheckBox *m_hideNullRectItems;
QCheckBox *m_enableTextToSpeach;
QSlider *m_scale;
};

View File

@ -107,6 +107,7 @@ void ScreenReader::processTouchPoint()
}
m_selectedInterface = currentInterface;
if (m_selectedInterface->object())
emit selected(m_selectedInterface->object());
if (m_optionsWidget->enableTextToSpeach())
speak(m_selectedInterface->text(QAccessible::Name)