Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qandroidplatformforeignwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
5#include "androidjnimain.h"
6#include <QtCore/qvariant.h>
7#include <qpa/qwindowsysteminterface.h>
8#include <QtCore/private/qjnihelpers_p.h>
9
11
14 m_surfaceId(-1)
15{
16 m_view = reinterpret_cast<jobject>(nativeHandle);
17 if (m_view.isValid())
18 QtAndroid::setViewVisibility(m_view.object(), false);
19}
20
22{
23 if (m_view.isValid())
24 QtAndroid::setViewVisibility(m_view.object(), false);
25 if (m_surfaceId != -1)
26 QtAndroid::destroySurface(m_surfaceId);
27}
28
30{
31 if (m_surfaceId == -1)
32 return;
33
35 QtAndroid::bringChildToBack(m_surfaceId);
36}
37
39{
40 if (m_surfaceId == -1)
41 return;
42
45}
46
48{
50
51 if (m_surfaceId != -1)
53}
54
56{
57 if (!m_view.isValid())
58 return;
59
60 QtAndroid::setViewVisibility(m_view.object(), visible);
61
63 if (!visible && m_surfaceId != -1) {
64 QtAndroid::destroySurface(m_surfaceId);
65 m_surfaceId = -1;
66 } else if (m_surfaceId == -1) {
67 m_surfaceId = QtAndroid::insertNativeView(m_view.object(), geometry());
68 }
69}
70
72{
74 && m_surfaceId != -1) {
75 QtAndroid::destroySurface(m_surfaceId);
76 m_surfaceId = -1;
77 } else if (m_view.isValid() && m_surfaceId == -1){
78 m_surfaceId = QtAndroid::insertNativeView(m_view.object(), geometry());
79 }
80
82}
83
85{
87}
88
void applicationStateChanged(Qt::ApplicationState state) override
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle)
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
virtual void applicationStateChanged(Qt::ApplicationState)
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
The QPlatformWindow class provides an abstraction for top-level windows.
QWindow * window() const
Returns the window which belongs to the QPlatformWindow.
virtual QRect geometry() const
Returns the current geometry of a window.
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qwindow.h:63
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
int insertNativeView(jobject view, const QRect &geometry)
void setViewVisibility(jobject view, bool visible)
void destroySurface(int surfaceId)
void setSurfaceGeometry(int surfaceId, const QRect &geometry)
void bringChildToFront(int surfaceId)
void bringChildToBack(int surfaceId)
ApplicationState
Definition qnamespace.h:261
@ ApplicationHidden
Definition qnamespace.h:263
#define Q_UNUSED(x)
aWidget window() -> setWindowTitle("New Window Title")
[2]