mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-18 10:32:53 +00:00
fix: fix crash on removing title bar
This commit is contained in:
parent
a1e721bfc3
commit
8fdd4f7e20
@ -2,10 +2,12 @@ import QtQuick 2.14
|
|||||||
import QtQuick.Window 2.14
|
import QtQuick.Window 2.14
|
||||||
import QtQuick.Controls 2.14
|
import QtQuick.Controls 2.14
|
||||||
|
|
||||||
|
import Sandbox 0.1
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
Window {
|
StatusWindow {
|
||||||
id: rootWindow
|
id: rootWindow
|
||||||
width: 1024
|
width: 1024
|
||||||
height: 840
|
height: 840
|
||||||
|
@ -12,7 +12,7 @@ SOURCES += \
|
|||||||
sandboxapp.cpp
|
sandboxapp.cpp
|
||||||
|
|
||||||
OBJECTIVE_SOURCES += \
|
OBJECTIVE_SOURCES += \
|
||||||
sandboxapp_mac.mm
|
statuswindow_mac.mm
|
||||||
|
|
||||||
RESOURCES += qml.qrc
|
RESOURCES += qml.qrc
|
||||||
|
|
||||||
@ -28,7 +28,8 @@ OTHER_FILES += $$files($$PWD/../src/*, true)
|
|||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
handler.h \
|
handler.h \
|
||||||
sandboxapp.h
|
sandboxapp.h \
|
||||||
|
statuswindow.h
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
../src/StatusQ/Controls/StatusBaseButton.qml \
|
../src/StatusQ/Controls/StatusBaseButton.qml \
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "statuswindow.h"
|
||||||
|
|
||||||
SandboxApp::SandboxApp(int &argc, char **argv)
|
SandboxApp::SandboxApp(int &argc, char **argv)
|
||||||
: QGuiApplication(argc, argv),
|
: QGuiApplication(argc, argv),
|
||||||
m_handler(new Handler(this))
|
m_handler(new Handler(this))
|
||||||
@ -13,6 +15,8 @@ SandboxApp::SandboxApp(int &argc, char **argv)
|
|||||||
|
|
||||||
void SandboxApp::startEngine()
|
void SandboxApp::startEngine()
|
||||||
{
|
{
|
||||||
|
qmlRegisterType<StatusWindow>("Sandbox", 0, 1, "StatusWindow");
|
||||||
|
|
||||||
const QUrl url(applicationDirPath() + "/../main.qml");
|
const QUrl url(applicationDirPath() + "/../main.qml");
|
||||||
|
|
||||||
m_engine.rootContext()->setContextProperty("app", m_handler);
|
m_engine.rootContext()->setContextProperty("app", m_handler);
|
||||||
@ -25,13 +29,6 @@ void SandboxApp::startEngine()
|
|||||||
QCoreApplication::exit(-1);
|
QCoreApplication::exit(-1);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
m_engine.load(url);
|
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()
|
void SandboxApp::restartEngine()
|
||||||
|
@ -13,8 +13,6 @@ public:
|
|||||||
|
|
||||||
void startEngine();
|
void startEngine();
|
||||||
|
|
||||||
void removeTitleBar(WId wid);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void restartEngine();
|
void restartEngine();
|
||||||
|
|
||||||
|
21
ui/StatusQ/sandbox/statuswindow.h
Normal file
21
ui/StatusQ/sandbox/statuswindow.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef STATUSWINDOW_H
|
||||||
|
#define STATUSWINDOW_H
|
||||||
|
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
|
class StatusWindow: public QQuickWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit StatusWindow(QWindow *parent = nullptr)
|
||||||
|
: QQuickWindow(parent)
|
||||||
|
{
|
||||||
|
removeTitleBar(winId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void removeTitleBar(WId wid);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATUSWINDOW_H
|
@ -1,4 +1,4 @@
|
|||||||
#include "sandboxapp.h"
|
#include "statuswindow.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
@ -7,7 +7,7 @@
|
|||||||
#include <AppKit/NSWindow.h>
|
#include <AppKit/NSWindow.h>
|
||||||
#include <AppKit/NSColor.h>
|
#include <AppKit/NSColor.h>
|
||||||
|
|
||||||
void SandboxApp::removeTitleBar(WId wid)
|
void StatusWindow::removeTitleBar(WId wid)
|
||||||
{
|
{
|
||||||
NSView *nsView = reinterpret_cast<NSView*>(wid);
|
NSView *nsView = reinterpret_cast<NSView*>(wid);
|
||||||
NSWindow *window = [nsView window];
|
NSWindow *window = [nsView window];
|
Loading…
x
Reference in New Issue
Block a user