From 161b77fd377bbb6e9b3938f1a2807f9587678bee Mon Sep 17 00:00:00 2001 From: Elias Date: Thu, 4 Apr 2019 17:19:19 +0200 Subject: [PATCH] Add macwindow --- ScreenPlayWindow/src/macwindow.cpp | 38 ++++++++++++++++++++++++++++++ ScreenPlayWindow/src/macwindow.h | 31 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 ScreenPlayWindow/src/macwindow.cpp create mode 100644 ScreenPlayWindow/src/macwindow.h diff --git a/ScreenPlayWindow/src/macwindow.cpp b/ScreenPlayWindow/src/macwindow.cpp new file mode 100644 index 00000000..d2d31754 --- /dev/null +++ b/ScreenPlayWindow/src/macwindow.cpp @@ -0,0 +1,38 @@ +#include "macwindow.h" + +MacWindow::MacWindow(QVector& activeScreensList, QString projectPath, QString id, QString volume, QObject* parent) + : BaseWindow(projectPath) +{ + setAppID(id); + bool ok = false; + float volumeParsed = volume.toFloat(&ok); + if (!ok) { + qFatal("Could not parse volume"); + } + setVolume(volumeParsed); + + // WARNING: Setting Window flags must be called *here*! + Qt::WindowFlags flags = m_window.flags(); + m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop); + + m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); + m_window.rootContext()->setContextProperty("window", this); + // Instead of setting "renderType: Text.NativeRendering" every time + // we can set it here once :) + m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); + m_window.setSource(QUrl("qrc:/mainWindow.qml")); +} + +void MacWindow::setVisible(bool show) +{ + m_window.setVisible(show); +} + +void MacWindow::destroyThis() +{ + QCoreApplication::quit(); +} + +void MacWindow::messageReceived(QString key, QString value) +{ +} diff --git a/ScreenPlayWindow/src/macwindow.h b/ScreenPlayWindow/src/macwindow.h new file mode 100644 index 00000000..f7fc87a2 --- /dev/null +++ b/ScreenPlayWindow/src/macwindow.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "basewindow.h" + +class MacWindow : public BaseWindow +{ + Q_OBJECT +public: + explicit MacWindow(QVector& activeScreensList, QString projectPath, QString id, QString volume,QObject *parent = nullptr); + +signals: + +public slots: + void setVisible(bool show) override; + void destroyThis() override; + void messageReceived(QString key, QString value) override; +private: + QQuickView m_window; +}; +