Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwasmwindowtreenode.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include "qwasmwindow.h"
7
9 : m_childStack(std::bind(&QWasmWindowTreeNode::onTopWindowChanged, this))
10{
11}
12
14
16 QWasmWindowTreeNode *currentParent,
17 QWasmWindowStack::PositionPreference positionPreference)
18{
19 auto *window = asWasmWindow();
20 if (previousParent) {
21 previousParent->m_childStack.removeWindow(window);
22 previousParent->onSubtreeChanged(QWasmWindowTreeNodeChangeType::NodeRemoval, previousParent,
23 window);
24 }
25
26 if (currentParent) {
27 currentParent->m_childStack.pushWindow(window, positionPreference);
28 currentParent->onSubtreeChanged(QWasmWindowTreeNodeChangeType::NodeInsertion, currentParent,
29 window);
30 }
31}
32
34{
35 return nullptr;
36}
37
40{
41 if (changeType == QWasmWindowTreeNodeChangeType::NodeInsertion && parent == this
42 && m_childStack.topWindow()
43 && m_childStack.topWindow()->window()) {
44
45 const QVariant showWithoutActivating = m_childStack.topWindow()->window()->property("_q_showWithoutActivating");
46 if (!showWithoutActivating.isValid() || !showWithoutActivating.toBool())
47 m_childStack.topWindow()->requestActivateWindow();
48 }
49
50 if (parentNode())
51 parentNode()->onSubtreeChanged(changeType, parent, child);
52}
53
58
60 QWasmWindowStack::PositionPreference positionPreference)
61{
62 if (parentNode()) {
63 parentNode()->m_childStack.windowPositionPreferenceChanged(asWasmWindow(),
64 positionPreference);
65 }
66}
67
69{
70 if (parentNode())
71 parentNode()->setActiveChildNode(asWasmWindow());
72}
73
75{
76 if (!parentNode())
77 return;
78 parentNode()->m_childStack.raise(asWasmWindow());
79 parentNode()->bringToTop();
80}
81
83{
84 if (!parentNode())
85 return;
86 m_childStack.lower(asWasmWindow());
87}
88
89void QWasmWindowTreeNode::onTopWindowChanged()
90{
91 constexpr int zOrderForElementInFrontOfScreen = 3;
92 int z = zOrderForElementInFrontOfScreen;
93 std::for_each(m_childStack.rbegin(), m_childStack.rend(),
94 [this, &z](QWasmWindow *window) { setWindowZOrder(window, z++); });
95}
96
97void QWasmWindowTreeNode::setActiveChildNode(QWasmWindow *activeChild)
98{
99 m_activeChild = activeChild;
100
101 auto it = m_childStack.begin();
102 if (it == m_childStack.end())
103 return;
104 for (; it != m_childStack.end(); ++it)
105 (*it)->onActivationChanged(*it == m_activeChild);
106
108}
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4323
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
void lower(QWasmWindow *window)
QWasmWindow * topWindow() const
const_reverse_iterator rbegin() const
const_reverse_iterator rend() const
QWasmWindow * activeChild() const
virtual ~QWasmWindowTreeNode()
virtual void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current, QWasmWindowStack::PositionPreference positionPreference)
virtual QWasmWindowTreeNode * parentNode()=0
virtual void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode *parent, QWasmWindow *child)
virtual QWasmWindow * asWasmWindow()
virtual void setWindowZOrder(QWasmWindow *window, int z)
void onPositionPreferenceChanged(QWasmWindowStack::PositionPreference positionPreference)
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
QWindow * window() const
Definition qwasmwindow.h:90
#define this
Definition dialogs.cpp:9
QSet< QString >::iterator it
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
QWasmWindowTreeNodeChangeType
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
socketLayer bind(QHostAddress::Any, 4000)