122 lines
3.4 KiB
C++
122 lines
3.4 KiB
C++
#ifndef GLOBALDEFINE_H
|
|
#define GLOBALDEFINE_H
|
|
|
|
#include <QJsonDocument>
|
|
#include <QNetworkReply>
|
|
|
|
class LedCard {
|
|
public:
|
|
QString id;
|
|
QString ip;
|
|
int mWidth{0};
|
|
int mHeight{0};
|
|
int bright{100};
|
|
int BrightnessLevel{255};
|
|
QString FirmwareVersion;
|
|
QString HardVersion = "0000";
|
|
QString ScreenResolution;
|
|
QString androidVersion;
|
|
QString alias;
|
|
QString IMEI;
|
|
bool hasPassword{false};
|
|
bool isLocked{true};
|
|
bool isScreenOn{true};
|
|
bool isOnline{true};
|
|
};
|
|
|
|
enum {
|
|
MainPage_DeviceManager = 0,
|
|
MainPage_ProgManager,
|
|
MainPage_Setting,
|
|
MainPage_LoraScreen,
|
|
MainPage_End,
|
|
};
|
|
|
|
|
|
struct ST_ANSY_PROGRAM_PACKET {
|
|
unsigned char SyncHead[3]{0x7e, 0x7e, 0x55};
|
|
unsigned char ucCommType;
|
|
int iBaoLiu;
|
|
unsigned int iLength;
|
|
unsigned char pDataBuffer[20];
|
|
};
|
|
|
|
class DevicePanel;
|
|
extern DevicePanel *gDevicePanel;
|
|
extern QList<LedCard> gSelCards;
|
|
extern bool gVideoCompress;
|
|
extern bool gVideoTranscoding;
|
|
extern bool gTextAntialiasing;
|
|
extern bool gShowLoraScreen;
|
|
extern bool gWidthSplit;
|
|
|
|
extern quint64 dirFileSize(const QString &path);
|
|
extern bool copyDir(const QString &source, const QString &destination, bool override);
|
|
extern unsigned char GetCheckCodeIn8(unsigned char * pBuffer,unsigned int uiSize);
|
|
|
|
enum _ENUM_CONTRL_WIDGET {
|
|
Setting_Bright=0,
|
|
Setting_PowerControl,
|
|
Setting_NetCfg,
|
|
Setting_VerifyClock,
|
|
Setting_Encrypt,
|
|
Setting_HDMI,
|
|
Setting_Volume,
|
|
Setting_Advanced,
|
|
Setting_Test,
|
|
Setting_End,
|
|
};
|
|
class DeviceItem;
|
|
extern DeviceItem *findItem(QString id);
|
|
|
|
|
|
inline int verCompare(const QString& a, const QString& b) {
|
|
auto aparts = a.split(".");
|
|
auto bparts = b.split(".");
|
|
int cnt = qMin(aparts.count(), bparts.count());
|
|
for(int i=0; i<cnt; ++i) {
|
|
int aaa = aparts[i].toInt();
|
|
int bbb = bparts[i].toInt();
|
|
if(aaa != bbb) return aaa - bbb;
|
|
}
|
|
if(aparts.count() == bparts.count()) return 0;
|
|
return aparts.count() > bparts.count() ? aparts[cnt].toInt() : bparts[cnt].toInt();
|
|
}
|
|
|
|
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
|
|
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
|
|
QString checkReplyForJson(QNetworkReply *, QString errField);
|
|
|
|
#define Def_CtrlReqPre \
|
|
waitingDlg->show();\
|
|
auto card = gSelCards[0];\
|
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);\
|
|
waitingDlg->connAbort(reply);
|
|
|
|
#define Def_CtrlSetReqAfter \
|
|
QString err = checkReplyForJson(reply);\
|
|
if(! err.isEmpty()) {\
|
|
waitingDlg->close();\
|
|
QMessageBox::critical(this, tr("Error"), err);\
|
|
return;\
|
|
}\
|
|
waitingDlg->success();
|
|
|
|
#define Def_CtrlSingleGetReply \
|
|
QJsonDocument json;\
|
|
QString err = checkReplyForJson(reply, &json);\
|
|
if(! err.isEmpty()) {\
|
|
waitingDlg->close();\
|
|
QMessageBox::critical(this, tr("Error"), err);\
|
|
return;\
|
|
}
|
|
|
|
#define Def_CtrlSetMulti(tip) \
|
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);\
|
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {\
|
|
QString err = checkReplyForJson(reply);\
|
|
gFdResInfo->append(card.id+" "+tip+" "+(err.isEmpty()?QCoreApplication::translate("Def","Success"):err));\
|
|
});
|
|
|
|
#endif // GLOBALDEFINE_H
|