chore: remove title bar example

Co-authored-by: Pascal Precht <pascal.precht@gmail.com>
This commit is contained in:
B.Melnik 2021-05-12 11:11:25 +03:00 committed by Pascal Precht
parent ea118d716e
commit 8737c06ab8
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
5 changed files with 39 additions and 2 deletions

View File

@ -11,6 +11,9 @@ SOURCES += \
main.cpp \
sandboxapp.cpp
OBJECTIVE_SOURCES += \
sandboxapp_mac.mm
RESOURCES += qml.qrc
DESTDIR = $$PWD/bin

View File

@ -1,7 +1,7 @@
#include "sandboxapp.h"
#include <QQmlContext>
#include <QWindow>
#include <QDebug>
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<QWindow*>(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<QWindow*>(m_engine.rootObjects().at(0));
if (rootWindow) {
rootWindow->close();
}
m_engine.clearComponentCache();
m_engine.load(url);
}

View File

@ -13,6 +13,8 @@ public:
void startEngine();
void removeTitleBar(WId wid);
public slots:
void restartEngine();

18
sandbox/sandboxapp_mac.mm Normal file
View File

@ -0,0 +1,18 @@
#include "sandboxapp.h"
#include <QColor>
#include <Foundation/Foundation.h>
#include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSColor.h>
void SandboxApp::removeTitleBar(WId wid)
{
NSView *nsView = reinterpret_cast<NSView*>(wid);
NSWindow *window = [nsView window];
window.titlebarAppearsTransparent = true;
window.titleVisibility = NSWindowTitleHidden;
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
}

View File

@ -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) {