1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/ScreenPlaySDK/screenplaysdk.h
Elias Steurer 272a86a61f Add connection type to sdkconnector. This means we no can distinguish between wallpaper and widgets.
Add remove all wallpaper button. No we can close all wallpapers and widgets seperate.
Add static function to write an QJsonObject into a file. Truncate is optional.
2019-09-14 19:33:58 +02:00

106 lines
2.3 KiB
C++

#pragma once
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
#include <QPluginLoader>
#include <QQuickItem>
#include <QSharedDataPointer>
#include <QSharedPointer>
#include <QTimer>
#include <QtGlobal>
class ScreenPlaySDK : public QQuickItem {
Q_OBJECT
Q_DISABLE_COPY(ScreenPlaySDK)
public:
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)
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
QString type() const
{
return m_type;
}
bool isConnected() const
{
return m_isConnected;
}
QString appID() const
{
return m_appID;
}
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
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);
}
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:
void incommingMessage(QString key, QString value);
void incommingMessageError(QString msg);
void sdkConnected();
void sdkDisconnected();
void typeChanged(QString type);
void isConnectedChanged(bool isConnected);
void appIDChanged(QString appID);
void newRedirectMessage(QByteArray& msg);
private:
void init();
private:
QLocalSocket m_socket;
QString m_type = "undefined";
bool m_isConnected = false;
QString m_appID;
};