Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qohosjswindowregistry.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 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
<
qohosplugincore
.
h
>
5
#
include
<
qohosutils
.
h
>
6
#
include
<
render
/
qohosjswindowregistry
.
h
>
7
#
include
<
tuple
>
8
9
QT_BEGIN_NAMESPACE
10
11
QOhosJsWindowRegistry
&
QOhosJsWindowRegistry
::instance(QOhosJsState &jsState)
12
{
13
return
QtOhos::JsState::castFrom(jsState).getAttachedObjectWithLazyCreate<
QOhosJsWindowRegistry
>();
14
}
15
16
QOhosJsWindowRegistry
::
QOhosJsWindowRegistry
() =
default
;
17
18
std
::shared_ptr<
void
>
QOhosJsWindowRegistry
::
registerJsWindow
(
std
::shared_ptr<
QArkUi
::
JsWindowRef
> jsWindowRef)
19
{
20
auto
jsWindowId = jsWindowRef->id();
21
22
bool
added =
false
;
23
std
::tie(
std
::ignore, added) = m_windowRefs.insert({jsWindowRef->id(), jsWindowRef});
24
if
(!added) {
25
qOhosReportFatalErrorAndAbort(
26
"%s: Duplicate jsWindow with id: %f"
, Q_FUNC_INFO, jsWindowId.value());
27
}
28
29
return
QtOhos::makeProxyWithJsThreadDeleter(
30
QtOhos::makeDestroyNotifier([
this
, jsWindowId]() {
31
std::ignore = m_windowRefs.erase(jsWindowId);
32
}));
33
}
34
35
std
::
vector
<
QArkUi
::
JsWindowId
>
QOhosJsWindowRegistry
::
queryByPredicate
(
36
QOhosJsState &jsState,
37
const
std::function<
bool
(QOhosJsState &,
const
QArkUi::JsWindowRef &)> &predicate)
38
{
39
std::vector<QArkUi::JsWindowId> result;
40
for
(
const
auto
&windowIdRefPair : m_windowRefs) {
41
if
(predicate(jsState, *(windowIdRefPair.second)))
42
result.push_back(windowIdRefPair.first);
43
}
44
return
result;
45
}
46
47
std
::shared_ptr<
QArkUi
::
JsWindowRef
>
QOhosJsWindowRegistry
::
tryFindJsWindowById
(
QArkUi
::JsWindowId jsWinId)
const
48
{
49
auto
jsWinIter = m_windowRefs.find(jsWinId);
50
return
jsWinIter != m_windowRefs.end()
51
? jsWinIter->second
52
:
nullptr
;
53
}
54
55
std
::shared_ptr<
QArkUi
::
JsWindowRef
>
QOhosJsWindowRegistry
::
tryFindJsWindowByQWindowRef
(
56
QtOhos::QObjectThreadSafeRef qwindow)
const
57
{
58
for
(
const
auto
&windowIdRefPair : m_windowRefs) {
59
if
(windowIdRefPair.second->owningQWindowRef() == qwindow)
60
return
windowIdRefPair.second;
61
}
62
return
nullptr
;
63
}
64
65
QT_END_NAMESPACE
QArkUi::JsWindowRef
Definition
window.h:35
QOhosJsWindowRegistry
Definition
qohosjswindowregistry.h:18
QOhosJsWindowRegistry::tryFindJsWindowById
std::shared_ptr< QArkUi::JsWindowRef > tryFindJsWindowById(QArkUi::JsWindowId jsWinId) const
Definition
qohosjswindowregistry.cpp:47
QOhosJsWindowRegistry::tryFindJsWindowByQWindowRef
std::shared_ptr< QArkUi::JsWindowRef > tryFindJsWindowByQWindowRef(QtOhos::QObjectThreadSafeRef qwindow) const
Definition
qohosjswindowregistry.cpp:55
QOhosJsWindowRegistry::QOhosJsWindowRegistry
QOhosJsWindowRegistry()
QOhosJsWindowRegistry::registerJsWindow
std::shared_ptr< void > registerJsWindow(std::shared_ptr< QArkUi::JsWindowRef > jsWindowRef)
Definition
qohosjswindowregistry.cpp:18
QOhosJsWindowRegistry::queryByPredicate
std::vector< QArkUi::JsWindowId > queryByPredicate(QOhosJsState &jsState, const std::function< bool(QOhosJsState &, const QArkUi::JsWindowRef &)> &predicate)
Definition
qohosjswindowregistry.cpp:35
QArkUi
Definition
displaymanager.cpp:17
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtbase
src
plugins
platforms
ohos
render
qohosjswindowregistry.cpp
Generated on
for Qt by
1.18.0