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
QtServiceEmbeddedDelegate.java
Go to the documentation of this file.
1
// Copyright (C) 2024 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
package
org.qtproject.qt.android;
5
6
import
static
org.qtproject.qt.android.QtNative.ApplicationState.ApplicationSuspended;
7
8
import
android.app.Service;
9
import
android.content.res.Resources;
10
import
android.util.DisplayMetrics;
11
12
import
java.util.HashSet;
13
18
class
QtServiceEmbeddedDelegate
implements
QtEmbeddedViewInterface
,
QtNative
.AppStateDetailsListener
19
{
20
private
final
Service m_service;
21
private
final
HashSet<QtView> m_views =
new
HashSet<>();
22
23
QtServiceEmbeddedDelegate(Service service)
24
{
25
m_service =
service
;
26
QtNative.registerAppStateListener(
this
);
27
QtNative.setService(service);
28
// QTBUG-122920 TODO Implement accessibility for service UIs
29
// QTBUG-122552 TODO Implement text input
30
}
31
32
@
Override
33
public
void
onNativePluginIntegrationReadyChanged(
boolean
ready)
34
{
35
synchronized
(
this
) {
36
if
(ready) {
37
QtNative.runAction(() -> {
38
final
DisplayMetrics
metrics
= Resources.getSystem().getDisplayMetrics();
39
40
final
int
maxWidth =
metrics
.widthPixels;
41
final
int
maxHeight =
metrics
.heightPixels;
42
43
QtDisplayManager.handleLayoutSizeChanged(maxWidth, maxHeight);
44
45
QtDisplayManager.updateRefreshRate(m_service);
46
QtDisplayManager.handleScreenDensityChanged(
metrics
.density);
47
});
48
}
49
}
50
}
51
52
// QtEmbeddedViewInterface implementation begin
53
@
Override
54
public
void
startQtApplication(String appParams, String mainLib)
55
{
56
QtNative.startApplication(appParams, mainLib);
57
}
58
59
@
Override
60
public
void
addView(QtView
view
)
61
{
62
if
(m_views.add(
view
)) {
63
QtNative.runAction(() -> createRootWindow(
view
));
64
}
65
}
66
67
@
Override
68
public
void
removeView(QtView
view
)
69
{
70
m_views.remove(
view
);
71
if
(m_views.isEmpty())
72
cleanup();
73
}
74
// QtEmbeddedViewInterface implementation end
75
76
private
void
createRootWindow(QtView
view
)
77
{
78
if
(m_views.contains(
view
)) {
79
QtView.createRootWindow(
view
,
view
.getLeft(),
view
.getTop(),
view
.getWidth(),
80
view
.getHeight());
81
}
82
}
83
84
private
void
cleanup()
85
{
86
QtNative.setApplicationState(ApplicationSuspended);
87
QtNative.unregisterAppStateListener(QtServiceEmbeddedDelegate.this);
88
QtEmbeddedViewInterfaceFactory.remove(m_service);
89
90
QtNative.terminateQtNativeApplication();
91
QtNative.setService(
null
);
92
}
93
}
org.qtproject.qt.android.QtNative
Definition
QtNative.java:38
org.qtproject.qt.android.QtEmbeddedViewInterface
Definition
QtEmbeddedViewInterface.java:11
QtAndroidPrivate::service
Q_CORE_EXPORT QtJniTypes::Service service()
Definition
qjnihelpers.cpp:385
QtMocConstants::Override
@ Override
Definition
qtmocconstants.h:43
metrics
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
Definition
qopengles2ext.h:3196
view
QQuickView * view
[0]
Definition
src_plugins_platforms_qnx_qqnxwindow.cpp:5
qtbase
src
android
jar
src
org
qtproject
qt
android
QtServiceEmbeddedDelegate.java
Generated on
for Qt by
1.18.0