ledok
This commit is contained in:
parent
cd2f566bcd
commit
135e321e60
|
@ -125,7 +125,6 @@ SOURCES += \
|
||||||
gutil/qwaitingdlg.cpp \
|
gutil/qwaitingdlg.cpp \
|
||||||
basedlg.cpp \
|
basedlg.cpp \
|
||||||
basewin.cpp \
|
basewin.cpp \
|
||||||
cfg.cpp \
|
|
||||||
device/ctrlhdmipanel.cpp \
|
device/ctrlhdmipanel.cpp \
|
||||||
device/ctrlnetworkpanel.cpp \
|
device/ctrlnetworkpanel.cpp \
|
||||||
device/ctrlpowerpanel.cpp \
|
device/ctrlpowerpanel.cpp \
|
||||||
|
@ -135,7 +134,6 @@ SOURCES += \
|
||||||
deviceitem.cpp \
|
deviceitem.cpp \
|
||||||
devicepanel.cpp \
|
devicepanel.cpp \
|
||||||
ffplayer.cpp \
|
ffplayer.cpp \
|
||||||
globaldefine.cpp \
|
|
||||||
gutil/cpp.cpp \
|
gutil/cpp.cpp \
|
||||||
gutil/qgui.cpp \
|
gutil/qgui.cpp \
|
||||||
gutil/qjson.cpp \
|
gutil/qjson.cpp \
|
||||||
|
@ -154,6 +152,7 @@ SOURCES += \
|
||||||
player/posdlg.cpp \
|
player/posdlg.cpp \
|
||||||
player/srccopy.cpp \
|
player/srccopy.cpp \
|
||||||
progpanel.cpp \
|
progpanel.cpp \
|
||||||
|
program/etimer2.cpp \
|
||||||
synctimer.cpp \
|
synctimer.cpp \
|
||||||
tools.cpp \
|
tools.cpp \
|
||||||
device/ctrladvancedpanel.cpp \
|
device/ctrladvancedpanel.cpp \
|
||||||
|
@ -194,7 +193,6 @@ HEADERS += \
|
||||||
gutil/qwaitingdlg.h \
|
gutil/qwaitingdlg.h \
|
||||||
basedlg.h \
|
basedlg.h \
|
||||||
basewin.h \
|
basewin.h \
|
||||||
cfg.h \
|
|
||||||
device/ctrlhdmipanel.h \
|
device/ctrlhdmipanel.h \
|
||||||
device/ctrlnetworkpanel.h \
|
device/ctrlnetworkpanel.h \
|
||||||
device/ctrlpowerpanel.h \
|
device/ctrlpowerpanel.h \
|
||||||
|
@ -204,11 +202,11 @@ HEADERS += \
|
||||||
deviceitem.h \
|
deviceitem.h \
|
||||||
devicepanel.h \
|
devicepanel.h \
|
||||||
ffplayer.h \
|
ffplayer.h \
|
||||||
globaldefine.h \
|
|
||||||
gutil/cpp.h \
|
gutil/cpp.h \
|
||||||
gutil/qgui.h \
|
gutil/qgui.h \
|
||||||
gutil/qjson.h \
|
gutil/qjson.h \
|
||||||
gutil/qnetwork.h \
|
gutil/qnetwork.h \
|
||||||
|
main.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
mguangyingpinwidget.h \
|
mguangyingpinwidget.h \
|
||||||
player/eleanaclock.h \
|
player/eleanaclock.h \
|
||||||
|
@ -222,6 +220,7 @@ HEADERS += \
|
||||||
player/posdlg.h \
|
player/posdlg.h \
|
||||||
player/srccopy.h \
|
player/srccopy.h \
|
||||||
progpanel.h \
|
progpanel.h \
|
||||||
|
program/etimer2.h \
|
||||||
synctimer.h \
|
synctimer.h \
|
||||||
tools.h \
|
tools.h \
|
||||||
device/ctrladvancedpanel.h \
|
device/ctrladvancedpanel.h \
|
||||||
|
|
|
@ -40,7 +40,7 @@ void BaseWin::paintEvent(QPaintEvent *e) {
|
||||||
void BaseWin::mousePressEvent(QMouseEvent *e) {
|
void BaseWin::mousePressEvent(QMouseEvent *e) {
|
||||||
if(e->button() != Qt::LeftButton) return;
|
if(e->button() != Qt::LeftButton) return;
|
||||||
setFrmSec(e->pos());
|
setFrmSec(e->pos());
|
||||||
if(mFrmSec==Qt::TitleBarArea || mFrmSec==Qt::TopSection || mFrmSec==Qt::LeftSection || mFrmSec==Qt::TopLeftSection) mPressRel = pos() - e->globalPos();
|
if(mFrmSec==Qt::TitleBarArea || mFrmSec==Qt::TopSection || mFrmSec==Qt::LeftSection || mFrmSec==Qt::TopLeftSection) mPressRel = -e->pos();
|
||||||
else if(mFrmSec==Qt::BottomRightSection) mPressRel = QPoint(width() - e->globalX(), height() - e->globalY());
|
else if(mFrmSec==Qt::BottomRightSection) mPressRel = QPoint(width() - e->globalX(), height() - e->globalY());
|
||||||
else if(mFrmSec==Qt::RightSection ) mPressRel = QPoint(width() - e->globalX(), height() );
|
else if(mFrmSec==Qt::RightSection ) mPressRel = QPoint(width() - e->globalX(), height() );
|
||||||
else if(mFrmSec==Qt::BottomSection ) mPressRel = QPoint(width() , height() - e->globalY());
|
else if(mFrmSec==Qt::BottomSection ) mPressRel = QPoint(width() , height() - e->globalY());
|
||||||
|
|
|
@ -36,8 +36,8 @@ protected:
|
||||||
void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
|
void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);
|
||||||
|
|
||||||
QPoint mPressRel{INT_MAX, INT_MAX};
|
QPoint mPressRel{INT_MAX, INT_MAX};
|
||||||
Qt::WindowFrameSection mFrmSec{Qt::NoSection};
|
Qt::WindowFrameSection mFrmSec = Qt::NoSection;
|
||||||
bool isActive{false};
|
bool isActive = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASEWIN_H
|
#endif // BASEWIN_H
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#include "cfg.h"
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
const QString UpdVerUrl = "https://www.ledok.cn/download/LedOK Express Updates.json";
|
|
||||||
|
|
||||||
QString programsDir() {
|
|
||||||
static auto rtn = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/programs";
|
|
||||||
return rtn;
|
|
||||||
}
|
|
13
LedOK/cfg.h
13
LedOK/cfg.h
|
@ -1,13 +0,0 @@
|
||||||
#ifndef CFG_H
|
|
||||||
#define CFG_H
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#define PAGEDEL_SUFFIX "@D$E$L&20111005&"
|
|
||||||
#define RECTF_INVALID QRectF(-9999, -9999, 0, 0)
|
|
||||||
|
|
||||||
extern const QString UpdVerUrl;
|
|
||||||
|
|
||||||
QString programsDir();
|
|
||||||
|
|
||||||
#endif // CFG_H
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ctrladvancedpanel.h"
|
#include "ctrladvancedpanel.h"
|
||||||
#include "device/progressesdlg.h"
|
#include "device/progressesdlg.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "base/changepasswordform.h"
|
#include "base/changepasswordform.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
@ -218,6 +218,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
|
|
||||||
fdRealtimeServer = new QComboBox;
|
fdRealtimeServer = new QComboBox;
|
||||||
fdRealtimeServer->addItem("www.ledokcloud.com/realtime");
|
fdRealtimeServer->addItem("www.ledokcloud.com/realtime");
|
||||||
|
fdRealtimeServer->addItem("192.168.8.:10010");
|
||||||
fdRealtimeServer->setMinimumWidth(260);
|
fdRealtimeServer->setMinimumWidth(260);
|
||||||
fdRealtimeServer->setEditable(true);
|
fdRealtimeServer->setEditable(true);
|
||||||
hBox->addWidget(fdRealtimeServer);
|
hBox->addWidget(fdRealtimeServer);
|
||||||
|
@ -632,36 +633,90 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnGetLog);
|
hBox->addWidget(btnGetLog);
|
||||||
|
|
||||||
hBox->addStretch();
|
auto btnLogOn = new QPushButton("Log On");
|
||||||
hBox = new HBox(vBox);
|
btnLogOn->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnLogOn, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetLogSwitch");
|
||||||
|
json.insert("_type", "SetLogSwitch");
|
||||||
|
json.insert("isOn", true);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("SetRealtimeServer")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
Def_CtrlSetMulti(tr("SetRealtimeServer"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnLogOn);
|
||||||
|
|
||||||
auto btnViewProg = new QPushButton("View Prog JSON");
|
auto btnLogOff = new QPushButton("Log Off");
|
||||||
|
btnLogOff->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnLogOff, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetLogSwitch");
|
||||||
|
json.insert("_type", "SetLogSwitch");
|
||||||
|
json.insert("isOn", false);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("SetRealtimeServer")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
Def_CtrlSetMulti(tr("SetRealtimeServer"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnLogOff);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
grpPlayer = new QGroupBox;
|
||||||
|
vBox->addWidget(grpPlayer);
|
||||||
|
hBox = new HBox(grpPlayer);
|
||||||
|
hBox->setContentsMargins(6,0,6,6);
|
||||||
|
|
||||||
|
auto btnViewProg = new QPushButton("View JSON");
|
||||||
btnViewProg->setProperty("ssType", "progManageTool");
|
btnViewProg->setProperty("ssType", "progManageTool");
|
||||||
connect(btnViewProg, &QPushButton::clicked, this, [this] {
|
connect(btnViewProg, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JObj json{{"_type", "GetFile"}, {"name", "program"}};
|
JObj json{{"_type", "GetJsonWithFileInfo"}};
|
||||||
auto fd = new QTextEdit;
|
auto edit = new QTextEdit;
|
||||||
LocalObj lll;
|
LocalObj lll;
|
||||||
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
|
connect(edit, &QTextEdit::destroyed, &lll, &LocalObj::reset);
|
||||||
fd->setAttribute(Qt::WA_DeleteOnClose);
|
edit->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
fd->setTabStopDistance(26);
|
edit->setTabStopDistance(26);
|
||||||
auto ft = fd->font();
|
auto ft = edit->font();
|
||||||
ft.setFamily("Consolas");
|
ft.setFamily("Consolas");
|
||||||
fd->setFont(ft);
|
edit->setFont(ft);
|
||||||
fd->setWindowTitle("program");
|
edit->setWindowTitle("program");
|
||||||
fd->resize(600, 900);
|
edit->resize(600, 900);
|
||||||
fd->show();
|
edit->show();
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
fd->append(card.id+" Prog JSON");
|
edit->append(card.id+" Prog JSON");
|
||||||
TcpSocket tcp;
|
TcpSocket tcp;
|
||||||
tcp.connectToHost(card.ip, 3333);
|
tcp.connectToHost(card.ip, 3333);
|
||||||
if(! tcp.waitForConnected(10000)) {
|
if(! tcp.waitForConnected(10000)) {
|
||||||
tcp.close();
|
tcp.close();
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
|
edit->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto resNum = tcp.write(JToBytes(json));
|
auto resNum = tcp.write(JToBytes(json));
|
||||||
|
@ -669,84 +724,29 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
tcp.close();
|
tcp.close();
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
|
edit->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(! tcp.waitForReadyRead()) {
|
if(! tcp.waitForReadyRead()) {
|
||||||
tcp.close();
|
tcp.close();
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
edit->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fd->insertPlainText(tcp.readAll());
|
edit->append(tcp.readAll());
|
||||||
while(tcp.waitForReadyRead(1000)) {
|
while(tcp.waitForReadyRead(1000)) {
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
fd->insertPlainText(tcp.readAll());
|
edit->insertPlainText(tcp.readAll());
|
||||||
}
|
}
|
||||||
tcp.close();
|
tcp.close();
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) edit->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
||||||
fd->append("");
|
edit->append("END");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnViewProg);
|
hBox->addWidget(btnViewProg);
|
||||||
|
|
||||||
auto btnListFiles = new QPushButton("List Prog Files");
|
auto btnGetPlayerInfo = new QPushButton("Get Info");
|
||||||
btnListFiles->setProperty("ssType", "progManageTool");
|
|
||||||
connect(btnListFiles, &QPushButton::clicked, this, [this] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObj json{{"_type", "ListProgFiles"}};
|
|
||||||
auto fd = new QTextEdit;
|
|
||||||
LocalObj lll;
|
|
||||||
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
|
|
||||||
fd->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
auto ft = fd->font();
|
|
||||||
ft.setFamily("Consolas");
|
|
||||||
fd->setFont(ft);
|
|
||||||
fd->setWindowTitle("List Prog Files");
|
|
||||||
fd->resize(600, 900);
|
|
||||||
fd->show();
|
|
||||||
for(auto &card : gSelCards) {
|
|
||||||
fd->append(card.id+" Prog Files");
|
|
||||||
TcpSocket tcp;
|
|
||||||
tcp.connectToHost(card.ip, 3333);
|
|
||||||
if(! tcp.waitForConnected(10000)) {
|
|
||||||
tcp.close();
|
|
||||||
if(lll.cnt==0) return;
|
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto resNum = tcp.write(JToBytes(json));
|
|
||||||
tcp.flush();
|
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
|
||||||
tcp.close();
|
|
||||||
if(lll.cnt==0) return;
|
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(! tcp.waitForReadyRead()) {
|
|
||||||
tcp.close();
|
|
||||||
if(lll.cnt==0) return;
|
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
fd->insertPlainText(tcp.readAll());
|
|
||||||
while(tcp.waitForReadyRead(1000)) {
|
|
||||||
if(lll.cnt==0) return;
|
|
||||||
fd->insertPlainText(tcp.readAll());
|
|
||||||
}
|
|
||||||
tcp.close();
|
|
||||||
if(lll.cnt==0) return;
|
|
||||||
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
|
||||||
fd->append("");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
hBox->addWidget(btnListFiles);
|
|
||||||
|
|
||||||
auto btnGetPlayerInfo = new QPushButton("Get Player Info");
|
|
||||||
btnGetPlayerInfo->setProperty("ssType", "progManageTool");
|
btnGetPlayerInfo->setProperty("ssType", "progManageTool");
|
||||||
connect(btnGetPlayerInfo, &QPushButton::clicked, this, [this] {
|
connect(btnGetPlayerInfo, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
|
@ -788,7 +788,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fd->insertPlainText(tcp.readAll());
|
fd->append(tcp.readAll());
|
||||||
while(tcp.waitForReadyRead(1000)) {
|
while(tcp.waitForReadyRead(1000)) {
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
fd->insertPlainText(tcp.readAll());
|
fd->insertPlainText(tcp.readAll());
|
||||||
|
@ -796,12 +796,12 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
tcp.close();
|
tcp.close();
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
||||||
fd->append("");
|
fd->append("END");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnGetPlayerInfo);
|
hBox->addWidget(btnGetPlayerInfo);
|
||||||
|
|
||||||
auto GetBuf = new QPushButton("Get Player Log");
|
auto GetBuf = new QPushButton("Get Log");
|
||||||
GetBuf->setProperty("ssType", "progManageTool");
|
GetBuf->setProperty("ssType", "progManageTool");
|
||||||
connect(GetBuf, &QPushButton::clicked, this, [this] {
|
connect(GetBuf, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
|
@ -843,7 +843,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fd->insertPlainText(tcp.readAll());
|
fd->append(tcp.readAll());
|
||||||
while(tcp.waitForReadyRead(1000)) {
|
while(tcp.waitForReadyRead(1000)) {
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
fd->insertPlainText(tcp.readAll());
|
fd->insertPlainText(tcp.readAll());
|
||||||
|
@ -851,11 +851,66 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
tcp.close();
|
tcp.close();
|
||||||
if(lll.cnt==0) return;
|
if(lll.cnt==0) return;
|
||||||
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
||||||
fd->append("");
|
fd->append("END");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(GetBuf);
|
hBox->addWidget(GetBuf);
|
||||||
|
|
||||||
|
auto btnListFiles = new QPushButton("List Files");
|
||||||
|
btnListFiles->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnListFiles, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json{{"_type", "ListProgFiles"}};
|
||||||
|
auto fd = new QTextEdit;
|
||||||
|
LocalObj lll;
|
||||||
|
connect(fd, &QTextEdit::destroyed, &lll, &LocalObj::reset);
|
||||||
|
fd->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
auto ft = fd->font();
|
||||||
|
ft.setFamily("Consolas");
|
||||||
|
fd->setFont(ft);
|
||||||
|
fd->setWindowTitle("List Prog Files");
|
||||||
|
fd->resize(600, 900);
|
||||||
|
fd->show();
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
fd->append(card.id+" Prog Files");
|
||||||
|
TcpSocket tcp;
|
||||||
|
tcp.connectToHost(card.ip, 3333);
|
||||||
|
if(! tcp.waitForConnected(10000)) {
|
||||||
|
tcp.close();
|
||||||
|
if(lll.cnt==0) return;
|
||||||
|
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitConnected\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto resNum = tcp.write(JToBytes(json));
|
||||||
|
tcp.flush();
|
||||||
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
|
tcp.close();
|
||||||
|
if(lll.cnt==0) return;
|
||||||
|
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at write\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(! tcp.waitForReadyRead()) {
|
||||||
|
tcp.close();
|
||||||
|
if(lll.cnt==0) return;
|
||||||
|
fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fd->append(tcp.readAll());
|
||||||
|
while(tcp.waitForReadyRead(1000)) {
|
||||||
|
if(lll.cnt==0) return;
|
||||||
|
fd->insertPlainText(tcp.readAll());
|
||||||
|
}
|
||||||
|
tcp.close();
|
||||||
|
if(lll.cnt==0) return;
|
||||||
|
if(tcp.error()!=QAbstractSocket::SocketTimeoutError) fd->append(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" at WaitRead2\n");
|
||||||
|
fd->append("END");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnListFiles);
|
||||||
|
|
||||||
auto btnDownFile = new QPushButton("Down File");
|
auto btnDownFile = new QPushButton("Down File");
|
||||||
btnDownFile->setProperty("ssType", "progManageTool");
|
btnDownFile->setProperty("ssType", "progManageTool");
|
||||||
connect(btnDownFile, &QPushButton::clicked, this, [this] {
|
connect(btnDownFile, &QPushButton::clicked, this, [this] {
|
||||||
|
@ -2054,7 +2109,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnM80Set);
|
hBox->addWidget(btnM80Set);
|
||||||
|
|
||||||
btnM80Refresh = new QPushButton();
|
btnM80Refresh = new QPushButton;
|
||||||
btnM80Refresh->setProperty("ssType", "progManageTool");
|
btnM80Refresh->setProperty("ssType", "progManageTool");
|
||||||
connect(btnM80Refresh, &QPushButton::clicked, this, [this] {
|
connect(btnM80Refresh, &QPushButton::clicked, this, [this] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
|
@ -2760,7 +2815,9 @@ void CtrlAdvancedPanel::init() {
|
||||||
|| card.id.startsWith("m5s", Qt::CaseInsensitive)
|
|| card.id.startsWith("m5s", Qt::CaseInsensitive)
|
||||||
|| card.id.startsWith("m6s", Qt::CaseInsensitive)
|
|| card.id.startsWith("m6s", Qt::CaseInsensitive)
|
||||||
|| card.id.startsWith("m7", Qt::CaseInsensitive)
|
|| card.id.startsWith("m7", Qt::CaseInsensitive)
|
||||||
|
|| card.id.startsWith("y0", Qt::CaseInsensitive)
|
||||||
|| card.id.startsWith("y1", Qt::CaseInsensitive)
|
|| card.id.startsWith("y1", Qt::CaseInsensitive)
|
||||||
|
|| card.id.startsWith("y3", Qt::CaseInsensitive)
|
||||||
|| card.id.startsWith("y4", Qt::CaseInsensitive)
|
|| card.id.startsWith("y4", Qt::CaseInsensitive)
|
||||||
|| card.id.startsWith("y5", Qt::CaseInsensitive);
|
|| card.id.startsWith("y5", Qt::CaseInsensitive);
|
||||||
grpY50->setVisible(isY50);
|
grpY50->setVisible(isY50);
|
||||||
|
@ -2801,12 +2858,13 @@ void CtrlAdvancedPanel::transUi() {
|
||||||
btnLedSet->setText(tr("Start LedSet4"));
|
btnLedSet->setText(tr("Start LedSet4"));
|
||||||
btnReceCardsGet->setText(tr("Get Receive Card Num"));
|
btnReceCardsGet->setText(tr("Get Receive Card Num"));
|
||||||
|
|
||||||
|
grpPlayer->setTitle(tr("Player Debug"));
|
||||||
grpM80->setTitle("M80 "+tr("Config"));
|
grpM80->setTitle("M80 "+tr("Config"));
|
||||||
btnM80Refresh->setText(tr("Refresh"));
|
btnM80Refresh->setText(tr("Refresh"));
|
||||||
btnM80Restore->setText(tr("Restore to default"));
|
btnM80Restore->setText(tr("Restore to default"));
|
||||||
btnM80Set->setText(tr("Set"));
|
btnM80Set->setText(tr("Set"));
|
||||||
|
|
||||||
grpY50->setTitle("M50S / M60S / M70S / M5H / M7L / ST50 / Y1G / Y1C / Y4A / Y5A "+tr("Resolution Config"));
|
grpY50->setTitle("M50S / M60S / M70S / M5H / M7L / ST50 / Y1G / Y1C / Y4A / Y5A / Y08 / Y35 / Y37 "+tr("Resolution Config"));
|
||||||
fdDisMode->setItemText(0, tr("Full screen"));
|
fdDisMode->setItemText(0, tr("Full screen"));
|
||||||
fdDisMode->setItemText(1, tr("Part"));
|
fdDisMode->setItemText(1, tr("Part"));
|
||||||
btnY50Set->setText(tr("Set"));
|
btnY50Set->setText(tr("Set"));
|
||||||
|
@ -2911,15 +2969,11 @@ void PlayerBackSendThread::run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QFileInfo info(file);
|
QFileInfo info(file);
|
||||||
auto baseName = info.baseName();
|
|
||||||
auto remain = info.size();
|
auto remain = info.size();
|
||||||
|
JObj req;
|
||||||
auto req = QJsonObject();
|
|
||||||
req.insert("_type", "imgFileStart");
|
req.insert("_type", "imgFileStart");
|
||||||
req.insert("id", baseName);
|
|
||||||
req.insert("size", remain);
|
req.insert("size", remain);
|
||||||
req.insert("zVer","xixun1");
|
auto resNum = tcp.write(JToBytes(req));
|
||||||
auto resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileStart'");
|
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileStart'");
|
||||||
tcp.close();
|
tcp.close();
|
||||||
|
@ -2955,27 +3009,6 @@ void PlayerBackSendThread::run() {
|
||||||
remain -= resNum;
|
remain -= resNum;
|
||||||
}
|
}
|
||||||
file->close();
|
file->close();
|
||||||
req = QJsonObject();
|
|
||||||
req.insert("_type", "imgFileEnd");
|
|
||||||
req.insert("id", baseName);
|
|
||||||
req.insert("zVer","xixun1");
|
|
||||||
resNum = tcp.write(QJsonDocument(req).toJson(QJsonDocument::Compact));
|
|
||||||
if(resNum == -1 || ! tcp.waitForBytesWritten()) {
|
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when write 'imgFileEnd'");
|
|
||||||
tcp.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(! tcp.waitForReadyRead()) {
|
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when waitForRead 'imgFileEnd'");
|
|
||||||
tcp.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto resp = tcp.readAll();
|
|
||||||
if(resp.isEmpty()) {
|
|
||||||
emit emErr(QString(socketErrKey(tcp.error()))+" ("+QString::number(tcp.error())+") "+tcp.errorString()+" when read 'imgFileEnd'");
|
|
||||||
tcp.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tcp.close();
|
tcp.close();
|
||||||
emit emErr("");
|
emit emErr("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
|
|
||||||
QLabel *lbTimingReboot;
|
QLabel *lbTimingReboot;
|
||||||
|
|
||||||
QGroupBox *grpM80, *grpY50;
|
QGroupBox *grpPlayer, *grpM80, *grpY50;
|
||||||
QComboBox *fdM80Resolu, *fdDisMode;
|
QComboBox *fdM80Resolu, *fdDisMode;
|
||||||
QPushButton *btnM80Set, *btnY50Set;
|
QPushButton *btnM80Set, *btnY50Set;
|
||||||
QPushButton *btnM80Refresh;
|
QPushButton *btnM80Refresh;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ctrlbrightpanel.h"
|
#include "ctrlbrightpanel.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "deviceitem.h"
|
#include "deviceitem.h"
|
||||||
#include "xlsxdocument.h"
|
#include "xlsxdocument.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ctrlnetworkpanel.h"
|
#include "ctrlnetworkpanel.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "ctrlpowerpanel.h"
|
#include "ctrlpowerpanel.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "deviceitem.h"
|
#include "deviceitem.h"
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "QFileDialog"
|
#include "QFileDialog"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "deviceitem.h"
|
#include "deviceitem.h"
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ctrlverifyclockpanel.h"
|
#include "ctrlverifyclockpanel.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "ctrlvolumepanel.h"
|
#include "ctrlvolumepanel.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "gutil/qcore.h"
|
#include "gutil/qcore.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
|
@ -353,6 +353,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
end:
|
end:
|
||||||
item->setText("ip", card.ip);
|
item->setText("ip", card.ip);
|
||||||
item->setText("alias", card.alias);
|
item->setText("alias", card.alias);
|
||||||
|
item->setText("firmware", card.firmwareVer);
|
||||||
item->fdOnline->setPixmap({card.isOnline ? ":/res/online.png" : ":/res/offline.png"});
|
item->fdOnline->setPixmap({card.isOnline ? ":/res/online.png" : ":/res/offline.png"});
|
||||||
item->OnCheckSoftVersions();
|
item->OnCheckSoftVersions();
|
||||||
item->OnCheckFpgaVersions();
|
item->OnCheckFpgaVersions();
|
||||||
|
@ -448,7 +449,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
table->addCol("alias", tr("Alias"), 80);
|
table->addCol("alias", tr("Alias"), 80);
|
||||||
table->addCol("encrypt", tr("Security"), 40);
|
table->addCol("encrypt", tr("Security"), 40);
|
||||||
table->addCol("progress", tr("Progress"), 100);
|
table->addCol("progress", tr("Progress"), 100);
|
||||||
table->addCol("remarks", tr("State"), 200, QHeaderView::Stretch);
|
table->addCol("remarks", tr("State"), 200);
|
||||||
table->addCol("playerVer", "XixunPlayer", 70);
|
table->addCol("playerVer", "XixunPlayer", 70);
|
||||||
table->addCol("cardsystem", "cardsystem", 70);
|
table->addCol("cardsystem", "cardsystem", 70);
|
||||||
table->addCol("starter", "starter", 70);
|
table->addCol("starter", "starter", 70);
|
||||||
|
@ -457,6 +458,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
table->addCol("fpga", "FPGA", 70);
|
table->addCol("fpga", "FPGA", 70);
|
||||||
table->addCol("connection", "connection", 70);
|
table->addCol("connection", "connection", 70);
|
||||||
table->addCol("update", "update", 40);
|
table->addCol("update", "update", 40);
|
||||||
|
table->addCol("firmware", "Firmware", 100);
|
||||||
table->setDefs()->setHeaderAlignC();
|
table->setDefs()->setHeaderAlignC();
|
||||||
table->addFd();
|
table->addFd();
|
||||||
table->setSelectionMode(QAbstractItemView::NoSelection);
|
table->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
@ -472,18 +474,18 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
show();
|
show();
|
||||||
|
|
||||||
emit btnRefresh->clicked();
|
emit btnRefresh->clicked();
|
||||||
int ccs[]{"taxiapp"**table, "fpga"**table};
|
// int ccs[]{"playerVer"**table, "firmware"**table};
|
||||||
for(auto cc : ccs) {
|
// for(auto cc : ccs) {
|
||||||
auto size = table->sizeHintForColumn(cc);
|
// auto size = table->sizeHintForColumn(cc);
|
||||||
if(size==0) {
|
// if(size==0) {
|
||||||
int cnt = 8;
|
// int cnt = 8;
|
||||||
do {
|
// do {
|
||||||
wait(50);
|
// wait(50);
|
||||||
size = table->sizeHintForColumn(cc);
|
// size = table->sizeHintForColumn(cc);
|
||||||
} while(size==0 && --cnt);
|
// } while(size==0 && --cnt);
|
||||||
}
|
// }
|
||||||
if(size>table->header()->sectionSize(cc)) table->header()->resizeSection(cc, size);
|
// if(size>table->header()->sectionSize(cc)) table->header()->resizeSection(cc, size);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpgradeApkDialog::sendProgress(UpdateApkItem *item) {
|
void UpgradeApkDialog::sendProgress(UpdateApkItem *item) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "deviceitem.h"
|
#include "deviceitem.h"
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define DEVICEITEM_H
|
#define DEVICEITEM_H
|
||||||
|
|
||||||
#include "base/loqtreewidget.h"
|
#include "base/loqtreewidget.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "deviceitem.h"
|
#include "deviceitem.h"
|
||||||
|
@ -139,7 +139,7 @@ QPushButton:hover {background-color: #08b;}
|
||||||
|
|
||||||
hBox->addWidget(areaFlash);
|
hBox->addWidget(areaFlash);
|
||||||
|
|
||||||
mHBox = new HBox(vBox);
|
vBox->addWidget(splitter = new QSplitter, 1);
|
||||||
|
|
||||||
auto table = new LoQTreeWidget;
|
auto table = new LoQTreeWidget;
|
||||||
table->addCol("#", "", 20);
|
table->addCol("#", "", 20);
|
||||||
|
@ -169,7 +169,7 @@ QPushButton:hover {background-color: #08b;}
|
||||||
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("check") == Qt::Checked) gSelCards.append(static_cast<DeviceItem*>(table->topLevelItem(i))->mCard);
|
for(int i=0; i<cnt; i++) if(table->item(i)->checkState("check") == Qt::Checked) gSelCards.append(static_cast<DeviceItem*>(table->topLevelItem(i))->mCard);
|
||||||
emit sigSelectedDeviceList();
|
emit sigSelectedDeviceList();
|
||||||
});
|
});
|
||||||
mHBox->addWidget(mDeviceTable = table);
|
splitter->addWidget(mDeviceTable = table);
|
||||||
|
|
||||||
connect(&mUdpTimer, &QTimer::timeout, this, &DevicePanel::sendGetInfo);
|
connect(&mUdpTimer, &QTimer::timeout, this, &DevicePanel::sendGetInfo);
|
||||||
connect(&mUdpSocket, &QUdpSocket::readyRead, this, [this] {
|
connect(&mUdpSocket, &QUdpSocket::readyRead, this, [this] {
|
||||||
|
@ -228,7 +228,7 @@ QPushButton:hover {background-color: #08b;}
|
||||||
msgpre.append(tr("Android OS Resolution")).append(": ").append(item->mCard.ScreenResolution).append("\n");
|
msgpre.append(tr("Android OS Resolution")).append(": ").append(item->mCard.ScreenResolution).append("\n");
|
||||||
msgpre.append(tr("Android Version")).append(": ").append(item->mCard.androidVersion).append("\n");
|
msgpre.append(tr("Android Version")).append(": ").append(item->mCard.androidVersion).append("\n");
|
||||||
msgpre.append(tr("FPGA Version")).append(": ").append(item->mCard.HardVersion).append("\n");
|
msgpre.append(tr("FPGA Version")).append(": ").append(item->mCard.HardVersion).append("\n");
|
||||||
msgpre.append(tr("Firmware Version")).append(": ").append(item->mCard.FirmwareVersion).append("\n");
|
msgpre.append(tr("Firmware Version")).append(": ").append(item->mCard.firmwareVer).append("\n");
|
||||||
msgpre.append("IMEI: ").append(item->mCard.IMEI).append("\n");
|
msgpre.append("IMEI: ").append(item->mCard.IMEI).append("\n");
|
||||||
QMessageBox msgBox(QMessageBox::Information, item->mCard.id+" "+tr("Detail Info"), msgpre + tr("Player Version")+": "+tr("Getting")+" ...");
|
QMessageBox msgBox(QMessageBox::Information, item->mCard.id+" "+tr("Detail Info"), msgpre + tr("Player Version")+": "+tr("Getting")+" ...");
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
|
@ -392,7 +392,7 @@ void DevicePanel::transCtrl() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void DevicePanel::newCtrl() {
|
void DevicePanel::newCtrl() {
|
||||||
mHBox->addWidget(mDeviceCtrlPanel = new QWidget);
|
splitter->addWidget(mDeviceCtrlPanel = new QWidget);
|
||||||
auto vBox = new QVBoxLayout(mDeviceCtrlPanel);
|
auto vBox = new QVBoxLayout(mDeviceCtrlPanel);
|
||||||
vBox->setContentsMargins(0,0,0,0);
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
vBox->setSpacing(0);
|
vBox->setSpacing(0);
|
||||||
|
@ -494,6 +494,10 @@ void DevicePanel::newCtrl() {
|
||||||
|
|
||||||
mBtnGrp->button(0)->setChecked(true);
|
mBtnGrp->button(0)->setChecked(true);
|
||||||
|
|
||||||
|
splitter->setStretchFactor(0, 0);
|
||||||
|
splitter->setStretchFactor(1, 1);
|
||||||
|
splitter->setSizes({300, 1});
|
||||||
|
|
||||||
transCtrl();
|
transCtrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +511,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
item->mCard.BrightnessLevel = json["BrightnessLevel"].toInt();
|
item->mCard.BrightnessLevel = json["BrightnessLevel"].toInt();
|
||||||
item->mCard.FirmwareVersion = json["FirmwareVersion"].toStr();
|
item->mCard.firmwareVer = json["FirmwareVersion"].toStr();
|
||||||
item->mCard.HardVersion = json["HardVersion"].toStr();
|
item->mCard.HardVersion = json["HardVersion"].toStr();
|
||||||
item->mCard.ScreenResolution = json["ScreenResolution"].toStr();
|
item->mCard.ScreenResolution = json["ScreenResolution"].toStr();
|
||||||
item->mCard.IMEI = json["IMEI"].toStr();
|
item->mCard.IMEI = json["IMEI"].toStr();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define DEVICEPANEL_H
|
#define DEVICEPANEL_H
|
||||||
|
|
||||||
#include "base/loqtreewidget.h"
|
#include "base/loqtreewidget.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
QLabel *label_3, *nDeviceNum;
|
QLabel *label_3, *nDeviceNum;
|
||||||
QComboBox *bnSpecifyIP;
|
QComboBox *bnSpecifyIP;
|
||||||
QPushButton *btnRefresh;
|
QPushButton *btnRefresh;
|
||||||
HBox *mHBox{0};
|
QSplitter *splitter;
|
||||||
|
|
||||||
QTextEdit *fdInfo;
|
QTextEdit *fdInfo;
|
||||||
QButtonGroup *mBtnGrp;
|
QButtonGroup *mBtnGrp;
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
#include "globaldefine.h"
|
|
||||||
#include "devicepanel.h"
|
|
||||||
#include "deviceitem.h"
|
|
||||||
#include "gutil/qnetwork.h"
|
|
||||||
#include <QDir>
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QMetaEnum>
|
|
||||||
|
|
||||||
QString gFileHome;
|
|
||||||
QString gApkHome;
|
|
||||||
QList<LedCard> gSelCards;
|
|
||||||
bool gVideoCompress = false;
|
|
||||||
bool gVideoTranscoding = false;
|
|
||||||
bool gTextAntialiasing = false;
|
|
||||||
bool gWidthSplit = false;
|
|
||||||
int gSendBatch = 5;
|
|
||||||
bool gHideDetect = false;
|
|
||||||
bool gShowAlias = false;
|
|
||||||
bool gShowLora = false;
|
|
||||||
|
|
||||||
DeviceItem *findItem(QString id) {
|
|
||||||
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
|
||||||
for(int i=0; i<cnt; ++i) {
|
|
||||||
auto item = (DeviceItem*) gDevicePanel->mDeviceTable->topLevelItem(i);
|
|
||||||
if(item==0) continue;
|
|
||||||
if(item->mCard.id==id) return item;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString checkReply(QNetworkReply *reply, QJsonDocument *outJson) {
|
|
||||||
auto err = errStr(reply);
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
auto data = reply->readAll();
|
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
if(outJson) {
|
|
||||||
auto data = reply->readAll();
|
|
||||||
QJsonParseError jsonErr;
|
|
||||||
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
QString errStrWithJson(QNetworkReply *reply, JValue *outJson, QByteArray *outData) {
|
|
||||||
auto err = errStr(reply);
|
|
||||||
auto data = reply->readAll();
|
|
||||||
if(outData) *outData = data;
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
QString error;
|
|
||||||
auto json = JFrom(data, &error);
|
|
||||||
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
if(outJson) *outJson = json;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
|
|
||||||
auto err = errStr(reply);
|
|
||||||
auto data = reply->readAll();
|
|
||||||
if(outData) *outData = data;
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
QJsonParseError jsonErr;
|
|
||||||
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
if(outJson) outJson->swap(json);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
QString checkReplyForJson(QNetworkReply *reply, QString errField) {
|
|
||||||
auto err = errStr(reply);
|
|
||||||
auto data = reply->readAll();
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
QJsonParseError jsonErr;
|
|
||||||
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
|
||||||
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
|
||||||
if(! json["success"].toBool()) {
|
|
||||||
auto errStr = json[errField].toString();
|
|
||||||
return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+(errStr.isEmpty() ? data : errStr);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
quint64 dirFileSize(const QString &path) {
|
|
||||||
QDir dir(path);
|
|
||||||
quint64 size = 0;
|
|
||||||
auto infos = dir.entryInfoList(QDir::Files);
|
|
||||||
foreach(QFileInfo fileInfo, infos) size += fileInfo.size();
|
|
||||||
auto subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
|
||||||
foreach(QString subDir, subDirs) size += dirFileSize(path + QDir::separator() + subDir);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool copyDir(const QString &source, const QString &destination, bool override) {
|
|
||||||
QDir directory(source);
|
|
||||||
if(!directory.exists()) return false;
|
|
||||||
QString srcPath = QDir::toNativeSeparators(source);
|
|
||||||
if(!srcPath.endsWith(QDir::separator())) srcPath += QDir::separator();
|
|
||||||
QString dstPath = QDir::toNativeSeparators(destination);
|
|
||||||
if (!dstPath.endsWith(QDir::separator())) dstPath += QDir::separator();
|
|
||||||
|
|
||||||
bool error = false;
|
|
||||||
QStringList fileNames = directory.entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden);
|
|
||||||
for (QStringList::size_type i=0; i != fileNames.size(); ++i)
|
|
||||||
{
|
|
||||||
QString fileName = fileNames.at(i);
|
|
||||||
QString srcFilePath = srcPath + fileName;
|
|
||||||
QString dstFilePath = dstPath + fileName;
|
|
||||||
QFileInfo fileInfo(srcFilePath);
|
|
||||||
if (fileInfo.isFile() || fileInfo.isSymLink())
|
|
||||||
{
|
|
||||||
if (override)
|
|
||||||
{
|
|
||||||
QFile::setPermissions(dstFilePath, QFile::WriteOwner);
|
|
||||||
}
|
|
||||||
QFile::copy(srcFilePath, dstFilePath);
|
|
||||||
}
|
|
||||||
else if (fileInfo.isDir())
|
|
||||||
{
|
|
||||||
QDir dstDir(dstFilePath);
|
|
||||||
dstDir.mkpath(dstFilePath);
|
|
||||||
if (!copyDir(srcFilePath, dstFilePath, override))
|
|
||||||
{
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return !error;
|
|
||||||
}
|
|
||||||
unsigned char GetCheckCodeIn8(unsigned char *str, unsigned int size) {
|
|
||||||
unsigned char checkCode = 0;
|
|
||||||
for(int i=0; i<size; i++) checkCode += str[i];
|
|
||||||
return (~checkCode) & 0xff;
|
|
||||||
}
|
|
|
@ -235,6 +235,10 @@ public:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using QTreeWidget::setColumnHidden;
|
||||||
|
void setColumnHidden(const QString& column, bool hide) {
|
||||||
|
setColumnHidden(fdmap.at(column), hide);
|
||||||
|
}
|
||||||
using QTreeWidget::showColumn;
|
using QTreeWidget::showColumn;
|
||||||
void showColumn(const QString& column) {
|
void showColumn(const QString& column) {
|
||||||
showColumn(fdmap.at(column));
|
showColumn(fdmap.at(column));
|
||||||
|
|
162
LedOK/main.cpp
162
LedOK/main.cpp
|
@ -1,13 +1,26 @@
|
||||||
|
#include "main.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "deviceitem.h"
|
||||||
|
#include "gutil/qnetwork.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
|
#include <QFileInfo>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#if(QT_VERSION_MAJOR > 5)
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const QString UpdVerUrl = "https://www.ledok.cn/download/LedOK Express Updates.json";
|
||||||
|
|
||||||
|
QString programsDir() {
|
||||||
|
static auto rtn = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/programs";
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER //MSVC编译器
|
#ifdef _MSC_VER //MSVC编译器
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <DbgHelp.h>
|
#include <DbgHelp.h>
|
||||||
|
@ -76,3 +89,152 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString gFileHome;
|
||||||
|
QList<LedCard> gSelCards;
|
||||||
|
|
||||||
|
DeviceItem *findItem(QString id) {
|
||||||
|
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
||||||
|
for(int i=0; i<cnt; ++i) {
|
||||||
|
auto item = (DeviceItem*) gDevicePanel->mDeviceTable->topLevelItem(i);
|
||||||
|
if(item==0) continue;
|
||||||
|
if(item->mCard.id==id) return item;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString checkReply(QNetworkReply *reply, QJsonDocument *outJson) {
|
||||||
|
auto err = errStr(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
auto data = reply->readAll();
|
||||||
|
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if(outJson) {
|
||||||
|
auto data = reply->readAll();
|
||||||
|
QJsonParseError jsonErr;
|
||||||
|
*outJson = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
|
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
QString errStrWithJson(QNetworkReply *reply, JValue *outJson, QByteArray *outData) {
|
||||||
|
auto err = errStr(reply);
|
||||||
|
auto data = reply->readAll();
|
||||||
|
if(outData) *outData = data;
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
QString error;
|
||||||
|
auto json = JFrom(data, &error);
|
||||||
|
if(! error.isEmpty()) return "JSON Error: "+error+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
if(outJson) *outJson = json;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArray *outData) {
|
||||||
|
auto err = errStr(reply);
|
||||||
|
auto data = reply->readAll();
|
||||||
|
if(outData) *outData = data;
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
QJsonParseError jsonErr;
|
||||||
|
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
|
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
if(! json["success"].toBool()) return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
if(outJson) outJson->swap(json);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
QString checkReplyForJson(QNetworkReply *reply, QString errField) {
|
||||||
|
auto err = errStr(reply);
|
||||||
|
auto data = reply->readAll();
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
if(! data.isEmpty()) err = err+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
QJsonParseError jsonErr;
|
||||||
|
QJsonDocument json = QJsonDocument::fromJson(data, &jsonErr);
|
||||||
|
if(jsonErr.error != QJsonParseError::NoError) return "Json error: "+jsonErr.errorString()+"\n"+QCoreApplication::translate("Def","Device replied")+": "+data;
|
||||||
|
if(! json["success"].toBool()) {
|
||||||
|
auto errStr = json[errField].toString();
|
||||||
|
return QCoreApplication::translate("Def","Fail")+". "+QCoreApplication::translate("Def","Device replied")+": "+(errStr.isEmpty() ? data : errStr);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 dirFileSize(const QString &path) {
|
||||||
|
QDir dir(path);
|
||||||
|
quint64 size = 0;
|
||||||
|
auto infos = dir.entryInfoList(QDir::Files);
|
||||||
|
foreach(QFileInfo fileInfo, infos) size += fileInfo.size();
|
||||||
|
auto subDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
foreach(QString subDir, subDirs) size += dirFileSize(path + QDir::separator() + subDir);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool copyDir(const QString &source, const QString &destination, bool override) {
|
||||||
|
QDir directory(source);
|
||||||
|
if(!directory.exists()) return false;
|
||||||
|
QString srcPath = QDir::toNativeSeparators(source);
|
||||||
|
if(!srcPath.endsWith(QDir::separator())) srcPath += QDir::separator();
|
||||||
|
QString dstPath = QDir::toNativeSeparators(destination);
|
||||||
|
if (!dstPath.endsWith(QDir::separator())) dstPath += QDir::separator();
|
||||||
|
|
||||||
|
bool error = false;
|
||||||
|
QStringList fileNames = directory.entryList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden);
|
||||||
|
for (QStringList::size_type i=0; i != fileNames.size(); ++i)
|
||||||
|
{
|
||||||
|
QString fileName = fileNames.at(i);
|
||||||
|
QString srcFilePath = srcPath + fileName;
|
||||||
|
QString dstFilePath = dstPath + fileName;
|
||||||
|
QFileInfo fileInfo(srcFilePath);
|
||||||
|
if (fileInfo.isFile() || fileInfo.isSymLink())
|
||||||
|
{
|
||||||
|
if (override)
|
||||||
|
{
|
||||||
|
QFile::setPermissions(dstFilePath, QFile::WriteOwner);
|
||||||
|
}
|
||||||
|
QFile::copy(srcFilePath, dstFilePath);
|
||||||
|
}
|
||||||
|
else if (fileInfo.isDir())
|
||||||
|
{
|
||||||
|
QDir dstDir(dstFilePath);
|
||||||
|
dstDir.mkpath(dstFilePath);
|
||||||
|
if (!copyDir(srcFilePath, dstFilePath, override))
|
||||||
|
{
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return !error;
|
||||||
|
}
|
||||||
|
unsigned char GetCheckCodeIn8(unsigned char *str, unsigned int size) {
|
||||||
|
unsigned char checkCode = 0;
|
||||||
|
for(int i=0; i<size; i++) checkCode += str[i];
|
||||||
|
return (~checkCode) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MergeFmt(QTextEdit *textEdit, const QTextCharFormat &fmt) {
|
||||||
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
cursor.mergeCharFormat(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
Tick::Tick(QWidget *parent) : QOpenGLWidget(parent) {
|
||||||
|
setGeometry(0, 0, 1, 1);
|
||||||
|
connect(this, &QOpenGLWidget::frameSwapped, this, &Tick::doFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Tick::doFrame() {
|
||||||
|
auto cur = QDateTime::currentDateTime();
|
||||||
|
auto secs = cur.toSecsSinceEpoch();
|
||||||
|
if(secs != Sec) {
|
||||||
|
Sec = secs;
|
||||||
|
emit secChanged(cur);
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
#ifndef GLOBALDEFINE_H
|
#ifndef MAIN_H
|
||||||
#define GLOBALDEFINE_H
|
#define MAIN_H
|
||||||
|
|
||||||
#include "gutil/qjson.h"
|
#include "gutil/qjson.h"
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
|
#define PAGEDEL_SUFFIX "@D$E$L&20111005&"
|
||||||
|
#define RECTF_INVALID QRectF(-9999, -9999, 0, 0)
|
||||||
|
|
||||||
struct LedCard {
|
struct LedCard {
|
||||||
QString id;
|
QString id;
|
||||||
|
@ -12,19 +17,29 @@ struct LedCard {
|
||||||
int mHeight = 0;
|
int mHeight = 0;
|
||||||
int bright = 100;
|
int bright = 100;
|
||||||
int BrightnessLevel = 255;
|
int BrightnessLevel = 255;
|
||||||
QString FirmwareVersion;
|
QString firmwareVer;
|
||||||
QString HardVersion = "0000";
|
QString HardVersion = "0000";
|
||||||
QString ScreenResolution;
|
QString ScreenResolution;
|
||||||
QString androidVersion;
|
QString androidVersion;
|
||||||
QString playerVer;
|
QString playerVer;
|
||||||
QString alias;
|
QString alias;
|
||||||
QString IMEI;
|
QString IMEI;
|
||||||
bool hasPassword{false};
|
bool hasPassword = false;
|
||||||
bool isLocked{true};
|
bool isLocked = true;
|
||||||
bool isScreenOn{true};
|
bool isScreenOn = true;
|
||||||
bool isOnline{true};
|
bool isOnline = true;
|
||||||
};
|
};
|
||||||
|
class Tick : public QOpenGLWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Tick(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void doFrame();
|
||||||
|
|
||||||
|
qint64 Sec;
|
||||||
|
signals:
|
||||||
|
void secChanged(const QDateTime &);
|
||||||
|
};
|
||||||
enum {
|
enum {
|
||||||
MainPage_DeviceManager = 0,
|
MainPage_DeviceManager = 0,
|
||||||
MainPage_ProgManager,
|
MainPage_ProgManager,
|
||||||
|
@ -42,6 +57,10 @@ struct ST_ANSY_PROGRAM_PACKET {
|
||||||
unsigned char pDataBuffer[20];
|
unsigned char pDataBuffer[20];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const QString UpdVerUrl;
|
||||||
|
QString programsDir();
|
||||||
|
|
||||||
|
extern Tick *gTick;
|
||||||
extern QString gFileHome;
|
extern QString gFileHome;
|
||||||
extern QString gApkHome;
|
extern QString gApkHome;
|
||||||
class DevicePanel;
|
class DevicePanel;
|
||||||
|
@ -53,6 +72,7 @@ extern bool gTextAntialiasing;
|
||||||
extern bool gWidthSplit;
|
extern bool gWidthSplit;
|
||||||
extern int gSendBatch;
|
extern int gSendBatch;
|
||||||
extern bool gHideDetect;
|
extern bool gHideDetect;
|
||||||
|
extern bool gShowIP;
|
||||||
extern bool gShowAlias;
|
extern bool gShowAlias;
|
||||||
extern bool gShowLora;
|
extern bool gShowLora;
|
||||||
|
|
||||||
|
@ -93,6 +113,8 @@ QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
|
||||||
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
|
QString checkReplyForJson(QNetworkReply *, QJsonDocument * = 0, QByteArray * = 0);
|
||||||
QString checkReplyForJson(QNetworkReply *, QString errField);
|
QString checkReplyForJson(QNetworkReply *, QString errField);
|
||||||
|
|
||||||
|
void MergeFmt(QTextEdit *textEdit, const QTextCharFormat &fmt);
|
||||||
|
|
||||||
#define Def_CtrlReqPre \
|
#define Def_CtrlReqPre \
|
||||||
waitingDlg->show();\
|
waitingDlg->show();\
|
||||||
auto card = gSelCards[0];\
|
auto card = gSelCards[0];\
|
||||||
|
@ -132,4 +154,4 @@ public :
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALDEFINE_H
|
#endif // MAIN_H
|
|
@ -1,7 +1,6 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "cfg.h"
|
#include "main.h"
|
||||||
#include "globaldefine.h"
|
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "device/upgradeapkdialog.h"
|
#include "device/upgradeapkdialog.h"
|
||||||
|
@ -18,9 +17,22 @@
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
|
||||||
extern QPoint gPlayPos;
|
extern QPoint gPlayPos;
|
||||||
|
|
||||||
|
QString gApkHome;
|
||||||
|
bool gVideoCompress = false;
|
||||||
|
bool gVideoTranscoding = false;
|
||||||
|
bool gTextAntialiasing = false;
|
||||||
|
bool gWidthSplit = false;
|
||||||
|
int gSendBatch = 5;
|
||||||
|
bool gHideDetect = false;
|
||||||
|
bool gShowIP = true;
|
||||||
|
bool gShowAlias = false;
|
||||||
|
bool gShowLora = false;
|
||||||
|
Tick *gTick;
|
||||||
|
|
||||||
class ImgBtn : public QToolButton {
|
class ImgBtn : public QToolButton {
|
||||||
public:
|
public:
|
||||||
ImgBtn() {
|
ImgBtn() {
|
||||||
|
@ -213,9 +225,6 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
pLayout->addWidget(m_wTitle->bn_Close);
|
pLayout->addWidget(m_wTitle->bn_Close);
|
||||||
|
|
||||||
auto menu_setting = new QMenu;
|
auto menu_setting = new QMenu;
|
||||||
act_lang = new QAction;
|
|
||||||
act_lang->setMenu(menuLang);
|
|
||||||
menu_setting->addAction(act_lang);
|
|
||||||
|
|
||||||
actFirmware = new QAction(tr("firmware manager"));
|
actFirmware = new QAction(tr("firmware manager"));
|
||||||
connect(actFirmware, &QAction::triggered, this, [this] {
|
connect(actFirmware, &QAction::triggered, this, [this] {
|
||||||
|
@ -267,6 +276,10 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
fdHideDetect->setChecked(gHideDetect);
|
fdHideDetect->setChecked(gHideDetect);
|
||||||
vBox->addWidget(fdHideDetect);
|
vBox->addWidget(fdHideDetect);
|
||||||
|
|
||||||
|
auto fdShowIP = new QCheckBox(tr("Show IP in Terminal Control"));
|
||||||
|
fdShowIP->setChecked(gShowIP);
|
||||||
|
vBox->addWidget(fdShowIP);
|
||||||
|
|
||||||
auto fdShowAlias = new QCheckBox(tr("Show Alias in Terminal Control"));
|
auto fdShowAlias = new QCheckBox(tr("Show Alias in Terminal Control"));
|
||||||
fdShowAlias->setChecked(gShowAlias);
|
fdShowAlias->setChecked(gShowAlias);
|
||||||
vBox->addWidget(fdShowAlias);
|
vBox->addWidget(fdShowAlias);
|
||||||
|
@ -286,6 +299,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
settings.setValue("WidthSplit", gWidthSplit = fdWidthSplit->isChecked());
|
settings.setValue("WidthSplit", gWidthSplit = fdWidthSplit->isChecked());
|
||||||
settings.setValue("SendBatch", gSendBatch = fdSendBatch->value());
|
settings.setValue("SendBatch", gSendBatch = fdSendBatch->value());
|
||||||
settings.setValue("HideDetect", gHideDetect = fdHideDetect->isChecked());
|
settings.setValue("HideDetect", gHideDetect = fdHideDetect->isChecked());
|
||||||
|
settings.setValue("ShowIP", gShowIP = fdShowIP->isChecked());
|
||||||
settings.setValue("ShowAlias", gShowAlias = fdShowAlias->isChecked());
|
settings.setValue("ShowAlias", gShowAlias = fdShowAlias->isChecked());
|
||||||
settings.setValue("GuangYingPin", gShowLora = fdShowLora->isChecked());
|
settings.setValue("GuangYingPin", gShowLora = fdShowLora->isChecked());
|
||||||
dlg.accept();
|
dlg.accept();
|
||||||
|
@ -295,19 +309,18 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
fdDetectCard->setVisible(! gHideDetect);
|
fdDetectCard->setVisible(! gHideDetect);
|
||||||
if(mDevicePanel->mDeviceTable->isColumnHidden(mDevicePanel->mDeviceTable->columnCount()-1)) {
|
if(mDevicePanel->mDeviceTable->isColumnHidden(mDevicePanel->mDeviceTable->columnCount()-1)) {
|
||||||
if(gShowAlias) {
|
mDevicePanel->mDeviceTable->setColumnHidden("ip", ! gShowIP);
|
||||||
mDevicePanel->mDeviceTable->showColumn("alias");
|
mDevicePanel->mDeviceTable->setColumnHidden("alias", ! gShowAlias);
|
||||||
mDevicePanel->mDeviceTable->hideColumn("ip");
|
|
||||||
} else {
|
|
||||||
mDevicePanel->mDeviceTable->hideColumn("alias");
|
|
||||||
mDevicePanel->mDeviceTable->showColumn("ip");
|
|
||||||
}
|
|
||||||
mDevicePanel->mDeviceTable->adjSections(-1, 0);
|
mDevicePanel->mDeviceTable->adjSections(-1, 0);
|
||||||
}
|
}
|
||||||
mBtnGrp->button(MainPage_LoraScreen)->setVisible(gShowLora);
|
mBtnGrp->button(MainPage_LoraScreen)->setVisible(gShowLora);
|
||||||
});
|
});
|
||||||
menu_setting->addAction(actPreferences);
|
menu_setting->addAction(actPreferences);
|
||||||
|
|
||||||
|
act_lang = new QAction;
|
||||||
|
act_lang->setMenu(menuLang);
|
||||||
|
menu_setting->addAction(act_lang);
|
||||||
|
|
||||||
#if !defined leyide && !defined citta
|
#if !defined leyide && !defined citta
|
||||||
act_upd = new QAction(tr("Check for updates"));
|
act_upd = new QAction(tr("Check for updates"));
|
||||||
connect(act_upd, &QAction::triggered, this, [this] {
|
connect(act_upd, &QAction::triggered, this, [this] {
|
||||||
|
@ -428,7 +441,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
act_help = new QAction();
|
act_help = new QAction;
|
||||||
connect(act_help, &QAction::triggered, this, [this] {
|
connect(act_help, &QAction::triggered, this, [this] {
|
||||||
auto act = langGrp->checkedAction();
|
auto act = langGrp->checkedAction();
|
||||||
if(act==0) return;
|
if(act==0) return;
|
||||||
|
@ -436,14 +449,11 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
});
|
});
|
||||||
menu_setting->addAction(act_help);
|
menu_setting->addAction(act_help);
|
||||||
|
|
||||||
actInfo = new QAction;
|
// QMessageBox::information(this, tr("Info"), QFileInfo("aaa.file").absoluteFilePath()
|
||||||
connect(actInfo, &QAction::triggered, this, [this] {
|
// .append("\nSupportsSsl: ").append(QSslSocket::supportsSsl()?"true":"false")
|
||||||
QMessageBox::information(this, tr("Info"), QFileInfo("aaa.file").absoluteFilePath()
|
// .append("\nSslLibraryBuildVersion: ").append(QSslSocket::sslLibraryBuildVersionString().append(" (").append(QString::number(QSslSocket::sslLibraryBuildVersionNumber())).append(")"))
|
||||||
.append("\nSupportsSsl: ").append(QSslSocket::supportsSsl()?"true":"false")
|
// .append("\nSslLibraryVersion: ").append(QSslSocket::sslLibraryVersionString()).append(" (").append(QString::number(QSslSocket::sslLibraryVersionNumber())).append(")"));
|
||||||
.append("\nSslLibraryBuildVersion: ").append(QSslSocket::sslLibraryBuildVersionString().append(" (").append(QString::number(QSslSocket::sslLibraryBuildVersionNumber())).append(")"))
|
|
||||||
.append("\nSslLibraryVersion: ").append(QSslSocket::sslLibraryVersionString()).append(" (").append(QString::number(QSslSocket::sslLibraryVersionNumber())).append(")"));
|
|
||||||
});
|
|
||||||
menu_setting->addAction(actInfo);
|
|
||||||
|
|
||||||
#if !defined leyide && !defined citta
|
#if !defined leyide && !defined citta
|
||||||
act_about = new QAction(tr("About"));
|
act_about = new QAction(tr("About"));
|
||||||
|
@ -544,11 +554,11 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
mDevicePanel->mDeviceTable->showColumn("check");
|
mDevicePanel->mDeviceTable->showColumn("check");
|
||||||
mDevicePanel->mDeviceTable->fdCheckAll->show();
|
mDevicePanel->mDeviceTable->fdCheckAll->show();
|
||||||
mDevicePanel->fdCardNumInfo->show();
|
mDevicePanel->fdCardNumInfo->show();
|
||||||
auto specialIdx = (gShowAlias ? "alias" : "ip")**mDevicePanel->mDeviceTable;
|
auto idxIP = ! gShowIP ? -1 : "ip"**mDevicePanel->mDeviceTable;
|
||||||
for(int j="id"**mDevicePanel->mDeviceTable+1; j<mDevicePanel->mDeviceTable->columnCount(); j++) if(j!=specialIdx) mDevicePanel->mDeviceTable->hideColumn(j);
|
auto idxAlias = ! gShowAlias ? -1 : "alias"**mDevicePanel->mDeviceTable;
|
||||||
|
for(int j="id"**mDevicePanel->mDeviceTable+1; j<mDevicePanel->mDeviceTable->columnCount(); j++) if(j!=idxIP && j!=idxAlias) mDevicePanel->mDeviceTable->hideColumn(j);
|
||||||
if(mDevicePanel->mDeviceCtrlPanel) mDevicePanel->mDeviceCtrlPanel->show();
|
if(mDevicePanel->mDeviceCtrlPanel) mDevicePanel->mDeviceCtrlPanel->show();
|
||||||
else mDevicePanel->newCtrl();
|
else mDevicePanel->newCtrl();
|
||||||
mDevicePanel->mDeviceTable->setMaximumWidth(300);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -614,6 +624,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
gSendBatch = settings.value("SendBatch", 5).toInt();
|
gSendBatch = settings.value("SendBatch", 5).toInt();
|
||||||
gHideDetect = settings.value("HideDetect").toBool();
|
gHideDetect = settings.value("HideDetect").toBool();
|
||||||
gShowAlias = settings.value("ShowAlias").toBool();
|
gShowAlias = settings.value("ShowAlias").toBool();
|
||||||
|
gShowIP = settings.value("ShowIP", ! gShowAlias).toBool();
|
||||||
gShowLora = settings.value("GuangYingPin").toBool();
|
gShowLora = settings.value("GuangYingPin").toBool();
|
||||||
|
|
||||||
if(gHideDetect) fdDetectCard->hide();
|
if(gHideDetect) fdDetectCard->hide();
|
||||||
|
@ -658,6 +669,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
QColorDialog::setStandardColor(ci++, QColor(lows[i], mids[i], higs[i]));
|
QColorDialog::setStandardColor(ci++, QColor(lows[i], mids[i], higs[i]));
|
||||||
QColorDialog::setStandardColor(ci++, QColor(mids[i], lows[i], higs[i]));
|
QColorDialog::setStandardColor(ci++, QColor(mids[i], lows[i], higs[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gTick = new Tick(this);
|
||||||
}
|
}
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
@ -691,7 +704,6 @@ void MainWindow::transUi() {
|
||||||
fdDetectCard->setText(tr("Check card"));
|
fdDetectCard->setText(tr("Check card"));
|
||||||
act_lang->setText(tr("Language"));
|
act_lang->setText(tr("Language"));
|
||||||
act_help->setText(tr("Help"));
|
act_help->setText(tr("Help"));
|
||||||
actInfo->setText(tr("Info"));
|
|
||||||
if(act_about) act_about->setText(tr("About"));
|
if(act_about) act_about->setText(tr("About"));
|
||||||
if(act_upd) act_upd->setText(tr("Check for updates"));
|
if(act_upd) act_upd->setText(tr("Check for updates"));
|
||||||
actFirmware->setText(tr("firmware manager"));
|
actFirmware->setText(tr("firmware manager"));
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "base/loqtitlebar.h"
|
#include "base/loqtitlebar.h"
|
||||||
#include "basewin.h"
|
#include "basewin.h"
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "mguangyingpinwidget.h"
|
#include "mguangyingpinwidget.h"
|
||||||
#include "progpanel.h"
|
#include "progpanel.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
@ -25,7 +25,7 @@ private:
|
||||||
LoQTitleBar *m_wTitle;
|
LoQTitleBar *m_wTitle;
|
||||||
QActionGroup *langGrp;
|
QActionGroup *langGrp;
|
||||||
QAction *act_lang;
|
QAction *act_lang;
|
||||||
QAction *act_help, *actInfo;
|
QAction *act_help;
|
||||||
QAction *act_upd = 0;
|
QAction *act_upd = 0;
|
||||||
QAction *actFirmware;
|
QAction *actFirmware;
|
||||||
QAction *actPreferences;
|
QAction *actPreferences;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "mguangyingpinwidget.h"
|
#include "mguangyingpinwidget.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSerialPortInfo>
|
#include <QSerialPortInfo>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "eletimer.h"
|
#include "eletimer.h"
|
||||||
#include "tools.h"
|
#include "main.h"
|
||||||
#include "globaldefine.h"
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
EleTimer::EleTimer(const JValue &json, QWidget *parent) : QWidget{parent} {
|
EleTimer::EleTimer(const JValue &json, QWidget *parent) : QWidget{parent} {
|
||||||
|
@ -22,11 +21,11 @@ EleTimer::EleTimer(const JValue &json, QWidget *parent) : QWidget{parent} {
|
||||||
textColor = json["textColor"].toString();
|
textColor = json["textColor"].toString();
|
||||||
auto color = json["backColor"].toString();
|
auto color = json["backColor"].toString();
|
||||||
backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
||||||
connect(Tools::getInstance(), &Tools::sTick, this, [this]() {
|
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
|
||||||
QDateTime cDateTime = QDateTime::currentDateTime();
|
auto sss = isDown ? cur.secsTo(targetTime) : targetTime.secsTo(cur);
|
||||||
qint64 ofs = isDown ? cDateTime.secsTo(targetTime) : targetTime.secsTo(cDateTime);
|
if(sss < 0) sss = 0;
|
||||||
if(ofs < 0) ofs = 0;
|
if(secs==sss) return;
|
||||||
secs = ofs;
|
secs = sss;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "progpanel.h"
|
#include "progpanel.h"
|
||||||
#include "program/progitem.h"
|
#include "program/progitem.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "player/playwin.h"
|
#include "player/playwin.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "eaclock.h"
|
#include "eaclock.h"
|
||||||
#include "QtWidgets/qgraphicsscene.h"
|
#include "QtWidgets/qgraphicsscene.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
|
|
|
@ -53,8 +53,10 @@ void EBase::setBaseAttr(const JObj &json) {
|
||||||
mEntryDur = json["entryDur"].toInt();
|
mEntryDur = json["entryDur"].toInt();
|
||||||
mExitDur = json["exitDur"].toInt();
|
mExitDur = json["exitDur"].toInt();
|
||||||
_rotate = json["rotate"].toInt();
|
_rotate = json["rotate"].toInt();
|
||||||
_blink = json["blink"].toDouble(1.0);
|
_opacity = json["opacity"].toDouble(1);
|
||||||
|
_blink = json["blink"].toDouble(1);
|
||||||
_hasBlink = json["hasBlink"].toBool();
|
_hasBlink = json["hasBlink"].toBool();
|
||||||
|
_hasBreathe = json["hasBreathe"].toBool();
|
||||||
auto geometry = json["geometry"];
|
auto geometry = json["geometry"];
|
||||||
setPos(geometry["x"].toInt(), geometry["y"].toInt());
|
setPos(geometry["x"].toInt(), geometry["y"].toInt());
|
||||||
setSize(geometry["w"].toInt(), geometry["h"].toInt());
|
setSize(geometry["w"].toInt(), geometry["h"].toInt());
|
||||||
|
@ -87,8 +89,10 @@ void EBase::addBaseAttr(JObj &obj) const {
|
||||||
obj.insert("entryDur", mEntryDur);
|
obj.insert("entryDur", mEntryDur);
|
||||||
obj.insert("exitDur", mExitDur);
|
obj.insert("exitDur", mExitDur);
|
||||||
obj["rotate"] = _rotate;
|
obj["rotate"] = _rotate;
|
||||||
|
obj["opacity"] = _opacity;
|
||||||
obj["blink"] = _blink;
|
obj["blink"] = _blink;
|
||||||
obj["hasBlink"] = _hasBlink;
|
obj["hasBlink"] = _hasBlink;
|
||||||
|
obj["hasBreathe"] = _hasBreathe;
|
||||||
if(bdImgIdx>-1) {
|
if(bdImgIdx>-1) {
|
||||||
obj["border"] = borderImgs[bdImgIdx].name;
|
obj["border"] = borderImgs[bdImgIdx].name;
|
||||||
obj["borderSize"] = JArray{borderImgs[bdImgIdx].img.width(), borderImgs[bdImgIdx].img.height()};
|
obj["borderSize"] = JArray{borderImgs[bdImgIdx].img.width(), borderImgs[bdImgIdx].img.height()};
|
||||||
|
@ -660,15 +664,31 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
hBox->addLabel(tr("Rotate")+": ");
|
hBox->addLabel(tr("Rotate")+": ");
|
||||||
|
|
||||||
auto fdRotate = new QSpinBox;
|
auto fdRotate = new QSpinBox;
|
||||||
fdRotate->setRange(0, 359);
|
fdRotate->setRange(-180, 360);
|
||||||
fdRotate->setValue(_rotate);
|
fdRotate->setValue(_rotate);
|
||||||
fdRotate->setToolTip("Need Player 2.1.4");
|
fdRotate->setToolTip("Need Player 2.1.9");
|
||||||
connect(fdRotate, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
connect(fdRotate, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
_rotate = value;
|
_rotate = value;
|
||||||
|
//setRotation(value);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdRotate);
|
hBox->addWidget(fdRotate);
|
||||||
hBox->addSpacing(-spacing+2);
|
hBox->addSpacing(-spacing+2);
|
||||||
hBox->addLabel("°");
|
hBox->addLabel("°");
|
||||||
|
hBox->addSpacing(10);
|
||||||
|
|
||||||
|
hBox->addLabel(tr("Opacity")+": ");
|
||||||
|
|
||||||
|
auto fdOpacity = new QDoubleSpinBox;
|
||||||
|
fdOpacity->setDecimals(2);
|
||||||
|
fdOpacity->setSingleStep(0.1);
|
||||||
|
fdOpacity->setRange(0, 1);
|
||||||
|
fdOpacity->setValue(_opacity);
|
||||||
|
fdOpacity->setToolTip("Need Player 2.1.9");
|
||||||
|
connect(fdOpacity, (void(QDoubleSpinBox::*)(double))&QDoubleSpinBox::valueChanged, this, [this](double value) {
|
||||||
|
_opacity = value;
|
||||||
|
setOpacity(value);
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdOpacity);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addSpacing(-spacing);
|
vBox->addSpacing(-spacing);
|
||||||
|
@ -898,15 +918,28 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hBox = new HBox;
|
||||||
ccc = 2;
|
|
||||||
auto fdBlink = new QCheckBox(tr("Blink"));
|
auto fdBlink = new QCheckBox(tr("Blink"));
|
||||||
fdBlink->setChecked(_hasBlink);
|
fdBlink->setChecked(_hasBlink);
|
||||||
fdBlink->setToolTip("Need Player 2.1.4");
|
fdBlink->setToolTip("Need Player 2.1.9");
|
||||||
|
hBox->addWidget(fdBlink);
|
||||||
|
|
||||||
|
auto fdBreathe = new QCheckBox(tr("Breathe"));
|
||||||
|
fdBreathe->setChecked(_hasBreathe);
|
||||||
|
fdBreathe->setToolTip("Need Player 2.1.9");
|
||||||
|
hBox->addWidget(fdBreathe);
|
||||||
|
|
||||||
connect(fdBlink, &QCheckBox::stateChanged, this, [=](int state) {
|
connect(fdBlink, &QCheckBox::stateChanged, this, [=](int state) {
|
||||||
_hasBlink = state==Qt::Checked;
|
_hasBlink = state==Qt::Checked;
|
||||||
|
if(_hasBlink) fdBreathe->setChecked(false);
|
||||||
});
|
});
|
||||||
grid->addWidget(fdBlink, 2, ccc++);
|
connect(fdBreathe, &QCheckBox::stateChanged, this, [=](int state) {
|
||||||
|
_hasBreathe = state==Qt::Checked;
|
||||||
|
if(_hasBreathe) fdBlink->setChecked(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
ccc = 2;
|
||||||
|
grid->addLayout(hBox, 2, ccc++);
|
||||||
ccc++;
|
ccc++;
|
||||||
|
|
||||||
grid->addLabel(tr("Freq"), 2, ccc++, Qt::AlignRight|Qt::AlignVCenter);
|
grid->addLabel(tr("Freq"), 2, ccc++, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
enum ElementType {
|
enum ElementType {
|
||||||
Text = QGraphicsItem::UserType + 1,
|
Text = QGraphicsItem::UserType + 1,
|
||||||
Image, Video, Gif, Audio,
|
Image, Video, Gif, Audio,
|
||||||
DClock, AClock, Timer, Environ, Window, Web
|
DClock, AClock, Timer, Timer2, Environ, Window, Web
|
||||||
};
|
};
|
||||||
Q_ENUM(ElementType)
|
Q_ENUM(ElementType)
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ public:
|
||||||
int mStartTime = 0, mDuration = 10;
|
int mStartTime = 0, mDuration = 10;
|
||||||
QString mEntryEffect, mExitEffect;
|
QString mEntryEffect, mExitEffect;
|
||||||
int mEntryDur = 1, mExitDur = 1;
|
int mEntryDur = 1, mExitDur = 1;
|
||||||
double _blink = 1.0;
|
double _opacity = 1, _blink = 1;
|
||||||
bool _hasBlink = 0;
|
bool _hasBlink = false, _hasBreathe = false;
|
||||||
signals:
|
signals:
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "edclock.h"
|
#include "edclock.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
@ -57,8 +57,8 @@ EDClock::EDClock(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EDClock::init() {
|
void EDClock::init() {
|
||||||
connect(Tools::getInstance(), &Tools::sTick, this, [this]() {
|
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
|
||||||
datetime = QDateTime::currentDateTime().toTimeZone(QTimeZone(m_attr.timeZoneId));
|
datetime = cur.toTimeZone(QTimeZone(m_attr.timeZoneId));
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "eenviron.h"
|
#include "eenviron.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
@ -40,7 +40,7 @@ JObj EEnviron::genProg(const JValue &json, const QString &dstDir, const QString
|
||||||
auto title = json["title"].toString();
|
auto title = json["title"].toString();
|
||||||
if(! title.isEmpty()) Tools::saveImg(dstDir, metric, font, color, res, title, "title");
|
if(! title.isEmpty()) Tools::saveImg(dstDir, metric, font, color, res, title, "title");
|
||||||
JObj values;
|
JObj values;
|
||||||
for(auto &str : str0_9) Tools::saveImg(dstDir, metric, font, color, values, str, str);
|
for(int i=0; i<=9; i++) Tools::saveImg(dstDir, metric, font, color, values, QString::number(i), QString::number(i));
|
||||||
Tools::saveImg(dstDir, metric, font, color, values, ".", ".");
|
Tools::saveImg(dstDir, metric, font, color, values, ".", ".");
|
||||||
Tools::saveImg(dstDir, metric, font, color, values, "-", "-");
|
Tools::saveImg(dstDir, metric, font, color, values, "-", "-");
|
||||||
Tools::saveImg(dstDir, metric, font, color, values, tr("N"), "N");
|
Tools::saveImg(dstDir, metric, font, color, values, tr("N"), "N");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "egif.h"
|
#include "egif.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "emultiwin.h"
|
#include "emultiwin.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "base/extendedgroupbox.h"
|
#include "base/extendedgroupbox.h"
|
||||||
#include "ebase.h"
|
#include "ebase.h"
|
||||||
#include "etext.h"
|
#include "etext.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ephoto.h"
|
#include "ephoto.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
#include "base/locolorselector.h"
|
#include "etext.h"
|
||||||
#include "etext.h"
|
#include "base/locolorselector.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QBoxLayout>
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QFontComboBox>
|
#include <QFontComboBox>
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#if(QT_VERSION_MAJOR > 5)
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
|
@ -19,7 +18,6 @@
|
||||||
#include <QTimeEdit>
|
#include <QTimeEdit>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
static QColor charColors[]{"#fff","#f00","#f00","#f0f","#c0c","#ff0","#f80","#0f0","#0f0","#0a0","#0a0","#7b0","#00f","#00f","#0af","#0ef"};
|
static QColor charColors[]{"#fff","#f00","#f00","#f0f","#c0c","#ff0","#f80","#0f0","#0f0","#0a0","#0a0","#7b0","#00f","#00f","#0af","#0ef"};
|
||||||
QString playModes[]{"Flip", "Scroll", "Static"};
|
QString playModes[]{"Flip", "Scroll", "Static"};
|
||||||
|
@ -80,17 +78,15 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout;
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addLabel(tr("Basic Properties"));
|
||||||
|
|
||||||
auto line = new QFrame;
|
auto line = new QFrame;
|
||||||
line->setFrameShape(QFrame::HLine);
|
line->setFrameShape(QFrame::HLine);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
|
||||||
|
|
||||||
auto fdText = new TTextEdit("");
|
auto fdText = new TTextEdit("");
|
||||||
|
|
||||||
|
@ -121,9 +117,7 @@ QWidget* EText::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontSize);
|
hBox->addWidget(fdFontSize);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
|
||||||
hBox->setSpacing(3);
|
hBox->setSpacing(3);
|
||||||
|
|
||||||
auto wTextAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
auto wTextAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
||||||
|
@ -157,7 +151,7 @@ QWidget* EText::attrWgt() {
|
||||||
connect(fdFontBold, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
connect(fdFontBold, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
|
fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
|
||||||
Tools::mergeFormat(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontBold);
|
hBox->addWidget(fdFontBold);
|
||||||
|
|
||||||
|
@ -168,7 +162,7 @@ QWidget* EText::attrWgt() {
|
||||||
connect(fdFontItalic, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
connect(fdFontItalic, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontItalic(checked);
|
fmt.setFontItalic(checked);
|
||||||
Tools::mergeFormat(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontItalic);
|
hBox->addWidget(fdFontItalic);
|
||||||
|
|
||||||
|
@ -179,7 +173,7 @@ QWidget* EText::attrWgt() {
|
||||||
connect(fdFontUnderline, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
connect(fdFontUnderline, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontUnderline(checked);
|
fmt.setFontUnderline(checked);
|
||||||
Tools::mergeFormat(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontUnderline);
|
hBox->addWidget(fdFontUnderline);
|
||||||
|
|
||||||
|
@ -192,7 +186,7 @@ QWidget* EText::attrWgt() {
|
||||||
if(! color.isValid()) return;
|
if(! color.isValid()) return;
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setForeground(color);
|
fmt.setForeground(color);
|
||||||
Tools::mergeFormat(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTextColor);
|
hBox->addWidget(fdTextColor);
|
||||||
|
|
||||||
|
@ -226,9 +220,7 @@ QWidget* EText::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdRandomColor);
|
hBox->addWidget(fdRandomColor);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
|
||||||
hBox->setSpacing(3);
|
hBox->setSpacing(3);
|
||||||
|
|
||||||
auto wTextAlignVT = new QPushButton(QIcon(":/res/program/TextAlignVT.png"), "");
|
auto wTextAlignVT = new QPushButton(QIcon(":/res/program/TextAlignVT.png"), "");
|
||||||
|
@ -258,35 +250,38 @@ QWidget* EText::attrWgt() {
|
||||||
lb->setToolTip(lb->text());
|
lb->setToolTip(lb->text());
|
||||||
hBox->addWidget(lb);
|
hBox->addWidget(lb);
|
||||||
|
|
||||||
auto fdLetterSpacing = new QSpinBox();
|
auto edLetterSpacing = new QSpinBox;
|
||||||
fdLetterSpacing->setMaximum(999);
|
edLetterSpacing->setMaximum(9999);
|
||||||
connect(fdLetterSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdText](int value) {
|
edLetterSpacing->setValue(100);
|
||||||
|
connect(edLetterSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdText](int value) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontLetterSpacing(value);
|
fmt.setFontLetterSpacing(value);
|
||||||
QTextCursor cursor = fdText->textCursor();
|
auto cursor = fdText->textCursor();
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
cursor.mergeCharFormat(fmt);
|
cursor.mergeCharFormat(fmt);
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdLetterSpacing);
|
hBox->addWidget(edLetterSpacing);
|
||||||
|
|
||||||
lb = new QLabel(tr("Line Spacing"));
|
lb = new QLabel(tr("Line Height"));
|
||||||
lb->setToolTip(lb->text());
|
lb->setToolTip(lb->text());
|
||||||
hBox->addWidget(lb);
|
hBox->addWidget(lb);
|
||||||
|
|
||||||
auto fdLineSpacing = new QSpinBox;
|
auto edLineHeight = new QSpinBox;
|
||||||
fdLineSpacing->setRange(-99, 999);
|
edLineHeight->setRange(-999, 9999);
|
||||||
connect(fdLineSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdText](int value) {
|
edLineHeight->setValue(100);
|
||||||
|
connect(edLineHeight, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdText](int value) {
|
||||||
QTextBlockFormat fmt;
|
QTextBlockFormat fmt;
|
||||||
fmt.setLineHeight(value, QTextBlockFormat::LineDistanceHeight);
|
fmt.setLineHeight(value, QTextBlockFormat::ProportionalHeight);
|
||||||
auto cursor = fdText->textCursor();
|
auto cursor = fdText->textCursor();
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
cursor.mergeBlockFormat(fmt);
|
cursor.mergeBlockFormat(fmt);
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdLineSpacing);
|
hBox->addWidget(edLineHeight);
|
||||||
|
hBox->addSpacing(-2);
|
||||||
|
hBox->addLabel("%");
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
auto fdAlignH = new QButtonGroup(wgtAttr);
|
auto fdAlignH = new QButtonGroup(wgtAttr);
|
||||||
fdAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
fdAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
||||||
|
@ -342,22 +337,23 @@ QWidget* EText::attrWgt() {
|
||||||
fdTextColor->setColor(foreground.style()==Qt::NoBrush ? Qt::white : foreground.color());
|
fdTextColor->setColor(foreground.style()==Qt::NoBrush ? Qt::white : foreground.color());
|
||||||
fdTextColor->blockSignals(false);
|
fdTextColor->blockSignals(false);
|
||||||
|
|
||||||
fdLetterSpacing->blockSignals(true);
|
auto spa = format.fontLetterSpacing();
|
||||||
fdLetterSpacing->setValue(format.fontLetterSpacing());
|
edLetterSpacing->blockSignals(true);
|
||||||
fdLetterSpacing->blockSignals(false);
|
edLetterSpacing->setValue(spa==0 ? 100 : spa);
|
||||||
|
edLetterSpacing->blockSignals(false);
|
||||||
|
|
||||||
auto cursor = fdText->textCursor();
|
auto cursor = fdText->textCursor();
|
||||||
auto blockFormat = cursor.blockFormat();
|
auto blockFormat = cursor.blockFormat();
|
||||||
auto btn = fdAlignH->button(blockFormat.alignment() & Qt::AlignHorizontal_Mask);
|
auto btn = fdAlignH->button(blockFormat.alignment() & Qt::AlignHorizontal_Mask);
|
||||||
if(btn) btn->setChecked(true);
|
if(btn) btn->setChecked(true);
|
||||||
|
|
||||||
fdLineSpacing->blockSignals(true);
|
edLineHeight->blockSignals(true);
|
||||||
fdLineSpacing->setValue(blockFormat.lineHeightType()==QTextBlockFormat::LineDistanceHeight ? blockFormat.lineHeight() : 0);
|
edLineHeight->setValue(blockFormat.lineHeightType()==QTextBlockFormat::ProportionalHeight ? blockFormat.lineHeight() : 100);
|
||||||
fdLineSpacing->blockSignals(false);
|
edLineHeight->blockSignals(false);
|
||||||
});
|
});
|
||||||
vBox->addWidget(fdText);
|
vBox->addWidget(fdText);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto pageInfoWgt = new QWidget;
|
auto pageInfoWgt = new QWidget;
|
||||||
|
@ -409,9 +405,7 @@ QWidget* EText::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnImport);
|
hBox->addWidget(btnImport);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
hBox->addWidget(new QLabel(tr("Play Properties")));
|
||||||
|
|
||||||
line = new QFrame();
|
line = new QFrame();
|
||||||
|
@ -419,9 +413,8 @@ QWidget* EText::attrWgt() {
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdFlip = new QRadioButton(tr("Flip"));
|
auto fdFlip = new QRadioButton(tr("Flip"));
|
||||||
|
@ -436,7 +429,6 @@ QWidget* EText::attrWgt() {
|
||||||
hBox->addWidget(fdStatic);
|
hBox->addWidget(fdStatic);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
auto fdPlayStyle = new QButtonGroup(wgtAttr);
|
auto fdPlayStyle = new QButtonGroup(wgtAttr);
|
||||||
fdPlayStyle->addButton(fdFlip, 0);
|
fdPlayStyle->addButton(fdFlip, 0);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
class EText : public EBase {
|
class EText : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EText(EBase *multiWin = nullptr);
|
explicit EText(EBase *multiWin = 0);
|
||||||
explicit EText(const JObj &json, EBase *multiWin = nullptr);
|
explicit EText(const JObj &json, EBase *multiWin = 0);
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
int type() const override { return EBase::Text; }
|
int type() const override { return EBase::Text; }
|
||||||
|
@ -17,11 +17,11 @@ public:
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
Qt::Alignment align;
|
Qt::Alignment align;
|
||||||
QColor backColor{Qt::transparent};
|
QColor backColor = Qt::transparent;
|
||||||
QString playMode = "Flip";
|
QString playMode = "Flip";
|
||||||
QString direction = "left";
|
QString direction = "left";
|
||||||
int speed = 60;
|
int speed = 60;
|
||||||
int headTailSpacing{10};
|
int headTailSpacing = 10;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updImg();
|
void updImg();
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#include "etimer.h"
|
#include "etimer.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "base/lodateselector.h"
|
#include "base/lodateselector.h"
|
||||||
#include "base/locolorselector.h"
|
#include "base/locolorselector.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QLabel>
|
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
@ -18,74 +17,74 @@
|
||||||
|
|
||||||
ETimer::ETimer(EBase *multiWin) : EBase(multiWin) {
|
ETimer::ETimer(EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::Timer;
|
mType = EBase::Timer;
|
||||||
attr.isDown = true;
|
isDown = true;
|
||||||
attr.targetTime = QDateTime::currentDateTime();
|
targetTime = QDateTime::currentDateTime();
|
||||||
attr.hasDay = true;
|
hasDay = true;
|
||||||
attr.hasHour = true;
|
hasHour = true;
|
||||||
attr.hasMin = true;
|
hasMin = true;
|
||||||
attr.hasSec = true;
|
hasSec = true;
|
||||||
attr.isMultiline = true;
|
isMultiline = true;
|
||||||
attr.font = qfont("Arial", 12);
|
font = qfont("Arial", 12);
|
||||||
attr.textColor = Qt::red;
|
textColor = Qt::red;
|
||||||
attr.backColor = Qt::transparent;
|
backColor = Qt::transparent;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ETimer::ETimer(const JObj &json, EBase *multiWin) : EBase(multiWin){
|
ETimer::ETimer(const JObj &json, EBase *multiWin) : EBase(multiWin){
|
||||||
mType = EBase::Timer;
|
mType = EBase::Timer;
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
attr.isDown = json["isDown"].toBool();
|
isDown = json["isDown"].toBool();
|
||||||
attr.targetTime = QDateTime::fromString(json["targetTime"].toString(), "yyyy-MM-dd HH:mm:ss");
|
targetTime = QDateTime::fromString(json["targetTime"].toString(), "yyyy-MM-dd HH:mm:ss");
|
||||||
attr.hasDay = json["hasDay"].toBool();
|
hasDay = json["hasDay"].toBool();
|
||||||
attr.hasHour = json["hasHour"].toBool();
|
hasHour = json["hasHour"].toBool();
|
||||||
attr.hasMin = json["hasMin"].toBool();
|
hasMin = json["hasMin"].toBool();
|
||||||
attr.hasSec = json["hasSec"].toBool();
|
hasSec = json["hasSec"].toBool();
|
||||||
attr.text = json["text"].toString();
|
text = json["text"].toString();
|
||||||
attr.isMultiline = json["isMultiline"].toBool();
|
isMultiline = json["isMultiline"].toBool();
|
||||||
attr.font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
font = qfont(json["font"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
||||||
attr.font.setUnderline(json["fontUnderline"].toBool());
|
font.setUnderline(json["fontUnderline"].toBool());
|
||||||
attr.textColor = json["textColor"].toString();
|
textColor = json["textColor"].toString();
|
||||||
auto color = json["backColor"].toString();
|
auto color = json["backColor"].toString();
|
||||||
attr.backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ETimer::init() {
|
void ETimer::init() {
|
||||||
connect(Tools::getInstance(), &Tools::sTick, this, [this]() {
|
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
|
||||||
QDateTime cDateTime = QDateTime::currentDateTime();
|
auto sss = isDown ? cur.secsTo(targetTime) : targetTime.secsTo(cur);
|
||||||
qint64 ofs = attr.isDown ? cDateTime.secsTo(attr.targetTime) : attr.targetTime.secsTo(cDateTime);
|
if(sss < 0) sss = 0;
|
||||||
if(ofs < 0) ofs = 0;
|
if(secs==sss) return;
|
||||||
secs = ofs;
|
secs = sss;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ETimer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void ETimer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
QString text;
|
QString text;
|
||||||
if(!attr.text.isEmpty()) {
|
if(!this->text.isEmpty()) {
|
||||||
text += attr.text;
|
text += this->text;
|
||||||
if(attr.isMultiline) text += '\n';
|
if(this->isMultiline) text += '\n';
|
||||||
else text += " ";
|
else text += " ";
|
||||||
}
|
}
|
||||||
int secs = this->secs;
|
int secs = this->secs;
|
||||||
if(attr.hasDay) {
|
if(this->hasDay) {
|
||||||
text.append(QString::number(secs/86400)).append(" ").append(tr("day")).append(" ");
|
text.append(QString::number(secs/86400)).append(" ").append(tr("day")).append(" ");
|
||||||
secs %= 86400;
|
secs %= 86400;
|
||||||
}
|
}
|
||||||
if(attr.hasHour) {
|
if(this->hasHour) {
|
||||||
text.append(QString::asprintf("%02d ", secs/3600)).append(tr("hour")).append(" ");
|
text.append(QString::asprintf("%02d ", secs/3600)).append(tr("hour")).append(" ");
|
||||||
secs %= 3600;
|
secs %= 3600;
|
||||||
}
|
}
|
||||||
if(attr.hasMin) {
|
if(this->hasMin) {
|
||||||
text.append(QString::asprintf("%02d ", secs/60)).append(tr("min")).append(" ");
|
text.append(QString::asprintf("%02d ", secs/60)).append(tr("min")).append(" ");
|
||||||
secs %= 60;
|
secs %= 60;
|
||||||
}
|
}
|
||||||
if(attr.hasSec) text.append(QString::asprintf("%02d ", secs)).append(tr("sec")).append(" ");
|
if(this->hasSec) text.append(QString::asprintf("%02d ", secs)).append(tr("sec")).append(" ");
|
||||||
text = text.trimmed();
|
text = text.trimmed();
|
||||||
attr.font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
this->font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
if(attr.backColor.alpha() != 0) painter->fillRect(0, 0, mWidth, mHeight, attr.backColor);
|
if(this->backColor.alpha() != 0) painter->fillRect(0, 0, mWidth, mHeight, this->backColor);
|
||||||
painter->setFont(attr.font);
|
painter->setFont(this->font);
|
||||||
painter->setPen(attr.textColor);
|
painter->setPen(this->textColor);
|
||||||
painter->drawText(innerRect(), text, QTextOption(Qt::AlignCenter));
|
painter->drawText(innerRect(), text, QTextOption(Qt::AlignCenter));
|
||||||
EBase::paint(painter, option, widget);
|
EBase::paint(painter, option, widget);
|
||||||
}
|
}
|
||||||
|
@ -112,13 +111,13 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
auto fdCntDown = new QRadioButton(tr("Count Down"));
|
auto fdCntDown = new QRadioButton(tr("Count Down"));
|
||||||
auto fdCntUp = new QRadioButton(tr("Count Up"));
|
auto fdCntUp = new QRadioButton(tr("Count Up"));
|
||||||
if(attr.isDown) fdCntDown->setChecked(true);
|
if(this->isDown) fdCntDown->setChecked(true);
|
||||||
else fdCntUp->setChecked(true);
|
else fdCntUp->setChecked(true);
|
||||||
auto cntGroup = new QButtonGroup(wgtAttr);
|
auto cntGroup = new QButtonGroup(wgtAttr);
|
||||||
cntGroup->addButton(fdCntDown);
|
cntGroup->addButton(fdCntDown);
|
||||||
cntGroup->addButton(fdCntUp);
|
cntGroup->addButton(fdCntUp);
|
||||||
connect(fdCntDown, &QRadioButton::toggled, this, [this](bool checked) {
|
connect(fdCntDown, &QRadioButton::toggled, this, [this](bool checked) {
|
||||||
attr.isDown = checked;
|
this->isDown = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdCntDown);
|
hBox->addWidget(fdCntDown);
|
||||||
|
@ -132,10 +131,10 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Time")));
|
hBox->addWidget(new QLabel(tr("Time")));
|
||||||
|
|
||||||
auto fdTime = new QDateTimeEdit(attr.targetTime);
|
auto fdTime = new QDateTimeEdit(this->targetTime);
|
||||||
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
||||||
attr.targetTime = dateTime;
|
this->targetTime = dateTime;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTime);
|
hBox->addWidget(fdTime);
|
||||||
|
@ -151,42 +150,42 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdHasDay = new QCheckBox(tr("Day"));
|
auto fdHasDay = new QCheckBox(tr("Day"));
|
||||||
fdHasDay->setChecked(attr.hasDay);
|
fdHasDay->setChecked(this->hasDay);
|
||||||
connect(fdHasDay, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdHasDay, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.hasDay = checked;
|
this->hasDay = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdHasDay);
|
hBox->addWidget(fdHasDay);
|
||||||
|
|
||||||
auto fdHasHour = new QCheckBox(tr("Hour"));
|
auto fdHasHour = new QCheckBox(tr("Hour"));
|
||||||
fdHasHour->setChecked(attr.hasHour);
|
fdHasHour->setChecked(this->hasHour);
|
||||||
connect(fdHasHour, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdHasHour, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.hasHour = checked;
|
this->hasHour = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdHasHour);
|
hBox->addWidget(fdHasHour);
|
||||||
|
|
||||||
auto fdHasMin = new QCheckBox(tr("Min"));
|
auto fdHasMin = new QCheckBox(tr("Min"));
|
||||||
fdHasMin->setChecked(attr.hasMin);
|
fdHasMin->setChecked(this->hasMin);
|
||||||
connect(fdHasMin, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdHasMin, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.hasMin = checked;
|
this->hasMin = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdHasMin);
|
hBox->addWidget(fdHasMin);
|
||||||
|
|
||||||
auto fdHasSec = new QCheckBox(tr("Sec"));
|
auto fdHasSec = new QCheckBox(tr("Sec"));
|
||||||
fdHasSec->setChecked(attr.hasSec);
|
fdHasSec->setChecked(this->hasSec);
|
||||||
connect(fdHasSec, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdHasSec, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.hasSec = checked;
|
this->hasSec = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdHasSec);
|
hBox->addWidget(fdHasSec);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdIsMultiline = new QCheckBox(tr("Multiline"));
|
auto fdIsMultiline = new QCheckBox(tr("Multiline"));
|
||||||
fdIsMultiline->setChecked(attr.isMultiline);
|
fdIsMultiline->setChecked(this->isMultiline);
|
||||||
connect(fdIsMultiline, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdIsMultiline, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.isMultiline = checked;
|
this->isMultiline = checked;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdIsMultiline);
|
hBox->addWidget(fdIsMultiline);
|
||||||
|
@ -197,10 +196,10 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Text")));
|
hBox->addWidget(new QLabel(tr("Text")));
|
||||||
|
|
||||||
auto fdText = new QTextEdit(attr.text);
|
auto fdText = new QTextEdit(this->text);
|
||||||
fdText->setMaximumHeight(50);
|
fdText->setMaximumHeight(50);
|
||||||
connect(fdText, &QTextEdit::textChanged, this, [this, fdText]() {
|
connect(fdText, &QTextEdit::textChanged, this, [this, fdText]() {
|
||||||
attr.text = fdText->toPlainText();
|
this->text = fdText->toPlainText();
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdText);
|
hBox->addWidget(fdText);
|
||||||
|
@ -211,24 +210,24 @@ QWidget* ETimer::attrWgt() {
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
|
|
||||||
auto fdFont = new QFontComboBox();
|
auto fdFont = new QFontComboBox();
|
||||||
fdFont->setCurrentText(attr.font.family());
|
fdFont->setCurrentText(this->font.family());
|
||||||
fdFont->setEditable(false);
|
fdFont->setEditable(false);
|
||||||
connect(fdFont, &QFontComboBox::currentFontChanged, this, [this](const QFont &f) {
|
connect(fdFont, &QFontComboBox::currentFontChanged, this, [this](const QFont &f) {
|
||||||
QFont font(f.family());
|
QFont font(f.family());
|
||||||
font.setPixelSize(attr.font.pixelSize());
|
font.setPixelSize(this->font.pixelSize());
|
||||||
font.setBold(attr.font.bold());
|
font.setBold(this->font.bold());
|
||||||
font.setItalic(attr.font.italic());
|
font.setItalic(this->font.italic());
|
||||||
font.setUnderline(attr.font.underline());
|
font.setUnderline(this->font.underline());
|
||||||
attr.font = font;
|
this->font = font;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFont);
|
hBox->addWidget(fdFont);
|
||||||
|
|
||||||
auto fdFontSize = new QSpinBox();
|
auto fdFontSize = new QSpinBox();
|
||||||
fdFontSize->setRange(4, 9999);
|
fdFontSize->setRange(4, 9999);
|
||||||
fdFontSize->setValue(attr.font.pixelSize());
|
fdFontSize->setValue(this->font.pixelSize());
|
||||||
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
attr.font.setPixelSize(value);
|
this->font.setPixelSize(value);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontSize);
|
hBox->addWidget(fdFontSize);
|
||||||
|
@ -243,9 +242,9 @@ QWidget* ETimer::attrWgt() {
|
||||||
fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontBold->setFixedSize(30, 30);
|
fdFontBold->setFixedSize(30, 30);
|
||||||
fdFontBold->setCheckable(true);
|
fdFontBold->setCheckable(true);
|
||||||
fdFontBold->setChecked(attr.font.bold());
|
fdFontBold->setChecked(this->font.bold());
|
||||||
connect(fdFontBold, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdFontBold, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.font.setBold(checked);
|
this->font.setBold(checked);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontBold);
|
hBox->addWidget(fdFontBold);
|
||||||
|
@ -254,9 +253,9 @@ QWidget* ETimer::attrWgt() {
|
||||||
fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontItalic->setFixedSize(30, 30);
|
fdFontItalic->setFixedSize(30, 30);
|
||||||
fdFontItalic->setCheckable(true);
|
fdFontItalic->setCheckable(true);
|
||||||
fdFontItalic->setChecked(attr.font.italic());
|
fdFontItalic->setChecked(this->font.italic());
|
||||||
connect(fdFontItalic, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdFontItalic, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.font.setItalic(checked);
|
this->font.setItalic(checked);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontItalic);
|
hBox->addWidget(fdFontItalic);
|
||||||
|
@ -265,28 +264,28 @@ QWidget* ETimer::attrWgt() {
|
||||||
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontUnderline->setFixedSize(30, 30);
|
fdFontUnderline->setFixedSize(30, 30);
|
||||||
fdFontUnderline->setCheckable(true);
|
fdFontUnderline->setCheckable(true);
|
||||||
fdFontUnderline->setChecked(attr.font.underline());
|
fdFontUnderline->setChecked(this->font.underline());
|
||||||
connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
|
connect(fdFontUnderline, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
attr.font.setUnderline(checked);
|
this->font.setUnderline(checked);
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontUnderline);
|
hBox->addWidget(fdFontUnderline);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdTextColor = new LoColorSelector("T", attr.textColor);
|
auto fdTextColor = new LoColorSelector("T", this->textColor);
|
||||||
fdTextColor->setFixedSize(30, 30);
|
fdTextColor->setFixedSize(30, 30);
|
||||||
fdTextColor->setFlat(true);
|
fdTextColor->setFlat(true);
|
||||||
connect(fdTextColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
connect(fdTextColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||||
attr.textColor = color;
|
this->textColor = color;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTextColor);
|
hBox->addWidget(fdTextColor);
|
||||||
|
|
||||||
auto fdBackColor = new LoColorSelector("B", attr.backColor);
|
auto fdBackColor = new LoColorSelector("B", this->backColor);
|
||||||
fdBackColor->setFixedSize(30, 30);
|
fdBackColor->setFixedSize(30, 30);
|
||||||
fdBackColor->setFlat(true);
|
fdBackColor->setFlat(true);
|
||||||
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||||
attr.backColor = color;
|
this->backColor = color;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdBackColor);
|
hBox->addWidget(fdBackColor);
|
||||||
|
@ -300,20 +299,20 @@ JObj ETimer::attrJson() const {
|
||||||
JObj obj;
|
JObj obj;
|
||||||
addBaseAttr(obj);
|
addBaseAttr(obj);
|
||||||
obj["elementType"] = "Timer";
|
obj["elementType"] = "Timer";
|
||||||
obj["isDown"] = attr.isDown;
|
obj["isDown"] = this->isDown;
|
||||||
obj["targetTime"] = attr.targetTime.toString("yyyy-MM-dd HH:mm:ss");
|
obj["targetTime"] = this->targetTime.toString("yyyy-MM-dd HH:mm:ss");
|
||||||
obj["hasDay"] = attr.hasDay;
|
obj["hasDay"] = this->hasDay;
|
||||||
obj["hasHour"] = attr.hasHour;
|
obj["hasHour"] = this->hasHour;
|
||||||
obj["hasMin"] = attr.hasMin;
|
obj["hasMin"] = this->hasMin;
|
||||||
obj["hasSec"] = attr.hasSec;
|
obj["hasSec"] = this->hasSec;
|
||||||
obj["text"] = attr.text;
|
obj["text"] = this->text;
|
||||||
obj["isMultiline"] = attr.isMultiline;
|
obj["isMultiline"] = this->isMultiline;
|
||||||
obj["font"] = attr.font.family();
|
obj["font"] = this->font.family();
|
||||||
obj["fontSize"] = attr.font.pixelSize();
|
obj["fontSize"] = this->font.pixelSize();
|
||||||
obj["fontBold"] = attr.font.bold();
|
obj["fontBold"] = this->font.bold();
|
||||||
obj["fontItalic"] = attr.font.italic();
|
obj["fontItalic"] = this->font.italic();
|
||||||
obj["fontUnderline"] = attr.font.underline();
|
obj["fontUnderline"] = this->font.underline();
|
||||||
obj["textColor"] = attr.textColor.name();
|
obj["textColor"] = this->textColor.name();
|
||||||
obj["backColor"] = attr.backColor.alpha()==0 ? "" : attr.backColor.name();
|
obj["backColor"] = this->backColor.alpha()==0 ? "" : this->backColor.name();
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,33 +10,28 @@
|
||||||
class ETimer : public EBase {
|
class ETimer : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
struct Data {
|
|
||||||
QDateTime targetTime;
|
|
||||||
QFont font;
|
|
||||||
QString text;
|
|
||||||
QColor textColor;
|
|
||||||
QColor backColor;
|
|
||||||
bool isDown;
|
|
||||||
bool isMultiline;
|
|
||||||
bool hasDay;
|
|
||||||
bool hasHour;
|
|
||||||
bool hasMin;
|
|
||||||
bool hasSec;
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit ETimer(EBase *multiWin = nullptr);
|
explicit ETimer(EBase *multiWin = nullptr);
|
||||||
explicit ETimer(const JObj &json, EBase *multiWin = nullptr);
|
explicit ETimer(const JObj &json, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
|
void init();
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
int type() const override { return EBase::Timer; }
|
int type() const override { return EBase::Timer; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() const override;
|
||||||
|
|
||||||
Data attr;
|
|
||||||
int secs = 0;
|
int secs = 0;
|
||||||
|
|
||||||
private:
|
QDateTime targetTime;
|
||||||
void init();
|
QFont font;
|
||||||
|
QString text;
|
||||||
|
QColor textColor;
|
||||||
|
QColor backColor;
|
||||||
|
bool isDown;
|
||||||
|
bool isMultiline;
|
||||||
|
bool hasDay;
|
||||||
|
bool hasHour;
|
||||||
|
bool hasMin;
|
||||||
|
bool hasSec;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ETIMER_H
|
#endif // ETIMER_H
|
||||||
|
|
|
@ -0,0 +1,404 @@
|
||||||
|
#include "etimer2.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "gutil/qgui.h"
|
||||||
|
#include "base/locolorselector.h"
|
||||||
|
#include "base/lodateselector.h"
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QFontComboBox>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QStackedLayout>
|
||||||
|
#include <QTextBlock>
|
||||||
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
|
#include <QStringConverter>
|
||||||
|
#else
|
||||||
|
#include <QTextCodec>
|
||||||
|
#endif
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QTimeEdit>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
ETimer2::ETimer2(EBase *multiWin) : EBase(multiWin) {
|
||||||
|
isUp = false;
|
||||||
|
targetTime = QDateTime::currentDateTime();
|
||||||
|
html = "<body>"+tr("There are")+" %d "+tr("Days")+" %h "+tr("Hours")+" %m "+tr("Mins")+" %s "+tr("Secs")+"</body>";
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
ETimer2::ETimer2(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
|
setBaseAttr(json);
|
||||||
|
isUp = json["isUp"].toBool();
|
||||||
|
targetTime = QDateTime::fromString(json["targetTime"].toString(), "yyyy-MM-dd HH:mm:ss");
|
||||||
|
html = json["html"].toString();
|
||||||
|
backColor = json["backColor"].toString("#00000000");
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ETimer2::init() {
|
||||||
|
mType = EBase::Timer2;
|
||||||
|
doc.setDocumentMargin(0);
|
||||||
|
QFont font;
|
||||||
|
font.setFamily("Arial");
|
||||||
|
font.setFamilies({"Arial","黑体"});
|
||||||
|
font.setPixelSize(16);
|
||||||
|
doc.setDefaultFont(font);
|
||||||
|
doc.setDefaultStyleSheet("body {color: #fff; line-height:1}");
|
||||||
|
|
||||||
|
connect(this, &ETimer2::sizeChanged, this, &ETimer2::updImg);
|
||||||
|
connect(gTick, &Tick::secChanged, this, [this](const QDateTime &cur) {
|
||||||
|
auto sss = isUp ? targetTime.secsTo(cur) : cur.secsTo(targetTime);
|
||||||
|
if(sss < 0) sss = 0;
|
||||||
|
if(secs==sss) return;
|
||||||
|
secs = sss;
|
||||||
|
updImg();
|
||||||
|
}, Qt::UniqueConnection);
|
||||||
|
updImg();
|
||||||
|
}
|
||||||
|
|
||||||
|
class TTextEdit : public QTextEdit {
|
||||||
|
public:
|
||||||
|
TTextEdit() {}
|
||||||
|
explicit TTextEdit(const QString &text) : QTextEdit(text){}
|
||||||
|
QSize minimumSizeHint() const override {
|
||||||
|
return sizeHint();
|
||||||
|
};
|
||||||
|
QSize sizeHint() const override {
|
||||||
|
auto size = QTextEdit::sizeHint();
|
||||||
|
auto minH = minimumHeight();
|
||||||
|
if(minH > 0) size.setHeight(minH+0xfff);
|
||||||
|
return size;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
QWidget* ETimer2::attrWgt() {
|
||||||
|
auto wgtAttr = new QWidget;
|
||||||
|
auto vBox = new VBox(wgtAttr);
|
||||||
|
vBox->setContentsMargins(4, 0, 4, 0);
|
||||||
|
vBox->setSpacing(3);
|
||||||
|
|
||||||
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Basic Properties"));
|
||||||
|
|
||||||
|
auto line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
auto fdCntDown = new QRadioButton(tr("Count Down"));
|
||||||
|
auto fdCntUp = new QRadioButton(tr("Count Up"));
|
||||||
|
(isUp ? fdCntUp : fdCntDown)->setChecked(true);
|
||||||
|
|
||||||
|
auto cntGroup = new QButtonGroup(wgtAttr);
|
||||||
|
cntGroup->addButton(fdCntDown);
|
||||||
|
cntGroup->addButton(fdCntUp);
|
||||||
|
connect(fdCntUp, &QRadioButton::toggled, this, [this](bool checked) {
|
||||||
|
isUp = checked;
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdCntDown);
|
||||||
|
hBox->addStretch();
|
||||||
|
hBox->addWidget(fdCntUp);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addSpacing(6);
|
||||||
|
hBox->addLabel(tr("Time"));
|
||||||
|
|
||||||
|
auto fdTime = new QDateTimeEdit(targetTime);
|
||||||
|
fdTime->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
connect(fdTime, &QTimeEdit::dateTimeChanged, this, [this](const QDateTime &dateTime) {
|
||||||
|
targetTime = dateTime;
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdTime);
|
||||||
|
|
||||||
|
auto wDateSelector = new LoDateSelector;
|
||||||
|
connect(wDateSelector, &LoDateSelector::sDateSelected, fdTime, &QDateTimeEdit::setDate);
|
||||||
|
hBox->addWidget(wDateSelector);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
|
||||||
|
auto fdText = new TTextEdit("");
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->setSpacing(3);
|
||||||
|
|
||||||
|
hBox->addLabel(tr("Font Size")+":");
|
||||||
|
auto fdFontSize = new QSpinBox;
|
||||||
|
fdFontSize->setRange(4, 9999);
|
||||||
|
fdFontSize->setValue(16);
|
||||||
|
connect(fdFontSize, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, fdText, [fdText](int value) {
|
||||||
|
if(value <= 0) return;
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setProperty(QTextFormat::FontPixelSize, value);
|
||||||
|
auto cursor = fdText->textCursor();
|
||||||
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
cursor.mergeCharFormat(fmt);
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdFontSize);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
hBox->addLabel(tr("Line Height"));
|
||||||
|
|
||||||
|
auto edLineHeight = new QDoubleSpinBox;
|
||||||
|
edLineHeight->setDecimals(1);
|
||||||
|
edLineHeight->setRange(-999, 999);
|
||||||
|
edLineHeight->setValue(1);
|
||||||
|
connect(edLineHeight, (void(QDoubleSpinBox::*)(double))&QDoubleSpinBox::valueChanged, this, [this, fdText](double value) {
|
||||||
|
QTextBlockFormat fmt;
|
||||||
|
fmt.setLineHeight(value*100, QTextBlockFormat::ProportionalHeight);
|
||||||
|
auto cursor = fdText->textCursor();
|
||||||
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
cursor.mergeBlockFormat(fmt);
|
||||||
|
updImg();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edLineHeight);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->setSpacing(3);
|
||||||
|
|
||||||
|
auto wTextAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
||||||
|
wTextAlignHL->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
wTextAlignHL->setFixedSize(30, 30);
|
||||||
|
wTextAlignHL->setIconSize(QSize(30, 30));
|
||||||
|
wTextAlignHL->setCheckable(true);
|
||||||
|
wTextAlignHL->setChecked(true);
|
||||||
|
hBox->addWidget(wTextAlignHL);
|
||||||
|
|
||||||
|
auto wTextAlignHC = new QPushButton(QIcon(":/res/program/TextAlignHC.png"), "");
|
||||||
|
wTextAlignHC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
wTextAlignHC->setFixedSize(30, 30);
|
||||||
|
wTextAlignHC->setIconSize(QSize(30, 30));
|
||||||
|
wTextAlignHC->setCheckable(true);
|
||||||
|
hBox->addWidget(wTextAlignHC);
|
||||||
|
|
||||||
|
auto wTextAlignHR = new QPushButton(QIcon(":/res/program/TextAlignHR.png"), "");
|
||||||
|
wTextAlignHR->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
wTextAlignHR->setFixedSize(30, 30);
|
||||||
|
wTextAlignHR->setIconSize(QSize(30, 30));
|
||||||
|
wTextAlignHR->setCheckable(true);
|
||||||
|
hBox->addWidget(wTextAlignHR);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
auto fdFontBold = new QPushButton("B");
|
||||||
|
fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
|
fdFontBold->setFixedSize(30, 30);
|
||||||
|
fdFontBold->setCheckable(true);
|
||||||
|
connect(fdFontBold, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
|
||||||
|
MergeFmt(fdText, fmt);
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdFontBold);
|
||||||
|
|
||||||
|
auto fdFontItalic = new QPushButton("I");
|
||||||
|
fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
|
fdFontItalic->setFixedSize(30, 30);
|
||||||
|
fdFontItalic->setCheckable(true);
|
||||||
|
connect(fdFontItalic, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setFontItalic(checked);
|
||||||
|
MergeFmt(fdText, fmt);
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdFontItalic);
|
||||||
|
|
||||||
|
auto fdFontUnderline = new QPushButton("U");
|
||||||
|
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
|
fdFontUnderline->setFixedSize(30, 30);
|
||||||
|
fdFontUnderline->setCheckable(true);
|
||||||
|
connect(fdFontUnderline, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setFontUnderline(checked);
|
||||||
|
MergeFmt(fdText, fmt);
|
||||||
|
});
|
||||||
|
hBox->addWidget(fdFontUnderline);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
auto edTextColor = new LoColorSelector("F", Qt::white);
|
||||||
|
edTextColor->setToolTip(tr("Foreground Color"));
|
||||||
|
edTextColor->setFixedSize(30, 30);
|
||||||
|
connect(edTextColor, &LoColorSelector::sColorChanged, fdText, [fdText](const QColor &color) {
|
||||||
|
if(! color.isValid()) return;
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setForeground(color);
|
||||||
|
MergeFmt(fdText, fmt);
|
||||||
|
});
|
||||||
|
hBox->addWidget(edTextColor);
|
||||||
|
|
||||||
|
auto edBack = new LoColorSelector("LB", Qt::white);
|
||||||
|
edBack->setToolTip(tr("Line Background"));
|
||||||
|
edBack->setFixedSize(34, 30);
|
||||||
|
connect(edBack, &LoColorSelector::sColorChanged, fdText, [fdText](const QColor &color) {
|
||||||
|
if(! color.isValid()) return;
|
||||||
|
QTextCharFormat fmt;
|
||||||
|
fmt.setBackground(color);
|
||||||
|
MergeFmt(fdText, fmt);
|
||||||
|
});
|
||||||
|
hBox->addWidget(edBack);
|
||||||
|
|
||||||
|
auto edBackColor = new LoColorSelector("B", backColor);
|
||||||
|
edBackColor->setToolTip(tr("Background Color"));
|
||||||
|
edBackColor->setFixedSize(30, 30);
|
||||||
|
connect(edBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||||
|
if(! color.isValid()) return;
|
||||||
|
backColor = color;
|
||||||
|
updImg();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edBackColor);
|
||||||
|
|
||||||
|
|
||||||
|
auto fdAlignH = new QButtonGroup(wgtAttr);
|
||||||
|
fdAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
||||||
|
fdAlignH->addButton(wTextAlignHC, Qt::AlignHCenter);
|
||||||
|
fdAlignH->addButton(wTextAlignHR, Qt::AlignRight);
|
||||||
|
connect(fdAlignH, &QButtonGroup::idClicked, this, [this, fdText](int value) {
|
||||||
|
QTextBlockFormat fmt;
|
||||||
|
fmt.setAlignment((Qt::Alignment) value);
|
||||||
|
QTextCursor cursor = fdText->textCursor();
|
||||||
|
cursor.mergeBlockFormat(fmt);
|
||||||
|
updImg();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto ll = vBox->addLabel("%d: "+tr("Days")+", %h: "+tr("Hours")+", %m: "+tr("Mins")+", %s: "+tr("Secs"));
|
||||||
|
gFont(ll, 16);
|
||||||
|
|
||||||
|
fdText->setMinimumHeight(160);
|
||||||
|
auto doc = fdText->document();
|
||||||
|
if(doc) doc->setDocumentMargin(2);
|
||||||
|
auto font = fdText->font();
|
||||||
|
font.setFamily("Arial");
|
||||||
|
font.setFamilies({"Arial","黑体"});
|
||||||
|
font.setPixelSize(16);
|
||||||
|
fdText->setFont(font);
|
||||||
|
auto pal = fdText->palette();
|
||||||
|
pal.setColor(QPalette::Base, Qt::black);
|
||||||
|
pal.setColor(QPalette::Text, Qt::white);
|
||||||
|
fdText->setPalette(pal);
|
||||||
|
fdText->document()->setDefaultStyleSheet("body {color: #fff; line-height:1}");
|
||||||
|
fdText->setFrameShape(QFrame::NoFrame);
|
||||||
|
fdText->setAcceptRichText(false);
|
||||||
|
fdText->setHtml(html);
|
||||||
|
connect(fdText, &QTextEdit::textChanged, this, [this, fdText] {
|
||||||
|
html = fdText->toHtml();
|
||||||
|
updImg();
|
||||||
|
});
|
||||||
|
connect(fdText, &QTextEdit::currentCharFormatChanged, this, [=](const QTextCharFormat &format) {
|
||||||
|
fdFontSize->blockSignals(true);
|
||||||
|
fdFontSize->setValue(format.font().pixelSize());
|
||||||
|
fdFontSize->blockSignals(false);
|
||||||
|
auto foreground = format.foreground();
|
||||||
|
edTextColor->blockSignals(true);
|
||||||
|
edTextColor->setColor(foreground.style()==Qt::NoBrush ? Qt::white : foreground.color());
|
||||||
|
edTextColor->blockSignals(false);
|
||||||
|
|
||||||
|
auto background = format.background();
|
||||||
|
edBack->blockSignals(true);
|
||||||
|
edBack->setColor(background.style()==Qt::NoBrush ? Qt::transparent : background.color());
|
||||||
|
edBack->blockSignals(false);
|
||||||
|
|
||||||
|
auto cursor = fdText->textCursor();
|
||||||
|
auto blockFormat = cursor.blockFormat();
|
||||||
|
auto btn = fdAlignH->button(blockFormat.alignment() & Qt::AlignHorizontal_Mask);
|
||||||
|
if(btn) btn->setChecked(true);
|
||||||
|
|
||||||
|
edLineHeight->blockSignals(true);
|
||||||
|
edLineHeight->setValue(blockFormat.lineHeightType()==QTextBlockFormat::ProportionalHeight ? blockFormat.lineHeight()*0.01 : 1.0);
|
||||||
|
edLineHeight->blockSignals(false);
|
||||||
|
});
|
||||||
|
vBox->addWidget(fdText);
|
||||||
|
|
||||||
|
return wgtAttr;
|
||||||
|
}
|
||||||
|
void repLineHeight(QString &html) {
|
||||||
|
QString pre;
|
||||||
|
int last = 0, idx;
|
||||||
|
while((idx = html.indexOf("line-height:", last)) > -1) {
|
||||||
|
idx += 12;
|
||||||
|
auto end = idx;
|
||||||
|
QChar ch;
|
||||||
|
while((ch = html[end])<='9' && ch>='-' && ch!='/') if(++end >= html.size()) goto end;
|
||||||
|
if(ch!='%') last = end;
|
||||||
|
else {
|
||||||
|
pre += html.mid(last, idx-last) + QString::number(html.mid(idx, end-idx).toDouble() / 100);
|
||||||
|
last = end + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end:
|
||||||
|
if(! pre.isEmpty()) html = pre + html.mid(last);
|
||||||
|
}
|
||||||
|
JObj ETimer2::attrJson() const {
|
||||||
|
JObj ele{{"elementType", "Timer2"}};
|
||||||
|
addBaseAttr(ele);
|
||||||
|
ele["isUp"] = isUp;
|
||||||
|
auto hhhh = html;
|
||||||
|
auto idx = hhhh.indexOf("<html");
|
||||||
|
if(idx > -1) hhhh = hhhh.mid(idx);
|
||||||
|
idx = hhhh.indexOf("<body style=\"");
|
||||||
|
if(idx > -1 && ! hhhh.mid(idx+13, 8).contains("color:")) hhhh = hhhh.insert(idx+13, "color:#fff;");
|
||||||
|
hhhh.replace("<meta name=\"qrichtext\" content=\"1\" />", "");
|
||||||
|
hhhh.replace(" -qt-block-indent:0; text-indent:0px;", "");
|
||||||
|
repLineHeight(hhhh);
|
||||||
|
ele["html"] = hhhh.replace("margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;", "margin:0;");
|
||||||
|
ele["targetTime"] = targetTime.toString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
ele["backColor"] = backColor.name(QColor::HexArgb);
|
||||||
|
return ele;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ETimer2::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
|
||||||
|
painter->save();
|
||||||
|
auto rect = innerRect();
|
||||||
|
painter->drawImage(rect, img);
|
||||||
|
painter->restore();
|
||||||
|
EBase::paint(painter, option, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ETimer2::updImg() {
|
||||||
|
auto innerRect = this->innerRect();
|
||||||
|
int width = innerRect.width();
|
||||||
|
int height = innerRect.height();
|
||||||
|
if(width<1 || height<1) return;
|
||||||
|
|
||||||
|
auto hasDay = html.contains("%d");
|
||||||
|
auto hasHour = html.contains("%h");
|
||||||
|
auto hasMin = html.contains("%m");
|
||||||
|
auto hasSec = html.contains("%s");
|
||||||
|
|
||||||
|
auto htm = html;
|
||||||
|
if(hasDay) {
|
||||||
|
htm = htm.replace("%d", QString::number(secs/86400));
|
||||||
|
secs %= 86400;
|
||||||
|
}
|
||||||
|
if(hasHour) {
|
||||||
|
htm = htm.replace("%h", QString::asprintf("%02d", secs/3600));
|
||||||
|
secs %= 3600;
|
||||||
|
}
|
||||||
|
if(hasMin) {
|
||||||
|
htm = htm.replace("%m", QString::asprintf("%02d", secs/60));
|
||||||
|
secs %= 60;
|
||||||
|
}
|
||||||
|
if(hasSec) htm = htm.replace("%s", QString::asprintf("%02d", secs));
|
||||||
|
|
||||||
|
doc.setHtml(htm);
|
||||||
|
doc.setTextWidth(width);
|
||||||
|
width<<=1;
|
||||||
|
height<<=1;
|
||||||
|
if(img.width()!=width || img.height()!=height) img = QImage(width, height, QImage::Format_ARGB32);
|
||||||
|
img.fill(backColor);
|
||||||
|
{
|
||||||
|
QPainter painter(&img);
|
||||||
|
painter.scale(2,2);
|
||||||
|
doc.drawContents(&painter);
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef ETIMER2_H
|
||||||
|
#define ETIMER2_H
|
||||||
|
|
||||||
|
#include "ebase.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QTextDocument>
|
||||||
|
|
||||||
|
class ETimer2 : public EBase {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ETimer2(EBase *multiWin = 0);
|
||||||
|
explicit ETimer2(const JObj &json, EBase *multiWin = 0);
|
||||||
|
void init();
|
||||||
|
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
int type() const override { return EBase::Timer2; }
|
||||||
|
QWidget* attrWgt() override;
|
||||||
|
JObj attrJson() const override;
|
||||||
|
|
||||||
|
QDateTime targetTime;
|
||||||
|
QString html;
|
||||||
|
QColor backColor = Qt::transparent;
|
||||||
|
bool isUp;
|
||||||
|
|
||||||
|
QImage img;
|
||||||
|
|
||||||
|
int secs = 0;
|
||||||
|
QTextDocument doc;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updImg();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ETIMER2_H
|
|
@ -1,7 +1,6 @@
|
||||||
#include "evideo.h"
|
#include "evideo.h"
|
||||||
#include "cfg.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "base/ffutil.h"
|
#include "base/ffutil.h"
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -21,8 +20,8 @@ EVideo *EVideo::create(const QString &file, PageListItem *pageItem, EBase *multi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
QFileInfo rawInfo(file);
|
QFileInfo rawInfo(file);
|
||||||
QString rawName = rawInfo.fileName();
|
auto rawName = rawInfo.fileName();
|
||||||
QString outFile = transcoding(pageItem->listWidget(), file, rawName, pageItem->mPageDir, img.width(), img.height(), codecId);
|
auto outFile = transcoding(pageItem->listWidget(), file, rawName, pageItem->mPageDir, img.width(), img.height(), codecId);
|
||||||
if(outFile.isEmpty()) return 0;
|
if(outFile.isEmpty()) return 0;
|
||||||
QFileInfo outInfo(outFile);
|
QFileInfo outInfo(outFile);
|
||||||
if(! outInfo.isFile() || outInfo.size()==0) return 0;
|
if(! outInfo.isFile() || outInfo.size()==0) return 0;
|
||||||
|
@ -36,7 +35,7 @@ EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin)
|
||||||
auto dir = widget["path"].toString();
|
auto dir = widget["path"].toString();
|
||||||
auto name = widget["file"].toString();
|
auto name = widget["file"].toString();
|
||||||
if(! QFileInfo::exists(dir)) dir = pageItem->mPageDir;
|
if(! QFileInfo::exists(dir)) dir = pageItem->mPageDir;
|
||||||
QString file = dir + "/" + name;
|
auto file = dir + "/" + name;
|
||||||
if(QFileInfo::exists(file)) ;
|
if(QFileInfo::exists(file)) ;
|
||||||
else if(QFileInfo::exists(file = pageItem->mPageDir + "/" + name)) dir = pageItem->mPageDir;
|
else if(QFileInfo::exists(file = pageItem->mPageDir + "/" + name)) dir = pageItem->mPageDir;
|
||||||
else return 0;
|
else return 0;
|
||||||
|
@ -52,27 +51,6 @@ EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin)
|
||||||
ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1);
|
ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1);
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
JObj EVideo::genProg(const JValue &ele, const QString &dstDir, ProgItem *progItem) {
|
|
||||||
auto widget = ele["widget"];
|
|
||||||
if(widget.isNull()) widget = ele;
|
|
||||||
auto path = widget["path"].toString();
|
|
||||||
auto name = widget["file"].toString();
|
|
||||||
//if(progItem->maxLen) name += "-square.mp4";
|
|
||||||
QString srcFile = path + "/" + name;
|
|
||||||
QFileInfo srcInfo(srcFile);
|
|
||||||
if(! srcInfo.isFile()) return JObj();
|
|
||||||
QString id = Tools::fileMd5(srcFile);
|
|
||||||
if(id.isEmpty()) return JObj();
|
|
||||||
QFile::copy(srcFile, dstDir+"/"+id);
|
|
||||||
JObj oRes;
|
|
||||||
oRes["_type"] = "Video";
|
|
||||||
oRes["id"] = id;
|
|
||||||
oRes["md5"] = id;
|
|
||||||
oRes["name"] = name;
|
|
||||||
auto play = ele["play"];
|
|
||||||
oRes["timeSpan"] = play.isNull() ? ele["duration"].toInt() * ele["playTimes"].toInt() : play["playDuration"].toInt() * play["playTimes"].toInt();
|
|
||||||
return oRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVideo::EVideo(const QString &dir, const QString &name, const QString &rawDir, const QString &rawName, QImage &coverImg, PageListItem *pageItem, EBase *multiWin)
|
EVideo::EVideo(const QString &dir, const QString &name, const QString &rawDir, const QString &rawName, QImage &coverImg, PageListItem *pageItem, EBase *multiWin)
|
||||||
: EBase(multiWin), mDir(dir), mName(name), mRawDir(rawDir), mRawName(rawName), mCoverImg(coverImg), mPageItem(pageItem) {
|
: EBase(multiWin), mDir(dir), mName(name), mRawDir(rawDir), mRawName(rawName), mCoverImg(coverImg), mPageItem(pageItem) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ public:
|
||||||
static QString transcoding(QWidget *parent, QString rawFile, QString rawName, QString dir, int rawW, int rawH, AVCodecID codec_id);
|
static QString transcoding(QWidget *parent, QString rawFile, QString rawName, QString dir, int rawW, int rawH, AVCodecID codec_id);
|
||||||
static EVideo *create(const QString &file, PageListItem *pageItem, EBase *multiWin = nullptr);
|
static EVideo *create(const QString &file, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
static EVideo *create(const JObj &, PageListItem *pageItem, EBase *multiWin = nullptr);
|
static EVideo *create(const JObj &, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
static JObj genProg(const JValue &, const QString &, ProgItem *mProgItem);
|
|
||||||
|
|
||||||
explicit EVideo(const QString &, const QString &, const QString &, const QString &, QImage &img, PageListItem *pageItem, EBase *multiWin = nullptr);
|
explicit EVideo(const QString &, const QString &, const QString &, const QString &, QImage &img, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,9 @@ EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
url = json["url"].toString();
|
url = json["url"].toString();
|
||||||
zoom = json["zoom"].toInt(100);
|
zoom = json["zoom"].toInt(100);
|
||||||
_x = json["offX"].toInt(0);
|
refresh = json["refreshSec"].toInt();
|
||||||
_y = json["offY"].toInt(0);
|
_x = json["offX"].toInt();
|
||||||
|
_y = json["offY"].toInt();
|
||||||
scaleX = json["scaleX"].toInt(100);
|
scaleX = json["scaleX"].toInt(100);
|
||||||
scaleY = json["scaleY"].toInt(100);
|
scaleY = json["scaleY"].toInt(100);
|
||||||
}
|
}
|
||||||
|
@ -73,6 +74,21 @@ QWidget* EWeb::attrWgt() {
|
||||||
hBox->addLabel("%");
|
hBox->addLabel("%");
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
lb = hBox->addLabel(tr("Refresh every")+":");
|
||||||
|
lb->setMinimumWidth(70);
|
||||||
|
lb->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
|
||||||
|
|
||||||
|
auto edRefresh = new QSpinBox;
|
||||||
|
edRefresh->setRange(0, 99999);
|
||||||
|
edRefresh->setValue(refresh);
|
||||||
|
connect(edRefresh, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
refresh = value;
|
||||||
|
});
|
||||||
|
hBox->addWidget(edRefresh);
|
||||||
|
hBox->addSpacing(-3);
|
||||||
|
hBox->addLabel("s");
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
lb = hBox->addLabel(tr("Offset")+" X:");
|
lb = hBox->addLabel(tr("Offset")+" X:");
|
||||||
|
@ -137,6 +153,7 @@ JObj EWeb::attrJson() const {
|
||||||
obj["elementType"] = "Web";
|
obj["elementType"] = "Web";
|
||||||
obj["url"] = url;
|
obj["url"] = url;
|
||||||
obj["zoom"] = zoom;
|
obj["zoom"] = zoom;
|
||||||
|
obj["refreshSec"] = refresh;
|
||||||
obj["offX"] = _x;
|
obj["offX"] = _x;
|
||||||
obj["offY"] = _y;
|
obj["offY"] = _y;
|
||||||
obj["scaleX"] = scaleX;
|
obj["scaleX"] = scaleX;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
JObj attrJson() const override;
|
JObj attrJson() const override;
|
||||||
|
|
||||||
QString url;
|
QString url;
|
||||||
int zoom = 100, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
|
int zoom = 100, refresh = 0, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EWEB_H
|
#endif // EWEB_H
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "gentmpthread.h"
|
#include "gentmpthread.h"
|
||||||
#include "cfg.h"
|
#include "main.h"
|
||||||
#include "globaldefine.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "program/eenviron.h"
|
#include "program/eenviron.h"
|
||||||
#include "program/evideo.h"
|
#include "program/evideo.h"
|
||||||
|
@ -147,6 +146,7 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson) {
|
||||||
source["width"] = geometry["w"];
|
source["width"] = geometry["w"];
|
||||||
source["height"] = geometry["h"];
|
source["height"] = geometry["h"];
|
||||||
source["rotate"] = ele["rotate"];
|
source["rotate"] = ele["rotate"];
|
||||||
|
source["opacity"] = ele["opacity"].toDouble(1);
|
||||||
source["playTime"] = startTime;
|
source["playTime"] = startTime;
|
||||||
startTime += source["timeSpan"].toInt();
|
startTime += source["timeSpan"].toInt();
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,8 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson) {
|
||||||
{"eff", ele["borderEff"]},
|
{"eff", ele["borderEff"]},
|
||||||
{"speed", ele["borderSpeed"]},
|
{"speed", ele["borderSpeed"]},
|
||||||
{"img_size", borderSize},
|
{"img_size", borderSize},
|
||||||
{"geometry", JArray{geometry["x"], geometry["y"], geometry["w"], geometry["h"]}}
|
{"geometry", JArray{geometry["x"], geometry["y"], geometry["w"], geometry["h"]}},
|
||||||
|
{"rotate", isWin ? 0 : ele["rotate"]}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
layers.append(layer);
|
layers.append(layer);
|
||||||
|
@ -223,13 +224,36 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
if(needType) type = ele["elementType"].toString();
|
if(needType) type = ele["elementType"].toString();
|
||||||
if(type=="Text") source = genText(ele, sources);
|
if(type=="Text") source = genText(ele, sources);
|
||||||
else if(type=="Image"||type=="Photo") source = genImage(ele);
|
else if(type=="Image"||type=="Photo") source = genImage(ele);
|
||||||
else if(type=="Video"||type=="Movie") source = EVideo::genProg(ele, dstDir, mProgItem);
|
else if(type=="Video"||type=="Movie") {
|
||||||
else if(type=="Gif") source = convertGif(ele);
|
//genProg(ele, dstDir, mProgItem);
|
||||||
|
auto widget = ele["widget"];
|
||||||
|
if(widget.isNull()) widget = ele;
|
||||||
|
auto path = widget["path"].toString();
|
||||||
|
auto name = widget["file"].toString();
|
||||||
|
auto srcFile = path + "/" + name;
|
||||||
|
if(! QFileInfo(srcFile).isFile() && ! QFileInfo(srcFile = srcPageDir + "/" + name).isFile()) continue;
|
||||||
|
auto id = Tools::fileMd5(srcFile);
|
||||||
|
if(id.isEmpty()) continue;
|
||||||
|
QFile::copy(srcFile, dstDir+"/"+id);
|
||||||
|
source["_type"] = "Video";
|
||||||
|
source["id"] = id;
|
||||||
|
source["md5"] = id;
|
||||||
|
source["name"] = name;
|
||||||
|
auto play = ele["play"];
|
||||||
|
source["timeSpan"] = play.isNull() ? ele["duration"].toInt() * ele["playTimes"].toInt() : play["playDuration"].toInt() * play["playTimes"].toInt();
|
||||||
|
} else if(type=="Gif") source = convertGif(ele);
|
||||||
else if(type=="DClock") source = convertDClock(ele);
|
else if(type=="DClock") source = convertDClock(ele);
|
||||||
else if(type=="AClock") source = convertAClock(ele);
|
else if(type=="AClock") source = convertAClock(ele);
|
||||||
else if(type=="Temp") source = EEnviron::genProg(ele, dstDir, srcPageDir);
|
else if(type=="Temp") source = EEnviron::genProg(ele, dstDir, srcPageDir);
|
||||||
else if(type=="Web") source = convertWeb(ele);
|
else if(type=="Web") source = convertWeb(ele);
|
||||||
else if(type=="Timer") source = convertTimer(ele);
|
else if(type=="Timer") source = convertTimer(ele);
|
||||||
|
else if(type=="Timer2") {
|
||||||
|
source["_type"] = "Countdown";
|
||||||
|
source["time"] = ele["targetTime"];
|
||||||
|
source["isUp"] = ele["isUp"];
|
||||||
|
source["html"] = ele["html"];
|
||||||
|
source["backColor"] = ele["backColor"];
|
||||||
|
}
|
||||||
if(! source.empty()) {
|
if(! source.empty()) {
|
||||||
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
||||||
source["entryEffect"] = ele["entryEffect"];
|
source["entryEffect"] = ele["entryEffect"];
|
||||||
|
@ -237,6 +261,7 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
source["entryEffectTimeSpan"] = ele["entryDur"];
|
source["entryEffectTimeSpan"] = ele["entryDur"];
|
||||||
source["exitEffectTimeSpan"] = ele["exitDur"];
|
source["exitEffectTimeSpan"] = ele["exitDur"];
|
||||||
if(ele["hasBlink"].toBool()) source["blink"] = ele["blink"];
|
if(ele["hasBlink"].toBool()) source["blink"] = ele["blink"];
|
||||||
|
else if(ele["hasBreathe"].toBool()) source["breathe"] = ele["blink"];
|
||||||
sources.append(source);
|
sources.append(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,16 +331,16 @@ JObj GenTmpThread::genText(const JValue &ele, JArray &sources) {
|
||||||
source["timeSpan"] = duration;
|
source["timeSpan"] = duration;
|
||||||
source["entryEffect"] = ele["entryEffect"];
|
source["entryEffect"] = ele["entryEffect"];
|
||||||
source["exitEffect"] = ele["exitEffect"];
|
source["exitEffect"] = ele["exitEffect"];
|
||||||
if(source["entryEffect"].toStr().isEmpty()) source["entryEffect"] = "None"; //兼容旧播放器
|
|
||||||
if(source["exitEffect"].toStr().isEmpty()) source["exitEffect"] = "None"; //兼容旧播放器
|
|
||||||
source["entryEffectTimeSpan"] = ele["entryDur"];
|
source["entryEffectTimeSpan"] = ele["entryDur"];
|
||||||
source["exitEffectTimeSpan"] = ele["exitDur"];
|
source["exitEffectTimeSpan"] = ele["exitDur"];
|
||||||
|
if(ele["hasBlink"].toBool()) source["blink"] = ele["blink"];
|
||||||
|
else if(ele["hasBreathe"].toBool()) source["breathe"] = ele["blink"];
|
||||||
sources.append(source);
|
sources.append(source);
|
||||||
}
|
}
|
||||||
return JObj();
|
return JObj();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//转换图片
|
|
||||||
JObj GenTmpThread::genImage(const JValue &ele) {
|
JObj GenTmpThread::genImage(const JValue &ele) {
|
||||||
auto widget = ele["widget"];
|
auto widget = ele["widget"];
|
||||||
auto name = widget.isNull() ? ele["name"].toString() : widget["file"].toString();
|
auto name = widget.isNull() ? ele["name"].toString() : widget["file"].toString();
|
||||||
|
@ -439,7 +464,7 @@ JObj GenTmpThread::convertDClock(const JValue &json){
|
||||||
oRes["spaceWidth"] = metric.horizontalAdvance(" ");
|
oRes["spaceWidth"] = metric.horizontalAdvance(" ");
|
||||||
QColor color(textColor);
|
QColor color(textColor);
|
||||||
JArray imgs;
|
JArray imgs;
|
||||||
for(auto &str : str0_9) Tools::saveImg2(dstDir, metric, font, color, imgs, str, str);
|
for(int i=0; i<=9; i++) Tools::saveImg2(dstDir, metric, font, color, imgs, QString::number(i), QString::number(i));
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("MON"), "MON");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("MON"), "MON");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("TUE"), "TUE");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("TUE"), "TUE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("WED"), "WED");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("WED"), "WED");
|
||||||
|
@ -508,6 +533,7 @@ JObj GenTmpThread::convertWeb(const JValue &res) {
|
||||||
dst["name"] = "WebURL";
|
dst["name"] = "WebURL";
|
||||||
dst["url"] = res["url"];
|
dst["url"] = res["url"];
|
||||||
dst["zoom"] = res["zoom"];
|
dst["zoom"] = res["zoom"];
|
||||||
|
dst["refreshSec"] = res["refreshSec"];
|
||||||
dst["offX"] = res["offX"];
|
dst["offX"] = res["offX"];
|
||||||
dst["offY"] = res["offY"];
|
dst["offY"] = res["offY"];
|
||||||
dst["scaleX"] = res["scaleX"].toDouble(100)/100;
|
dst["scaleX"] = res["scaleX"].toDouble(100)/100;
|
||||||
|
@ -515,38 +541,38 @@ JObj GenTmpThread::convertWeb(const JValue &res) {
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
JObj GenTmpThread::convertTimer(const JValue &json) {
|
JObj GenTmpThread::convertTimer(const JValue &json) {
|
||||||
JObj oRes;
|
JObj src;
|
||||||
oRes["_type"] = "Timer";
|
src["_type"] = "Timer";
|
||||||
oRes["name"] = "Timer";
|
src["name"] = "Timer";
|
||||||
oRes["targetTime"] = json["targetTime"];
|
src["targetTime"] = json["targetTime"];
|
||||||
oRes["isDown"] = json["isDown"];
|
src["isDown"] = json["isDown"];
|
||||||
oRes["hasDay"] = json["hasDay"];
|
src["hasDay"] = json["hasDay"];
|
||||||
oRes["hasHour"] = json["hasHour"];
|
src["hasHour"] = json["hasHour"];
|
||||||
oRes["hasMin"] = json["hasMin"];
|
src["hasMin"] = json["hasMin"];
|
||||||
oRes["hasSec"] = json["hasSec"];
|
src["hasSec"] = json["hasSec"];
|
||||||
auto isMultiline = json["isMultiline"].toBool();
|
auto isMultiline = json["isMultiline"].toBool();
|
||||||
oRes["isMultiline"] = isMultiline;
|
src["isMultiline"] = isMultiline;
|
||||||
auto text = json["text"].toString();
|
auto text = json["text"].toString();
|
||||||
oRes["text"] = text;
|
src["text"] = text;
|
||||||
QFont font(json["font"].toString());
|
QFont font(json["font"].toString());
|
||||||
font.setPixelSize(json["fontSize"].toInt());
|
font.setPixelSize(json["fontSize"].toInt());
|
||||||
font.setBold(json["fontBold"].toBool());
|
font.setBold(json["fontBold"].toBool());
|
||||||
font.setItalic(json["fontItalic"].toBool());
|
font.setItalic(json["fontItalic"].toBool());
|
||||||
font.setUnderline(json["fontUnderline"].toBool());
|
font.setUnderline(json["fontUnderline"].toBool());
|
||||||
oRes["font"] = font.family();
|
src["font"] = font.family();
|
||||||
oRes["fontSize"] = font.pixelSize();
|
src["fontSize"] = font.pixelSize();
|
||||||
oRes["fontBold"] = font.bold();
|
src["fontBold"] = font.bold();
|
||||||
oRes["fontItalic"] = font.italic();
|
src["fontItalic"] = font.italic();
|
||||||
oRes["fontUnderline"] = font.underline();
|
src["fontUnderline"] = font.underline();
|
||||||
auto textColor = json["textColor"].toString();
|
auto textColor = json["textColor"].toString();
|
||||||
oRes["textColor"] = textColor;
|
src["textColor"] = textColor;
|
||||||
oRes["backColor"] = json["backColor"];
|
src["backColor"] = json["backColor"];
|
||||||
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
QFontMetrics metric(font);
|
QFontMetrics metric(font);
|
||||||
oRes["spaceWidth"] = metric.horizontalAdvance(" ");
|
src["spaceWidth"] = metric.horizontalAdvance(" ");
|
||||||
QColor color(textColor);
|
QColor color(textColor);
|
||||||
JObj imgs;
|
JObj imgs;
|
||||||
for(auto &str : str0_9) Tools::saveImg(dstDir, metric, font, color, imgs, str, str);
|
for(int i=0; i<=9; i++) Tools::saveImg(dstDir, metric, font, color, imgs, QString::number(i), QString::number(i));
|
||||||
Tools::saveImg(dstDir, metric, font, color, imgs, tr("day"), "day");
|
Tools::saveImg(dstDir, metric, font, color, imgs, tr("day"), "day");
|
||||||
Tools::saveImg(dstDir, metric, font, color, imgs, tr("hour"), "hour");
|
Tools::saveImg(dstDir, metric, font, color, imgs, tr("hour"), "hour");
|
||||||
Tools::saveImg(dstDir, metric, font, color, imgs, tr("min"), "min");
|
Tools::saveImg(dstDir, metric, font, color, imgs, tr("min"), "min");
|
||||||
|
@ -582,6 +608,6 @@ JObj GenTmpThread::convertTimer(const JValue &json) {
|
||||||
} else emit onErr("convertTimer file.open false");
|
} else emit onErr("convertTimer file.open false");
|
||||||
} else emit onErr("convertTimer img.save false");
|
} else emit onErr("convertTimer img.save false");
|
||||||
}
|
}
|
||||||
oRes["imgs"] = imgs;
|
src["imgs"] = imgs;
|
||||||
return oRes;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "pagelistitem.h"
|
#include "pagelistitem.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "base/ffutil.h"
|
#include "base/ffutil.h"
|
||||||
#include "base/lodateselector.h"
|
#include "base/lodateselector.h"
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
#include "program/ephoto.h"
|
#include "program/ephoto.h"
|
||||||
#include "program/etext.h"
|
#include "program/etext.h"
|
||||||
#include "program/etimer.h"
|
#include "program/etimer.h"
|
||||||
|
#include "program/etimer2.h"
|
||||||
#include "program/evideo.h"
|
#include "program/evideo.h"
|
||||||
#include "program/eweb.h"
|
#include "program/eweb.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
@ -51,6 +52,7 @@ PageListItem::PageListItem(const JObj &attr, const QString &pageDir) : mAttr(att
|
||||||
else if(type=="Temp") element = new EEnviron(ele.toObj());
|
else if(type=="Temp") element = new EEnviron(ele.toObj());
|
||||||
else if(type=="Web") element = new EWeb(ele.toObj());
|
else if(type=="Web") element = new EWeb(ele.toObj());
|
||||||
else if(type=="Timer") element = new ETimer(ele.toObj());
|
else if(type=="Timer") element = new ETimer(ele.toObj());
|
||||||
|
else if(type=="Timer2") element = new ETimer2(ele.toObj());
|
||||||
else if(type=="Window") element = new EMultiWin(ele.toObj(), this);
|
else if(type=="Window") element = new EMultiWin(ele.toObj(), this);
|
||||||
if(element) mScene->addItem(element);
|
if(element) mScene->addItem(element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "pagelistitem.h"
|
#include "pagelistitem.h"
|
||||||
#include "player/playwin.h"
|
#include "player/playwin.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "main.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "program/ebase.h"
|
#include "program/ebase.h"
|
||||||
#include "program/etext.h"
|
#include "program/etext.h"
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
#include "program/eenviron.h"
|
#include "program/eenviron.h"
|
||||||
#include "program/eweb.h"
|
#include "program/eweb.h"
|
||||||
#include "program/etimer.h"
|
#include "program/etimer.h"
|
||||||
|
#include "program/etimer2.h"
|
||||||
#include "program/emultiwin.h"
|
#include "program/emultiwin.h"
|
||||||
#include "program/gentmpthread.h"
|
#include "program/gentmpthread.h"
|
||||||
#include "program/sendprogramdialog.h"
|
#include "program/sendprogramdialog.h"
|
||||||
|
@ -190,6 +191,9 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer"));
|
||||||
action->setData(EBase::Timer);
|
action->setData(EBase::Timer);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
|
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer")+"2");
|
||||||
|
action->setData(EBase::Timer2);
|
||||||
|
toolBar->addAction(action);
|
||||||
action = new QAction(QIcon(":/res/program/demo-video.png"), tr("Demos"));
|
action = new QAction(QIcon(":/res/program/demo-video.png"), tr("Demos"));
|
||||||
connect(action, &QAction::triggered, this, [this] {
|
connect(action, &QAction::triggered, this, [this] {
|
||||||
auto file = QFileDialog::getOpenFileName(this, tr("Open Demo"), "Demos");
|
auto file = QFileDialog::getOpenFileName(this, tr("Open Demo"), "Demos");
|
||||||
|
@ -335,19 +339,20 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
element = eVideo;
|
element = eVideo;
|
||||||
} else if(type==EBase::Text) {
|
} else if(type==EBase::Text) {
|
||||||
if(iNewHeight > 80 && (mProgItem->mWidth >= mProgItem->mHeight)) iNewHeight = 80;
|
if(iNewHeight > 80 && (mProgItem->mWidth >= mProgItem->mHeight)) iNewHeight = 80;
|
||||||
element = new EText();
|
element = new EText;
|
||||||
} else if(type==EBase::DClock) {
|
} else if(type==EBase::DClock) {
|
||||||
if(iNewHeight>80 && (mProgItem->mWidth>=mProgItem->mHeight)) iNewHeight=80;
|
if(iNewHeight>80 && (mProgItem->mWidth>=mProgItem->mHeight)) iNewHeight=80;
|
||||||
element = new EDClock();
|
element = new EDClock;
|
||||||
} else if(type==EBase::AClock) {
|
} else if(type==EBase::AClock) {
|
||||||
if(iNewWidth > 120) iNewWidth = 120;
|
if(iNewWidth > 120) iNewWidth = 120;
|
||||||
if(iNewHeight > 120) iNewHeight = 120;
|
if(iNewHeight > 120) iNewHeight = 120;
|
||||||
element = new EAClock();
|
element = new EAClock;
|
||||||
} else if(type==EBase::Environ) element = new EEnviron();
|
} else if(type==EBase::Environ) element = new EEnviron;
|
||||||
else if(type==EBase::Web) {
|
else if(type==EBase::Web) {
|
||||||
element = new EWeb();
|
element = new EWeb;
|
||||||
element->setSize(mProgItem->mWidth, mProgItem->mHeight);
|
element->setSize(mProgItem->mWidth, mProgItem->mHeight);
|
||||||
} else if(type==EBase::Timer) element = new ETimer();
|
} else if(type==EBase::Timer) element = new ETimer;
|
||||||
|
else if(type==EBase::Timer2) element = new ETimer2;
|
||||||
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
||||||
if(element) {
|
if(element) {
|
||||||
if(element->mWidth==0) {
|
if(element->mWidth==0) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "gentmpthread.h"
|
#include "gentmpthread.h"
|
||||||
#include <globaldefine.h>
|
#include <main.h>
|
||||||
#include "sendprogramdialog.h"
|
#include "sendprogramdialog.h"
|
||||||
#include "program/progeditorwin.h"
|
#include "program/progeditorwin.h"
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
|
@ -3,15 +3,6 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
void Tools::timerEvent(QTimerEvent *event) {
|
|
||||||
if(timer_id==event->timerId()) emit sTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
Tools* Tools::getInstance() {
|
|
||||||
static const auto ins = new Tools(qApp);
|
|
||||||
return ins;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect Tools::centerRect(qreal width, qreal height, int maxW, int maxH) {
|
QRect Tools::centerRect(qreal width, qreal height, int maxW, int maxH) {
|
||||||
if(maxW < width || maxH < height) {
|
if(maxW < width || maxH < height) {
|
||||||
auto rate = qMin(maxW / width, maxH / height);
|
auto rate = qMin(maxW / width, maxH / height);
|
||||||
|
@ -53,11 +44,6 @@ QString Tools::fileMd5(QString filePath) {
|
||||||
file.close();
|
file.close();
|
||||||
return QString::fromLatin1(cryptoHash.result().toHex());
|
return QString::fromLatin1(cryptoHash.result().toHex());
|
||||||
}
|
}
|
||||||
void Tools::mergeFormat(QTextEdit *textEdit, const QTextCharFormat &fmt) {
|
|
||||||
QTextCursor cursor = textEdit->textCursor();
|
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
|
||||||
cursor.mergeCharFormat(fmt);
|
|
||||||
}
|
|
||||||
QString Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, const QString& str) {
|
QString Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, const QString& str) {
|
||||||
if(str.isEmpty()) return QString();
|
if(str.isEmpty()) return QString();
|
||||||
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
||||||
|
|
|
@ -13,21 +13,18 @@
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
const QString str0_9[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
|
|
||||||
extern QTextEdit *gFdResInfo;
|
extern QTextEdit *gFdResInfo;
|
||||||
extern ProgItem *gProgItem;
|
extern ProgItem *gProgItem;
|
||||||
|
|
||||||
class Tools : public QObject {
|
class Tools : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static Tools* getInstance();
|
|
||||||
static QNetworkAccessManager &netManager() {
|
static QNetworkAccessManager &netManager() {
|
||||||
static QNetworkAccessManager manager;
|
static QNetworkAccessManager manager;
|
||||||
return manager;
|
return manager;
|
||||||
};
|
};
|
||||||
static QRect centerRect(qreal, qreal, int, int);
|
static QRect centerRect(qreal, qreal, int, int);
|
||||||
static QString addSufix(QString);
|
static QString addSufix(QString);
|
||||||
static void mergeFormat(QTextEdit *textEdit, const QTextCharFormat &format);
|
|
||||||
static QString readErrStr(QImageReader::ImageReaderError);
|
static QString readErrStr(QImageReader::ImageReaderError);
|
||||||
static QString fileMd5(QString);
|
static QString fileMd5(QString);
|
||||||
static QString saveImg(const QString&, const QFontMetrics&, const QFont&, const QColor&, const QString&);
|
static QString saveImg(const QString&, const QFontMetrics&, const QFont&, const QColor&, const QString&);
|
||||||
|
@ -37,18 +34,6 @@ public:
|
||||||
static int color2Int(const QColor& color);
|
static int color2Int(const QColor& color);
|
||||||
static QBrush getBrush(const QColor& color);
|
static QBrush getBrush(const QColor& color);
|
||||||
static QString selectStr(bool f, const QString &s0, const QString &s1 = "");
|
static QString selectStr(bool f, const QString &s0, const QString &s1 = "");
|
||||||
~Tools() {
|
|
||||||
killTimer(timer_id);
|
|
||||||
}
|
|
||||||
signals:
|
|
||||||
void sTick();
|
|
||||||
protected:
|
|
||||||
virtual void timerEvent(QTimerEvent *event);
|
|
||||||
private:
|
|
||||||
Tools(QObject *parent = 0) : QObject(parent) {
|
|
||||||
timer_id = startTimer(500, Qt::PreciseTimer);
|
|
||||||
};
|
|
||||||
int timer_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOOLS_H
|
#endif // TOOLS_H
|
||||||
|
|
1588
LedOK/ts/app_en.ts
1588
LedOK/ts/app_en.ts
File diff suppressed because it is too large
Load Diff
1488
LedOK/ts/app_ja.ts
1488
LedOK/ts/app_ja.ts
File diff suppressed because it is too large
Load Diff
1492
LedOK/ts/app_pt.ts
1492
LedOK/ts/app_pt.ts
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user