summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Millán Soto <fid@gpul.org>2012-10-26 15:23:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-15 20:45:59 +0100
commit568b278b75496861881bdf6834ea9b0e99d97537 (patch)
treed35ffa71e7ed4eca7cb5d24391bb5553acd8a9e9
parent139f416237c52575b236c3b61e25796c83034567 (diff)
Implemented AtSpiAdaptor::notifyStateChange
Adding a new private method to simplify notifying that the state has changed as it is something that is frequently done in AtSpiAdaptor::notify Change-Id: Idf21715b5d20212adb301ae9bca05f1edfc19946 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp28
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor_p.h2
2 files changed, 15 insertions, 15 deletions
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index eb0177bfb7..506416af53 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -904,6 +904,14 @@ QAIPointer AtSpiAdaptor::interfaceFromPath(const QString& dbusPath) const
return QAIPointer();
}
+void AtSpiAdaptor::notifyStateChange(const QAIPointer &interface, const QString &state, int value)
+{
+ QString path = pathForInterface(interface);
+ QVariantList stateArgs = packDBusSignalArguments(state, value, 0, variantForPath(path));
+ sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+ QLatin1String("StateChanged"), stateArgs);
+}
+
/*!
This function gets called when Qt notifies about accessibility updates.
@@ -920,19 +928,13 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
break;
case QAccessible::ObjectShow: {
if (sendObject || sendObject_state_changed) {
- QString path = pathForInterface(QAIPointer(event->accessibleInterface()));
- QVariantList stateArgs = packDBusSignalArguments(QLatin1String("showing"), 1, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), stateArgs);
+ notifyStateChange(QAIPointer(event->accessibleInterface()), QLatin1String("showing"), 1);
}
break;
}
case QAccessible::ObjectHide: {
if (sendObject || sendObject_state_changed) {
- QString path = pathForInterface(QAIPointer(event->accessibleInterface()));
- QVariantList stateArgs = packDBusSignalArguments(QLatin1String("showing"), 0, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), stateArgs);
+ notifyStateChange(QAIPointer(event->accessibleInterface()), QLatin1String("showing"), 0);
}
break;
}
@@ -1076,10 +1078,7 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
if (stateChange.checked) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
int checked = iface->state().checked;
- QString path = pathForInterface(iface);
- QVariantList args = packDBusSignalArguments(QLatin1String("checked"), checked, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), args);
+ notifyStateChange(iface, QLatin1String("checked"), checked);
} else if (stateChange.active) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
if (!(iface->role() == QAccessible::Window && (sendWindow || sendWindow_activate)))
@@ -1093,9 +1092,8 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
QString path = pathForInterface(iface);
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_WINDOW), status, args);
- QVariantList stateArgs = packDBusSignalArguments(QLatin1String("active"), iface->state().active ? 1 : 0, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), stateArgs);
+ int isActive = iface->state().active;
+ notifyStateChange(iface, QLatin1String("active"), isActive);
}
}
break;
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h
index 4a8ff23bef..5b5eb60228 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor_p.h
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor_p.h
@@ -111,6 +111,8 @@ private:
QString pathForInterface(const QAIPointer &interface, bool inDestructor = false) const;
QString pathForObject(QObject *object) const;
+ void notifyStateChange(const QAIPointer& interface, const QString& state, int value);
+
// accessible helper functions
AtspiRole getRole(const QAIPointer &interface) const;
QSpiRelationArray relationSet(const QAIPointer &interface, const QDBusConnection &connection) const;