1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "qml-utilities.h"
#include "inprocesswindow.h"
#include "inprocesssurfaceitem.h"
QT_BEGIN_NAMESPACE_AM
InProcessWindow::InProcessWindow(Application *app, const QSharedPointer<InProcessSurfaceItem> &surfaceItem)
: Window(app)
, m_surfaceItem(surfaceItem)
{
connect(m_surfaceItem.data(), &InProcessSurfaceItem::windowPropertyChanged,
this, &Window::windowPropertyChanged);
connect(m_surfaceItem.data(), &QQuickItem::widthChanged, this, &Window::sizeChanged);
connect(m_surfaceItem.data(), &QQuickItem::heightChanged, this, &Window::sizeChanged);
// queued to emulate the behavior of the out-of-process counterpart
connect(m_surfaceItem.data(), &InProcessSurfaceItem::visibleClientSideChanged,
this, [this]() {
setContentState(m_surfaceItem->visibleClientSide()
? Window::SurfaceWithContent : Window::SurfaceNoContent);
}, Qt::QueuedConnection);
connect(m_surfaceItem.data(), &InProcessSurfaceItem::deadClientSideChanged,
this, [this]() {
if (m_surfaceItem->isDeadClientSide())
setContentState(Window::NoSurface);
}, Qt::QueuedConnection);
connect(m_surfaceItem.data(), &InProcessSurfaceItem::closedChanged,
this, [this]() {
if (m_surfaceItem->isClosed())
setContentState(Window::NoSurface);
}, Qt::QueuedConnection);
}
InProcessWindow::~InProcessWindow()
{
emit m_surfaceItem->released();
}
bool InProcessWindow::setWindowProperty(const QString &name, const QVariant &value)
{
const QVariant v = convertFromJSVariant(value);
return m_surfaceItem->setWindowProperty(name, v);
}
QVariant InProcessWindow::windowProperty(const QString &name) const
{
return m_surfaceItem->windowProperty(name);
}
QVariantMap InProcessWindow::windowProperties() const
{
return m_surfaceItem->windowPropertiesAsVariantMap();
}
void InProcessWindow::setContentState(ContentState newState)
{
if (m_contentState != newState) {
m_contentState = newState;
emit contentStateChanged();
}
}
QSize InProcessWindow::size() const
{
return m_surfaceItem->size().toSize();
}
void InProcessWindow::resize(const QSize &size)
{
m_surfaceItem->setSize(size);
}
void InProcessWindow::close()
{
m_surfaceItem->close();
}
bool InProcessWindow::isPopup() const
{
return false;
}
QPoint InProcessWindow::requestedPopupPosition() const
{
return QPoint();
}
QT_END_NAMESPACE_AM
#include "moc_inprocesswindow.cpp"
|