mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Add not yet working WebSocketServer
This commit is contained in:
parent
d2080c2bd3
commit
0153bee4a3
@ -19,7 +19,6 @@ namespace ScreenPlay {
|
||||
ScreenPlayManager::ScreenPlayManager(
|
||||
QObject* parent)
|
||||
: QObject { parent }
|
||||
, m_server { std::make_unique<QLocalServer>() }
|
||||
{
|
||||
|
||||
if (checkIsAnotherScreenPlayInstanceRunning()) {
|
||||
@ -27,6 +26,8 @@ ScreenPlayManager::ScreenPlayManager(
|
||||
return;
|
||||
}
|
||||
|
||||
m_server = std::make_unique<QLocalServer>();
|
||||
|
||||
QObject::connect(m_server.get(), &QLocalServer::newConnection, this, &ScreenPlayManager::newConnection);
|
||||
m_server->setSocketOptions(QLocalServer::WorldAccessOption);
|
||||
if (!m_server->listen("ScreenPlay")) {
|
||||
@ -76,6 +77,16 @@ void ScreenPlayManager::init(
|
||||
m_monitorListModel = mlm;
|
||||
m_telemetry = telemetry;
|
||||
m_settings = settings;
|
||||
|
||||
if (m_settings->desktopEnvironment() == Settings::DesktopEnvironment::KDE) {
|
||||
m_websocketServer = std::make_unique<QWebSocketServer>(QStringLiteral("ScreenPlayWebSocket"), QWebSocketServer::SslMode::NonSecureMode);
|
||||
m_websocketServer->listen(QHostAddress::Any, m_webSocketPort);
|
||||
QObject::connect(m_websocketServer.get(), &QWebSocketServer::newConnection, this, [this]() {
|
||||
qInfo() << "New Websocket Connection";
|
||||
auto* socket = m_websocketServer->nextPendingConnection();
|
||||
});
|
||||
}
|
||||
|
||||
loadProfiles();
|
||||
}
|
||||
|
||||
@ -388,7 +399,7 @@ void ScreenPlayManager::newConnection()
|
||||
*/
|
||||
void ScreenPlayManager::closeAllWallpapers()
|
||||
{
|
||||
if(m_screenPlayWallpapers.empty() && m_activeWallpaperCounter == 0)
|
||||
if (m_screenPlayWallpapers.empty() && m_activeWallpaperCounter == 0)
|
||||
return;
|
||||
|
||||
closeConntectionByType(GlobalVariables::getAvailableWallpaper());
|
||||
@ -405,7 +416,7 @@ void ScreenPlayManager::closeAllWallpapers()
|
||||
*/
|
||||
void ScreenPlayManager::closeAllWidgets()
|
||||
{
|
||||
if(m_screenPlayWidgets.empty() && m_activeWidgetsCounter == 0)
|
||||
if (m_screenPlayWidgets.empty() && m_activeWidgetsCounter == 0)
|
||||
return;
|
||||
|
||||
closeConntectionByType(GlobalVariables::getAvailableWidgets());
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QProcess>
|
||||
#include <QtWebSockets/QWebSocket>
|
||||
|
||||
#include "ganalytics.h"
|
||||
#include "globalvariables.h"
|
||||
@ -199,6 +200,7 @@ private:
|
||||
std::shared_ptr<GAnalytics> m_telemetry;
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
std::unique_ptr<QLocalServer> m_server;
|
||||
std::unique_ptr<QWebSocketServer> m_websocketServer;
|
||||
|
||||
QVector<std::shared_ptr<ScreenPlayWallpaper>> m_screenPlayWallpapers;
|
||||
QVector<std::shared_ptr<ScreenPlayWidget>> m_screenPlayWidgets;
|
||||
@ -208,6 +210,8 @@ private:
|
||||
|
||||
bool m_isAnotherScreenPlayInstanceRunning = false;
|
||||
QTimer m_saveLimiter;
|
||||
|
||||
const quint16 m_webSocketPort = 16395;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ Settings::Settings(const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||
|
||||
qRegisterMetaType<Settings::Language>("Settings::Language");
|
||||
qRegisterMetaType<Settings::Theme>("Settings::Theme");
|
||||
qRegisterMetaType<Settings::DesktopEnvironment>("Settings::DesktopEnvironment");
|
||||
|
||||
qmlRegisterUncreatableType<Settings>("Settings", 1, 0, "Settings", "Error only for enums");
|
||||
|
||||
@ -119,6 +120,19 @@ Settings::Settings(const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||
|
||||
setupWidgetAndWindowPaths();
|
||||
setGitBuildHash(COMPILE_INFO);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
setDesktopEnvironment(DesktopEnvironment::Windows);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
setDesktopEnvironment(DesktopEnvironment::OSX);
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// We only support KDE for now
|
||||
setDesktopEnvironment(DesktopEnvironment::KDE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
#include <QSysInfo>
|
||||
#include <QTextStream>
|
||||
#include <QThread>
|
||||
#include <QUrl>
|
||||
@ -84,6 +85,7 @@ class Settings : public QObject {
|
||||
Q_PROPERTY(bool steamVersion READ steamVersion WRITE setSteamVersion NOTIFY steamVersionChanged)
|
||||
|
||||
Q_PROPERTY(ScreenPlay::FillMode::FillMode videoFillMode READ videoFillMode WRITE setVideoFillMode NOTIFY videoFillModeChanged)
|
||||
Q_PROPERTY(DesktopEnvironment desktopEnvironment READ desktopEnvironment WRITE setDesktopEnvironment NOTIFY desktopEnvironmentChanged)
|
||||
Q_PROPERTY(Language language READ language WRITE setLanguage NOTIFY languageChanged)
|
||||
Q_PROPERTY(Theme theme READ theme WRITE setTheme NOTIFY themeChanged)
|
||||
|
||||
@ -96,6 +98,21 @@ public:
|
||||
const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
enum class DesktopEnvironment {
|
||||
Unknown,
|
||||
OSX,
|
||||
Windows,
|
||||
Cinnamon,
|
||||
Enlightenment,
|
||||
Gnome,
|
||||
KDE,
|
||||
Lxde,
|
||||
Lxqt,
|
||||
Mate,
|
||||
Unity,
|
||||
XFCE,
|
||||
};
|
||||
|
||||
enum class Language {
|
||||
En,
|
||||
De,
|
||||
@ -188,6 +205,11 @@ public:
|
||||
return m_steamVersion;
|
||||
}
|
||||
|
||||
DesktopEnvironment desktopEnvironment() const
|
||||
{
|
||||
return m_desktopEnvironment;
|
||||
}
|
||||
|
||||
signals:
|
||||
void requestRetranslation();
|
||||
void resetInstalledListmodel();
|
||||
@ -206,8 +228,8 @@ signals:
|
||||
void languageChanged(ScreenPlay::Settings::Language language);
|
||||
void fontChanged(QString font);
|
||||
void themeChanged(ScreenPlay::Settings::Theme theme);
|
||||
|
||||
void steamVersionChanged(bool steamVersion);
|
||||
void desktopEnvironmentChanged(DesktopEnvironment desktopEnvironment);
|
||||
|
||||
public slots:
|
||||
void writeJsonFileFromResource(const QString& filename);
|
||||
@ -397,6 +419,15 @@ public slots:
|
||||
emit steamVersionChanged(m_steamVersion);
|
||||
}
|
||||
|
||||
void setDesktopEnvironment(DesktopEnvironment desktopEnvironment)
|
||||
{
|
||||
if (m_desktopEnvironment == desktopEnvironment)
|
||||
return;
|
||||
|
||||
m_desktopEnvironment = desktopEnvironment;
|
||||
emit desktopEnvironmentChanged(m_desktopEnvironment);
|
||||
}
|
||||
|
||||
private:
|
||||
void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType);
|
||||
|
||||
@ -420,5 +451,6 @@ private:
|
||||
Theme m_theme { Theme::System };
|
||||
QString m_font { "Roboto" };
|
||||
bool m_steamVersion { false };
|
||||
DesktopEnvironment m_desktopEnvironment = DesktopEnvironment::Unknown;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user