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

106 lines
2.3 KiB
C
Raw Normal View History

#pragma once
2018-04-18 18:39:25 +02:00
#include <QByteArray>
#include <QJsonDocument>
2018-04-18 18:39:25 +02:00
#include <QJsonObject>
#include <QJsonParseError>
2018-04-18 18:39:25 +02:00
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
2018-09-06 13:57:36 +02:00
#include <QPluginLoader>
2018-04-18 18:39:25 +02:00
#include <QQuickItem>
#include <QSharedDataPointer>
#include <QSharedPointer>
#include <QTimer>
2018-09-06 13:57:36 +02:00
#include <QtGlobal>
2018-04-18 18:39:25 +02:00
class ScreenPlaySDK : public QQuickItem {
Q_OBJECT
Q_DISABLE_COPY(ScreenPlaySDK)
public:
2018-04-18 18:39:25 +02:00
ScreenPlaySDK(QQuickItem* parent = nullptr);
ScreenPlaySDK( const QString& appID, const QString& type,QQuickItem* parent = nullptr);
~ScreenPlaySDK();
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged)
2018-03-12 16:20:48 +01:00
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
QString type() const
{
return m_type;
}
bool isConnected() const
{
return m_isConnected;
}
2018-03-12 16:20:48 +01:00
QString appID() const
{
return m_appID;
}
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
2018-09-08 13:46:31 +02:00
void redirectMessage(QByteArray& msg);
void setType(QString type)
{
if (m_type == type)
return;
m_type = type;
emit typeChanged(m_type);
}
void setIsConnected(bool isConnected)
{
if (m_isConnected == isConnected)
return;
m_isConnected = isConnected;
emit isConnectedChanged(m_isConnected);
}
2018-03-12 16:20:48 +01:00
void setAppID(QString appID)
{
if (m_appID == appID)
return;
m_appID = appID;
emit appIDChanged(m_appID);
}
static void redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg);
signals:
2018-03-12 16:20:48 +01:00
void incommingMessage(QString key, QString value);
void incommingMessageError(QString msg);
void sdkConnected();
void sdkDisconnected();
void typeChanged(QString type);
void isConnectedChanged(bool isConnected);
2018-03-12 16:20:48 +01:00
void appIDChanged(QString appID);
2018-09-08 13:46:31 +02:00
void newRedirectMessage(QByteArray& msg);
2018-03-12 16:20:48 +01:00
private:
void init();
private:
2018-09-06 13:57:36 +02:00
QLocalSocket m_socket;
QString m_type = "undefined";
bool m_isConnected = false;
2018-03-12 16:20:48 +01:00
QString m_appID;
};