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
qwindowsuiawindowprovider.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 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 "qwindowsuiawindowprovider.h"
9#include "qwindowsuiautils.h"
10#include "qwindowscontext.h"
11
12#include <QtGui/qaccessible.h>
13#include <QtGui/private/qwindow_p.h>
14#include <QtCore/qloggingcategory.h>
15#include <QtCore/qstring.h>
16
17QT_BEGIN_NAMESPACE
18
19using namespace QWindowsUiAutomation;
20
21
22QWindowsUiaWindowProvider::QWindowsUiaWindowProvider(QAccessible::Id id) :
23 QWindowsUiaBaseProvider(id)
24{
25}
26
27QWindowsUiaWindowProvider::~QWindowsUiaWindowProvider()
28{
29}
30
31HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::SetVisualState(WindowVisualState state) {
32 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
33 QAccessibleInterface *accessible = accessibleInterface();
34 if (!accessible || !accessible->window())
35 return UIA_E_ELEMENTNOTAVAILABLE;
36 auto window = accessible->window();
37 switch (state) {
38 case WindowVisualState_Normal:
39 window->showNormal();
40 break;
41 case WindowVisualState_Maximized:
42 window->showMaximized();
43 break;
44 case WindowVisualState_Minimized:
45 window->showMinimized();
46 break;
47 }
48 return S_OK;
49}
50
51HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::Close() {
52 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
53 QAccessibleInterface *accessible = accessibleInterface();
54 if (!accessible || !accessible->window())
55 return UIA_E_ELEMENTNOTAVAILABLE;
56 accessible->window()->close();
57 return S_OK;
58}
59
60HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::WaitForInputIdle(int milliseconds, __RPC__out BOOL *pRetVal) {
61 Q_UNUSED(milliseconds);
62 Q_UNUSED(pRetVal);
63 return UIA_E_NOTSUPPORTED;
64}
65
66HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::get_CanMaximize(__RPC__out BOOL *pRetVal) {
67 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
68 QAccessibleInterface *accessible = accessibleInterface();
69 if (!accessible || !accessible->window())
70 return UIA_E_ELEMENTNOTAVAILABLE;
71
72 auto window = accessible->window();
73 auto flags = window->flags();
74
75 *pRetVal = (!(flags & Qt::MSWindowsFixedSizeDialogHint)
76 && (flags & Qt::WindowMaximizeButtonHint)
77 && ((flags & Qt::CustomizeWindowHint)
78 || window->maximumSize() == QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)));
79 return S_OK;
80}
81
82HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::get_CanMinimize(__RPC__out BOOL *pRetVal) {
83 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
84 QAccessibleInterface *accessible = accessibleInterface();
85 if (!accessible || !accessible->window())
86 return UIA_E_ELEMENTNOTAVAILABLE;
87 *pRetVal = accessible->window()->flags() & Qt::WindowMinimizeButtonHint;
88 return S_OK;
89}
90
91HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::get_IsModal(__RPC__out BOOL *pRetVal) {
92 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
93 QAccessibleInterface *accessible = accessibleInterface();
94 if (!accessible || !accessible->window())
95 return UIA_E_ELEMENTNOTAVAILABLE;
96 *pRetVal = accessible->window()->isModal();
97 return S_OK;
98}
99
100HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::get_WindowVisualState(__RPC__out enum WindowVisualState *pRetVal) {
101 qCDebug(lcQpaUiAutomation) << __FUNCTION__;
102 QAccessibleInterface *accessible = accessibleInterface();
103 if (!accessible || !accessible->window())
104 return UIA_E_ELEMENTNOTAVAILABLE;
105 auto visibility = accessible->window()->visibility();
106 switch (visibility) {
107 case QWindow::FullScreen:
108 case QWindow::Maximized:
109 *pRetVal = WindowVisualState_Maximized;
110 break;
111 case QWindow::Minimized:
112 *pRetVal = WindowVisualState_Minimized;
113 break;
114 default:
115 *pRetVal = WindowVisualState_Normal;
116 break;
117 }
118 return S_OK;
119}
120
121HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::get_WindowInteractionState(__RPC__out enum WindowInteractionState *pRetVal) {
122 Q_UNUSED(pRetVal);
123 return UIA_E_NOTSUPPORTED;
124}
125
126HRESULT STDMETHODCALLTYPE QWindowsUiaWindowProvider::get_IsTopmost(__RPC__out BOOL *pRetVal) {
127 Q_UNUSED(pRetVal);
128 return UIA_E_NOTSUPPORTED;
129}
130
131QT_END_NAMESPACE
132
133#endif // QT_CONFIG(accessibility)