1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Add incomming message

This commit is contained in:
kelteseth 2018-09-07 20:56:38 +02:00
parent 8faa86a132
commit 3fc75239ef
3 changed files with 67 additions and 67 deletions

View File

@ -28,10 +28,12 @@ int main(int argc, char* argv[])
// Args: which monitor, (2) path to project, (3)wallpaper secret to identify the connected socket, (4) decoder, (5) volume, (6) fillmode
// See screenplay.h @ScreenPlayWallpaper constructor how the args get created
// MainWindow w(0,"D:/672870/827148653","","","","");
qDebug() << "Starting: " << argumentList.at(2) << argumentList.at(3) << argumentList.at(4) << argumentList.at(5)<< argumentList.at(6);
sdk.setAppID(argumentList.at(3));
qDebug() << "Starting MainWindow: " << argumentList.at(2) << argumentList.at(3) << argumentList.at(4) << argumentList.at(5) << argumentList.at(6);
MainWindow w(monitor, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), argumentList.at(6));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &w, &MainWindow::destroyThis);
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &w, &MainWindow::messageReceived);
return a.exec();
}

View File

@ -1,7 +1,6 @@
#include "SPWmainwindow.h"
#ifdef Q_OS_WIN
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
{
// 0xXXXXXXX "" WorkerW
@ -22,22 +21,23 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
#ifdef Q_OS_WIN
setOpacity(0);
m_projectPath = projectPath;
m_appID = id;
m_screenNumber.insert(0, i);
setDecoder(decoder);
setProjectPath(projectPath);
QFile configTmp;
QFile projectFile;
QJsonDocument configJsonDocument;
QJsonParseError parseError;
configTmp.setFileName(projectPath + "/project.json");
configTmp.open(QIODevice::ReadOnly | QIODevice::Text);
m_projectConfig = configTmp.readAll();
projectFile.setFileName(projectPath + "/project.json");
projectFile.open(QIODevice::ReadOnly | QIODevice::Text);
m_projectConfig = projectFile.readAll();
configJsonDocument = QJsonDocument::fromJson(m_projectConfig.toUtf8(), &parseError);
if (!(parseError.error == QJsonParseError::NoError)) {
qWarning("Settings Json Parse Error ");
qWarning("Settings Json Parse Error. Exiting now!");
destroyThis();
}
m_project = configJsonDocument.object();
@ -141,35 +141,7 @@ void MainWindow::init()
#endif
}
QString MainWindow::getApplicationPath()
{
return QApplication::applicationDirPath();
}
void MainWindow::setScreenNumber(const QVector<int>& screenNumber)
{
m_screenNumber = screenNumber;
}
void MainWindow::connected()
{
}
void MainWindow::disconnected()
{
}
void MainWindow::bytesWritten(qint64 bytes)
{
}
void MainWindow::readyRead()
{
}
void MainWindow::error(QLocalSocket::LocalSocketError socketError)
{
}
void MainWindow::destroyThis()
{
#ifdef Q_OS_WIN
@ -178,17 +150,3 @@ void MainWindow::destroyThis()
#endif
QCoreApplication::quit();
}
QUrl MainWindow::projectPath() const
{
return m_projectPath;
}
void MainWindow::setProjectPath(const QUrl& projectPath)
{
m_projectPath = projectPath;
}
MainWindow::~MainWindow()
{
}

View File

@ -5,7 +5,6 @@
#include <QEasingCurve>
#include <QJsonDocument>
#include <QJsonObject>
#include <QLocalSocket>
#include <QObject>
#include <QPropertyAnimation>
#include <QQmlContext>
@ -21,24 +20,24 @@
#include <qt_windows.h>
#endif
class MainWindow : public QWindow {
Q_OBJECT
public:
explicit MainWindow(int i, QString projectPath, QString id, QString decoder, QString volume, QString fillmode, QScreen* parent = nullptr);
~MainWindow();
Q_PROPERTY(QVector<int> screenNumber READ screenNumber WRITE setScreenNumber NOTIFY screenNumberChanged)
Q_PROPERTY(QString projectConfig READ projectConfig WRITE setProjectConfig NOTIFY projectConfigChanged)
Q_PROPERTY(QString appID READ name WRITE setname NOTIFY nameChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
Q_PROPERTY(float playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged) // Not yet needed
QString projectConfig() const
{
@ -55,16 +54,16 @@ public:
return m_screenNumber;
}
QUrl projectPath() const;
void setProjectPath(const QUrl& projectPath);
QUrl projectPath() const
{
return m_projectPath;
}
QString type() const
{
return m_type;
}
void setScreenNumber(const QVector<int>& screenNumber);
QString fillMode() const
{
return m_fillMode;
@ -89,15 +88,25 @@ public:
{
return m_isPlaying;
}
float playbackRate() const
{
return m_playbackRate;
}
QString decoder() const
{
return m_decoder;
}
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
void destroyThis();
void init();
QString getApplicationPath()
{
return QApplication::applicationDirPath();
}
void setProjectConfig(QString projectConfig)
{
if (m_projectConfig == projectConfig)
@ -153,7 +162,15 @@ public slots:
emit volumeChanged(m_volume);
}
QString getApplicationPath();
void setProjectPath(const QUrl& projectPath)
{
m_projectPath = projectPath;
}
void setScreenNumber(const QVector<int>& screenNumber)
{
m_screenNumber = screenNumber;
}
void setFullContentPath(QString fullContentPath)
{
@ -173,6 +190,25 @@ public slots:
emit isPlayingChanged(m_isPlaying);
}
void setPlaybackRate(float playbackRate)
{
qWarning("Floating point comparison needs context sanity check");
if (qFuzzyCompare(m_playbackRate, playbackRate))
return;
m_playbackRate = playbackRate;
emit playbackRateChanged(m_playbackRate);
}
void setDecoder(QString decoder)
{
if (m_decoder == decoder)
return;
m_decoder = decoder;
emit decoderChanged(m_decoder);
}
signals:
void playVideo(QString path);
void playQmlScene(QString file);
@ -184,8 +220,11 @@ signals:
void loopsChanged(bool loops);
void volumeChanged(float volume);
void fullContentPathChanged(QString fullContentPath);
void messageReceived(QString key, QString value);
void isPlayingChanged(bool isPlaying);
void playbackRateChanged(float playbackRate);
void decoderChanged(QString decoder);
private:
#ifdef Q_OS_WIN
@ -197,7 +236,6 @@ private:
QString m_projectFile;
QJsonObject m_project;
QString m_projectConfig;
QSharedPointer<QLocalSocket> m_socket;
QString m_appID;
QVector<int> m_screenNumber;
@ -207,4 +245,6 @@ private:
float m_volume;
QString m_fullContentPath;
bool m_isPlaying;
float m_playbackRate;
QString m_decoder;
};