From 2a77ce9a375dbc63c9398e86c445c91c87842e23 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Mon, 1 Apr 2019 13:42:35 +0200 Subject: [PATCH] Add linuxwindow --- ScreenPlayWindow/ScreenPlayWindow.pro | 8 ++++++ ScreenPlayWindow/main.cpp | 16 +++++++++++ ScreenPlayWindow/mainWindow.qml | 2 +- ScreenPlayWindow/src/linuxwindow.cpp | 38 +++++++++++++++++++++++++++ ScreenPlayWindow/src/linuxwindow.h | 31 ++++++++++++++++++++++ 5 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 ScreenPlayWindow/src/linuxwindow.cpp create mode 100644 ScreenPlayWindow/src/linuxwindow.h diff --git a/ScreenPlayWindow/ScreenPlayWindow.pro b/ScreenPlayWindow/ScreenPlayWindow.pro index e63c64a2..ee607a93 100644 --- a/ScreenPlayWindow/ScreenPlayWindow.pro +++ b/ScreenPlayWindow/ScreenPlayWindow.pro @@ -13,6 +13,14 @@ SOURCES += \ HEADERS += \ src/basewindow.h \ +unix{ +SOURCES += \ + src/linuxwindow.cpp + +HEADERS += \ + src/linuxwindow.h + +} win32 { LIBS += -luser32 SOURCES += \ diff --git a/ScreenPlayWindow/main.cpp b/ScreenPlayWindow/main.cpp index de2c5fd7..8428071c 100644 --- a/ScreenPlayWindow/main.cpp +++ b/ScreenPlayWindow/main.cpp @@ -8,6 +8,12 @@ #include "src/winwindow.h" #endif +#if defined(Q_OS_LINUX) +#include "src/linuxwindow.h" +#endif + + + #if defined(Q_OS_OSX) // TODO MAC OSX PORT HERE @@ -38,6 +44,10 @@ int main(int argc, char* argv[]) #if defined(Q_OS_WIN) WinWindow window(list, "test", "appid", "1"); #endif +#if defined(Q_OS_LINUX) + LinuxWindow window(list, "test", "appid", "1"); +#endif + return app.exec(); } @@ -80,6 +90,12 @@ int main(int argc, char* argv[]) QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived); #endif +#if defined(Q_OS_LINUX) + LinuxWindow window(list, argumentList.at(2), argumentList.at(3), argumentList.at(5)); + QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &window, &LinuxWindow::destroyThis); + QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &LinuxWindow::messageReceived); +#endif + #if defined(Q_OS_OSX) // TODO MAC OSX PORT HERE diff --git a/ScreenPlayWindow/mainWindow.qml b/ScreenPlayWindow/mainWindow.qml index 3e4b652b..99333f5c 100644 --- a/ScreenPlayWindow/mainWindow.qml +++ b/ScreenPlayWindow/mainWindow.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 import QtWebEngine 1.8 -import net.aimber.wallpaper 1.0 +//import net.aimber.wallpaper 1.0 Rectangle { anchors.fill: parent diff --git a/ScreenPlayWindow/src/linuxwindow.cpp b/ScreenPlayWindow/src/linuxwindow.cpp new file mode 100644 index 00000000..dfb083c3 --- /dev/null +++ b/ScreenPlayWindow/src/linuxwindow.cpp @@ -0,0 +1,38 @@ +#include "linuxwindow.h" + +LinuxWindow::LinuxWindow(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 LinuxWindow::setVisible(bool show) +{ + m_window.setVisible(show); +} + +void LinuxWindow::destroyThis() +{ + QCoreApplication::quit(); +} + +void LinuxWindow::messageReceived(QString key, QString value) +{ +} diff --git a/ScreenPlayWindow/src/linuxwindow.h b/ScreenPlayWindow/src/linuxwindow.h new file mode 100644 index 00000000..592735de --- /dev/null +++ b/ScreenPlayWindow/src/linuxwindow.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "basewindow.h" + +class LinuxWindow : public BaseWindow +{ + Q_OBJECT +public: + explicit LinuxWindow(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; +}; +