Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmwindowtreenode.inc
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWASMWINDOWTREENODE_INC
5#define QWASMWINDOWTREENODE_INC
6
7template<class Window>
9 : m_childStack(std::bind(&QWasmWindowTreeNode<Window>::onTopWindowChanged, this))
10{
11}
12
13template<class Window>
15
16template<class Window>
18 QWasmWindowTreeNode *currentParent,
19 typename QWasmWindowStack<Window>::PositionPreference positionPreference)
20{
21 auto *window = asWasmWindow();
22 if (previousParent) {
23 previousParent->m_childStack.removeWindow(window);
25 window);
26 }
27
28 if (currentParent) {
29 currentParent->m_childStack.pushWindow(window, positionPreference);
31 window);
32 }
33}
34
35template<class Window>
37{
38 return nullptr;
39}
40
41template<class Window>
44{
45 if (changeType == QWasmWindowTreeNodeChangeType::NodeInsertion && parent == this
46 && m_childStack.topWindow()
47 && m_childStack.topWindow()->window()) {
48
49 const auto flags = m_childStack.topWindow()->window()->flags();
50 const bool notToolOrPopup = ((flags & Qt::ToolTip) != Qt::ToolTip) && ((flags & Qt::Popup) != Qt::Popup);
51 const QVariant showWithoutActivating = m_childStack.topWindow()->window()->property("_q_showWithoutActivating");
52 if (!showWithoutActivating.isValid() || !showWithoutActivating.toBool()) {
53 if (notToolOrPopup)
54 m_childStack.topWindow()->requestActivateWindow();
55 }
56 }
57
58 if (parentNode())
59 parentNode()->onSubtreeChanged(changeType, parent, child);
60}
61
62template<class Window>
64{
65 window->setZOrder(z);
66}
67
68template<class Window>
70 typename QWasmWindowStack<Window>::PositionPreference positionPreference)
71{
72 if (parentNode()) {
73 parentNode()->m_childStack.windowPositionPreferenceChanged(asWasmWindow(),
74 positionPreference);
75 }
76}
77
78template<class Window>
80{
81 if (parentNode())
82 parentNode()->setActiveChildNode(asWasmWindow());
83
84 // At the end, this is a recursive function
85 m_activeIndex = ++s_nextActiveIndex;
86}
87
88template<class Window>
90{
91 if (!parentNode())
92 return;
93 parentNode()->m_childStack.raise(asWasmWindow());
94 parentNode()->bringToTop();
95}
96
97template<class Window>
99{
100 if (!parentNode())
101 return;
102 m_childStack.lower(asWasmWindow());
103}
104
105template<class Window>
106void QWasmWindowTreeNode<Window>::onTopWindowChanged()
107{
108 constexpr int zOrderForElementInFrontOfScreen = 3;
109 int z = zOrderForElementInFrontOfScreen;
110 std::for_each(m_childStack.rbegin(), m_childStack.rend(),
111 [this, &z](Window *window) { setWindowZOrder(window, z++); });
112}
113
114template<class Window>
115void QWasmWindowTreeNode<Window>::setActiveChildNode(Window *activeChild)
116{
117 m_activeChild = activeChild;
118
119 auto it = m_childStack.begin();
120 if (it == m_childStack.end())
121 return;
122 for (; it != m_childStack.end(); ++it)
123 (*it)->onActivationChanged(*it == m_activeChild);
124
125 setAsActiveNode();
126}
127
128#endif /* QWASMWINDOWTREENODE_INC */
\inmodule QtCore
Definition qvariant.h:66
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:715
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
virtual void setWindowZOrder(Window *window, int z)
void onPositionPreferenceChanged(typename QWasmWindowStack< Window >::PositionPreference positionPreference)
virtual Window * asWasmWindow()
virtual ~QWasmWindowTreeNode()
virtual void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode *parent, Window *child)
virtual void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current, typename QWasmWindowStack< Window >::PositionPreference positionPreference)
[Window class with invokable method]
Definition window.h:11
#define this
Definition dialogs.cpp:8
@ ToolTip
Definition qnamespace.h:219
@ Popup
Definition qnamespace.h:217
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLbitfield flags
QWasmWindowTreeNodeChangeType
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
socketLayer bind(QHostAddress::Any, 4000)
QJSValueIterator it(object)