Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwindowsuiaexpandcollapseprovider.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtGui/qtguiglobal.h>
5#if QT_CONFIG(accessibility)
6
8#include "qwindowsuiautils.h"
9#include "qwindowscontext.h"
10
11#include <QtGui/qaccessible.h>
12#include <QtCore/qloggingcategory.h>
13#include <QtCore/qstring.h>
14
16
17using namespace QWindowsUiAutomation;
18
19static bool isExpanded(QAccessibleInterface *accessible)
20{
21 Q_ASSERT(accessible);
22 if (accessible->role() == QAccessible::MenuItem)
23 return accessible->childCount() > 0 && !accessible->child(0)->state().invisible;
24 else
25 return accessible->state().expandable && accessible->state().expanded;
26}
27
28QWindowsUiaExpandCollapseProvider::QWindowsUiaExpandCollapseProvider(QAccessible::Id id) :
29 QWindowsUiaBaseProvider(id)
30{
31}
32
33QWindowsUiaExpandCollapseProvider::~QWindowsUiaExpandCollapseProvider() = default;
34
35HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::Expand()
36{
37 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
38
39 QAccessibleInterface *accessible = accessibleInterface();
40 if (!accessible)
41 return UIA_E_ELEMENTNOTAVAILABLE;
42
43 QAccessibleActionInterface *actionInterface = accessible->actionInterface();
44 if (!actionInterface)
45 return UIA_E_ELEMENTNOTAVAILABLE;
46
47 if (!isExpanded(accessible))
48 actionInterface->doAction(QAccessibleActionInterface::showMenuAction());
49
50 return S_OK;
51}
52
53HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::Collapse()
54{
55 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
56
57 QAccessibleInterface *accessible = accessibleInterface();
58 if (!accessible)
59 return UIA_E_ELEMENTNOTAVAILABLE;
60
61 QAccessibleActionInterface *actionInterface = accessible->actionInterface();
62 if (!actionInterface)
63 return UIA_E_ELEMENTNOTAVAILABLE;
64
65 if (isExpanded(accessible))
66 actionInterface->doAction(QAccessibleActionInterface::showMenuAction());
67
68 return S_OK;
69}
70
71HRESULT STDMETHODCALLTYPE QWindowsUiaExpandCollapseProvider::get_ExpandCollapseState(__RPC__out ExpandCollapseState *pRetVal)
72{
73 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
74
75 if (!pRetVal)
76 return E_INVALIDARG;
77 *pRetVal = ExpandCollapseState_LeafNode;
78
79 QAccessibleInterface *accessible = accessibleInterface();
80 if (!accessible)
81 return UIA_E_ELEMENTNOTAVAILABLE;
82
83 *pRetVal = isExpanded(accessible) ? ExpandCollapseState_Expanded : ExpandCollapseState_Collapsed;
84
85 return S_OK;
86}
87
89
90#endif // QT_CONFIG(accessibility)
Combined button and popup list for selecting options.
#define qCDebug(category,...)
GLenum GLuint id
[7]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
long HRESULT