MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / addWindow

Method addWindow

app/src/Platform/NativeWindow_CSD.cpp:206–269  ·  view source on GitHub ↗

* @brief Configures native window customization. */

Source from the content-addressed store, hash-verified

204 * @brief Configures native window customization.
205 */
206void NativeWindow::addWindow(QObject* window, const QString& color)
207{
208 auto* w = qobject_cast<QWindow*>(window);
209 if (!w)
210 return;
211
212 if (m_windows.contains(w)) {
213 m_colors.insert(w, color);
214
215 if (isWindows11())
216 Q_EMIT w->activeChanged();
217
218 else {
219 auto* decorator = s_decorators.value(w, nullptr);
220 if (decorator)
221 decorator->setColor(color);
222 }
223
224 return;
225 }
226
227 m_windows.append(w);
228 m_colors.insert(w, color);
229
230 if (isWindows11()) {
231 connect(w, &QWindow::activeChanged, this, &NativeWindow::onActiveChanged);
232 connect(w, &QObject::destroyed, this, [this, w]() {
233 auto index = m_windows.indexOf(w);
234 if (index != -1 && index >= 0) {
235 m_windows.removeAt(index);
236 m_colors.remove(w);
237 }
238 });
239 Q_EMIT w->activeChanged();
240 }
241
242 else if (m_csdEnabled) {
243 auto* decorator = new CSD::Window(w, color, m_csdShadowEnabled, this);
244 s_decorators.insert(w, decorator);
245 connect(w, &QObject::destroyed, this, [this, w]() {
246 auto* dec = s_decorators.value(w, nullptr);
247 s_decorators.remove(w);
248 delete dec;
249
250 auto index = m_windows.indexOf(w);
251 if (index != -1 && index >= 0) {
252 m_windows.removeAt(index);
253 m_colors.remove(w);
254 }
255 });
256
257 connect(w, &QWindow::activeChanged, this, &NativeWindow::onActiveChanged);
258 }
259
260 else {
261 connect(w, &QObject::destroyed, this, [this, w]() {
262 auto index = m_windows.indexOf(w);
263 if (index != -1 && index >= 0) {

Callers

nothing calls this directly

Calls 7

isWindows11Function · 0.85
containsMethod · 0.45
valueMethod · 0.45
setColorMethod · 0.45
appendMethod · 0.45
indexOfMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected