5#include <QtGui/qtguiglobal.h>
6#if QT_CONFIG(accessibility)
8#include "qwindowsuiaexpandcollapseprovider.h"
9#include "qwindowsuiautils.h"
10#include "qwindowscontext.h"
12#include <QtGui/qaccessible.h>
13#include <QtCore/qloggingcategory.h>
14#include <QtCore/qstring.h>
18using namespace QWindowsUiAutomation;
20static bool isExpanded(QAccessibleInterface *accessible)
23 if (accessible->role() == QAccessible::MenuItem)
24 return accessible->childCount() > 0 && !accessible->child(0)->state().invisible;
26 return accessible->state().expandable && accessible->state().expanded;
29QWindowsUiaExpandCollapseProvider::QWindowsUiaExpandCollapseProvider(QAccessible::Id id) :
30 QWindowsUiaBaseProvider(id)
34QWindowsUiaExpandCollapseProvider::~QWindowsUiaExpandCollapseProvider() =
default;
36HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::Expand()
38 qCDebug(lcQpaUiAutomation) <<
__FUNCTION__;
40 QAccessibleInterface *accessible = accessibleInterface();
42 return UIA_E_ELEMENTNOTAVAILABLE;
44 QAccessibleActionInterface *actionInterface = accessible->actionInterface();
46 return UIA_E_ELEMENTNOTAVAILABLE;
48 if (!isExpanded(accessible))
49 actionInterface->doAction(QAccessibleActionInterface::showMenuAction());
54HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::Collapse()
56 qCDebug(lcQpaUiAutomation) <<
__FUNCTION__;
58 QAccessibleInterface *accessible = accessibleInterface();
60 return UIA_E_ELEMENTNOTAVAILABLE;
62 QAccessibleActionInterface *actionInterface = accessible->actionInterface();
64 return UIA_E_ELEMENTNOTAVAILABLE;
66 if (isExpanded(accessible))
67 actionInterface->doAction(QAccessibleActionInterface::showMenuAction());
72HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::get_ExpandCollapseState(__RPC__out ExpandCollapseState *pRetVal)
74 qCDebug(lcQpaUiAutomation) <<
__FUNCTION__;
78 *pRetVal = ExpandCollapseState_LeafNode;
80 QAccessibleInterface *accessible = accessibleInterface();
82 return UIA_E_ELEMENTNOTAVAILABLE;
84 *pRetVal = isExpanded(accessible) ? ExpandCollapseState_Expanded : ExpandCollapseState_Collapsed;