From 8737c06ab8ac5752c245b40534295f016aa43f7c Mon Sep 17 00:00:00 2001 From: "B.Melnik" Date: Wed, 12 May 2021 11:11:25 +0300 Subject: [PATCH] chore: remove title bar example Co-authored-by: Pascal Precht --- sandbox/sandbox.pro | 3 +++ sandbox/sandboxapp.cpp | 15 +++++++++++++-- sandbox/sandboxapp.h | 2 ++ sandbox/sandboxapp_mac.mm | 18 ++++++++++++++++++ src/StatusQ/Core/Theme/Theme.qml | 3 +++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 sandbox/sandboxapp_mac.mm diff --git a/sandbox/sandbox.pro b/sandbox/sandbox.pro index 45d95690..f9823b5c 100644 --- a/sandbox/sandbox.pro +++ b/sandbox/sandbox.pro @@ -11,6 +11,9 @@ SOURCES += \ main.cpp \ sandboxapp.cpp +OBJECTIVE_SOURCES += \ + sandboxapp_mac.mm + RESOURCES += qml.qrc DESTDIR = $$PWD/bin diff --git a/sandbox/sandboxapp.cpp b/sandbox/sandboxapp.cpp index 43db4827..cc4eeeed 100644 --- a/sandbox/sandboxapp.cpp +++ b/sandbox/sandboxapp.cpp @@ -1,7 +1,7 @@ #include "sandboxapp.h" #include - +#include #include SandboxApp::SandboxApp(int &argc, char **argv) @@ -25,12 +25,23 @@ void SandboxApp::startEngine() QCoreApplication::exit(-1); }, Qt::QueuedConnection); m_engine.load(url); + + QWindow *rootWindow = qobject_cast(m_engine.rootObjects().at(0)); + if (rootWindow) { + removeTitleBar(rootWindow->winId()); + } else { + qDebug() << "Window doesn't exist"; + } } void SandboxApp::restartEngine() { const QUrl url(applicationDirPath() + "/../main.qml"); - m_engine.rootObjects().at(0)->deleteLater(); + QWindow *rootWindow = qobject_cast(m_engine.rootObjects().at(0)); + if (rootWindow) { + + rootWindow->close(); + } m_engine.clearComponentCache(); m_engine.load(url); } diff --git a/sandbox/sandboxapp.h b/sandbox/sandboxapp.h index 8589baab..834d7045 100644 --- a/sandbox/sandboxapp.h +++ b/sandbox/sandboxapp.h @@ -13,6 +13,8 @@ public: void startEngine(); + void removeTitleBar(WId wid); + public slots: void restartEngine(); diff --git a/sandbox/sandboxapp_mac.mm b/sandbox/sandboxapp_mac.mm new file mode 100644 index 00000000..f4b5c608 --- /dev/null +++ b/sandbox/sandboxapp_mac.mm @@ -0,0 +1,18 @@ +#include "sandboxapp.h" + +#include + +#include +#include +#include +#include + +void SandboxApp::removeTitleBar(WId wid) +{ + NSView *nsView = reinterpret_cast(wid); + NSWindow *window = [nsView window]; + + window.titlebarAppearsTransparent = true; + window.titleVisibility = NSWindowTitleHidden; + window.styleMask |= NSWindowStyleMaskFullSizeContentView; +} diff --git a/src/StatusQ/Core/Theme/Theme.qml b/src/StatusQ/Core/Theme/Theme.qml index cb7f3fa3..1b142cad 100644 --- a/src/StatusQ/Core/Theme/Theme.qml +++ b/src/StatusQ/Core/Theme/Theme.qml @@ -4,6 +4,9 @@ import QtQuick 2.13 QtObject { id: appTheme + // Replace it with: + // property QtObject palette: StatusLightTheme {} + // for reloading property ThemePalette palette: StatusLightTheme {} function setTheme(theme) {