chore: remove title bar example
Co-authored-by: Pascal Precht <pascal.precht@gmail.com>
This commit is contained in:
parent
ea118d716e
commit
8737c06ab8
|
@ -11,6 +11,9 @@ SOURCES += \
|
|||
main.cpp \
|
||||
sandboxapp.cpp
|
||||
|
||||
OBJECTIVE_SOURCES += \
|
||||
sandboxapp_mac.mm
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
DESTDIR = $$PWD/bin
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ public:
|
|||
|
||||
void startEngine();
|
||||
|
||||
void removeTitleBar(WId wid);
|
||||
|
||||
public slots:
|
||||
void restartEngine();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue