chore(general): Deduplicate and move StatusWindow to StatusQ
This commit is contained in:
parent
3a07651dd8
commit
ad34694826
|
@ -1,5 +1,4 @@
|
||||||
#ifndef STATUSWINDOW_H
|
#pragma once
|
||||||
#define STATUSWINDOW_H
|
|
||||||
|
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
@ -11,10 +10,9 @@ class StatusWindow: public QQuickWindow
|
||||||
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged)
|
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StatusWindow(QQuickWindow *parent = nullptr);
|
explicit StatusWindow(QWindow *parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE void toggleFullScreen();
|
Q_INVOKABLE void toggleFullScreen();
|
||||||
|
|
||||||
Q_INVOKABLE void updatePosition();
|
Q_INVOKABLE void updatePosition();
|
||||||
|
|
||||||
bool isFullScreen() const;
|
bool isFullScreen() const;
|
||||||
|
@ -25,16 +23,6 @@ signals:
|
||||||
private:
|
private:
|
||||||
void removeTitleBar();
|
void removeTitleBar();
|
||||||
void showTitleBar();
|
void showTitleBar();
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
void removeTitleBarWin();
|
|
||||||
void showTitleBarWin();
|
|
||||||
#elif defined Q_OS_MACOS
|
|
||||||
void removeTitleBarMac();
|
|
||||||
void showTitleBarMac();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_isFullScreen;
|
bool m_isFullScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STATUSWINDOW_H
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void registerStatusQTypes();
|
|
@ -7,11 +7,29 @@ find_package(
|
||||||
|
|
||||||
file(GLOB_RECURSE QML_FILES "../*.qml" "../qmldir")
|
file(GLOB_RECURSE QML_FILES "../*.qml" "../qmldir")
|
||||||
file(GLOB_RECURSE JS_FILES "../*.js")
|
file(GLOB_RECURSE JS_FILES "../*.js")
|
||||||
file(GLOB_RECURSE HEADERS *.h)
|
|
||||||
|
set(HEADERS sandboxapp.h)
|
||||||
|
set(SOURCES main.cpp sandboxapp.cpp)
|
||||||
|
|
||||||
|
set(STATUSQ_DIR ..)
|
||||||
|
set(STATUSQ_HEADERS
|
||||||
|
${STATUSQ_DIR}/include/StatusQ/statuswindow.h
|
||||||
|
${STATUSQ_DIR}/include/StatusQ/typesregistration.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(STATUSQ_SOURCES
|
||||||
|
${STATUSQ_DIR}/src/statuswindow.cpp
|
||||||
|
${STATUSQ_DIR}/src/typesregistration.cpp
|
||||||
|
)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
file(GLOB_RECURSE SOURCES *.cpp *.mm)
|
list(APPEND STATUSQ_SOURCES
|
||||||
|
${STATUSQ_DIR}/src/statuswindow_osx.mm
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
file(GLOB_RECURSE SOURCES *.cpp)
|
list(APPEND STATUSQ_SOURCES
|
||||||
|
${STATUSQ_DIR}/src/statuswindow_other.cpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(QRC_FILES qml.qrc ../src/statusq.qrc ../src/assets.qrc)
|
set(QRC_FILES qml.qrc ../src/statusq.qrc ../src/assets.qrc)
|
||||||
|
@ -21,11 +39,14 @@ add_executable(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
${HEADERS}
|
${HEADERS}
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
|
${STATUSQ_HEADERS}
|
||||||
|
${STATUSQ_SOURCES}
|
||||||
${QRC_FILES}
|
${QRC_FILES}
|
||||||
${QRC_COMPILED}
|
${QRC_COMPILED}
|
||||||
${QML_FILES}
|
${QML_FILES}
|
||||||
${JS_FILES})
|
${JS_FILES})
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC ${STATUSQ_DIR}/include)
|
||||||
target_compile_definitions(${PROJECT_NAME}
|
target_compile_definitions(${PROJECT_NAME}
|
||||||
PRIVATE SRC_DIR="${CMAKE_CURRENT_LIST_DIR}")
|
PRIVATE SRC_DIR="${CMAKE_CURRENT_LIST_DIR}")
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
|
|
@ -6,7 +6,7 @@ import QtQuick.Layouts 1.14
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
import QtQml.Models 2.14
|
import QtQml.Models 2.14
|
||||||
|
|
||||||
import Sandbox 0.1
|
import StatusQ 0.1
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
|
|
||||||
#include "statuswindow.h"
|
#include "StatusQ/typesregistration.h"
|
||||||
|
|
||||||
SandboxApp::SandboxApp(int &argc, char **argv)
|
SandboxApp::SandboxApp(int &argc, char **argv)
|
||||||
: QGuiApplication(argc, argv)
|
: QGuiApplication(argc, argv)
|
||||||
|
@ -20,7 +20,7 @@ SandboxApp::SandboxApp(int &argc, char **argv)
|
||||||
|
|
||||||
void SandboxApp::startEngine()
|
void SandboxApp::startEngine()
|
||||||
{
|
{
|
||||||
qmlRegisterType<StatusWindow>("Sandbox", 0, 1, "StatusWindow");
|
registerStatusQTypes();
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
const QUrl url = QUrl::fromLocalFile(SRC_DIR + QStringLiteral("/main.qml"));
|
const QUrl url = QUrl::fromLocalFile(SRC_DIR + QStringLiteral("/main.qml"));
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
#include "statuswindow.h"
|
|
||||||
|
|
||||||
StatusWindow::StatusWindow(QQuickWindow *parent)
|
|
||||||
: QQuickWindow(parent)
|
|
||||||
, m_isFullScreen(false)
|
|
||||||
{
|
|
||||||
removeTitleBar();
|
|
||||||
|
|
||||||
connect(this, &QQuickWindow::windowStateChanged, [&](Qt::WindowState windowState) {
|
|
||||||
if (windowState == Qt::WindowNoState) {
|
|
||||||
removeTitleBar();
|
|
||||||
m_isFullScreen = false;
|
|
||||||
emit isFullScreenChanged();
|
|
||||||
} else if (windowState == Qt::WindowFullScreen) {
|
|
||||||
m_isFullScreen = true;
|
|
||||||
emit isFullScreenChanged();
|
|
||||||
showTitleBar();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusWindow::updatePosition()
|
|
||||||
{
|
|
||||||
auto point = QPoint(screen()->geometry().center().x() - geometry().width() / 2,
|
|
||||||
screen()->geometry().center().y() - geometry().height() / 2);
|
|
||||||
if (point != this->position()) {
|
|
||||||
this->setPosition(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusWindow::toggleFullScreen()
|
|
||||||
{
|
|
||||||
if (m_isFullScreen) {
|
|
||||||
showNormal();
|
|
||||||
} else {
|
|
||||||
showFullScreen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StatusWindow::isFullScreen() const
|
|
||||||
{
|
|
||||||
return m_isFullScreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusWindow::removeTitleBar()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
removeTitleBarWin();
|
|
||||||
#elif defined Q_OS_MACOS
|
|
||||||
removeTitleBarMac();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusWindow::showTitleBar()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
showTitleBarWin();
|
|
||||||
#elif defined Q_OS_MACOS
|
|
||||||
showTitleBarMac();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
void StatusWindow::removeTitleBarWin()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void StatusWindow::showTitleBarWin()
|
|
||||||
{}
|
|
||||||
#endif
|
|
|
@ -1,39 +0,0 @@
|
||||||
#include "statuswindow.h"
|
|
||||||
|
|
||||||
#include <QColor>
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <Foundation/Foundation.h>
|
|
||||||
#include <AppKit/NSView.h>
|
|
||||||
#include <AppKit/NSWindow.h>
|
|
||||||
#include <AppKit/NSColor.h>
|
|
||||||
#include <AppKit/NSToolbar.h>
|
|
||||||
#include <AppKit/NSButton.h>
|
|
||||||
#include <AppKit/AppKit.h>
|
|
||||||
|
|
||||||
void StatusWindow::removeTitleBarMac()
|
|
||||||
{
|
|
||||||
NSView *nsView = reinterpret_cast<NSView*>(this->winId());
|
|
||||||
NSWindow *window = [nsView window];
|
|
||||||
|
|
||||||
window.titlebarAppearsTransparent = true;
|
|
||||||
window.titleVisibility = NSWindowTitleHidden;
|
|
||||||
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
|
|
||||||
NSButton* close = [window standardWindowButton:NSWindowCloseButton];
|
|
||||||
NSView* titleBarContainerView = close.superview.superview;
|
|
||||||
[titleBarContainerView setHidden:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusWindow::showTitleBarMac()
|
|
||||||
{
|
|
||||||
NSView *nsView = reinterpret_cast<NSView*>(this->winId());
|
|
||||||
NSWindow *window = [nsView window];
|
|
||||||
|
|
||||||
window.titlebarAppearsTransparent = true;
|
|
||||||
window.titleVisibility = NSWindowTitleHidden;
|
|
||||||
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
|
|
||||||
NSButton* close = [window standardWindowButton:NSWindowCloseButton];
|
|
||||||
NSView* titleBarContainerView = close.superview.superview;
|
|
||||||
[titleBarContainerView setHidden:NO];
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "DOtherSide/DOtherSideStatusWindow.h"
|
#include "StatusQ/statuswindow.h"
|
||||||
|
|
||||||
StatusWindow::StatusWindow(QWindow *parent)
|
StatusWindow::StatusWindow(QWindow *parent)
|
||||||
: QQuickWindow(parent),
|
: QQuickWindow(parent),
|
||||||
|
@ -19,6 +19,15 @@ StatusWindow::StatusWindow(QWindow *parent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatusWindow::updatePosition()
|
||||||
|
{
|
||||||
|
auto point = QPoint(screen()->geometry().center().x() - geometry().width() / 2,
|
||||||
|
screen()->geometry().center().y() - geometry().height() / 2);
|
||||||
|
if (point != this->position()) {
|
||||||
|
this->setPosition(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void StatusWindow::toggleFullScreen()
|
void StatusWindow::toggleFullScreen()
|
||||||
{
|
{
|
||||||
if (m_isFullScreen) {
|
if (m_isFullScreen) {
|
|
@ -1,4 +1,4 @@
|
||||||
#include "DOtherSide/DOtherSideStatusWindow.h"
|
#include "StatusQ/statuswindow.h"
|
||||||
|
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
#include <AppKit/NSView.h>
|
#include <AppKit/NSView.h>
|
|
@ -1,4 +1,4 @@
|
||||||
#include "DOtherSide/DOtherSideStatusWindow.h"
|
#include "StatusQ/statuswindow.h"
|
||||||
|
|
||||||
void StatusWindow::removeTitleBar()
|
void StatusWindow::removeTitleBar()
|
||||||
{
|
{
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "StatusQ/typesregistration.h"
|
||||||
|
|
||||||
|
#include "StatusQ/statuswindow.h"
|
||||||
|
|
||||||
|
#include <QQmlEngine>
|
||||||
|
|
||||||
|
void registerStatusQTypes()
|
||||||
|
{
|
||||||
|
qmlRegisterType<StatusWindow>("StatusQ", 0 , 1, "StatusWindow");
|
||||||
|
}
|
|
@ -7,8 +7,6 @@ import QtQuick.Window 2.12
|
||||||
import QtQml 2.13
|
import QtQml 2.13
|
||||||
import QtQuick.Controls.Universal 2.12
|
import QtQuick.Controls.Universal 2.12
|
||||||
|
|
||||||
import DotherSide 0.1
|
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
import shared 1.0
|
import shared 1.0
|
||||||
import shared.panels 1.0
|
import shared.panels 1.0
|
||||||
|
@ -17,6 +15,7 @@ import shared.popups 1.0
|
||||||
import mainui 1.0
|
import mainui 1.0
|
||||||
import AppLayouts.Onboarding 1.0
|
import AppLayouts.Onboarding 1.0
|
||||||
|
|
||||||
|
import StatusQ 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
|
||||||
StatusWindow {
|
StatusWindow {
|
||||||
|
|
|
@ -18,13 +18,38 @@ macro(add_target name type)
|
||||||
file(GLOB MONITORING_SOURCES src/Status/Monitoring/*.cpp)
|
file(GLOB MONITORING_SOURCES src/Status/Monitoring/*.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(STATUSQ_DIR ../../../ui/StatusQ)
|
||||||
|
set(STATUSQ_HEADERS
|
||||||
|
${STATUSQ_DIR}/include/StatusQ/statuswindow.h
|
||||||
|
${STATUSQ_DIR}/include/StatusQ/typesregistration.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(STATUSQ_SOURCES
|
||||||
|
${STATUSQ_DIR}/src/statuswindow.cpp
|
||||||
|
${STATUSQ_DIR}/src/typesregistration.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
list(APPEND STATUSQ_SOURCES
|
||||||
|
${STATUSQ_DIR}/src/statuswindow_osx.mm
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
list(APPEND STATUSQ_SOURCES
|
||||||
|
${STATUSQ_DIR}/src/statuswindow_other.cpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
file(GLOB MM_FILES src/*.mm src/Status/*.mm)
|
file(GLOB MM_FILES src/*.mm src/Status/*.mm)
|
||||||
#prepend items because .mm files need build priority to override cpp impl
|
#prepend items because .mm files need build priority to override cpp impl
|
||||||
list(INSERT SOURCES 0 ${MM_FILES})
|
list(INSERT SOURCES 0 ${MM_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${name} ${type} ${SOURCES} ${HEADERS} ${MONITORING_SOURCES} ${MONITORING_HEADERS})
|
add_library(${name} ${type}
|
||||||
|
${SOURCES} ${HEADERS}
|
||||||
|
${MONITORING_SOURCES} ${MONITORING_HEADERS}
|
||||||
|
${STATUSQ_HEADERS} ${STATUSQ_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions(${name} PRIVATE -DWIN32)
|
target_compile_definitions(${name} PRIVATE -DWIN32)
|
||||||
|
@ -32,7 +57,7 @@ macro(add_target name type)
|
||||||
|
|
||||||
set_target_properties(${name} PROPERTIES CXX_STANDARD 11 AUTOMOC ON)
|
set_target_properties(${name} PROPERTIES CXX_STANDARD 11 AUTOMOC ON)
|
||||||
|
|
||||||
target_include_directories(${name} PUBLIC include include/Qt)
|
target_include_directories(${name} PUBLIC include include/Qt ${STATUSQ_DIR}/include)
|
||||||
|
|
||||||
target_link_libraries(${name} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::Network Qt5::Multimedia SortFilterProxyModel)
|
target_link_libraries(${name} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::Network Qt5::Multimedia SortFilterProxyModel)
|
||||||
|
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
#ifndef STATUSWINDOW_H
|
|
||||||
#define STATUSWINDOW_H
|
|
||||||
|
|
||||||
#include <QQuickWindow>
|
|
||||||
#include <QScreen>
|
|
||||||
|
|
||||||
class StatusWindow: public QQuickWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
explicit StatusWindow(QWindow *parent = nullptr);
|
|
||||||
|
|
||||||
Q_INVOKABLE void toggleFullScreen();
|
|
||||||
|
|
||||||
bool isFullScreen() const;
|
|
||||||
|
|
||||||
Q_INVOKABLE void updatePosition() {
|
|
||||||
auto point = QPoint(screen()->geometry().center().x() - geometry().width() / 2, screen()->geometry().center().y() - geometry().height() / 2);
|
|
||||||
if (point != this->position()) {
|
|
||||||
this->setPosition(point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void isFullScreenChanged();
|
|
||||||
void secondInstanceDetected();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void removeTitleBar();
|
|
||||||
void showTitleBar();
|
|
||||||
void initCallbacks();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_isFullScreen;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // STATUSWINDOW_H
|
|
|
@ -63,7 +63,6 @@
|
||||||
#include "DOtherSide/DosQAbstractItemModel.h"
|
#include "DOtherSide/DosQAbstractItemModel.h"
|
||||||
#include "DOtherSide/DosQDeclarative.h"
|
#include "DOtherSide/DosQDeclarative.h"
|
||||||
#include "DOtherSide/DosQQuickImageProvider.h"
|
#include "DOtherSide/DosQQuickImageProvider.h"
|
||||||
#include "DOtherSide/DOtherSideStatusWindow.h"
|
|
||||||
#include "DOtherSide/DOtherSideSingleInstance.h"
|
#include "DOtherSide/DOtherSideSingleInstance.h"
|
||||||
#include "DOtherSide/DOtherSideStatusSyntaxHighlighter.h"
|
#include "DOtherSide/DOtherSideStatusSyntaxHighlighter.h"
|
||||||
|
|
||||||
|
@ -76,6 +75,8 @@
|
||||||
#include "DOtherSide/Status/QClipboardProxy.h"
|
#include "DOtherSide/Status/QClipboardProxy.h"
|
||||||
#include "DOtherSide/Status/RXValidator.h"
|
#include "DOtherSide/Status/RXValidator.h"
|
||||||
|
|
||||||
|
#include "StatusQ/statuswindow.h"
|
||||||
|
|
||||||
#ifdef MONITORING
|
#ifdef MONITORING
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include "DOtherSide/Status/Monitoring/Monitor.h"
|
#include "DOtherSide/Status/Monitoring/Monitor.h"
|
||||||
|
@ -88,7 +89,8 @@ namespace {
|
||||||
void register_meta_types()
|
void register_meta_types()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<QVector<int>>();
|
qRegisterMetaType<QVector<int>>();
|
||||||
qmlRegisterType<StatusWindow>("DotherSide", 0 , 1, "StatusWindow");
|
|
||||||
|
qmlRegisterType<StatusWindow>("StatusQ", 0 , 1, "StatusWindow");
|
||||||
qmlRegisterType<StatusSyntaxHighlighter>("DotherSide", 0 , 1, "StatusSyntaxHighlighter");
|
qmlRegisterType<StatusSyntaxHighlighter>("DotherSide", 0 , 1, "StatusSyntaxHighlighter");
|
||||||
qmlRegisterSingletonType<QClipboardProxy>("DotherSide", 0 , 1, "QClipboardProxy", &QClipboardProxy::qmlInstance);
|
qmlRegisterSingletonType<QClipboardProxy>("DotherSide", 0 , 1, "QClipboardProxy", &QClipboardProxy::qmlInstance);
|
||||||
qmlRegisterType<RXValidator>("DotherSide", 0, 1, "RXValidator");
|
qmlRegisterType<RXValidator>("DotherSide", 0, 1, "RXValidator");
|
||||||
|
|
Loading…
Reference in New Issue