Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsuiatoggleprovider.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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// Qt-Security score:significant reason:default
4
5#include <QtGui/qtguiglobal.h>
6#if QT_CONFIG(accessibility)
7
8#include "qwindowsuiatoggleprovider.h"
9#include "qwindowsuiautils.h"
10#include "qwindowscontext.h"
11
12#include <QtGui/qaccessible.h>
13#include <QtCore/qloggingcategory.h>
14#include <QtCore/qstring.h>
15
16QT_BEGIN_NAMESPACE
17
18using namespace QWindowsUiAutomation;
19
20
21QWindowsUiaToggleProvider::QWindowsUiaToggleProvider(QAccessible::Id id) :
22 QWindowsUiaBaseProvider(id)
23{
24}
25
26QWindowsUiaToggleProvider::~QWindowsUiaToggleProvider()
27{
28}
29
30// toggles the state by invoking the toggle action
31HRESULT STDMETHODCALLTYPE QWindowsUiaToggleProvider::Toggle()
32{
33 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
34
35 QAccessibleInterface *accessible = accessibleInterface();
36 if (!accessible)
37 return UIA_E_ELEMENTNOTAVAILABLE;
38
39 QAccessibleActionInterface *actionInterface = accessible->actionInterface();
40 if (!actionInterface)
41 return UIA_E_ELEMENTNOTAVAILABLE;
42
43 actionInterface->doAction(QAccessibleActionInterface::toggleAction());
44 return S_OK;
45}
46
47// Gets the current toggle state.
48HRESULT STDMETHODCALLTYPE QWindowsUiaToggleProvider::get_ToggleState(ToggleState *pRetVal)
49{
50 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
51
52 if (!pRetVal)
53 return E_INVALIDARG;
54 *pRetVal = ToggleState_Off;
55
56 QAccessibleInterface *accessible = accessibleInterface();
57 if (!accessible)
58 return UIA_E_ELEMENTNOTAVAILABLE;
59
60 if (accessible->state().checked)
61 *pRetVal = accessible->state().checkStateMixed ? ToggleState_Indeterminate : ToggleState_On;
62 else
63 *pRetVal = ToggleState_Off;
64 return S_OK;
65}
66
67QT_END_NAMESPACE
68
69#endif // QT_CONFIG(accessibility)