ledok
This commit is contained in:
parent
4411e50aee
commit
e54f367005
Binary file not shown.
After Width: | Height: | Size: 160 KiB |
Binary file not shown.
After Width: | Height: | Size: 140 KiB |
|
@ -23,7 +23,7 @@ CONFIG += embed_translations
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
VERSION = 1.4.2
|
VERSION = 1.5.0
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
msvc {
|
msvc {
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
|
@ -40,6 +40,8 @@ win32 {
|
||||||
RC_ICONS = res/Logo.ico
|
RC_ICONS = res/Logo.ico
|
||||||
}
|
}
|
||||||
osx {
|
osx {
|
||||||
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
|
||||||
|
-mmacosx-version-min=11.0
|
||||||
ICON = res/Logo-raw.png
|
ICON = res/Logo-raw.png
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +50,7 @@ copydir.files += AClock
|
||||||
copydir.files += borders
|
copydir.files += borders
|
||||||
copydir.files += Demos
|
copydir.files += Demos
|
||||||
copydir.files += translations
|
copydir.files += translations
|
||||||
copydir.files += $$quote(y50 param)
|
copydir.files += rk_lcd_parameters
|
||||||
copydir.files += $$quote(files)
|
copydir.files += $$quote(files)
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
|
@ -104,6 +106,7 @@ SOURCES += \
|
||||||
base/lodateselector.cpp \
|
base/lodateselector.cpp \
|
||||||
base/loqtitlebar.cpp \
|
base/loqtitlebar.cpp \
|
||||||
base/loqtreewidget.cpp \
|
base/loqtreewidget.cpp \
|
||||||
|
gutil/qcore.cpp \
|
||||||
gutil/qwaitingdlg.cpp \
|
gutil/qwaitingdlg.cpp \
|
||||||
basedlg.cpp \
|
basedlg.cpp \
|
||||||
basewin.cpp \
|
basewin.cpp \
|
||||||
|
@ -129,12 +132,12 @@ SOURCES += \
|
||||||
player/eleborder.cpp \
|
player/eleborder.cpp \
|
||||||
player/eledigiclock.cpp \
|
player/eledigiclock.cpp \
|
||||||
player/elegif.cpp \
|
player/elegif.cpp \
|
||||||
player/elemultipng.cpp \
|
|
||||||
player/elescroll.cpp \
|
player/elescroll.cpp \
|
||||||
player/eletimer.cpp \
|
player/eletimer.cpp \
|
||||||
player/elevideo.cpp \
|
player/elevideo.cpp \
|
||||||
player/playwin.cpp \
|
player/playwin.cpp \
|
||||||
player/posdlg.cpp \
|
player/posdlg.cpp \
|
||||||
|
player/srccopy.cpp \
|
||||||
progpanel.cpp \
|
progpanel.cpp \
|
||||||
synctimer.cpp \
|
synctimer.cpp \
|
||||||
tools.cpp \
|
tools.cpp \
|
||||||
|
@ -161,7 +164,7 @@ SOURCES += \
|
||||||
program/progitem.cpp \
|
program/progitem.cpp \
|
||||||
program/sendprogramdialog.cpp \
|
program/sendprogramdialog.cpp \
|
||||||
program/sendprogthread.cpp \
|
program/sendprogthread.cpp \
|
||||||
program/videosplitthread.cpp \
|
program/videosplitthread.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
base/changepasswordform.h \
|
base/changepasswordform.h \
|
||||||
|
@ -171,6 +174,7 @@ HEADERS += \
|
||||||
base/lodateselector.h \
|
base/lodateselector.h \
|
||||||
base/loqtitlebar.h \
|
base/loqtitlebar.h \
|
||||||
base/loqtreewidget.h \
|
base/loqtreewidget.h \
|
||||||
|
gutil/qcore.h \
|
||||||
gutil/qwaitingdlg.h \
|
gutil/qwaitingdlg.h \
|
||||||
basedlg.h \
|
basedlg.h \
|
||||||
basewin.h \
|
basewin.h \
|
||||||
|
@ -195,12 +199,12 @@ HEADERS += \
|
||||||
player/eleborder.h \
|
player/eleborder.h \
|
||||||
player/eledigiclock.h \
|
player/eledigiclock.h \
|
||||||
player/elegif.h \
|
player/elegif.h \
|
||||||
player/elemultipng.h \
|
|
||||||
player/elescroll.h \
|
player/elescroll.h \
|
||||||
player/eletimer.h \
|
player/eletimer.h \
|
||||||
player/elevideo.h \
|
player/elevideo.h \
|
||||||
player/playwin.h \
|
player/playwin.h \
|
||||||
player/posdlg.h \
|
player/posdlg.h \
|
||||||
|
player/srccopy.h \
|
||||||
progpanel.h \
|
progpanel.h \
|
||||||
synctimer.h \
|
synctimer.h \
|
||||||
tools.h \
|
tools.h \
|
||||||
|
@ -227,7 +231,7 @@ HEADERS += \
|
||||||
program/progitem.h \
|
program/progitem.h \
|
||||||
program/sendprogramdialog.h \
|
program/sendprogramdialog.h \
|
||||||
program/sendprogthread.h \
|
program/sendprogthread.h \
|
||||||
program/videosplitthread.h \
|
program/videosplitthread.h
|
||||||
|
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
ts/app_zh_CN.ts \
|
ts/app_zh_CN.ts \
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
const QString UpdVerUrl = "https://www.ledok.cn/download/LedOK Express Updates.json";
|
const QString UpdVerUrl = "https://www.ledok.cn/download/LedOK Express Updates.json";
|
||||||
|
|
||||||
QString programsDir() {
|
QString programsDir() {
|
||||||
static auto rtn = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/" + QApplication::applicationName() + "/NPrograms";
|
static auto rtn = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/programs";
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,21 +177,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto serverAddr = fdWebServerAddr->currentText();
|
||||||
QString serverAddr = fdWebServerAddr->currentText();
|
|
||||||
if(serverAddr.isEmpty()) {
|
|
||||||
QMessageBox::information(this, tr("Tip"),tr("InputWebServerAddressTip"));
|
|
||||||
fdWebServerAddr->setFocus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto companyId = fdCompanyId->text();
|
auto companyId = fdCompanyId->text();
|
||||||
if(companyId.isEmpty()) {
|
// auto res = QMessageBox::question(this, tr("Tip Info"), tr("This operation will clear current program.")+"\n"+tr("Do you want to continue?"));
|
||||||
QMessageBox::information(this, tr("Tip"),tr("InputCompanyIdTip"));
|
// if(res != QMessageBox::Yes) return;
|
||||||
fdCompanyId->setFocus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto res = QMessageBox::question(this, tr("Tip Info"), tr("This operation will clear current program.")+"\n"+tr("Do you want to continue?"));
|
|
||||||
if(res != QMessageBox::Yes) return;
|
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "SetOnlineAddr");
|
json.insert("_id", "SetOnlineAddr");
|
||||||
json.insert("_type", "SetOnlineAddr");
|
json.insert("_type", "SetOnlineAddr");
|
||||||
|
@ -214,12 +203,10 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addWidget(lbRealtime = new QLabel);
|
||||||
label = new QLabel;
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
fdRealtimeServer = new QComboBox;
|
fdRealtimeServer = new QComboBox;
|
||||||
fdRealtimeServer->addItem(tr("www.ledokcloud.com/realtime"));
|
fdRealtimeServer->addItem("www.ledokcloud.com/realtime");
|
||||||
fdRealtimeServer->setMinimumWidth(260);
|
fdRealtimeServer->setMinimumWidth(260);
|
||||||
fdRealtimeServer->setEditable(true);
|
fdRealtimeServer->setEditable(true);
|
||||||
hBox->addWidget(fdRealtimeServer);
|
hBox->addWidget(fdRealtimeServer);
|
||||||
|
@ -635,6 +622,188 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnGetLog);
|
hBox->addWidget(btnGetLog);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
|
auto btnViewProg = new QPushButton("View Prog JSON");
|
||||||
|
btnViewProg->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnViewProg, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json{{"_type", "GetFile"}, {"name", "program"}};
|
||||||
|
auto fd = new QTextEdit;
|
||||||
|
fd->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
fd->setTabStopDistance(26);
|
||||||
|
auto ft = fd->font();
|
||||||
|
ft.setFamily("Consolas");
|
||||||
|
fd->setFont(ft);
|
||||||
|
fd->setWindowTitle("program");
|
||||||
|
fd->resize(600, 900);
|
||||||
|
fd->show();
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto tcp = new TcpSocket;
|
||||||
|
auto cardId = card.id;
|
||||||
|
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater);
|
||||||
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->write(JToBytes(json));
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::readyRead, fd, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
auto resp = tcp->readAll();
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
fd->append(cardId+" Prog JSON");
|
||||||
|
fd->append(resp);
|
||||||
|
fd->append("");
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
fd->append(cardId+" View Prog JSON "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
|
});
|
||||||
|
tcp->connectToHost(card.ip, 3333);
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnViewProg);
|
||||||
|
|
||||||
|
auto btnListFiles = new QPushButton("List Prog 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;
|
||||||
|
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) {
|
||||||
|
auto tcp = new TcpSocket;
|
||||||
|
auto cardId = card.id;
|
||||||
|
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater);
|
||||||
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->write(JToBytes(json));
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::readyRead, fd, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
auto resp = tcp->readAll();
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
fd->append(cardId+" Prog Files");
|
||||||
|
fd->append(resp);
|
||||||
|
fd->append("");
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
fd->append(cardId+" List Prog Files "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
|
});
|
||||||
|
tcp->connectToHost(card.ip, 3333);
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnListFiles);
|
||||||
|
|
||||||
|
auto btnGetPlayerInfo = new QPushButton("Get Player Info");
|
||||||
|
btnGetPlayerInfo->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnGetPlayerInfo, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json{{"_type", "GetInfo"}};
|
||||||
|
auto fd = new QTextEdit;
|
||||||
|
fd->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
auto ft = fd->font();
|
||||||
|
ft.setFamily("Consolas");
|
||||||
|
fd->setFont(ft);
|
||||||
|
fd->setWindowTitle("Get Player Info");
|
||||||
|
fd->resize(600, 900);
|
||||||
|
fd->show();
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto tcp = new TcpSocket;
|
||||||
|
auto cardId = card.id;
|
||||||
|
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater);
|
||||||
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->write(JToBytes(json));
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::readyRead, fd, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
auto resp = tcp->readAll();
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
fd->append(cardId+" Player Info");
|
||||||
|
fd->append(resp);
|
||||||
|
fd->append("");
|
||||||
|
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
fd->append(cardId+" Get Player Info "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
|
});
|
||||||
|
tcp->connectToHost(card.ip, 3333);
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnGetPlayerInfo);
|
||||||
|
|
||||||
|
auto GetBuf = new QPushButton("Get Player Log");
|
||||||
|
GetBuf->setProperty("ssType", "progManageTool");
|
||||||
|
connect(GetBuf, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json{{"_type", "GetLog"}};
|
||||||
|
auto fd = new QTextEdit;
|
||||||
|
fd->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
auto ft = fd->font();
|
||||||
|
ft.setFamily("Consolas");
|
||||||
|
fd->setFont(ft);
|
||||||
|
fd->setWindowTitle("Get Player Log");
|
||||||
|
fd->resize(600, 900);
|
||||||
|
fd->show();
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto tcp = new TcpSocket;
|
||||||
|
auto cardId = card.id;
|
||||||
|
connect(fd, &QTextEdit::destroyed, tcp, &QTcpSocket::deleteLater);
|
||||||
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->write(JToBytes(json));
|
||||||
|
tcp->startTimer(5000);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::readyRead, fd, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
auto resp = tcp->readAll();
|
||||||
|
if(fd->document()->isEmpty()) fd->append(cardId+" Player Log");
|
||||||
|
fd->append(resp);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, fd, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
if(fd->document()->isEmpty() || err!=QAbstractSocket::SocketTimeoutError) fd->append(cardId+" Get Player Log "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
|
});
|
||||||
|
tcp->connectToHost(card.ip, 3333);
|
||||||
|
tcp->startTimer(8000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(GetBuf);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addWidget(lbTimingReboot = new QLabel);
|
hBox->addWidget(lbTimingReboot = new QLabel);
|
||||||
|
@ -708,8 +877,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
auto hBox = new HBox(grpY50);
|
auto hBox = new HBox(grpY50);
|
||||||
|
|
||||||
auto fdY50Resolu = new QComboBox;
|
auto fdY50Resolu = new QComboBox;
|
||||||
auto dirs = QDir(QApplication::applicationDirPath()+"/y50 param").entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
auto params = QDir(QApplication::applicationDirPath()+"/rk_lcd_parameters").entryList(QDir::Files);
|
||||||
foreach(auto dir, dirs) fdY50Resolu->addItem(dir);
|
for(auto ¶m : params) fdY50Resolu->addItem(param);
|
||||||
fdY50Resolu->setMinimumWidth(160);
|
fdY50Resolu->setMinimumWidth(160);
|
||||||
hBox->addWidget(fdY50Resolu);
|
hBox->addWidget(fdY50Resolu);
|
||||||
|
|
||||||
|
@ -720,14 +889,14 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto filePath = QApplication::applicationDirPath()+"/y50 param/"+fdY50Resolu->currentText()+"/rk_lcd_parameters";
|
auto file = QApplication::applicationDirPath()+"/rk_lcd_parameters/"+fdY50Resolu->currentText();
|
||||||
QFile qFile(filePath);
|
QFile qFile(file);
|
||||||
if(! qFile.exists()) {
|
if(! qFile.exists()) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("File not exist"));
|
QMessageBox::information(this, tr("Tip"), tr("File not exist"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(! qFile.open(QIODevice::ReadOnly)) {
|
if(! qFile.open(QIODevice::ReadOnly)) {
|
||||||
QMessageBox::information(this, tr("Tip"), tr("Cannot Open File")+": "+qFile.errorString()+"\n"+filePath);
|
QMessageBox::information(this, tr("Tip"), tr("Cannot Open File")+": "+qFile.errorString()+"\n"+file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto fileData = qFile.readAll();
|
auto fileData = qFile.readAll();
|
||||||
|
@ -928,11 +1097,66 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
btnLedSet->setProperty("ssType", "progManageTool");
|
btnLedSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnLedSet, &QPushButton::clicked, btnLedSet, [] {
|
connect(btnLedSet, &QPushButton::clicked, btnLedSet, [] {
|
||||||
QFileInfo file("LedSet4.0/LedSet4.0.exe");
|
QFileInfo file("LedSet4.0/LedSet4.0.exe");
|
||||||
if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList());
|
if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnLedSet);
|
hBox->addWidget(btnLedSet);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
|
btnReceCardsGet = new QPushButton;
|
||||||
|
btnReceCardsGet->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnReceCardsGet, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject json;
|
||||||
|
json.insert("_id", "GetReceCards");
|
||||||
|
json.insert("_type", "GetReceCards");
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, btnReceCardsGet->text() + " ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::information(this, btnReceCardsGet->text(), QString::number(json["receCardNum"].toInt()));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
foreach(auto card, gSelCards) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
|
auto cardId = card.id;
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
QJsonDocument json;
|
||||||
|
QString err = checkReplyForJson(reply, &json);
|
||||||
|
if(err.isEmpty()) err = QString::number(json["receCardNum"].toInt());
|
||||||
|
gFdResInfo->append(cardId+" "+btnReceCardsGet->text()+" "+err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnReceCardsGet);
|
||||||
|
|
||||||
|
// auto btnTool = new QPushButton("本地监控");
|
||||||
|
// btnTool->setMinimumHeight(30);
|
||||||
|
// btnTool->setProperty("ssType", "progManageTool");
|
||||||
|
// connect(btnTool, &QPushButton::clicked, btnTool, [] {
|
||||||
|
// QFileInfo file("EasyTool/EasyTool.exe");
|
||||||
|
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(btnTool);
|
||||||
|
|
||||||
|
// auto btnVMS = new QPushButton("平台监控");
|
||||||
|
// btnVMS->setMinimumHeight(30);
|
||||||
|
// btnVMS->setProperty("ssType", "progManageTool");
|
||||||
|
// connect(btnVMS, &QPushButton::clicked, btnVMS, [] {
|
||||||
|
// QFileInfo file("EasyVMS/EasyVMS.exe");
|
||||||
|
// if(file.exists()) QProcess::startDetached(file.absoluteFilePath(), QStringList(), file.absolutePath());
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(btnVMS);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
btnLedSet->setVisible(false);
|
btnLedSet->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1562,6 +1786,19 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
|
|
||||||
fdM80Resolu = new QComboBox;
|
fdM80Resolu = new QComboBox;
|
||||||
fdM80Resolu->setMinimumWidth(160);
|
fdM80Resolu->setMinimumWidth(160);
|
||||||
|
fdM80Resolu->addItem("480x4096", "550x4500");
|
||||||
|
fdM80Resolu->addItem("576x3840", "625x3960");
|
||||||
|
fdM80Resolu->addItem("720x3200", "750x3300");
|
||||||
|
fdM80Resolu->addItem("864x2672", "900x2750");
|
||||||
|
fdM80Resolu->addItem("1080x1920", "1125x2200");
|
||||||
|
fdM80Resolu->addItem("1280x1760", "1320x1850");
|
||||||
|
fdM80Resolu->addItem("1472x1536", "1500x1650");
|
||||||
|
fdM80Resolu->addItem("1536x1472", "1650x1500");
|
||||||
|
fdM80Resolu->addItem("1920x1080", "2200x1125");
|
||||||
|
fdM80Resolu->addItem("2672x864", "2750x900");
|
||||||
|
fdM80Resolu->addItem("3200x720", "3300x750");
|
||||||
|
fdM80Resolu->addItem("3840x576", "3960x625");
|
||||||
|
fdM80Resolu->addItem("4096x480", "4500x550");
|
||||||
hBox->addWidget(fdM80Resolu);
|
hBox->addWidget(fdM80Resolu);
|
||||||
|
|
||||||
btnM80Set = new QPushButton();
|
btnM80Set = new QPushButton();
|
||||||
|
@ -2188,6 +2425,28 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
}
|
}
|
||||||
vBox->addWidget(grpBoxHiddenSettings);
|
vBox->addWidget(grpBoxHiddenSettings);
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
auto btn = new QPushButton("List Card Infos");
|
||||||
|
btn->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btn, &QPushButton::clicked, this, [this] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto fd = new QTextEdit;
|
||||||
|
fd->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
auto ft = fd->font();
|
||||||
|
ft.setFamily("Consolas");
|
||||||
|
fd->setFont(ft);
|
||||||
|
fd->setWindowTitle("List Card Infos");
|
||||||
|
fd->resize(600, 900);
|
||||||
|
fd->show();
|
||||||
|
for(auto &card : gSelCards) fd->append(card.id+", "+card.ip+", "+QString::number(card.mWidth)+" x "+QString::number(card.mHeight)+", "+card.alias+", "+QString::number(card.bright)+"%, "+(card.isScreenOn?"On":"Off"));
|
||||||
|
});
|
||||||
|
hBox->addWidget(btn);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
|
|
||||||
if(QSettings().value("advUiPs", "888").toString().isEmpty()) isPassed = true;
|
if(QSettings().value("advUiPs", "888").toString().isEmpty()) isPassed = true;
|
||||||
|
@ -2260,21 +2519,21 @@ void CtrlAdvancedPanel::init() {
|
||||||
|
|
||||||
auto isM80 = card.id.startsWith("M8", Qt::CaseInsensitive);
|
auto isM80 = card.id.startsWith("M8", Qt::CaseInsensitive);
|
||||||
grpM80->setVisible(isM80);
|
grpM80->setVisible(isM80);
|
||||||
if(isM80) {
|
// if(isM80) {
|
||||||
QJsonObject json;
|
// QJsonObject json;
|
||||||
json.insert("_id", "GetAllScreenSizeM80");
|
// json.insert("_id", "GetAllScreenSizeM80");
|
||||||
json.insert("_type", "GetAllScreenSizeM80");
|
// json.insert("_type", "GetAllScreenSizeM80");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
// auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
// connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
// QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
// QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
// if(! err.isEmpty()) return;
|
||||||
auto sizes = json["result"].toObject();
|
// auto sizes = json["result"].toObject();
|
||||||
fdM80Resolu->clear();
|
// fdM80Resolu->clear();
|
||||||
auto send = sizes.constEnd();
|
// auto send = sizes.constEnd();
|
||||||
for(auto size=sizes.constBegin(); size<send; size++) fdM80Resolu->addItem(size.key(), size.value().toString());
|
// for(auto size=sizes.constBegin(); size<send; size++) fdM80Resolu->addItem(size.key(), size.value().toString());
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
auto isY50 = card.id.startsWith("st5", Qt::CaseInsensitive)
|
auto isY50 = card.id.startsWith("st5", Qt::CaseInsensitive)
|
||||||
|| card.id.startsWith("m5h", Qt::CaseInsensitive)
|
|| card.id.startsWith("m5h", Qt::CaseInsensitive)
|
||||||
|
@ -2289,7 +2548,7 @@ void CtrlAdvancedPanel::init() {
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("_id", "GetOnlineAddr");
|
json.insert("_id", "GetOnlineAddr");
|
||||||
json.insert("_type", "GetOnlineAddr");
|
json.insert("_type", "GetOnlineAddr");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
|
@ -2301,10 +2560,10 @@ void CtrlAdvancedPanel::init() {
|
||||||
json = QJsonObject();
|
json = QJsonObject();
|
||||||
json.insert("_id", "GetRealtimeServer");
|
json.insert("_id", "GetRealtimeServer");
|
||||||
json.insert("_type", "GetRealtimeServer");
|
json.insert("_type", "GetRealtimeServer");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").timeout(30000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
fdRealtimeServer->setCurrentText(json["server"].toString());
|
fdRealtimeServer->setCurrentText(json["server"].toString());
|
||||||
});
|
});
|
||||||
|
@ -2317,6 +2576,7 @@ void CtrlAdvancedPanel::transUi() {
|
||||||
btnBindTaxiIc->setText(tr("Binding *.ic account indentity voucher"));
|
btnBindTaxiIc->setText(tr("Binding *.ic account indentity voucher"));
|
||||||
btnGetTopLevel->setText(tr("Readback"));
|
btnGetTopLevel->setText(tr("Readback"));
|
||||||
btnLedSet->setText(tr("Start LedSet4"));
|
btnLedSet->setText(tr("Start LedSet4"));
|
||||||
|
btnReceCardsGet->setText(tr("Get Receive Card Num"));
|
||||||
|
|
||||||
grpM80->setTitle("M80 "+tr("Config"));
|
grpM80->setTitle("M80 "+tr("Config"));
|
||||||
btnM80Refresh->setText(tr("Refresh"));
|
btnM80Refresh->setText(tr("Refresh"));
|
||||||
|
@ -2365,7 +2625,7 @@ void CtrlAdvancedPanel::transUi() {
|
||||||
btnCustomJsonGet->setText(tr("Get"));
|
btnCustomJsonGet->setText(tr("Get"));
|
||||||
|
|
||||||
grpHighForBusy->setTitle(tr("Taxi top screen configuration"));
|
grpHighForBusy->setTitle(tr("Taxi top screen configuration"));
|
||||||
label->setText(tr("Realtimer Server Address:"));
|
lbRealtime->setText(tr("Realtime Address:"));
|
||||||
lbTitle->setText(tr("Advanced"));
|
lbTitle->setText(tr("Advanced"));
|
||||||
lbCompanyId->setText(tr("Compant ID:"));
|
lbCompanyId->setText(tr("Compant ID:"));
|
||||||
labelWebServer->setText(tr("Web Server Address:"));
|
labelWebServer->setText(tr("Web Server Address:"));
|
||||||
|
|
|
@ -43,7 +43,7 @@ private:
|
||||||
QLabel *lbCompanyId;
|
QLabel *lbCompanyId;
|
||||||
QLineEdit *fdCompanyId;
|
QLineEdit *fdCompanyId;
|
||||||
QPushButton *btnWebServerSet;
|
QPushButton *btnWebServerSet;
|
||||||
QLabel *label;
|
QLabel *lbRealtime;
|
||||||
QComboBox *fdRealtimeServer;
|
QComboBox *fdRealtimeServer;
|
||||||
QPushButton *btnRealtimeServerSet;
|
QPushButton *btnRealtimeServerSet;
|
||||||
QPushButton *btnRealtimeClear;
|
QPushButton *btnRealtimeClear;
|
||||||
|
@ -78,7 +78,7 @@ private:
|
||||||
QPushButton *btnHighForBusySet;
|
QPushButton *btnHighForBusySet;
|
||||||
QPushButton *btnGetTopLevel;
|
QPushButton *btnGetTopLevel;
|
||||||
QPushButton *btnLedSet;
|
QPushButton *btnLedSet;
|
||||||
QPushButton *btnBindTaxiIc;
|
QPushButton *btnReceCardsGet, *btnBindTaxiIc;
|
||||||
|
|
||||||
QGroupBox *grpMinMaxBrightness;
|
QGroupBox *grpMinMaxBrightness;
|
||||||
QLabel *lbMinBright;
|
QLabel *lbMinBright;
|
||||||
|
|
|
@ -177,9 +177,9 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
hhh = new HBox(vv);
|
hhh = new HBox(vv);
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
|
|
||||||
pushButtonStopTest = new QPushButton;
|
btnStopTest = new QPushButton;
|
||||||
pushButtonStopTest->setMinimumSize(QSize(60, 30));
|
btnStopTest->setMinimumSize(QSize(60, 30));
|
||||||
hhh->addWidget(pushButtonStopTest);
|
hhh->addWidget(btnStopTest);
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
|
|
||||||
vv->addStretch();
|
vv->addStretch();
|
||||||
|
@ -192,14 +192,12 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
|
|
||||||
vv = new VBox(hBox);
|
vv = new VBox(hBox);
|
||||||
|
|
||||||
lineEdit = new QLineEdit;
|
fdAnycast = new QLineEdit;
|
||||||
lineEdit->setMinimumSize(QSize(0, 36));
|
fdAnycast->setValidator(new QIntValidator(0, 100, this));
|
||||||
lineEdit->setMaximumSize(QSize(194, 16777215));
|
fdAnycast->setMinimumHeight(36);
|
||||||
lineEdit->setAutoFillBackground(false);
|
fdAnycast->setStyleSheet("color: #0f0; background: #000;");
|
||||||
lineEdit->setStyleSheet(QString::fromUtf8("color: rgb(0, 255, 0);\n"
|
fdAnycast->setAlignment(Qt::AlignCenter);
|
||||||
"background-color: rgb(0, 0, 0);"));
|
vv->addWidget(fdAnycast);
|
||||||
lineEdit->setAlignment(Qt::AlignCenter);
|
|
||||||
vv->addWidget(lineEdit);
|
|
||||||
|
|
||||||
auto gridLayout = new Grid(vv);
|
auto gridLayout = new Grid(vv);
|
||||||
|
|
||||||
|
@ -221,20 +219,47 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
gridLayout->addWidget(btngrp->button(9), 2, 2);
|
gridLayout->addWidget(btngrp->button(9), 2, 2);
|
||||||
gridLayout->addWidget(btngrp->button(0), 3, 0);
|
gridLayout->addWidget(btngrp->button(0), 3, 0);
|
||||||
connect(btngrp, &QButtonGroup::idClicked, this, [=](int id) {
|
connect(btngrp, &QButtonGroup::idClicked, this, [=](int id) {
|
||||||
if(lineEdit->text().contains("-")) lineEdit->clear();
|
if(fdAnycast->text().contains("-")) fdAnycast->clear();
|
||||||
lineEdit->setText(lineEdit->text() + QString::number(id));
|
fdAnycast->setText(fdAnycast->text() + QString::number(id));
|
||||||
btnAnycast->setEnabled(true);
|
btnAnycast->setEnabled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
pushButton_11 = new QPushButton;
|
btnAnycastClear = new QPushButton;
|
||||||
pushButton_11->setFixedSize(QSize(60, 30));
|
btnAnycastClear->setFixedSize(60, 30);
|
||||||
gridLayout->addWidget(pushButton_11, 3, 1, 1, 1);
|
btnAnycastClear->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnAnycastClear, &QPushButton::clicked, this, [=] {
|
||||||
|
fdAnycast->clear();
|
||||||
|
btnAnycast->setEnabled(false);
|
||||||
|
});
|
||||||
|
gridLayout->addWidget(btnAnycastClear, 3, 1, 1, 1);
|
||||||
|
|
||||||
pushButton_12 = new QPushButton;
|
btnAnycastReset = new QPushButton;
|
||||||
pushButton_12->setFixedSize(QSize(60, 30));
|
btnAnycastReset->setFixedSize(60, 30);
|
||||||
gridLayout->addWidget(pushButton_12, 3, 2, 1, 1);
|
btnAnycastReset->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SendAnycastCmd(0);
|
||||||
|
fdAnycast->setText("- "+tr("Loop Mode")+" -");
|
||||||
|
btnAnycast->setEnabled(false);
|
||||||
|
});
|
||||||
|
gridLayout->addWidget(btnAnycastReset, 3, 2, 1, 1);
|
||||||
|
|
||||||
btnAnycast = new QPushButton;
|
btnAnycast = new QPushButton;
|
||||||
|
btnAnycast->setEnabled(false);
|
||||||
|
btnAnycast->setMinimumHeight(36);
|
||||||
|
btnAnycast->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SendAnycastCmd(fdAnycast->text().toInt());
|
||||||
|
fdAnycast->setText(tr("Anycast")+" - "+fdAnycast->text());
|
||||||
|
btnAnycast->setEnabled(false);
|
||||||
|
});
|
||||||
vv->addWidget(btnAnycast);
|
vv->addWidget(btnAnycast);
|
||||||
vv->addStretch();
|
vv->addStretch();
|
||||||
|
|
||||||
|
@ -244,10 +269,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
pushButtonStartLine->setProperty("ssType", "progManageTool");
|
pushButtonStartLine->setProperty("ssType", "progManageTool");
|
||||||
pushButtonStartGray->setProperty("ssType", "progManageTool");
|
pushButtonStartGray->setProperty("ssType", "progManageTool");
|
||||||
pushButtonStartColor->setProperty("ssType", "progManageTool");
|
pushButtonStartColor->setProperty("ssType", "progManageTool");
|
||||||
pushButtonStopTest->setProperty("ssType", "progManageTool");
|
btnStopTest->setProperty("ssType", "progManageTool");
|
||||||
pushButton_11->setProperty("ssType", "progManageTool");
|
|
||||||
pushButton_12->setProperty("ssType", "progManageTool");
|
|
||||||
btnAnycast->setProperty("ssType", "progManageTool");
|
|
||||||
|
|
||||||
spinBoxLineSpeed->setValue(10);
|
spinBoxLineSpeed->setValue(10);
|
||||||
spinBoxLineDistance->setValue(15);
|
spinBoxLineDistance->setValue(15);
|
||||||
|
@ -371,7 +393,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(pushButtonStopTest, &QPushButton::clicked, this, [this] {
|
connect(btnStopTest, &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;
|
||||||
|
@ -392,38 +414,6 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(pushButton_11, &QPushButton::clicked, this, [=] {
|
|
||||||
lineEdit->clear();
|
|
||||||
btnAnycast->setEnabled(false);
|
|
||||||
});
|
|
||||||
connect(pushButton_12, &QPushButton::clicked, this, [=] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int iIndex = lineEdit->text().toInt();
|
|
||||||
if(gSelCards.count()==1) SendAnycastCmd(gSelCards[0], 0, true);
|
|
||||||
else {
|
|
||||||
foreach(auto card, gSelCards) SendAnycastCmd(card, iIndex, false);
|
|
||||||
}
|
|
||||||
lineEdit->setText("-"+tr("loopback mode")+"-");
|
|
||||||
btnAnycast->setEnabled(false);
|
|
||||||
});
|
|
||||||
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
|
||||||
QMessageBox::information(this, tr("Tip"), tr("NoSelectedController"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int iIndex = lineEdit->text().toInt();
|
|
||||||
if(gSelCards.count()==1) SendAnycastCmd(gSelCards[0], iIndex, true);
|
|
||||||
else foreach(auto card, gSelCards) SendAnycastCmd(card, iIndex, false);
|
|
||||||
lineEdit->setText(tr("Anycast")+" - "+lineEdit->text());
|
|
||||||
btnAnycast->setEnabled(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
btnAnycast->setEnabled(false);
|
|
||||||
|
|
||||||
lineEdit->setValidator(new QIntValidator(0, 100, this));
|
|
||||||
|
|
||||||
transUi();
|
transUi();
|
||||||
}
|
}
|
||||||
|
@ -467,43 +457,74 @@ void CtrlTestPanel::transUi() {
|
||||||
radioButton_Green->setText(tr("Green"));
|
radioButton_Green->setText(tr("Green"));
|
||||||
radioButton_Blue->setText(tr("Blue"));
|
radioButton_Blue->setText(tr("Blue"));
|
||||||
radioButton_White->setText(tr("White"));
|
radioButton_White->setText(tr("White"));
|
||||||
pushButtonStopTest->setText(tr("Stop"));
|
btnStopTest->setText(tr("Stop"));
|
||||||
pushButton_11->setText(tr("Clear"));
|
btnAnycastClear->setText(tr("Clear"));
|
||||||
pushButton_12->setText(tr("Reset"));
|
btnAnycastReset->setText(tr("Reset"));
|
||||||
btnAnycast->setText(tr("Anycast"));
|
btnAnycast->setText(tr("Anycast"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlTestPanel::SendAnycastCmd(LedCard card, int iProgramIndex, bool isSingle) {
|
void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
QTcpSocket *send = new QTcpSocket();
|
|
||||||
connect(send, SIGNAL(connected()), this, SLOT(connect_sucessful()));
|
|
||||||
connect(send, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(show_error(QAbstractSocket::SocketError)));
|
|
||||||
send->connectToHost(QHostAddress(card.ip),31299);
|
|
||||||
|
|
||||||
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
||||||
tempStreadPakcet.ucCommType=0x97;
|
tempStreadPakcet.ucCommType = 0x97;
|
||||||
tempStreadPakcet.iBaoLiu=0;
|
tempStreadPakcet.iBaoLiu = 0;
|
||||||
tempStreadPakcet.iLength=4;
|
tempStreadPakcet.iLength = 4;
|
||||||
unsigned char uctemp[4]={0};
|
unsigned char uctemp[4] = {0};
|
||||||
uctemp[0]=iProgramIndex;
|
uctemp[0] = progIdx;
|
||||||
|
memcpy(tempStreadPakcet.pDataBuffer, uctemp, 4);
|
||||||
memcpy(tempStreadPakcet.pDataBuffer,uctemp,4);
|
tempStreadPakcet.pDataBuffer[tempStreadPakcet.iLength] = GetCheckCodeIn8(&tempStreadPakcet.ucCommType,tempStreadPakcet.iLength+sizeof(tempStreadPakcet.iBaoLiu)+sizeof(tempStreadPakcet.ucCommType)+sizeof(tempStreadPakcet.iLength));
|
||||||
tempStreadPakcet.pDataBuffer[tempStreadPakcet.iLength]=GetCheckCodeIn8(&tempStreadPakcet.ucCommType,tempStreadPakcet.iLength+sizeof(tempStreadPakcet.iBaoLiu)+sizeof(tempStreadPakcet.ucCommType)+sizeof(tempStreadPakcet.iLength));
|
int iLenPacket = 3*sizeof(unsigned char) + sizeof(char) + sizeof(int) + sizeof(int) + tempStreadPakcet.iLength + sizeof(char); //除正文外的协议结构大小;
|
||||||
int iLenPacket=3*sizeof(unsigned char)+sizeof(char)+sizeof(int)+sizeof(int)+tempStreadPakcet.iLength+sizeof(char);/////除正文外的协议结构大小;
|
auto data = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
||||||
QByteArray databuf = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
auto action = progIdx==0 ? tr("Reset loop mode") : tr("Anycast");
|
||||||
if(!send->waitForConnected(10000)) //等待连接返回
|
if(gSelCards.count() == 1) {
|
||||||
{
|
auto waitingDlg = new WaitingDlg(this, action+" ...");
|
||||||
if(isSingle) QMessageBox::information(this, tr("Tip"), tr("Connect timeout"));
|
waitingDlg->show();
|
||||||
else gFdResInfo->append(card.id+":"+tr("receive")+"<-"+tr("Connect")+":"+tr("timeout"));
|
auto card = gSelCards[0];
|
||||||
send->close();
|
auto tcp = new TcpSocket;
|
||||||
delete send;
|
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
||||||
return;
|
tcp->abort();
|
||||||
|
tcp->deleteLater();
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->write(data);
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
waitingDlg->success();
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, tr("Tip"), QString(socketErrKey(err))+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
|
});
|
||||||
|
tcp->connectToHost(card.ip, 31299);
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto tcp = new TcpSocket;
|
||||||
|
auto cardId = card.id;
|
||||||
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->write(data);
|
||||||
|
tcp->startTimer(10000);
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::readyRead, tcp, [=] {
|
||||||
|
tcp->stopTimer();
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
gFdResInfo->append(cardId+" "+action+" "+tr("Success"));
|
||||||
|
});
|
||||||
|
connect(tcp, &QTcpSocket::errorOccurred, tcp, [=](QAbstractSocket::SocketError err) {
|
||||||
|
tcp->close();
|
||||||
|
tcp->deleteLater();
|
||||||
|
gFdResInfo->append(cardId+" "+action+" "+socketErrKey(err)+" ("+QString::number(err)+") "+tcp->errorString());
|
||||||
|
});
|
||||||
|
tcp->connectToHost(card.ip, 31299);
|
||||||
|
tcp->startTimer(10000);
|
||||||
}
|
}
|
||||||
send->write(databuf);
|
|
||||||
if(send->waitForBytesWritten(3000)) {
|
|
||||||
send->read(send->bytesAvailable());
|
|
||||||
if(isSingle) QMessageBox::information(this, tr("Tip"), (iProgramIndex==0 ? tr("Reset loop mode") : tr("Anycast"))+":"+tr("success"));
|
|
||||||
else gFdResInfo->append(card.id+":"+tr("receive")+"<-"+tr("Anycast")+":"+tr("success"));
|
|
||||||
}
|
}
|
||||||
send->close();
|
|
||||||
delete send;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef CTRLTESTPANEL_H
|
#ifndef CTRLTESTPANEL_H
|
||||||
#define CTRLTESTPANEL_H
|
#define CTRLTESTPANEL_H
|
||||||
|
|
||||||
#include "globaldefine.h"
|
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
@ -20,7 +19,7 @@ protected:
|
||||||
signals:
|
signals:
|
||||||
void sigSend(QJsonObject &,QString);
|
void sigSend(QJsonObject &,QString);
|
||||||
private:
|
private:
|
||||||
void SendAnycastCmd(LedCard, int, bool);
|
void SendAnycastCmd(int);
|
||||||
|
|
||||||
QLabel *labelTestScreen;
|
QLabel *labelTestScreen;
|
||||||
QGroupBox *groupBox;
|
QGroupBox *groupBox;
|
||||||
|
@ -58,10 +57,10 @@ private:
|
||||||
QRadioButton *radioButton_Blue;
|
QRadioButton *radioButton_Blue;
|
||||||
QRadioButton *radioButton_White;
|
QRadioButton *radioButton_White;
|
||||||
QPushButton *pushButtonStartColor;
|
QPushButton *pushButtonStartColor;
|
||||||
QPushButton *pushButtonStopTest;
|
QPushButton *btnStopTest;
|
||||||
QLineEdit *lineEdit;
|
QLineEdit *fdAnycast;
|
||||||
QPushButton *pushButton_11;
|
QPushButton *btnAnycastClear;
|
||||||
QPushButton *pushButton_12;
|
QPushButton *btnAnycastReset;
|
||||||
QPushButton *btnAnycast;
|
QPushButton *btnAnycast;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -194,11 +194,11 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
item->fdProgress->setValue(0);
|
item->fdProgress->setValue(0);
|
||||||
NetReq req("http://"+item->text("ip")+":2016/upload?type="+(isApk ? "software":"hardware"));
|
NetReq req("http://"+item->text("ip")+":2016/upload?type="+(isApk ? "software":"hardware"));
|
||||||
auto reply = req.timeout(60000).type("multipart/form-data; boundary="+Boundary).post(data);
|
auto reply = req.timeout(60000).type("multipart/form-data; boundary="+Boundary).post(data);
|
||||||
connect(reply, &QNetworkReply::uploadProgress, item->fdProgress, [item](qint64 bytesSent, qint64 bytesTotal) {
|
connect(reply, &QNetworkReply::uploadProgress, item, [item](qint64 bytesSent, qint64 bytesTotal) {
|
||||||
if(bytesTotal==0) return;
|
if(bytesTotal==0) return;
|
||||||
item->fdProgress->setValue(bytesSent*100/bytesTotal);
|
item->fdProgress->setValue(bytesSent*100/bytesTotal);
|
||||||
});
|
});
|
||||||
ConnReply(reply, item->fdProgress) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
auto err = errStrWithData(reply);
|
auto err = errStrWithData(reply);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
item->setResult(tr("Upload error")+": "+err, Qt::red);
|
item->setResult(tr("Upload error")+": "+err, Qt::red);
|
||||||
|
@ -206,7 +206,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
item->fdProgress->setValue(100);
|
item->fdProgress->setValue(100);
|
||||||
auto info = tr("Installing")+" ...";
|
auto info = tr("Upgrading")+" ...";
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
if(isApk) {
|
if(isApk) {
|
||||||
json.insert("_id", "UpgradeSoftware");
|
json.insert("_id", "UpgradeSoftware");
|
||||||
|
@ -220,7 +220,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
}
|
}
|
||||||
item->setResult(info);
|
item->setResult(info);
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
||||||
ConnReply(reply, item->fdProgress) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
if(item->treeWidget()==0) return;
|
if(item->treeWidget()==0) return;
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = checkReplyForJson(reply, &json);
|
||||||
|
@ -277,7 +277,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
json.insert("_type", "UninstallSoftware");
|
json.insert("_type", "UninstallSoftware");
|
||||||
json.insert("packageName", strApkName);
|
json.insert("packageName", strApkName);
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [reply, item, strApkName] {
|
ConnReply(reply, item) [reply, item, strApkName] {
|
||||||
QString err = checkReplyForJson(reply, "error");
|
QString err = checkReplyForJson(reply, "error");
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
item->setResult(tr("Uninstall error")+": "+err, Qt::red);
|
item->setResult(tr("Uninstall error")+": "+err, Qt::red);
|
||||||
|
@ -301,7 +301,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
json.insert("_type", "IsSoftwareRunning");
|
json.insert("_type", "IsSoftwareRunning");
|
||||||
json.insert("packageName", strApkName);
|
json.insert("packageName", strApkName);
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(60000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [reply, item, strApkName] {
|
ConnReply(reply, item) [reply, item, strApkName] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
auto err = errStrWithData(reply, &json);
|
auto err = errStrWithData(reply, &json);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
|
@ -365,7 +365,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
item->btnUnlock = new QPushButton;
|
item->btnUnlock = new QPushButton;
|
||||||
item->btnUnlock->setMaximumHeight(36);
|
item->btnUnlock->setMaximumHeight(36);
|
||||||
item->setCellWidget("encrypt", item->btnUnlock);
|
item->setCellWidget("encrypt", item->btnUnlock);
|
||||||
connect(item->btnUnlock, &QPushButton::clicked, item->btnUnlock, [=] {
|
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
|
||||||
if(! item->isLocked) return;
|
if(! item->isLocked) return;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
||||||
|
@ -491,7 +491,7 @@ void UpgradeApkDialog::sendProgress(UpdateApkItem *item) {
|
||||||
json.insert("_id", "GetFpgaUpdateProgress");
|
json.insert("_id", "GetFpgaUpdateProgress");
|
||||||
json.insert("_type", "GetFpgaUpdateProgress");
|
json.insert("_type", "GetFpgaUpdateProgress");
|
||||||
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(30000).post(json);
|
auto reply = NetReq("http://"+item->text("ip")+":2016/settings").timeout(30000).post(json);
|
||||||
ConnReply(reply, item->fdProgress) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
if(item->treeWidget()==0) return;
|
if(item->treeWidget()==0) return;
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = checkReplyForJson(reply, &json);
|
||||||
|
|
|
@ -18,7 +18,7 @@ protected:
|
||||||
LoQTreeWidget *table;
|
LoQTreeWidget *table;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UpdateApkItem : public TreeWidgetItem {
|
class UpdateApkItem : public TreeWidgetItem, public QObject {
|
||||||
public:
|
public:
|
||||||
using TreeWidgetItem::TreeWidgetItem;
|
using TreeWidgetItem::TreeWidgetItem;
|
||||||
void setResult(QString tip, QColor color = Qt::blue) {
|
void setResult(QString tip, QColor color = Qt::blue) {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
#ifndef DEVICEITEM_H
|
#ifndef DEVICEITEM_H
|
||||||
#define DEVICEITEM_H
|
#define DEVICEITEM_H
|
||||||
|
|
||||||
#include <QPushButton>
|
|
||||||
#include "base/loqtreewidget.h"
|
#include "base/loqtreewidget.h"
|
||||||
#include "globaldefine.h"
|
#include "globaldefine.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QDialog>
|
#include <QPushButton>
|
||||||
|
|
||||||
class DeviceItem : public TreeWidgetItem {
|
class DeviceItem : public TreeWidgetItem, public QObject {
|
||||||
public:
|
public:
|
||||||
explicit DeviceItem(LoQTreeWidget *);
|
explicit DeviceItem(LoQTreeWidget *);
|
||||||
void init();
|
void init();
|
||||||
|
|
|
@ -258,14 +258,14 @@ QPushButton:hover {background-color: #08b;}
|
||||||
}
|
}
|
||||||
init(item);
|
init(item);
|
||||||
nDeviceNum->setText(QString::number(mDeviceTable->topLevelItemCount()));
|
nDeviceNum->setText(QString::number(mDeviceTable->topLevelItemCount()));
|
||||||
{
|
// {
|
||||||
QJsonObject json;
|
// QJsonObject json;
|
||||||
json.insert("_id", "SyncTime");
|
// json.insert("_id", "SyncTime");
|
||||||
json.insert("_type", "SyncTime");
|
// json.insert("_type", "SyncTime");
|
||||||
json.insert("time", QDateTime::currentDateTime().toMSecsSinceEpoch());
|
// json.insert("time", QDateTime::currentDateTime().toMSecsSinceEpoch());
|
||||||
auto reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(60000).post(json);
|
// auto reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(60000).post(json);
|
||||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
// connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||||
}
|
// }
|
||||||
end:;
|
end:;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -459,7 +459,10 @@ void DevicePanel::newCtrl() {
|
||||||
|
|
||||||
auto vBox2 = new QVBoxLayout();
|
auto vBox2 = new QVBoxLayout();
|
||||||
|
|
||||||
fdInfo = new QTextEdit();
|
fdInfo = new QTextEdit;
|
||||||
|
auto ft = fdInfo->font();
|
||||||
|
ft.setFamily("Consolas");
|
||||||
|
fdInfo->setFont(ft);
|
||||||
gFdResInfo = fdInfo;
|
gFdResInfo = fdInfo;
|
||||||
fdInfo->setReadOnly(true);
|
fdInfo->setReadOnly(true);
|
||||||
fdInfo->setMaximumWidth(360);
|
fdInfo->setMaximumWidth(360);
|
||||||
|
@ -502,7 +505,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
json.insert("_id", "GetBuildInformation");
|
json.insert("_id", "GetBuildInformation");
|
||||||
json.insert("_type", "GetBuildInformation");
|
json.insert("_type", "GetBuildInformation");
|
||||||
auto reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
@ -520,7 +523,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
json.insert("_id", "GetScreenSize");
|
json.insert("_id", "GetScreenSize");
|
||||||
json.insert("_type", "GetScreenSize");
|
json.insert("_type", "GetScreenSize");
|
||||||
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
@ -534,7 +537,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
json.insert("_id", "GetBrightness");
|
json.insert("_id", "GetBrightness");
|
||||||
json.insert("_type", "GetBrightness");
|
json.insert("_type", "GetBrightness");
|
||||||
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
@ -546,7 +549,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
json.insert("_id", "IsScreenOn");
|
json.insert("_id", "IsScreenOn");
|
||||||
json.insert("_type", "IsScreenOn");
|
json.insert("_type", "IsScreenOn");
|
||||||
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
@ -558,7 +561,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
json.insert("_id", "GetCardAlias");
|
json.insert("_id", "GetCardAlias");
|
||||||
json.insert("_type", "GetCardAlias");
|
json.insert("_type", "GetCardAlias");
|
||||||
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
@ -570,7 +573,7 @@ void DevicePanel::init(DeviceItem *item) {
|
||||||
json.insert("_id", "HasControllerPassword");
|
json.insert("_id", "HasControllerPassword");
|
||||||
json.insert("_type", "HasControllerPassword");
|
json.insert("_type", "HasControllerPassword");
|
||||||
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+item->mCard.ip+":2016/settings").timeout(120000).post(json);
|
||||||
ConnReply(reply, item->fdOnline) [=] {
|
ConnReply(reply, item) [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
QString err = checkReplyForJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
|
|
@ -122,18 +122,18 @@ AVFmt::AVFmt(QByteArray url) {
|
||||||
#endif
|
#endif
|
||||||
sink = new QAudioSink(audioDevice, audioFmt);
|
sink = new QAudioSink(audioDevice, audioFmt);
|
||||||
sinkWriter = sink->start();
|
sinkWriter = sink->start();
|
||||||
if(sinkWriter==nullptr) {
|
if(sinkWriter==0) {
|
||||||
au.idx = -1;
|
au.idx = -1;
|
||||||
qCritical()<<"Couldn't Start Audio Output"<<sink->error();
|
qCritical()<<"Couldn't Start Audio Output"<<sink->error();
|
||||||
} else {
|
} else {
|
||||||
const AVCodec *decoder = avcodec_find_decoder(codecpar->codec_id);
|
const AVCodec *decoder = avcodec_find_decoder(codecpar->codec_id);
|
||||||
if(decoder==nullptr) {
|
if(decoder==0) {
|
||||||
au.idx = -1;
|
au.idx = -1;
|
||||||
qWarning()<<"Couldn't found Audio Decoder";
|
qWarning()<<"Couldn't found Audio Decoder";
|
||||||
} else {
|
} else {
|
||||||
au.ctx = avcodec_alloc_context3(decoder);
|
au.ctx = avcodec_alloc_context3(decoder);
|
||||||
avcodec_parameters_to_context(au.ctx, codecpar);
|
avcodec_parameters_to_context(au.ctx, codecpar);
|
||||||
if(avcodec_open2(au.ctx, decoder, nullptr) < 0) {
|
if(avcodec_open2(au.ctx, decoder, 0) < 0) {
|
||||||
au.idx = -1;
|
au.idx = -1;
|
||||||
qWarning()<<"Couldn't open aCodecCtx";
|
qWarning()<<"Couldn't open aCodecCtx";
|
||||||
} else {
|
} else {
|
||||||
|
@ -171,18 +171,18 @@ AVFmt::AVFmt(QByteArray url) {
|
||||||
if(vi.idx > -1) vi.thd = new thread(&AVFmt::mainViDecode, this);
|
if(vi.idx > -1) vi.thd = new thread(&AVFmt::mainViDecode, this);
|
||||||
}
|
}
|
||||||
AVFmt::~AVFmt() {
|
AVFmt::~AVFmt() {
|
||||||
if(read_thd!=nullptr) {
|
if(read_thd) {
|
||||||
acts.lockAddNtf(new Act{0, nullptr, 'Q'});
|
acts.lockAddNtf(new Act{0, 0, 'Q'});
|
||||||
read_thd->join();
|
read_thd->join();
|
||||||
delete read_thd;
|
delete read_thd;
|
||||||
qInfo() << "~ read thread";
|
qInfo() << "~ read thread";
|
||||||
}
|
}
|
||||||
if(au.thd!=nullptr) {
|
if(au.thd) {
|
||||||
au.thd->join();
|
au.thd->join();
|
||||||
delete au.thd;
|
delete au.thd;
|
||||||
qInfo() << "~ au thread";
|
qInfo() << "~ au thread";
|
||||||
}
|
}
|
||||||
if(vi.thd!=nullptr) {
|
if(vi.thd) {
|
||||||
vi.thd->join();
|
vi.thd->join();
|
||||||
delete vi.thd;
|
delete vi.thd;
|
||||||
qInfo() << "~ vi thread";
|
qInfo() << "~ vi thread";
|
||||||
|
@ -199,7 +199,7 @@ void AVFmt::mainRead() {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
auto act = wait==0 ? acts.lockPoll() : acts.take(wait);
|
auto act = wait==0 ? acts.lockPoll() : acts.take(wait);
|
||||||
while(act!=nullptr) {
|
while(act) {
|
||||||
if(act->act=='S') {
|
if(act->act=='S') {
|
||||||
if(au.idx!=-1) {
|
if(au.idx!=-1) {
|
||||||
unique_lock<mutex> lock(au.pkts.mtx);
|
unique_lock<mutex> lock(au.pkts.mtx);
|
||||||
|
@ -616,12 +616,12 @@ void FFPlayer::updFrame() {
|
||||||
}
|
}
|
||||||
auto now_epoch = chrono::duration_cast<chrono::microseconds>(chrono::steady_clock::now().time_since_epoch()).count();
|
auto now_epoch = chrono::duration_cast<chrono::microseconds>(chrono::steady_clock::now().time_since_epoch()).count();
|
||||||
dur = now_epoch - last_epoch;
|
dur = now_epoch - last_epoch;
|
||||||
|
last_epoch = now_epoch;
|
||||||
|
if(dur>100000) return;
|
||||||
if(dur<4000) {
|
if(dur<4000) {
|
||||||
qWarning()<<"FFPlayer UpdFrame Fail: dur"<<dur;
|
qWarning()<<"FFPlayer UpdFrame Fail: dur"<<dur;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
last_epoch = now_epoch;
|
|
||||||
if(dur>100000) return;
|
|
||||||
ctx->checkAndUpd(this, now_epoch);
|
ctx->checkAndUpd(this, now_epoch);
|
||||||
viSize = ctx->vi_frms.size;
|
viSize = ctx->vi_frms.size;
|
||||||
auSize = ctx->au_frms.size;
|
auSize = ctx->au_frms.size;
|
||||||
|
|
|
@ -25,18 +25,18 @@ public:
|
||||||
delAll();
|
delAll();
|
||||||
}
|
}
|
||||||
void add(T *node) {
|
void add(T *node) {
|
||||||
if(node==nullptr) {
|
if(node==0) {
|
||||||
throw std::invalid_argument("node is null");
|
throw std::invalid_argument("node is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(last!=nullptr) last->next = node;
|
if(last) last->next = node;
|
||||||
else first = node;
|
else first = node;
|
||||||
last = node;
|
last = node;
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
void remove() {
|
void remove() {
|
||||||
if(first==nullptr) return;
|
if(first==0) return;
|
||||||
if(first==last) first = last = nullptr;
|
if(first==last) first = last = 0;
|
||||||
else first = first->next;
|
else first = first->next;
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
void delAll() {
|
void delAll() {
|
||||||
while(first!=nullptr) delete poll();
|
while(first) delete poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
T *volatile first{0};
|
T *volatile first{0};
|
||||||
|
@ -154,7 +154,6 @@ public:
|
||||||
avcodec_free_context(&ctx);
|
avcodec_free_context(&ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class FFPlayer;
|
|
||||||
class AVFmt {
|
class AVFmt {
|
||||||
friend class FFPlayer;
|
friend class FFPlayer;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
QString gFileHome;
|
QString gFileHome;
|
||||||
QString gApkHome;
|
QString gApkHome;
|
||||||
QList<LedCard> gSelCards;
|
QList<LedCard> gSelCards;
|
||||||
bool gVideoCompress = true;
|
bool gVideoCompress = false;
|
||||||
bool gVideoTranscoding = true;
|
bool gVideoTranscoding = false;
|
||||||
bool gTextAntialiasing = false;
|
bool gTextAntialiasing = false;
|
||||||
bool gWidthSplit = false;
|
bool gWidthSplit = false;
|
||||||
int gSendBatch = 5;
|
int gSendBatch = 5;
|
||||||
bool gHideDetect = false;
|
bool gHideDetect = false;
|
||||||
|
bool gShowAlias = false;
|
||||||
bool gShowLora = false;
|
bool gShowLora = false;
|
||||||
|
|
||||||
DeviceItem *findItem(QString id) {
|
DeviceItem *findItem(QString id) {
|
||||||
|
|
|
@ -51,6 +51,7 @@ extern bool gTextAntialiasing;
|
||||||
extern bool gWidthSplit;
|
extern bool gWidthSplit;
|
||||||
extern int gSendBatch;
|
extern int gSendBatch;
|
||||||
extern bool gHideDetect;
|
extern bool gHideDetect;
|
||||||
|
extern bool gShowAlias;
|
||||||
extern bool gShowLora;
|
extern bool gShowLora;
|
||||||
|
|
||||||
extern quint64 dirFileSize(const QString &path);
|
extern quint64 dirFileSize(const QString &path);
|
||||||
|
|
|
@ -157,55 +157,4 @@ protected:
|
||||||
bool connAndExec(int msecs, QEventLoop *loop);
|
bool connAndExec(int msecs, QEventLoop *loop);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NetReplyData {
|
|
||||||
QNetworkReply* reply;
|
|
||||||
size_t cnt = 1;
|
|
||||||
bool isDeleted = false;
|
|
||||||
};
|
|
||||||
class NetReply {
|
|
||||||
public:
|
|
||||||
NetReply(QNetworkReply *reply) : ptr{new NetReplyData{reply}} {}
|
|
||||||
~NetReply() {
|
|
||||||
if(ptr->cnt > 1) ptr->cnt--;
|
|
||||||
else {
|
|
||||||
if(! ptr->isDeleted) ptr->reply->deleteLater();
|
|
||||||
delete ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NetReply(const NetReply &other) : ptr{other.ptr} {
|
|
||||||
ptr->cnt++;
|
|
||||||
}
|
|
||||||
NetReply &operator=(const NetReply &other) {
|
|
||||||
NetReply ooo(other);
|
|
||||||
auto aaa = ptr;
|
|
||||||
ptr = ooo.ptr;
|
|
||||||
ooo.ptr = aaa;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
NetReply(NetReply &&other) noexcept : ptr(other.ptr) {
|
|
||||||
other.ptr = 0;
|
|
||||||
}
|
|
||||||
NetReply &operator=(NetReply &&other) noexcept {
|
|
||||||
auto aaa = ptr;
|
|
||||||
ptr = other.ptr;
|
|
||||||
other.ptr = aaa;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void deleteLater() {
|
|
||||||
if(ptr->isDeleted) return;
|
|
||||||
ptr->reply->deleteLater();
|
|
||||||
ptr->isDeleted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkReply *operator*() const {
|
|
||||||
return ptr->reply;
|
|
||||||
}
|
|
||||||
QNetworkReply *operator->() const {
|
|
||||||
return ptr->reply;
|
|
||||||
}
|
|
||||||
NetReplyData *ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QNETWORK_H
|
#endif // QNETWORK_H
|
||||||
|
|
|
@ -38,7 +38,7 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
#endif
|
#endif
|
||||||
QApplication::setOrganizationName("Shanghai Xixun Electronic Technology Co., Ltd.");
|
QApplication::setOrganizationName("Sysolution");
|
||||||
QApplication::setOrganizationDomain("www.ledok.cn");
|
QApplication::setOrganizationDomain("www.ledok.cn");
|
||||||
QApplication::setApplicationName("LedOK Express");
|
QApplication::setApplicationName("LedOK Express");
|
||||||
QApplication::setStyle("Fusion");
|
QApplication::setStyle("Fusion");
|
||||||
|
|
|
@ -98,6 +98,16 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
});
|
});
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
auto MainGeo = settings.value("MainGeo");
|
||||||
|
if(! MainGeo.isValid()) {
|
||||||
|
QSettings old("Shanghai Xixun Electronic Technology Co., Ltd.", "LedOK Express");
|
||||||
|
MainGeo = old.value("MainGeo");
|
||||||
|
if(MainGeo.isValid()) {
|
||||||
|
auto keys = old.allKeys();
|
||||||
|
for(auto &key : keys) settings.setValue(key, old.value(key));
|
||||||
|
old.remove("");
|
||||||
|
}
|
||||||
|
}
|
||||||
QString langName = settings.value("Language").toString();
|
QString langName = settings.value("Language").toString();
|
||||||
QAction *actLan = 0;
|
QAction *actLan = 0;
|
||||||
if(! langName.isEmpty()) {
|
if(! langName.isEmpty()) {
|
||||||
|
@ -120,7 +130,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
emit menuLang->triggered(actLan);
|
emit menuLang->triggered(actLan);
|
||||||
QCoreApplication::installTranslator(&translator);
|
QCoreApplication::installTranslator(&translator);
|
||||||
|
|
||||||
auto geo = settings.value("MainGeo").toRect();
|
auto geo = MainGeo.toRect();
|
||||||
if(geo.width()>=800 && geo.height()>=500 && geo.x()>=-600 && geo.x()<=1280 && geo.y()>=-200 && geo.y()<=800) setGeometry(geo);
|
if(geo.width()>=800 && geo.height()>=500 && geo.x()>=-600 && geo.x()<=1280 && geo.y()>=-200 && geo.y()<=800) setGeometry(geo);
|
||||||
else resize(1280, 800);
|
else resize(1280, 800);
|
||||||
if(settings.value("MainIsMax", false).toBool()) setWindowState(Qt::WindowMaximized);
|
if(settings.value("MainIsMax", false).toBool()) setWindowState(Qt::WindowMaximized);
|
||||||
|
@ -136,16 +146,12 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
setPalette(plt);
|
setPalette(plt);
|
||||||
|
|
||||||
//项目保存的文档路径
|
//项目保存的文档路径
|
||||||
QString doc_path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
if(!doc_path.isEmpty()) {
|
if(! dataDir.isEmpty()) {
|
||||||
QDir app_dir = QDir(doc_path + "/" + QCoreApplication::applicationName());
|
QDir dataQDir(dataDir);
|
||||||
if(!app_dir.exists()) {
|
if(! dataQDir.exists()) dataQDir.mkpath(dataDir);
|
||||||
QDir doc_dir(doc_path);
|
|
||||||
doc_dir.mkdir(QCoreApplication::applicationName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建一个垂直布局
|
|
||||||
auto vBox = new VBox(center);
|
auto vBox = new VBox(center);
|
||||||
vBox->setContentsMargins(0, 0, 0, 0);
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
vBox->setSpacing(0);
|
vBox->setSpacing(0);
|
||||||
|
@ -223,6 +229,10 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
fdHideDetect->setChecked(gHideDetect);
|
fdHideDetect->setChecked(gHideDetect);
|
||||||
vBox->addWidget(fdHideDetect);
|
vBox->addWidget(fdHideDetect);
|
||||||
|
|
||||||
|
auto fdShowAlias = new QCheckBox(tr("Show Alias in Terminal Control"));
|
||||||
|
fdShowAlias->setChecked(gShowAlias);
|
||||||
|
vBox->addWidget(fdShowAlias);
|
||||||
|
|
||||||
auto fdShowLora = new QCheckBox(tr("Show Lora Screen"));
|
auto fdShowLora = new QCheckBox(tr("Show Lora Screen"));
|
||||||
fdShowLora->setChecked(gShowLora);
|
fdShowLora->setChecked(gShowLora);
|
||||||
vBox->addWidget(fdShowLora);
|
vBox->addWidget(fdShowLora);
|
||||||
|
@ -238,6 +248,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("ShowAlias", gShowAlias = fdShowAlias->isChecked());
|
||||||
settings.setValue("GuangYingPin", gShowLora = fdShowLora->isChecked());
|
settings.setValue("GuangYingPin", gShowLora = fdShowLora->isChecked());
|
||||||
dlg.accept();
|
dlg.accept();
|
||||||
});
|
});
|
||||||
|
@ -245,6 +256,16 @@ 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(gShowAlias) {
|
||||||
|
mDevicePanel->mDeviceTable->showColumn("alias");
|
||||||
|
mDevicePanel->mDeviceTable->hideColumn("ip");
|
||||||
|
} else {
|
||||||
|
mDevicePanel->mDeviceTable->hideColumn("alias");
|
||||||
|
mDevicePanel->mDeviceTable->showColumn("ip");
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
@ -351,7 +372,11 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
#if(QT_VERSION_MAJOR > 5)
|
||||||
|
updates = json["win-64"].toObject();
|
||||||
|
#else
|
||||||
updates = json["win"].toObject();
|
updates = json["win"].toObject();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
updates = json["mac"].toObject();
|
updates = json["mac"].toObject();
|
||||||
|
@ -470,7 +495,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
mDevicePanel->mDeviceTable->fdCheckAll->hide();
|
mDevicePanel->mDeviceTable->fdCheckAll->hide();
|
||||||
mDevicePanel->fdCardNumInfo->hide();
|
mDevicePanel->fdCardNumInfo->hide();
|
||||||
if(mDevicePanel->mDeviceCtrlPanel) {
|
if(mDevicePanel->mDeviceCtrlPanel) {
|
||||||
for(int j="screenSize"**mDevicePanel->mDeviceTable; j<mDevicePanel->mDeviceTable->columnCount(); j++) mDevicePanel->mDeviceTable->showColumn(j);
|
for(int j="id"**mDevicePanel->mDeviceTable+1; j<mDevicePanel->mDeviceTable->columnCount(); j++) mDevicePanel->mDeviceTable->showColumn(j);
|
||||||
mDevicePanel->mDeviceTable->setMaximumWidth(0xffffff);
|
mDevicePanel->mDeviceTable->setMaximumWidth(0xffffff);
|
||||||
mDevicePanel->mDeviceCtrlPanel->hide();
|
mDevicePanel->mDeviceCtrlPanel->hide();
|
||||||
}
|
}
|
||||||
|
@ -478,10 +503,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();
|
||||||
for(int j="screenSize"**mDevicePanel->mDeviceTable; j<mDevicePanel->mDeviceTable->columnCount(); j++) mDevicePanel->mDeviceTable->hideColumn(j);
|
auto specialIdx = (gShowAlias ? "alias" : "ip")**mDevicePanel->mDeviceTable;
|
||||||
|
for(int j="id"**mDevicePanel->mDeviceTable+1; j<mDevicePanel->mDeviceTable->columnCount(); j++) if(j!=specialIdx) 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(340);
|
mDevicePanel->mDeviceTable->setMaximumWidth(300);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -527,18 +553,27 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdDetectCard);
|
hBox->addWidget(fdDetectCard);
|
||||||
|
|
||||||
|
// auto btn = new QPushButton("Test");
|
||||||
|
// connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
// auto www = new TTTWgt;
|
||||||
|
// www->show();
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(btn);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox->addLabel("V" APP_VERSION" - " __DATE__);
|
hBox->addLabel("V" APP_VERSION" - " __DATE__);
|
||||||
|
|
||||||
gApkHome = settings.value("ApkHome").toString();
|
gApkHome = settings.value("ApkHome").toString();
|
||||||
gVideoCompress = settings.value("VideoCompress", true).toBool();
|
gVideoCompress = settings.value("VideoCompress").toBool();
|
||||||
gVideoTranscoding = settings.value("VideoTranscoding", true).toBool();
|
gVideoTranscoding = settings.value("VideoTranscoding").toBool();
|
||||||
gTextAntialiasing = settings.value("TextAntialiasing", false).toBool();
|
gTextAntialiasing = settings.value("TextAntialiasing").toBool();
|
||||||
gWidthSplit = settings.value("WidthSplit", false).toBool();
|
gWidthSplit = settings.value("WidthSplit").toBool();
|
||||||
gSendBatch = settings.value("SendBatch", 5).toInt();
|
gSendBatch = settings.value("SendBatch", 5).toInt();
|
||||||
gHideDetect = settings.value("HideDetect", false).toBool();
|
gHideDetect = settings.value("HideDetect").toBool();
|
||||||
gShowLora = settings.value("GuangYingPin", false).toBool();
|
gShowAlias = settings.value("ShowAlias").toBool();
|
||||||
|
gShowLora = settings.value("GuangYingPin").toBool();
|
||||||
|
|
||||||
if(gHideDetect) fdDetectCard->hide();
|
if(gHideDetect) fdDetectCard->hide();
|
||||||
if(! gShowLora) mBtnGrp->button(MainPage_LoraScreen)->hide();
|
if(! gShowLora) mBtnGrp->button(MainPage_LoraScreen)->hide();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "progpanel.h"
|
#include "progpanel.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
class MainWindow : public BaseWin {
|
class MainWindow : public BaseWin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -10,10 +10,10 @@ EleGif::EleGif(QString path, QWidget *parent) : QWidget{parent} {
|
||||||
|
|
||||||
void EleGif::paintEvent(QPaintEvent *){
|
void EleGif::paintEvent(QPaintEvent *){
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
if(movie!=nullptr) {
|
if(movie) {
|
||||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||||
painter.drawPixmap(0, 0, width(), height(), movie->currentPixmap());
|
painter.drawPixmap(0, 0, width(), height(), movie->currentPixmap());
|
||||||
if(timer==nullptr) {
|
if(timer==0) {
|
||||||
timer = new SyncTimer(movie->nextFrameDelay());
|
timer = new SyncTimer(movie->nextFrameDelay());
|
||||||
connect(timer, &SyncTimer::timeout, this, &EleGif::sltNext, Qt::BlockingQueuedConnection);
|
connect(timer, &SyncTimer::timeout, this, &EleGif::sltNext, Qt::BlockingQueuedConnection);
|
||||||
timer->start();
|
timer->start();
|
||||||
|
@ -25,8 +25,8 @@ void EleGif::sltNext(){
|
||||||
movie->jumpToNextFrame();
|
movie->jumpToNextFrame();
|
||||||
timer->inter = movie->nextFrameDelay();
|
timer->inter = movie->nextFrameDelay();
|
||||||
update();
|
update();
|
||||||
} else if(timer!=nullptr) {
|
} else if(timer) {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
timer = nullptr;
|
timer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
#include "elemultipng.h"
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QTimerEvent>
|
|
||||||
|
|
||||||
const QChar effTypes[] = {'l', 't', 'r', 'b'};
|
|
||||||
|
|
||||||
EleMultiPng::EleMultiPng(QString dirPre, const JValue &maps, QWidget *parent) : QWidget{parent} {
|
|
||||||
auto map = maps[0];
|
|
||||||
picDur = map["picDuration"].toInt()*1000;
|
|
||||||
if(picDur==0) return;
|
|
||||||
EffDur = map["effectSpeed"].toInt()*1000;
|
|
||||||
for(auto &map : maps) imgs.append(dirPre+map["id"].toString());
|
|
||||||
auto effStr = map["effect"].toString();
|
|
||||||
if(effStr.isEmpty() || effStr=="no") EffDur = 0;
|
|
||||||
else if(effStr.endsWith("left")) effType = 'l';
|
|
||||||
else if(effStr.endsWith("top")) effType = 't';
|
|
||||||
else if(effStr.endsWith("right")) effType = 'r';
|
|
||||||
else if(effStr.endsWith("bottom")) effType = 'b';
|
|
||||||
else if(effStr == "random") needRand = true;
|
|
||||||
else EffDur = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EleMultiPng::startMove() {
|
|
||||||
if(EffDur==0) return;
|
|
||||||
if(needRand) effType = effTypes[rand.generate() % 4];
|
|
||||||
double effDurD = EffDur;
|
|
||||||
if(effType=='l') {
|
|
||||||
imgx = width();
|
|
||||||
imgy = 0;
|
|
||||||
effDurD /= width();
|
|
||||||
} else if(effType=='r') {
|
|
||||||
imgx = -width();
|
|
||||||
imgy = 0;
|
|
||||||
effDurD /= width();
|
|
||||||
} else if(effType=='t') {
|
|
||||||
imgx = 0;
|
|
||||||
imgy = height();
|
|
||||||
effDurD /= height();
|
|
||||||
} else if(effType=='b') {
|
|
||||||
imgx = 0;
|
|
||||||
imgy = -height();
|
|
||||||
effDurD /= height();
|
|
||||||
} else return;
|
|
||||||
movePx = ceil(17/effDurD);
|
|
||||||
moveInter = effDurD*movePx;
|
|
||||||
moveTimerId = startTimer(moveInter, Qt::PreciseTimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EleMultiPng::paintEvent(QPaintEvent *) {
|
|
||||||
if(timerId==0 && (EffDur!=0 || imgs.size()>1)) {
|
|
||||||
timerId = startTimer(picDur, Qt::PreciseTimer);
|
|
||||||
startMove();
|
|
||||||
}
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
|
||||||
painter.drawPixmap(imgx, imgy, imgs[imgc]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EleMultiPng::timerEvent(QTimerEvent *e) {
|
|
||||||
if(isVisible()) {
|
|
||||||
int id = e->timerId();
|
|
||||||
if(id==timerId){
|
|
||||||
if(imgc+2 > imgs.size()) imgc = 0;
|
|
||||||
else imgc++;
|
|
||||||
startMove();
|
|
||||||
} else if(id==moveTimerId){
|
|
||||||
if(effType=='l') {
|
|
||||||
imgx -= movePx;
|
|
||||||
if(imgx < 0) imgx = 0;
|
|
||||||
} else if(effType=='t') {
|
|
||||||
imgy -= movePx;
|
|
||||||
if(imgy < 0) imgy = 0;
|
|
||||||
} else if(effType=='r') {
|
|
||||||
imgx += movePx;
|
|
||||||
if(imgx > 0) imgx = 0;
|
|
||||||
} else if(effType=='b') {
|
|
||||||
imgy += movePx;
|
|
||||||
if(imgy > 0) imgy = 0;
|
|
||||||
}
|
|
||||||
if(imgx==0 && imgy==0) {
|
|
||||||
killTimer(moveTimerId);
|
|
||||||
moveTimerId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
foreach(auto split, splits) split->update();
|
|
||||||
} else {
|
|
||||||
if(timerId!=0) {
|
|
||||||
killTimer(timerId);
|
|
||||||
timerId = 0;
|
|
||||||
}
|
|
||||||
if(moveTimerId!=0) {
|
|
||||||
killTimer(moveTimerId);
|
|
||||||
moveTimerId = 0;
|
|
||||||
}
|
|
||||||
imgc = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EleSplitPng::paintEvent(QPaintEvent *) {
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
|
||||||
painter.drawPixmap(multiPng->imgx, multiPng->imgy, multiPng->imgs[multiPng->imgc]);
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
#ifndef ELEMULTIPNG_H
|
|
||||||
#define ELEMULTIPNG_H
|
|
||||||
|
|
||||||
#include "gutil/qjson.h"
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QRandomGenerator>
|
|
||||||
|
|
||||||
class EleSplitPng;
|
|
||||||
class EleMultiPng : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit EleMultiPng(QString, const JValue &, QWidget *parent);
|
|
||||||
void startMove();
|
|
||||||
|
|
||||||
QVector<QPixmap> imgs;
|
|
||||||
int timerId = 0, moveTimerId = 0;
|
|
||||||
int picDur = 0, EffDur = 0, moveInter = 0, movePx = 0, imgc = 0, imgx = 0, imgy = 0;
|
|
||||||
QChar effType{0};
|
|
||||||
QRandomGenerator rand;
|
|
||||||
bool needRand = false;
|
|
||||||
QList<EleSplitPng*> splits;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
void timerEvent(QTimerEvent *) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EleSplitPng : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit EleSplitPng(EleMultiPng *multiPng, QWidget *parent) : QWidget{parent}, multiPng(multiPng) {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
|
|
||||||
EleMultiPng *multiPng;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ELEMULTIPNG_H
|
|
|
@ -1,19 +1,23 @@
|
||||||
#include "elescroll.h"
|
#include "elescroll.h"
|
||||||
#include <QJsonObject>
|
#include "playwin.h"
|
||||||
|
#include <QOpenGLWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <complex>
|
#include <QPaintEvent>
|
||||||
|
|
||||||
EleScroll::EleScroll(QWidget *parent, QString dirPre, const JValue &map) : QWidget{parent} {
|
EleScroll::EleScroll(QWidget *parent, QString dirPre, const JValue &json, int w, int h) : QWidget{parent}, w(w), h(h) {
|
||||||
img.load(dirPre + map["id"].toString());
|
img.load(dirPre + json["id"].toString());
|
||||||
auto effStr = map["effect"].toString();
|
auto effStr = json["effect"].toString();
|
||||||
if(effStr.isEmpty() || effStr=="no") return;
|
if(effStr.isEmpty() || effStr=="no") return;
|
||||||
double effDurD = map["effectSpeed"].toInt()/2;
|
|
||||||
if(effDurD==0) return;
|
auto scrollSpeed = json["scrollSpeed"].toDouble();
|
||||||
auto interva = round(effDurD / 16.666666666666666666);
|
if(scrollSpeed==0) {
|
||||||
if(interva==0) interva = 1;
|
auto scrollDur = json["effectSpeed"].toDouble();
|
||||||
interval = interva * 16.666666666666666666;
|
if(scrollDur==0) return;
|
||||||
step = round(interval / effDurD);
|
scrollSpeed = 1000 / scrollDur;
|
||||||
if(step==0) step = 1;
|
}
|
||||||
|
interval = step = 1;
|
||||||
|
if(scrollSpeed > 60) step = (int) round(scrollSpeed/60);
|
||||||
|
else if(scrollSpeed < 60) interval = (int) round(60/scrollSpeed);
|
||||||
int idx = effStr.lastIndexOf(' ');
|
int idx = effStr.lastIndexOf(' ');
|
||||||
if(idx > -1) {
|
if(idx > -1) {
|
||||||
effect = effStr.at(idx+1).toLatin1();
|
effect = effStr.at(idx+1).toLatin1();
|
||||||
|
@ -23,46 +27,65 @@ EleScroll::EleScroll(QWidget *parent, QString dirPre, const JValue &map) : QWidg
|
||||||
else if(effect=='b') end = img.height()-step;
|
else if(effect=='b') end = img.height()-step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EleScroll::EleScroll(QWidget *parent, QString imgPath, char effect, double effDur) : QWidget{parent}, effect(effect) {
|
EleScroll::EleScroll(QWidget *parent, QString imgPath, char effect, double scrollSpeed) : QWidget{parent}, effect(effect) {
|
||||||
img.load(imgPath);
|
img.load(imgPath);
|
||||||
if(effect==0) return;
|
if(effect==0) return;
|
||||||
if(effDur==0) return;
|
if(scrollSpeed==0) return;
|
||||||
auto interva = round(effDur / 16.666666666666666666);
|
interval = step = 1;
|
||||||
if(interva==0) interva = 1;
|
if(scrollSpeed > 60) step = (int) round(scrollSpeed/60);
|
||||||
interval = interva * 16.666666666666666666;
|
else if(scrollSpeed < 60) interval = (int) round(60/scrollSpeed);
|
||||||
step = round(interval / effDur);
|
|
||||||
if(step==0) step = 1;
|
|
||||||
if(effect=='l') end = -(img.width()-step);
|
if(effect=='l') end = -(img.width()-step);
|
||||||
else if(effect=='r') end = img.width()-step;
|
else if(effect=='r') end = img.width()-step;
|
||||||
else if(effect=='t') end = -(img.height()-step);
|
else if(effect=='t') end = -(img.height()-step);
|
||||||
else if(effect=='b') end = img.height()-step;
|
else if(effect=='b') end = img.height()-step;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EleScroll::paintEvent(QPaintEvent *) {
|
void EleScroll::paintEvent(QPaintEvent *e) {
|
||||||
paint(this);
|
|
||||||
}
|
|
||||||
void EleScroll::paint(QPaintDevice *that) {
|
|
||||||
if(img.isNull()) return;
|
if(img.isNull()) return;
|
||||||
if(timerId==0 && effect!=0 && interval!=0) timerId = startTimer(round(interval), Qt::PreciseTimer);
|
auto rect = e->rect();
|
||||||
QPainter painter(that);
|
QPainter painter(this);
|
||||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||||
if(effect=='l') {
|
if(effect=='l') {
|
||||||
painter.drawPixmap(cur, 0, img);
|
int x = cur;
|
||||||
painter.drawPixmap(cur+img.width(), 0, img);
|
do {
|
||||||
|
if(x > rect.left()-img.width() && x < rect.right()+1) painter.drawPixmap(x, 0, img);
|
||||||
|
x += img.width();
|
||||||
|
} while(x < rect.right()+1);
|
||||||
} else if(effect=='r') {
|
} else if(effect=='r') {
|
||||||
painter.drawPixmap(cur, 0, img);
|
int x = cur + w;
|
||||||
painter.drawPixmap(cur-img.width(), 0, img);
|
boolean con1;
|
||||||
|
do {
|
||||||
|
x -= img.width();
|
||||||
|
con1 = x > rect.left()-img.width();
|
||||||
|
if(con1 && x < rect.right()+1) painter.drawPixmap(x, 0, img);
|
||||||
|
} while(con1);
|
||||||
} else if(effect=='t') {
|
} else if(effect=='t') {
|
||||||
painter.drawPixmap(0, cur, img);
|
int y = cur;
|
||||||
painter.drawPixmap(0, cur+img.height(), img);
|
do {
|
||||||
|
if(y > rect.top()-img.height() && y < rect.bottom()+1) painter.drawPixmap(0, y, img);
|
||||||
|
y += img.height();
|
||||||
|
} while(y < rect.bottom()+1);
|
||||||
} else if(effect=='b') {
|
} else if(effect=='b') {
|
||||||
painter.drawPixmap(0, cur, img);
|
int y = cur + h;
|
||||||
painter.drawPixmap(0, cur-img.height(), img);
|
boolean con1;
|
||||||
|
do {
|
||||||
|
y -= img.height();
|
||||||
|
con1 = y > rect.top()-img.height();
|
||||||
|
if(con1 && y < rect.bottom()+1) painter.drawPixmap(0, y, img);
|
||||||
|
} while(con1);
|
||||||
} else painter.drawPixmap(0, 0, img);
|
} else painter.drawPixmap(0, 0, img);
|
||||||
|
if(freshCnt==0 && effect!=0 && interval!=0) connect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, &EleScroll::doFrame, Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EleScroll::timerEvent(QTimerEvent *) {
|
void EleScroll::doFrame() {
|
||||||
if(isVisible()) {
|
if(! isVisible()) {
|
||||||
|
freshCnt = cur = 0;
|
||||||
|
disconnect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, &EleScroll::doFrame);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(freshCnt < interval) freshCnt++;
|
||||||
|
else {
|
||||||
|
freshCnt = 1;
|
||||||
if(effect=='t' || effect=='l') {
|
if(effect=='t' || effect=='l') {
|
||||||
if(cur <= end) cur -= end;
|
if(cur <= end) cur -= end;
|
||||||
else cur -= step;
|
else cur -= step;
|
||||||
|
@ -71,13 +94,5 @@ void EleScroll::timerEvent(QTimerEvent *) {
|
||||||
else cur += step;
|
else cur += step;
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
for(auto split : splits) split->update();
|
|
||||||
} else if(timerId!=0) {
|
|
||||||
killTimer(timerId);
|
|
||||||
timerId = cur = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EleSplitScroll::paintEvent(QPaintEvent *) {
|
|
||||||
scroll->paint(this);
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,30 +4,19 @@
|
||||||
#include "gutil/qjson.h"
|
#include "gutil/qjson.h"
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class EleSplitScroll;
|
|
||||||
class EleScroll : public QWidget {
|
class EleScroll : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EleScroll(QWidget *, QString, const JValue &);
|
explicit EleScroll(QWidget *, QString, const JValue &, int, int);
|
||||||
explicit EleScroll(QWidget *, QString, char effect = 0, double effDur = 0.0);
|
explicit EleScroll(QWidget *, QString, char effect = 0, double effDur = 0.0);
|
||||||
|
int w = 0, h = 0;
|
||||||
QPixmap img;
|
QPixmap img;
|
||||||
char effect = 0;
|
char effect = 0;
|
||||||
int interval = 0, timerId = 0, cur = 0, end = 0, step = 1;
|
int interval = 0, freshCnt = 0, cur = 0, end = 0, step = 1;
|
||||||
std::vector<EleSplitScroll*> splits;
|
bool noUpdate = false;
|
||||||
void paint(QPaintDevice *);
|
void doFrame();
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
void timerEvent(QTimerEvent *) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class EleSplitScroll : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit EleSplitScroll(QWidget *parent, EleScroll *scroll) : QWidget{parent}, scroll(scroll) {};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
|
|
||||||
EleScroll *scroll;
|
|
||||||
};
|
|
||||||
#endif // ELESCROLL_H
|
#endif // ELESCROLL_H
|
||||||
|
|
|
@ -3,171 +3,182 @@
|
||||||
#include "eleanaclock.h"
|
#include "eleanaclock.h"
|
||||||
#include "eleborder.h"
|
#include "eleborder.h"
|
||||||
#include "elegif.h"
|
#include "elegif.h"
|
||||||
#include "elemultipng.h"
|
|
||||||
#include "elescroll.h"
|
#include "elescroll.h"
|
||||||
#include "eletimer.h"
|
#include "eletimer.h"
|
||||||
#include "elevideo.h"
|
#include "elevideo.h"
|
||||||
|
#include "srccopy.h"
|
||||||
#include "posdlg.h"
|
#include "posdlg.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QMovie>
|
#include <QMovie>
|
||||||
#include <QThread>
|
|
||||||
#include <QWebEngineView>
|
#include <QWebEngineView>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
|
||||||
PlayWin* PlayWin::self = 0;
|
PlayWin* PlayWin::self = 0;
|
||||||
QPoint gPlayPos{0, 0};
|
QPoint gPlayPos{0, 0};
|
||||||
|
|
||||||
Page::Page(QWidget *parent) : QWidget{parent} {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayWin *PlayWin::newIns(int width, int height, QString dir, const JValue &aprog, QWidget *parent) {
|
PlayWin *PlayWin::newIns(int width, int height, QString dir, const JValue &aprog, QWidget *parent) {
|
||||||
if(! gPlayPos.isNull() && QGuiApplication::screenAt(QPoint(gPlayPos.x()+width/2, gPlayPos.y()+height/2))==0) gPlayPos = QPoint();
|
if(! gPlayPos.isNull() && QGuiApplication::screenAt(QPoint(gPlayPos.x()+width/2, gPlayPos.y()+height/2))==0) gPlayPos = QPoint();
|
||||||
return new PlayWin(gPlayPos.x(), gPlayPos.y(), width, height, dir, aprog, parent);
|
return new PlayWin(gPlayPos.x(), gPlayPos.y(), width, height, dir, aprog, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue &aprog, QWidget *parent) : QWidget(parent) {
|
PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue &aprog, QWidget *parent) : QWidget(parent) {
|
||||||
|
self = this;
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setAttribute(Qt::WA_QuitOnClose, false);
|
setAttribute(Qt::WA_QuitOnClose, false);
|
||||||
setWindowFlag(Qt::FramelessWindowHint);
|
setWindowFlag(Qt::FramelessWindowHint);
|
||||||
setWindowFlag(Qt::WindowStaysOnTopHint);
|
setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||||
setGeometry(x, y, width, height);
|
setGeometry(x, y, width, height+1);
|
||||||
QPalette plt = palette();
|
auto plt = palette();
|
||||||
plt.setColor(QPalette::Window, QColor(0,0,0));
|
plt.setColor(QPalette::Window, Qt::black);
|
||||||
setPalette(plt);
|
setPalette(plt);
|
||||||
connect(this, &PlayWin::sigSetVisible, this, &PlayWin::sltSetVisible);
|
gl = new QOpenGLWidget(this);
|
||||||
|
gl->setGeometry(0, height, width, 1);
|
||||||
|
connect(gl, &QOpenGLWidget::frameSwapped, gl, (void(QOpenGLWidget::*)())&QOpenGLWidget::update);
|
||||||
|
auto task = aprog["task"];
|
||||||
|
auto jpages = task["items"];
|
||||||
|
|
||||||
auto pageMaps = aprog["task"]["items"];
|
auto partLengths = task["partLengths"];
|
||||||
EleBase ele; Page *page;
|
auto isVertical = task["isVertical"].toBool();
|
||||||
for(auto &pageMap : pageMaps) {
|
QWidget *box = this;
|
||||||
|
if(partLengths.size() > 1) {
|
||||||
|
box = new QWidget(this);
|
||||||
|
auto width = task["width"].toInt();
|
||||||
|
auto height = task["height"].toInt();
|
||||||
|
box->setGeometry(0, 0, width, height);
|
||||||
|
auto mask = new QWidget(this);
|
||||||
|
mask->setAutoFillBackground(true);
|
||||||
|
auto pal = mask->palette();
|
||||||
|
pal.setColor(QPalette::Window, Qt::black);
|
||||||
|
mask->setPalette(pal);
|
||||||
|
auto len0 = partLengths[0].toInt();
|
||||||
|
isVertical ? mask->setGeometry(0, len0, width, height - len0) : mask->setGeometry(len0, 0, width - len0, height);
|
||||||
|
int x = 0, y = 0;
|
||||||
|
for(int i=1; i<(int)partLengths.size(); i++) {
|
||||||
|
auto part = new SrcCopy(this, box);
|
||||||
|
if(isVertical) {
|
||||||
|
y -= partLengths[i-1].toInt();
|
||||||
|
x += width;
|
||||||
|
part->setGeometry(x, y, width, partLengths[i].toInt() - y);
|
||||||
|
} else {
|
||||||
|
x -= partLengths[i-1].toInt();
|
||||||
|
y += height;
|
||||||
|
part->setGeometry(x, y, partLengths[i].toInt() - x, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(auto &pageMap : jpages) {
|
||||||
auto _program = pageMap["_program"];
|
auto _program = pageMap["_program"];
|
||||||
auto layers = _program["layers"];
|
auto layers = _program["layers"];
|
||||||
if(layers.empty()) continue;
|
if(layers.empty()) continue;
|
||||||
auto splitWidths = _program["splitWidths"];
|
Page page;
|
||||||
page = new Page(this);
|
page.repeatTimes = pageMap["repeatTimes"].toInt();
|
||||||
page->setGeometry(0, 0, width, height);
|
|
||||||
page->setVisible(false);
|
|
||||||
for(int ll=(int)layers.size()-1; ll>=0; ll--) {
|
for(int ll=(int)layers.size()-1; ll>=0; ll--) {
|
||||||
auto layer = layers[ll].toObj();
|
Layer layer;
|
||||||
auto repeat = layer["repeat"].toBool();
|
layer.isLoop = layers[ll]["repeat"].toBool();
|
||||||
auto sources = layer["sources"];
|
auto sources = layers[ll]["sources"];
|
||||||
auto border = layer["border"];
|
auto border = layers[ll]["border"];
|
||||||
EleBorder *bdEle = 0;
|
EleBorder *bdEle = 0;
|
||||||
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
|
||||||
if(! border.isNull()) {
|
if(! border.isNull()) {
|
||||||
bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page);
|
bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), box);
|
||||||
bdWidth = bdEle->img.height();
|
bdWidth = bdEle->img.height();
|
||||||
}
|
}
|
||||||
|
Source src;
|
||||||
for(auto &source : sources) {
|
for(auto &source : sources) {
|
||||||
ele.type = source["_type"].toString();
|
src.type = source["_type"].toString();
|
||||||
if(ele.type.isEmpty()) continue;
|
if(src.type.isEmpty()) continue;
|
||||||
auto timeSpan = source["timeSpan"].toInt()*1000;
|
auto timeSpan = source["timeSpan"].toInt()*1000;
|
||||||
if(timeSpan==0) continue;
|
if(timeSpan==0) continue;
|
||||||
ele.x = source["left"].toInt()+bdWidth;
|
auto x = source["left"].toInt()+bdWidth;
|
||||||
ele.y = source["top"].toInt()+bdWidth;
|
auto y = source["top"].toInt()+bdWidth;
|
||||||
ele.w = source["width"].toInt()-bdWidth-bdWidth;
|
auto w = source["width"].toInt()-bdWidth-bdWidth;
|
||||||
ele.h = source["height"].toInt()-bdWidth-bdWidth;
|
auto h = source["height"].toInt()-bdWidth-bdWidth;
|
||||||
bool notAudio = ele.type!="Audio";
|
bool notAudio = src.type!="Audio";
|
||||||
if((ele.w<=0 || ele.h<=0) && notAudio) continue;
|
if((w<=0 || h<=0) && notAudio) continue;
|
||||||
ele.repeat = repeat;
|
src.startTime = source["playTime"].toInt()*1000;
|
||||||
ele.startTime = source["playTime"].toInt()*1000;
|
if(bdStart > src.startTime) bdStart = src.startTime;
|
||||||
if(bdStart > ele.startTime) bdStart = ele.startTime;
|
src.endTime = src.startTime + timeSpan;
|
||||||
ele.endTime = ele.startTime + timeSpan;
|
if(bdEnd < src.endTime) bdEnd = src.endTime;
|
||||||
if(bdEnd < ele.endTime) bdEnd = ele.endTime;
|
if(layer.dur < src.endTime) layer.dur = src.endTime;
|
||||||
if(page->timeSpan < ele.endTime && notAudio) page->timeSpan = ele.endTime;
|
if(notAudio) {
|
||||||
ele.id = source["id"].toString();
|
if(page.sDur < src.endTime) page.sDur = src.endTime;
|
||||||
ele.wgt = 0;
|
} else if(page.audioDur < src.endTime) page.audioDur = src.endTime;
|
||||||
if(ele.type=="Image") {
|
|
||||||
if(source["mime"].toString().endsWith("gif")) ele.wgt = new EleGif(dir+"/"+ele.id, page);
|
if(src.exitDur!=0) src.exitStart = timeSpan*60/1000 - src.exitDur;
|
||||||
|
|
||||||
|
auto id = source["id"].toString();
|
||||||
|
src.view = 0;
|
||||||
|
if(src.type=="Image") {
|
||||||
|
if(source["fileExt"].toString()=="gif") src.view = new EleGif(dir+"/"+id, box);
|
||||||
else {
|
else {
|
||||||
auto lb = new QLabel(page);
|
auto lb = new QLabel(box);
|
||||||
lb->setPixmap(QPixmap(dir+"/"+ele.id));
|
lb->setPixmap(QPixmap(dir+"/"+id));
|
||||||
lb->setScaledContents(true);
|
lb->setScaledContents(true);
|
||||||
ele.wgt = lb;
|
src.view = lb;
|
||||||
}
|
}
|
||||||
} else if(ele.type.startsWith("Environ")) {
|
} else if(src.type.startsWith("Environ")) {
|
||||||
auto arrayPics = source["arrayPics"];
|
auto arrayPics = source["arrayPics"];
|
||||||
for(int i=(int)arrayPics.size()-1; i>=0; i--) if(arrayPics[i]["name"].toString() == "previewTmp") {
|
for(int i=(int)arrayPics.size()-1; i>=0; i--) if(arrayPics[i]["name"].toString() == "previewTmp") {
|
||||||
if(source["bSingleScroll"].toBool()) ele.wgt = new EleScroll(page, dir+"/" + arrayPics[i]["id"].toString(), 'l', source["iScrollSpeed"].toDouble());
|
if(source["bSingleScroll"].toBool()) src.view = new EleScroll(box, dir+"/" + arrayPics[i]["id"].toString(), 'l', source["iScrollSpeed"].toDouble());
|
||||||
else ele.wgt = new EleScroll(page, dir+"/"+arrayPics[i]["id"].toString());
|
else src.view = new EleScroll(box, dir+"/"+arrayPics[i]["id"].toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if(ele.type=="MultiPng") {
|
} else if(src.type=="MultiPng" || src.type=="SplitText") {
|
||||||
auto imgs = source["arrayPics"];
|
auto imgs = source["arrayPics"];
|
||||||
if(imgs.empty()) continue;
|
if(! imgs.empty()) src.view = new EleScroll(box, dir+"/", imgs[0], w, h);
|
||||||
if(imgs.size()==1 && imgs[0]["picDuration"].toInt()==0) ele.wgt = new EleScroll(page, dir+"/", imgs[0]);
|
} else if(src.type=="DigitalClockNew") src.view = new EleDigiClock(dir+"/", source, box);
|
||||||
else ele.wgt = new EleMultiPng(dir+"/", imgs, page);
|
else if(src.type=="AnalogClock") src.view = new EleAnaClock(w, h, dir+"/"+id, source, box);
|
||||||
} else if(ele.type=="SplitText") {
|
else if(src.type=="Video" || src.type=="Audio") {
|
||||||
auto imgs = source["arrayPics"];
|
auto video = new EleVideo(dir+"/"+id, box);
|
||||||
if(imgs.empty()) continue;
|
|
||||||
ele.wgt = new QWidget(page);
|
|
||||||
ele.wgt->setGeometry(0, 0, width, height);
|
|
||||||
auto height = _program["height"].toInt();
|
|
||||||
if(imgs.size()==1 && imgs[0]["picDuration"].toInt()==0) {
|
|
||||||
auto wgt = new EleScroll(ele.wgt, dir+"/", imgs[0]);
|
|
||||||
wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
|
|
||||||
for(int i=1; i<(int)splitWidths.size(); i++) {
|
|
||||||
ele.x -= splitWidths[i-1].toInt();
|
|
||||||
ele.y += height;
|
|
||||||
auto split = new EleSplitScroll(ele.wgt, wgt);
|
|
||||||
split->setGeometry(ele.x, ele.y, splitWidths[i].toInt()-ele.x, ele.h);
|
|
||||||
wgt->splits.emplace_back(split);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto wgt = new EleMultiPng(dir+"/", imgs, ele.wgt);
|
|
||||||
wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
|
|
||||||
for(int i=1; i<(int)splitWidths.size(); i++) {
|
|
||||||
ele.x -= splitWidths[i-1].toInt();
|
|
||||||
ele.y += height;
|
|
||||||
auto split = new EleSplitPng(wgt, ele.wgt);
|
|
||||||
split->setGeometry(ele.x, ele.y, splitWidths[i].toInt()-ele.x, ele.h);
|
|
||||||
wgt->splits.append(split);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ele.w = 0;
|
|
||||||
} else if(ele.type=="DigitalClockNew") ele.wgt = new EleDigiClock(dir+"/", source, page);
|
|
||||||
else if(ele.type=="AnalogClock") ele.wgt = new EleAnaClock(ele.w, ele.h, dir+"/"+ele.id, source, page);
|
|
||||||
else if(ele.type=="Video" || ele.type=="Audio") {
|
|
||||||
auto video = new EleVideo(dir+"/"+ele.id, page);
|
|
||||||
auto vol = source["vol"].toInt(100);
|
auto vol = source["vol"].toInt(100);
|
||||||
if(vol<100) video->player->setVol(vol/100.0);
|
if(vol<100) video->player->setVol(vol/100.0);
|
||||||
ele.wgt = video;
|
src.view = video;
|
||||||
} else if(ele.type=="WebURL") {
|
} else if(src.type=="WebURL") {
|
||||||
auto web = new QWebEngineView(page);
|
auto web = new QWebEngineView(box);
|
||||||
web->load(QUrl(source["url"].toString()));
|
web->load(QUrl(source["url"].toString()));
|
||||||
ele.wgt = web;
|
src.view = web;
|
||||||
}
|
}
|
||||||
else if(ele.type=="Timer") ele.wgt = new EleTimer(source, page);
|
else if(src.type=="Timer") src.view = new EleTimer(source, box);
|
||||||
else continue;
|
else continue;
|
||||||
if(ele.wgt==0) continue;
|
if(src.view==0) continue;
|
||||||
if(ele.startTime>0) ele.wgt->setVisible(false);
|
src.view->setVisible(false);
|
||||||
if(ele.w) ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
|
if(w) src.view->setGeometry(x, y, w, h);
|
||||||
page->eles.emplace_back(ele);
|
layer.srcs.push_back(src);
|
||||||
}
|
}
|
||||||
if(bdEle && ! sources.empty()) {
|
if(bdEle && ! sources.empty()) {
|
||||||
auto geometry = border["geometry"];
|
auto geometry = border["geometry"];
|
||||||
ele.x = geometry[0].toInt();
|
src.startTime = bdStart;
|
||||||
ele.y = geometry[1].toInt();
|
src.endTime = bdEnd;
|
||||||
ele.w = geometry[2].toInt();
|
src.view = bdEle;
|
||||||
ele.h = geometry[3].toInt();
|
src.view->setVisible(false);
|
||||||
ele.startTime = bdStart;
|
src.view->setGeometry(geometry[0].toInt(), geometry[1].toInt(), geometry[2].toInt(), geometry[3].toInt());
|
||||||
ele.endTime = bdEnd;
|
layer.srcs.push_back(src);
|
||||||
ele.wgt = bdEle;
|
|
||||||
if(ele.startTime>0) ele.wgt->setVisible(false);
|
|
||||||
ele.wgt->setGeometry(ele.x, ele.y, ele.w, ele.h);
|
|
||||||
page->eles.emplace_back(ele);
|
|
||||||
}
|
}
|
||||||
|
if(! layer.srcs.empty()) page.layers.emplace_back(std::move(layer));
|
||||||
}
|
}
|
||||||
if(page->timeSpan==0) continue;
|
if(page.sDur==0) {
|
||||||
for(int i=0; i<page->eles.size(); i++) if(page->eles[i].repeat) page->eles[i].endTime = page->timeSpan;
|
if(page.audioDur > 0) page.sDur = page.audioDur;
|
||||||
pages.emplace_back(page);
|
else continue;
|
||||||
}
|
}
|
||||||
setVisible(true);
|
page.tDur = page.sDur * page.repeatTimes;
|
||||||
if(! pages.empty()) for(auto& ele : pages[0]->eles) if(ele.startTime > 0 || ele.endTime < pages[0]->timeSpan) {
|
for(auto layer=page.layers.begin(); layer<page.layers.end(); ++layer) {
|
||||||
if(ele.startTime > 0) timerMap.insert(startTimer(ele.startTime), TimerValue(ele.wgt, true));
|
for(auto src=layer->srcs.begin(); src<layer->srcs.end(); ++src) {
|
||||||
timerMap.insert(startTimer(ele.endTime), TimerValue(ele.wgt, false));
|
if(src->startTime >= page.sDur) {
|
||||||
|
if(layer->srcs.size() > 1) layer->srcs.erase(src--);
|
||||||
|
else {
|
||||||
|
page.layers.erase(layer--);
|
||||||
|
goto conti_layer;
|
||||||
|
}
|
||||||
|
} else if(src->endTime > page.sDur) src->endTime = page.sDur;
|
||||||
|
}
|
||||||
|
if(layer->dur > page.sDur) layer->dur = page.sDur;
|
||||||
|
if(layer->dur == page.sDur) layer->isLoop = false;
|
||||||
|
conti_layer:;
|
||||||
|
}
|
||||||
|
pages.emplace_back(std::move(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
menu = new QMenu(this);
|
menu = new QMenu(this);
|
||||||
|
@ -185,46 +196,51 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue
|
||||||
if(self==this) self = nullptr;
|
if(self==this) self = nullptr;
|
||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setVisible(true);
|
||||||
|
if(pages.empty()) return;
|
||||||
|
pages[0].setMillis((std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() + 999)/1000*1000);
|
||||||
|
|
||||||
|
connect(gl, &QOpenGLWidget::frameSwapped, this, &PlayWin::doFrame, Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
void PlayWin::sltNext() {
|
|
||||||
if(isVisible()) {
|
void PlayWin::doFrame() {
|
||||||
pages[cur]->setVisible(false);
|
if(! isVisible()) return;
|
||||||
if(cur+2 > pages.size()) cur = 0;
|
auto milli = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
else cur++;
|
auto& lastPage = pages[curAva];
|
||||||
auto page = pages[cur];
|
if(milli >= lastPage.endMilli) {
|
||||||
if(timer) timer->inter = page->timeSpan;
|
lastPage.hide();
|
||||||
for(auto &ele : page->eles) if(ele.startTime > 0 || ele.endTime < page->timeSpan) {
|
if(curTimes < lastPage.repeatTimes) curTimes++;
|
||||||
if(ele.startTime > 0) timerMap.insert(startTimer(ele.startTime), TimerValue(ele.wgt, true));
|
else {
|
||||||
else ele.wgt->setVisible(true);
|
curTimes = 1;
|
||||||
timerMap.insert(startTimer(ele.endTime), TimerValue(ele.wgt, false));
|
curAva++;
|
||||||
|
if(curAva >= (int)pages.size()) {
|
||||||
|
curAva = 0;
|
||||||
|
auto isDiff = milli-lastPage.endMilli>=1000;
|
||||||
|
pages[curAva].setMillis(isDiff ? milli : lastPage.endMilli);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
page->setVisible(true);
|
|
||||||
} else if(timer) {
|
|
||||||
timer->stop();
|
|
||||||
timer = 0;
|
|
||||||
}
|
}
|
||||||
}
|
pages[curAva].setMillis(lastPage.endMilli);
|
||||||
void PlayWin::timerEvent(QTimerEvent *e){
|
} else {
|
||||||
int id = e->timerId();
|
for(auto &layer : lastPage.layers) {
|
||||||
killTimer(id);
|
for(auto &src : layer.srcs) {
|
||||||
TimerValue value = timerMap[id];
|
if(src.view->isVisible()) {
|
||||||
if(value.ele) {
|
if(milli >= src.endMilli) src.hide();
|
||||||
timerMap.remove(id);
|
else src.doEff();
|
||||||
value.ele->setVisible(value.visible);
|
} else if(milli < src.endMilli && milli >= src.startMilli) src.show();
|
||||||
|
}
|
||||||
|
if(milli >= layer.endMilli) {
|
||||||
|
layer.endMilli += layer.dur;
|
||||||
|
for(auto &src : layer.srcs) {
|
||||||
|
src.endMilli += layer.dur;
|
||||||
|
src.startMilli += layer.dur;
|
||||||
|
if(src.startTime > 0) src.hide();
|
||||||
|
else src.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void PlayWin::paintEvent(QPaintEvent *e){
|
|
||||||
if(timer==0 && isVisible() && ! pages.empty()) {
|
|
||||||
if(cur!=0) {
|
|
||||||
pages[cur]->setVisible(false);
|
|
||||||
cur = 0;
|
|
||||||
}
|
}
|
||||||
pages[cur]->setVisible(true);
|
|
||||||
timer = new SyncTimer(pages[cur]->timeSpan);
|
|
||||||
connect(timer, &SyncTimer::timeout, this, &PlayWin::sltNext, Qt::BlockingQueuedConnection);
|
|
||||||
timer->start();
|
|
||||||
}
|
}
|
||||||
QWidget::paintEvent(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayWin::mousePressEvent(QMouseEvent *e) {
|
void PlayWin::mousePressEvent(QMouseEvent *e) {
|
||||||
|
|
|
@ -1,37 +1,204 @@
|
||||||
#ifndef PLAYWIN_H
|
#ifndef PLAYWIN_H
|
||||||
#define PLAYWIN_H
|
#define PLAYWIN_H
|
||||||
#include "gutil/qjson.h"
|
#include "gutil/qjson.h"
|
||||||
#include "synctimer.h"
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
class EleBase {
|
enum Effect {
|
||||||
|
EXPAND_HOR, EXPAND_VER, EXPAND_LEFT, EXPAND_TOP, EXPAND_RIGHT, EXPAND_BOTTOM,
|
||||||
|
ZOOM, ZOOM_TL, ZOOM_TR, ZOOM_BR, ZOOM_BL,
|
||||||
|
ROTATE, ROTATE_R,
|
||||||
|
FADE,
|
||||||
|
MOVE_LEFT, MOVE_TOP, MOVE_RIGHT, MOVE_BOTTOM,
|
||||||
|
End
|
||||||
|
};
|
||||||
|
|
||||||
|
class Source {
|
||||||
public:
|
public:
|
||||||
QString id;
|
QWidget *view = 0;
|
||||||
|
int64_t startMilli = 0, endMilli = LLONG_MAX;
|
||||||
|
int startTime = 0, entryDur = 0, exitStart = INT_MAX, exitDur = 0, endTime = 0, ff = 0;
|
||||||
|
Effect entryEff, exitEff;
|
||||||
QString type;
|
QString type;
|
||||||
int x;
|
bool isEntryRand = 0, isExitRand = 0;
|
||||||
int y;
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
int startTime;
|
|
||||||
int endTime;
|
|
||||||
bool repeat;
|
|
||||||
|
|
||||||
QWidget *wgt{0};
|
void show() {
|
||||||
|
if(view->isVisible()) return;
|
||||||
|
view->setVisible(true);
|
||||||
|
ff = 0;
|
||||||
|
if(isEntryRand) entryEff = (Effect) (rand() % Effect::End);
|
||||||
|
if(isExitRand) exitEff = (Effect) (rand() % Effect::End);
|
||||||
|
resetEff();
|
||||||
|
doEff();
|
||||||
|
}
|
||||||
|
void hide() {
|
||||||
|
if(! view->isVisible()) return;
|
||||||
|
view->setVisible(false);
|
||||||
|
}
|
||||||
|
void doEff() {
|
||||||
|
// auto w = view->width();
|
||||||
|
// auto h = view->height();
|
||||||
|
// if(ff < entryDur) {
|
||||||
|
// if(entryEff == Effect::EXPAND_HOR) view.setScaleX(ff / (float) entryDur);
|
||||||
|
// else if(entryEff == Effect::EXPAND_VER) view.setScaleY(ff / (float) entryDur);
|
||||||
|
// else if(entryEff == Effect::EXPAND_LEFT) {
|
||||||
|
// view.setScaleX(ff / (float) entryDur);
|
||||||
|
// view.setTranslationX((1 - view.getScaleX()) * w / 2);
|
||||||
|
// } else if(entryEff == Effect::EXPAND_TOP) {
|
||||||
|
// view.setScaleY(ff / (float) entryDur);
|
||||||
|
// view.setTranslationY((1 - view.getScaleY()) * h / 2);
|
||||||
|
// } else if(entryEff == Effect::EXPAND_RIGHT) {
|
||||||
|
// view.setScaleX(ff / (float) entryDur);
|
||||||
|
// view.setTranslationX((view.getScaleX() - 1) * w / 2);
|
||||||
|
// } else if(entryEff == Effect::EXPAND_BOTTOM) {
|
||||||
|
// view.setScaleY(ff / (float) entryDur);
|
||||||
|
// view.setTranslationY((view.getScaleY() - 1) * h / 2);
|
||||||
|
// }
|
||||||
|
// else if(entryEff == Effect::MOVE_LEFT) view.setTranslationX(w - ff*w/(float) entryDur);
|
||||||
|
// else if(entryEff == Effect::MOVE_TOP) view.setTranslationY(h - ff*h/(float) entryDur);
|
||||||
|
// else if(entryEff == Effect::MOVE_RIGHT) view.setTranslationX(ff*w/(float) entryDur - w);
|
||||||
|
// else if(entryEff == Effect::MOVE_BOTTOM) view.setTranslationY(ff*h/(float) entryDur - h);
|
||||||
|
// else if(entryEff == Effect::FADE) view.setAlpha(ff / (float) entryDur);
|
||||||
|
// else if(entryEff == Effect::ZOOM) {
|
||||||
|
// view.setScaleX(ff / (float) entryDur);
|
||||||
|
// view.setScaleY(view.getScaleX());
|
||||||
|
// } else if(entryEff == Effect::ZOOM_TL) {
|
||||||
|
// var rate = ff / (float) entryDur;
|
||||||
|
// view.setTranslationX((rate - 1) * w / 2);
|
||||||
|
// view.setTranslationY((rate - 1) * h / 2);
|
||||||
|
// view.setScaleX(rate);
|
||||||
|
// view.setScaleY(rate);
|
||||||
|
// } else if(entryEff == Effect::ZOOM_BR) {
|
||||||
|
// var rate = ff / (float) entryDur;
|
||||||
|
// view.setTranslationX((1 - rate) * w / 2);
|
||||||
|
// view.setTranslationY((1 - rate) * h / 2);
|
||||||
|
// view.setScaleX(rate);
|
||||||
|
// view.setScaleY(rate);
|
||||||
|
// } else if(entryEff == Effect::ZOOM_TR) {
|
||||||
|
// var rate = ff / (float) entryDur;
|
||||||
|
// view.setTranslationX((1 - rate) * w / 2);
|
||||||
|
// view.setTranslationY((rate - 1) * h / 2);
|
||||||
|
// view.setScaleX(rate);
|
||||||
|
// view.setScaleY(rate);
|
||||||
|
// } else if(entryEff == Effect::ZOOM_BL) {
|
||||||
|
// var rate = ff / (float) entryDur;
|
||||||
|
// view.setTranslationX((rate - 1) * w / 2);
|
||||||
|
// view.setTranslationY((1 - rate) * h / 2);
|
||||||
|
// view.setScaleX(rate);
|
||||||
|
// view.setScaleY(rate);
|
||||||
|
// } else if(entryEff == Effect::ROTATE) {
|
||||||
|
// view.setScaleX(ff / (float) entryDur);
|
||||||
|
// view.setScaleY(view.getScaleX());
|
||||||
|
// view.setRotation(view.getScaleX() * 360);
|
||||||
|
// } else if(entryEff == Effect::ROTATE_R) {
|
||||||
|
// view.setScaleX(ff / (float) entryDur);
|
||||||
|
// view.setScaleY(view.getScaleX());
|
||||||
|
// view.setRotation(- view.getScaleX() * 360);
|
||||||
|
// }
|
||||||
|
// } else if(ff>=exitStart) {
|
||||||
|
// var fff = ff - exitStart;
|
||||||
|
// if(fff > exitDur) fff = exitDur;
|
||||||
|
// if(exitEff == Effect::EXPAND_HOR) view.setScaleX(1 - fff / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::EXPAND_VER) view.setScaleY(1 - fff / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::EXPAND_LEFT) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setTranslationX(rate * w / 2);
|
||||||
|
// } else if(exitEff == Effect::EXPAND_TOP) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setScaleY(1 - rate);
|
||||||
|
// view.setTranslationY(rate * h / 2);
|
||||||
|
// } else if(exitEff == Effect::EXPAND_RIGHT) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setTranslationX(- rate * w / 2);
|
||||||
|
// } else if(exitEff == Effect::EXPAND_BOTTOM) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setScaleY(1 - rate);
|
||||||
|
// view.setTranslationY(- rate * h / 2);
|
||||||
|
// }
|
||||||
|
// else if(exitEff == Effect::MOVE_LEFT) view.setTranslationX(- fff*w / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::MOVE_RIGHT) view.setTranslationX(fff*w / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::MOVE_TOP) view.setTranslationY(- fff*h / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::MOVE_BOTTOM) view.setTranslationY(fff*h / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::FADE) view.setAlpha(1 - fff / (float) exitDur);
|
||||||
|
// else if(exitEff == Effect::ZOOM) {
|
||||||
|
// view.setScaleX(1 - fff / (float) exitDur);
|
||||||
|
// view.setScaleY(view.getScaleX());
|
||||||
|
// } else if(exitEff == Effect::ZOOM_TL) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setTranslationX(- rate * w / 2);
|
||||||
|
// view.setTranslationY(- rate * h / 2);
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setScaleY(1 - rate);
|
||||||
|
// } else if(exitEff == Effect::ZOOM_BR) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setTranslationX(rate * w / 2);
|
||||||
|
// view.setTranslationY(rate * h / 2);
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setScaleY(1 - rate);
|
||||||
|
// } else if(exitEff == Effect::ZOOM_TR) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setTranslationX(rate * w / 2);
|
||||||
|
// view.setTranslationY(- rate * h / 2);
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setScaleY(1 - rate);
|
||||||
|
// } else if(exitEff == Effect::ZOOM_BL) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setTranslationX(- rate * w / 2);
|
||||||
|
// view.setTranslationY(rate * h / 2);
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setScaleY(1 - rate);
|
||||||
|
// } else if(exitEff == Effect::ROTATE) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setScaleY(view.getScaleX());
|
||||||
|
// view.setRotation(rate * 360);
|
||||||
|
// } else if(exitEff == Effect::ROTATE_R) {
|
||||||
|
// var rate = fff / (float) exitDur;
|
||||||
|
// view.setScaleX(1 - rate);
|
||||||
|
// view.setScaleY(view.getScaleX());
|
||||||
|
// view.setRotation(- rate * 360);
|
||||||
|
// }
|
||||||
|
// } else resetEff();
|
||||||
|
ff++;
|
||||||
|
}
|
||||||
|
void resetEff() {
|
||||||
|
// view.setTranslationX(0);
|
||||||
|
// view.setTranslationY(0);
|
||||||
|
// view.setAlpha(1);
|
||||||
|
// view.setScaleX(1);
|
||||||
|
// view.setScaleY(1);
|
||||||
|
// view.setRotation(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
struct Layer {
|
||||||
|
std::vector<Source> srcs;
|
||||||
|
int64_t endMilli = LLONG_MAX;
|
||||||
|
int dur = 0;
|
||||||
|
bool isLoop = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Page : public QWidget {
|
struct Page {
|
||||||
public:
|
std::vector<Layer> layers;
|
||||||
explicit Page(QWidget *parent = nullptr);
|
int64_t endMilli = LLONG_MAX;
|
||||||
int timeSpan{0};
|
int sDur = 0, tDur = 0, repeatTimes = 0, audioDur = 0;
|
||||||
std::vector<EleBase> eles;
|
|
||||||
};
|
|
||||||
|
|
||||||
class TimerValue{
|
void hide() {
|
||||||
public:
|
for(auto &layer : layers) for(auto &src : layer.srcs) src.hide();
|
||||||
TimerValue(QWidget *ele = nullptr, bool visible = false): ele(ele), visible(visible){}
|
}
|
||||||
QWidget* ele;
|
|
||||||
bool visible;
|
void setMillis(int64_t milli) {
|
||||||
|
endMilli = milli + sDur;
|
||||||
|
for(auto &layer : layers) {
|
||||||
|
if(layer.isLoop) layer.endMilli = milli + layer.dur;
|
||||||
|
for(auto &src : layer.srcs) {
|
||||||
|
src.endMilli = milli + src.endTime;
|
||||||
|
src.startMilli = milli + src.startTime;
|
||||||
|
if(src.startTime == 0) src.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayWin : public QWidget {
|
class PlayWin : public QWidget {
|
||||||
|
@ -41,23 +208,18 @@ public:
|
||||||
static PlayWin *newIns(int width, int height, QString dir, const JValue &prog, QWidget *parent = nullptr);
|
static PlayWin *newIns(int width, int height, QString dir, const JValue &prog, QWidget *parent = nullptr);
|
||||||
PlayWin(int x, int y, int width, int height, QString dir, const JValue &prog, QWidget *parent = nullptr);
|
PlayWin(int x, int y, int width, int height, QString dir, const JValue &prog, QWidget *parent = nullptr);
|
||||||
|
|
||||||
SyncTimer* timer = 0;
|
QOpenGLWidget *gl;
|
||||||
int cur = 0;
|
int cur = 0;
|
||||||
std::vector<Page*> pages;
|
std::vector<Page> pages;
|
||||||
QMap<int,TimerValue> timerMap;
|
std::vector<Page> avas;
|
||||||
|
int curAva = 0, curTimes = 1;
|
||||||
|
|
||||||
QPoint mPressRel;
|
QPoint mPressRel;
|
||||||
QMenu *menu;
|
QMenu *menu;
|
||||||
|
|
||||||
public slots:
|
void doFrame();
|
||||||
void sltNext();
|
|
||||||
void sltSetVisible(QWidget *wgt, bool visible){
|
|
||||||
wgt->setVisible(visible);
|
|
||||||
}
|
|
||||||
signals:
|
|
||||||
void sigSetVisible(QWidget *, bool);
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
|
||||||
void timerEvent(QTimerEvent *) override;
|
|
||||||
void mousePressEvent(QMouseEvent *) override;
|
void mousePressEvent(QMouseEvent *) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *) override;
|
void mouseReleaseEvent(QMouseEvent *) override;
|
||||||
void mouseMoveEvent(QMouseEvent *) override;
|
void mouseMoveEvent(QMouseEvent *) override;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "srccopy.h"
|
||||||
|
#include "playwin.h"
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
#include <QBackingStore>
|
||||||
|
|
||||||
|
SrcCopy::SrcCopy(QWidget *parent, QWidget *master) : QWidget{parent}, master(master) {
|
||||||
|
connect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, (void(SrcCopy::*)())&SrcCopy::update);
|
||||||
|
}
|
||||||
|
void SrcCopy::paintEvent(QPaintEvent *) {
|
||||||
|
master->render(backingStore()->paintDevice(), pos(), QRegion(), DrawChildren|IgnoreMask);
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef SRCCOPY_H
|
||||||
|
#define SRCCOPY_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class SrcCopy : public QWidget {
|
||||||
|
public:
|
||||||
|
SrcCopy(QWidget *parent, QWidget *master);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
|
QWidget *master;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SRCCOPY_H
|
|
@ -1,4 +1,5 @@
|
||||||
#include "progpanel.h"
|
#include "progpanel.h"
|
||||||
|
#include "program/progitem.h"
|
||||||
#include "globaldefine.h"
|
#include "globaldefine.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
|
@ -32,32 +33,32 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
bnNew->setProperty("ssType", "progManageTool");
|
bnNew->setProperty("ssType", "progManageTool");
|
||||||
hBox->addWidget(bnNew);
|
hBox->addWidget(bnNew);
|
||||||
connect(bnNew, &QPushButton::clicked, this, [this] {
|
connect(bnNew, &QPushButton::clicked, this, [this] {
|
||||||
ProgCreateDlg dlg("", 512, 256, "", "", this);
|
ProgCreateDlg dlg("", 512, 256, "", "", false, this);
|
||||||
if(dlg.exec() != QDialog::Accepted) return;
|
if(dlg.exec() != QDialog::Accepted) return;
|
||||||
if(checkIfNameRepeated(dlg.fdName->text())) return;
|
if(checkIfNameRepeated(dlg.fdName->text())) return;
|
||||||
QList<int> widths;
|
std::vector<int> widths;
|
||||||
int max = 0;
|
int max = 0;
|
||||||
auto width = dlg.fdWidth->value();
|
auto width = dlg.fdVer->isChecked() ? dlg.fdHeight->value() : dlg.fdWidth->value();
|
||||||
if(dlg.fdIsUltraLong->isChecked()) {
|
if(dlg.fdIsUltraLong->isChecked()) {
|
||||||
auto splitWidths = dlg.fdSplitWidths->text().split(" ", Qt::SkipEmptyParts);
|
auto partLengths = dlg.fdSplitWidths->text().split(" ", Qt::SkipEmptyParts);
|
||||||
int ttl = 0;
|
int ttl = 0;
|
||||||
for(auto &splitWidth : splitWidths) {
|
for(auto &partLength : partLengths) {
|
||||||
int val = splitWidth.toInt();
|
int val = partLength.toInt();
|
||||||
if(val==0) continue;
|
if(val==0) continue;
|
||||||
if(max < val) max = val;
|
if(max < val) max = val;
|
||||||
widths.append(val);
|
|
||||||
ttl += val;
|
ttl += val;
|
||||||
|
widths.emplace_back(val);
|
||||||
if(ttl>=width) break;
|
if(ttl>=width) break;
|
||||||
}
|
}
|
||||||
if(max) {
|
if(max) {
|
||||||
while(ttl < width) {
|
while(ttl < width) {
|
||||||
widths.append(max);
|
|
||||||
ttl += max;
|
ttl += max;
|
||||||
|
widths.emplace_back(max);
|
||||||
}
|
}
|
||||||
if(ttl > width) widths.last() -= ttl - width;
|
if(ttl > width) widths.back() -= ttl - width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), width, dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, mProgTree);
|
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), dlg.fdWidth->value(), dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, dlg.fdVer->isChecked(), mProgTree);
|
||||||
item->save();//保存pro.json
|
item->save();//保存pro.json
|
||||||
if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
|
if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
|
||||||
mProgTree->fdCheckAll->blockSignals(true);
|
mProgTree->fdCheckAll->blockSignals(true);
|
||||||
|
@ -129,14 +130,7 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
|
|
||||||
mProgTree->clear();
|
mProgTree->clear();
|
||||||
QStringList progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
QStringList progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
foreach(QString pro_name, progNames) {
|
for(auto &pro_name : progNames) addProFile(mProgsDir + "/" + pro_name + "/pro.json");
|
||||||
QFile jFile(mProgsDir + "/" + pro_name + "/pro.json");
|
|
||||||
if(! jFile.exists()) continue;
|
|
||||||
if(! jFile.open(QIODevice::ReadOnly)) continue;
|
|
||||||
auto data = jFile.readAll();
|
|
||||||
jFile.close();
|
|
||||||
m_pwPorgramItemList.append(new ProgItem(mProgsDir, QJsonDocument::fromJson(data).object(), mProgTree));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
bnExport = new QPushButton(tr("Export"));
|
bnExport = new QPushButton(tr("Export"));
|
||||||
|
@ -200,8 +194,8 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
QString jsErr;
|
QString jsErr;
|
||||||
auto prog = JFrom(value, &jsErr);
|
auto prog = JFrom(value, &jsErr);
|
||||||
if(! jsErr.isEmpty()) return;
|
if(! jsErr.isEmpty()) return;
|
||||||
if(item->mSplitWidths.isEmpty()) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog);
|
if(item->partLens.empty()) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog);
|
||||||
else PlayWin::self = PlayWin::newIns(item->mMaxWidth, item->mHeight * item->mSplitWidths.size(), dir, prog);
|
else PlayWin::self = item->isVer ? PlayWin::newIns(item->mWidth * item->partLens.size(), item->maxLen, dir, prog) : PlayWin::newIns(item->maxLen, item->mHeight * item->partLens.size(), dir, prog);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,27 +243,29 @@ ProgPanel::ProgPanel(QWidget *parent) : QWidget(parent) {
|
||||||
});
|
});
|
||||||
vBox->addWidget(mProgTree = table);
|
vBox->addWidget(mProgTree = table);
|
||||||
|
|
||||||
QString doc_path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
auto dataDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
if(!doc_path.isEmpty()) {
|
if(! dataDir.isEmpty()) {
|
||||||
QString app_path = doc_path + "/" + QApplication::applicationName();
|
mProgsDir = dataDir + "/programs";
|
||||||
mProgsDir = app_path + "/NPrograms";
|
if(! QFileInfo::exists(mProgsDir)) {
|
||||||
if(!QFileInfo::exists(mProgsDir)) QDir(app_path).mkdir("NPrograms");
|
qDebug()<<"mkdir programs"<<QDir(dataDir).mkdir("programs");
|
||||||
|
auto oldProgsDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)+"/"+QApplication::applicationName()+"/NPrograms";
|
||||||
|
QDir oldProgsQDir(oldProgsDir);
|
||||||
|
if(oldProgsQDir.exists()) {
|
||||||
|
CopyDirThread thread;
|
||||||
|
thread.dirDst = mProgsDir;
|
||||||
|
auto names = oldProgsQDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
|
for(auto &name : names) if(! name.endsWith("_tmp")) thread.dirSrcs.append(oldProgsDir + "/" + name);
|
||||||
|
if(! thread.dirSrcs.isEmpty()) thread.move();
|
||||||
|
oldProgsQDir.removeRecursively();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//查找根路径下的项目文件夹,查找文件夹下的节目pro.json信息,包括节目名称,大小,像素,备注等信息
|
//查找根路径下的项目文件夹,查找文件夹下的节目pro.json信息,包括节目名称,大小,像素,备注等信息
|
||||||
if(!mProgsDir.isEmpty()) {
|
if(! mProgsDir.isEmpty()) {
|
||||||
QDir root_dir(mProgsDir);
|
QDir root_dir(mProgsDir);
|
||||||
QStringList pro_list = root_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
auto pro_list = root_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||||
foreach(QString pro_name, pro_list) {
|
for(auto &pro_name : pro_list) addProFile(mProgsDir + "/" + pro_name + "/pro.json");
|
||||||
QDir pro_dir(mProgsDir + "/" + pro_name);
|
|
||||||
if(pro_dir.exists("pro.json")) {
|
|
||||||
QFile fPro(pro_dir.path() + "/pro.json");
|
|
||||||
fPro.open(QIODevice::ReadOnly);
|
|
||||||
QJsonDocument pro = QJsonDocument::fromJson(fPro.readAll());
|
|
||||||
fPro.close();
|
|
||||||
m_pwPorgramItemList.append(new ProgItem(mProgsDir, pro.object(), mProgTree));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder);
|
if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder);
|
||||||
|
@ -298,6 +294,35 @@ void ProgPanel::transUi() {
|
||||||
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
|
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgPanel::addProFile(const QString &file) {
|
||||||
|
QFile qFile(file);
|
||||||
|
if(! qFile.exists()) return;
|
||||||
|
if(! qFile.open(QIODevice::ReadOnly)) return;
|
||||||
|
auto data = qFile.readAll();
|
||||||
|
qFile.close();
|
||||||
|
QString error;
|
||||||
|
auto json = JFrom(data, &error);
|
||||||
|
if(! error.isEmpty()) return;
|
||||||
|
auto item = new ProgItem(mProgTree);
|
||||||
|
item->mProgsDir = mProgsDir;
|
||||||
|
item->mName = json["name"].toString();
|
||||||
|
item->mWidth = json["resolution"]["w"].toInt();
|
||||||
|
item->mHeight = json["resolution"]["h"].toInt();
|
||||||
|
item->mRemark = json["remarks"].toString();
|
||||||
|
item->isVer = json["isVer"].toBool();
|
||||||
|
auto partLengths = json["splitWidths"].toArray();
|
||||||
|
for(auto &partLength : partLengths) {
|
||||||
|
auto len = partLength.toInt();
|
||||||
|
if(item->maxLen < len) item->maxLen = len;
|
||||||
|
item->partLens.emplace_back(len);
|
||||||
|
}
|
||||||
|
item->m_fsize = json["file_size"].toDouble();
|
||||||
|
item->mProgDir = item->mProgsDir + "/" + item->mName;
|
||||||
|
item->m_orgName = item->mName;
|
||||||
|
item->setText("lasttime", QFileInfo(file).lastModified().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
|
item->init();
|
||||||
|
}
|
||||||
|
|
||||||
void ProgPanel::onEditClicked(bool){
|
void ProgPanel::onEditClicked(bool){
|
||||||
int cnt = mProgTree->topLevelItemCount();
|
int cnt = mProgTree->topLevelItemCount();
|
||||||
for(int i=0; i<cnt; i++) {
|
for(int i=0; i<cnt; i++) {
|
||||||
|
@ -322,19 +347,6 @@ bool ProgPanel::checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip){
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &splitWidths, int max)
|
|
||||||
{
|
|
||||||
if(checkIfNameRepeated(name)) return;
|
|
||||||
auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, splitWidths, max, mProgTree);
|
|
||||||
item->save();//保存pro.json
|
|
||||||
if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
|
|
||||||
mProgTree->fdCheckAll->blockSignals(true);
|
|
||||||
mProgTree->fdCheckAll->setCheckState(Qt::PartiallyChecked);
|
|
||||||
mProgTree->fdCheckAll->blockSignals(false);
|
|
||||||
}
|
|
||||||
auto editor = new ProgEditorWin(item, this);
|
|
||||||
editor->show();
|
|
||||||
}
|
|
||||||
void ProgPanel::onDeleteClicked(bool){
|
void ProgPanel::onDeleteClicked(bool){
|
||||||
auto res = QMessageBox::information(this, tr("Tip Info"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);
|
auto res = QMessageBox::information(this, tr("Tip Info"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||||
if(res == QMessageBox::Ok) {
|
if(res == QMessageBox::Ok) {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define PROGPANEL_H
|
#define PROGPANEL_H
|
||||||
|
|
||||||
#include "base/loqtreewidget.h"
|
#include "base/loqtreewidget.h"
|
||||||
#include "program/progitem.h"
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
|
@ -18,15 +17,14 @@ protected:
|
||||||
void changeEvent(QEvent *) override;
|
void changeEvent(QEvent *) override;
|
||||||
void transUi();
|
void transUi();
|
||||||
bool checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip = nullptr);
|
bool checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip = nullptr);
|
||||||
|
void addProFile(const QString &);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onEditClicked(bool f);
|
void onEditClicked(bool f);
|
||||||
void onDeleteClicked(bool f);
|
void onDeleteClicked(bool f);
|
||||||
void onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &, int);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mProgsDir;
|
QString mProgsDir;
|
||||||
QList<ProgItem *> m_pwPorgramItemList;
|
|
||||||
QPushButton *bnNew;
|
QPushButton *bnNew;
|
||||||
QPushButton *bnEdit;
|
QPushButton *bnEdit;
|
||||||
QPushButton *bnDelete;
|
QPushButton *bnDelete;
|
||||||
|
|
|
@ -16,7 +16,7 @@ bool CopyDirThread::copyDir(const QString &fromDir, const QString &toDir, bool c
|
||||||
QDir targetDir(toDir);
|
QDir targetDir(toDir);
|
||||||
if(! targetDir.exists() && ! targetDir.mkdir(toDir)) return false;
|
if(! targetDir.exists() && ! targetDir.mkdir(toDir)) return false;
|
||||||
QFileInfoList fileInfos = QDir(fromDir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
|
QFileInfoList fileInfos = QDir(fromDir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
|
||||||
foreach(QFileInfo fileInfo, fileInfos) {
|
for(auto &fileInfo : fileInfos) {
|
||||||
if(fileInfo.isDir()) { //< 当为目录时,递归的进行copy
|
if(fileInfo.isDir()) { //< 当为目录时,递归的进行copy
|
||||||
if(! copyDir(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()), coverIfExist)) return false;
|
if(! copyDir(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()), coverIfExist)) return false;
|
||||||
} else { //当允许覆盖操作时,将旧文件进行删除操作
|
} else { //当允许覆盖操作时,将旧文件进行删除操作
|
||||||
|
@ -30,3 +30,29 @@ bool CopyDirThread::copyDir(const QString &fromDir, const QString &toDir, bool c
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CopyDirThread::move() {
|
||||||
|
for(; i<dirSrcs.size(); i++) {
|
||||||
|
copiedSize = 0;
|
||||||
|
moveDir(dirSrcs[i], dirDst+"/"+QFileInfo(dirSrcs[i]).fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CopyDirThread::moveDir(const QString &fromDir, const QString &toDir) {
|
||||||
|
QDir targetDir(toDir);
|
||||||
|
if(! targetDir.exists() && ! targetDir.mkdir(toDir)) return false;
|
||||||
|
QFileInfoList fileInfos = QDir(fromDir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
|
||||||
|
foreach(QFileInfo fileInfo, fileInfos) {
|
||||||
|
if(fileInfo.isDir()) { //< 当为目录时,递归的进行copy
|
||||||
|
if(! moveDir(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()))) return false;
|
||||||
|
} else { //当允许覆盖操作时,将旧文件进行删除操作
|
||||||
|
if(! QFile::rename(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()))) return false;
|
||||||
|
else {
|
||||||
|
copiedSize += fileInfo.size();
|
||||||
|
emit sigProgress(i, copiedSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -9,9 +9,11 @@ public:
|
||||||
CopyDirThread();
|
CopyDirThread();
|
||||||
QStringList dirSrcs;
|
QStringList dirSrcs;
|
||||||
QString dirDst;
|
QString dirDst;
|
||||||
protected:
|
|
||||||
void run();
|
void run();
|
||||||
|
void move();
|
||||||
|
protected:
|
||||||
bool copyDir(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
|
bool copyDir(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
|
||||||
|
bool moveDir(const QString &fromDir, const QString &toDir);
|
||||||
|
|
||||||
int i{0};
|
int i{0};
|
||||||
int copiedSize = 0;
|
int copiedSize = 0;
|
||||||
|
|
|
@ -27,6 +27,7 @@ EAClock::EAClock(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::AClock;
|
mType = EBase::AClock;
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
|
if(widget.isNull()) widget = json;
|
||||||
m_attr.timeZone = QTimeZone(widget["timeZone"].toString().toUtf8());
|
m_attr.timeZone = QTimeZone(widget["timeZone"].toString().toUtf8());
|
||||||
m_attr.hourMark = widget["hourMark"].toInt();
|
m_attr.hourMark = widget["hourMark"].toInt();
|
||||||
m_attr.hourMarkSize = widget["hourMarkSize"].toInt();
|
m_attr.hourMarkSize = widget["hourMarkSize"].toInt();
|
||||||
|
@ -57,14 +58,10 @@ EAClock::EAClock(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
m_attr.mhWidth = widget["mhWidth"].toInt(m_attr.mhWidth);
|
m_attr.mhWidth = widget["mhWidth"].toInt(m_attr.mhWidth);
|
||||||
m_attr.shWidth = widget["shWidth"].toInt(m_attr.shWidth);
|
m_attr.shWidth = widget["shWidth"].toInt(m_attr.shWidth);
|
||||||
m_attr.showSecHand = widget["showSecHand"].toBool(true);
|
m_attr.showSecHand = widget["showSecHand"].toBool(true);
|
||||||
m_attr.playDuration = json["play"]["duration"].toInt();
|
|
||||||
m_attr.path = widget["path"].toString();
|
m_attr.path = widget["path"].toString();
|
||||||
m_attr.name = widget["name"].toString();
|
m_attr.name = widget["name"].toString();
|
||||||
m_attr.selfCreateDialName= widget["selfCreateDialName"].toString();
|
|
||||||
m_attr.hasDialImg = widget["bCustomDial"].toBool();
|
m_attr.hasDialImg = widget["bCustomDial"].toBool();
|
||||||
|
if(m_attr.hasDialImg) dial_img.load(m_attr.path+"/"+m_attr.name);
|
||||||
if(! m_attr.hasDialImg) m_attr.selfCreateDialName = QString("%1%2%3%4%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
|
|
||||||
else dial_img.load(m_attr.path+"/"+m_attr.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EAClock::timerEvent(QTimerEvent *) {
|
void EAClock::timerEvent(QTimerEvent *) {
|
||||||
|
@ -85,62 +82,24 @@ void EAClock::cal() {
|
||||||
void EAClock::paintDial(QPainter *painter) {
|
void EAClock::paintDial(QPainter *painter) {
|
||||||
if(! m_attr.hasDialImg || dial_img.isNull()) {
|
if(! m_attr.hasDialImg || dial_img.isNull()) {
|
||||||
auto inner = innerRect();
|
auto inner = innerRect();
|
||||||
qreal r = radius();
|
auto r = (qMin(inner.width(), inner.height()) - qMax(m_attr.minMarkSize, m_attr.hourMarkSize)) / 2;
|
||||||
qreal cx = inner.width() / 2;
|
auto cx = inner.width() / 2;
|
||||||
qreal cy = inner.height() / 2;
|
auto cy = inner.height() / 2;
|
||||||
QVector<QPointF> plist;
|
painter->translate(cx, cy);
|
||||||
qreal x, y, ox, oy;
|
|
||||||
qreal k;
|
|
||||||
qreal a = 0;
|
|
||||||
const qreal s = 6;
|
|
||||||
for(int i=0; i<60; i++) {
|
|
||||||
if (a < 90) {
|
|
||||||
k = a * M_PI / 180;
|
|
||||||
ox = sin(k) * r;
|
|
||||||
oy = cos(k) * r;
|
|
||||||
x = cx + ox;
|
|
||||||
y = cy - oy;
|
|
||||||
} else if (a < 180) {
|
|
||||||
k = (a - 90) * M_PI / 180;
|
|
||||||
ox = cos(k) * r;
|
|
||||||
oy = sin(k) * r;
|
|
||||||
x = cx + ox;
|
|
||||||
y = cy + oy;
|
|
||||||
} else if (a < 270) {
|
|
||||||
k = (a - 180) * M_PI / 180;
|
|
||||||
ox = sin(k) * r;
|
|
||||||
oy = cos(k) * r;
|
|
||||||
x = cx - ox;
|
|
||||||
y = cy + oy;
|
|
||||||
} else {
|
|
||||||
k = (a - 270) * M_PI / 180;
|
|
||||||
ox = cos(k) * r;
|
|
||||||
oy = sin(k) * r;
|
|
||||||
x = cx - ox;
|
|
||||||
y = cy - oy;
|
|
||||||
}
|
|
||||||
a += s;
|
|
||||||
plist.push_back(QPointF(x, y));
|
|
||||||
}
|
|
||||||
|
|
||||||
a = 0;
|
|
||||||
for(int i=0; i<60; i++) {
|
for(int i=0; i<60; i++) {
|
||||||
|
auto k = i * M_PI / 30;
|
||||||
|
auto x = sin(k) * r;
|
||||||
|
auto y = -cos(k) * r;
|
||||||
if(i % 5) {
|
if(i % 5) {
|
||||||
switch (m_attr.minMark) {
|
if(m_attr.minMark==0) drawMarkCircular(painter, {x, y}, m_attr.minMarkColor, m_attr.minMarkSize);
|
||||||
case 0: drawMarkCircular (painter, plist.at(i), m_attr.minMarkColor, m_attr.minMarkSize); break;
|
else if(m_attr.minMark==1) drawMarkRectangle(painter, {x, y}, m_attr.minMarkColor, m_attr.minMarkSize, i*6);
|
||||||
case 1: drawMarkRectangle(painter, plist.at(i), m_attr.minMarkColor, m_attr.minMarkSize, a); break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch (m_attr.hourMark) {
|
if(m_attr.hourMark==0) drawMarkCircular(painter, {x, y}, m_attr.hourMarkColor, m_attr.hourMarkSize);
|
||||||
case 0: drawMarkCircular (painter, plist.at(i), m_attr.hourMarkColor, m_attr.hourMarkSize); break;
|
else if(m_attr.hourMark==1) drawMarkRectangle(painter, {x, y}, m_attr.hourMarkColor, m_attr.hourMarkSize, i*6);
|
||||||
case 1: drawMarkRectangle(painter, plist.at(i), m_attr.hourMarkColor, m_attr.hourMarkSize, a); break;
|
else if(m_attr.hourMark==2) drawMarkNumber(painter, {x, y}, m_attr.hourMarkColor, m_attr.hourMarkSize, i/5);
|
||||||
case 2: drawMarkNumber (painter, plist.at(i), m_attr.hourMarkColor, m_attr.hourMarkSize, i/5); break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a += s;
|
painter->translate(-cx, -cy);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
auto inner = innerRect();
|
auto inner = innerRect();
|
||||||
int wid, hei;
|
int wid, hei;
|
||||||
|
@ -152,45 +111,30 @@ void EAClock::paintDial(QPainter *painter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EAClock::drawMarkCircular(QPainter *painter, const QPointF &pos, const QColor &color, qreal diameter) {
|
void EAClock::drawMarkCircular(QPainter *painter, const QPointF &pos, const QColor &color, qreal diameter) {
|
||||||
QPointF cp(pos.x(), pos.y());
|
auto r = diameter / 2;
|
||||||
qreal r = diameter / 2;
|
|
||||||
painter->save();
|
|
||||||
painter->setBrush(color);
|
painter->setBrush(color);
|
||||||
painter->setPen(color);
|
painter->setPen(color);
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->drawEllipse(pos, r, r);
|
||||||
painter->drawEllipse(cp, r, r);
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EAClock::drawMarkRectangle(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, qreal angle)
|
void EAClock::drawMarkRectangle(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, qreal angle) {
|
||||||
{
|
|
||||||
QPointF cp(pos.x(), pos.y());
|
|
||||||
QRectF rect(-len/2, -len/2, len, len);
|
QRectF rect(-len/2, -len/2, len, len);
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setBrush(color);
|
painter->setBrush(color);
|
||||||
painter->setPen(color);
|
painter->setPen(color);
|
||||||
painter->translate(cp);
|
painter->translate(pos);
|
||||||
painter->rotate(angle);
|
painter->rotate(angle);
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
|
||||||
painter->drawRect(rect);
|
painter->drawRect(rect);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EAClock::drawMarkNumber(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, int num)
|
void EAClock::drawMarkNumber(QPainter *painter, const QPointF &pos, const QColor &color, qreal len, int num) {
|
||||||
{
|
|
||||||
QRectF rect(pos.x()-len/2, pos.y()-len/2, len, len);
|
QRectF rect(pos.x()-len/2, pos.y()-len/2, len, len);
|
||||||
QFont font("Arial");
|
QFont font("Arial");
|
||||||
font.setPixelSize(round(len));
|
font.setPixelSize(round(len));
|
||||||
QTextOption opt;
|
|
||||||
opt.setAlignment(Qt::AlignCenter);
|
|
||||||
painter->save();
|
|
||||||
painter->setPen(color);
|
|
||||||
painter->setFont(font);
|
painter->setFont(font);
|
||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setPen(color);
|
||||||
if(num==0)
|
painter->drawText(rect, QString::number(num==0 ? 12 : num), QTextOption(Qt::AlignCenter));
|
||||||
num=12;
|
|
||||||
painter->drawText(rect, QString("%1").arg(num), opt);
|
|
||||||
painter->restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EAClock::paintText(QPainter *painter){
|
void EAClock::paintText(QPainter *painter){
|
||||||
|
@ -599,32 +543,6 @@ QWidget* EAClock::attrWgt() {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTextColor);
|
hBox->addWidget(fdTextColor);
|
||||||
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
|
||||||
|
|
||||||
line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
hBox->addWidget(line, 1);
|
|
||||||
|
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto fdDuration = new QSpinBox();
|
|
||||||
fdDuration->setRange(1, 99999);
|
|
||||||
fdDuration->setValue(m_attr.playDuration);
|
|
||||||
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
m_attr.playDuration = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdDuration);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
|
@ -649,8 +567,8 @@ bool EAClock::save(const QString &pRoot){
|
||||||
QFile old_f(old_file);
|
QFile old_f(old_file);
|
||||||
QFile new_f(new_file);
|
QFile new_f(new_file);
|
||||||
if(!new_f.exists()) old_f.copy(new_file);
|
if(!new_f.exists()) old_f.copy(new_file);
|
||||||
}
|
} else {
|
||||||
m_attr.selfCreateDialName = QString("%1%2%3%4%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
|
auto filename = QString("%1-%2-%3-%4-%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
|
||||||
m_attr.path = pRoot;
|
m_attr.path = pRoot;
|
||||||
QRectF inner = innerRect();
|
QRectF inner = innerRect();
|
||||||
QImage img(inner.width(), inner.height(), QImage::Format_ARGB32);
|
QImage img(inner.width(), inner.height(), QImage::Format_ARGB32);
|
||||||
|
@ -660,43 +578,41 @@ bool EAClock::save(const QString &pRoot){
|
||||||
paintDial(&painter);
|
paintDial(&painter);
|
||||||
paintText(&painter);
|
paintText(&painter);
|
||||||
}
|
}
|
||||||
img.save(pRoot+"/"+m_attr.selfCreateDialName, "PNG");
|
img.save(pRoot+"/"+filename, "PNG");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
JObj EAClock::attrJson() const {
|
JObj EAClock::attrJson() const {
|
||||||
JObj json;
|
JObj json;
|
||||||
addBaseAttr(json);
|
|
||||||
json["elementType"] = "AClock";
|
json["elementType"] = "AClock";
|
||||||
JObj widget;
|
json["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
|
||||||
widget["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
|
json["hourMark"] = m_attr.hourMark;
|
||||||
widget["hourMark"] = m_attr.hourMark;
|
json["hourMarkSize"] = m_attr.hourMarkSize;
|
||||||
widget["hourMarkSize"] = m_attr.hourMarkSize;
|
json["hourMarkColor"] = m_attr.hourMarkColor.name();
|
||||||
widget["hourMarkColor"] = m_attr.hourMarkColor.name();
|
json["minMark"] = m_attr.minMark;
|
||||||
widget["minMark"] = m_attr.minMark;
|
json["minMarkSize"] = m_attr.minMarkSize;
|
||||||
widget["minMarkSize"] = m_attr.minMarkSize;
|
json["minMarkColor"] = m_attr.minMarkColor.name();
|
||||||
widget["minMarkColor"] = m_attr.minMarkColor.name();
|
json["hourHandColor"] = m_attr.hourHandColor.name();
|
||||||
widget["hourHandColor"] = m_attr.hourHandColor.name();
|
json["minHandColor"] = m_attr.minHandColor.name();
|
||||||
widget["minHandColor"] = m_attr.minHandColor.name();
|
json["secHandColor"] = m_attr.secHandColor.name();
|
||||||
widget["secHandColor"] = m_attr.secHandColor.name();
|
json["text"] = m_attr.text;
|
||||||
widget["text"] = m_attr.text;
|
json["textFontFamily"] = m_attr.textFont.family();
|
||||||
widget["textFontFamily"] = m_attr.textFont.family();
|
json["textFontSize"] = m_attr.textFont.pixelSize();
|
||||||
widget["textFontSize"] = m_attr.textFont.pixelSize();
|
json["textFontBold"] = m_attr.textFont.bold();
|
||||||
widget["textFontBold"] = m_attr.textFont.bold();
|
json["textFontItalics"] = m_attr.textFont.italic();
|
||||||
widget["textFontItalics"] = m_attr.textFont.italic();
|
json["textFontUnderline"] = m_attr.textFont.underline();
|
||||||
widget["textFontUnderline"] = m_attr.textFont.underline();
|
json["textColor"] = m_attr.textColor.name();
|
||||||
widget["textColor"] = m_attr.textColor.name();
|
json["hhLen"] = m_attr.hhLen;
|
||||||
widget["hhLen"] = m_attr.hhLen;
|
json["mhLen"] = m_attr.mhLen;
|
||||||
widget["mhLen"] = m_attr.mhLen;
|
json["shLen"] = m_attr.shLen;
|
||||||
widget["shLen"] = m_attr.shLen;
|
json["hhWidth"] = m_attr.hhWidth;
|
||||||
widget["hhWidth"] = m_attr.hhWidth;
|
json["mhWidth"] = m_attr.mhWidth;
|
||||||
widget["mhWidth"] = m_attr.mhWidth;
|
json["shWidth"] = m_attr.shWidth;
|
||||||
widget["shWidth"] = m_attr.shWidth;
|
json["showSecHand"] = m_attr.showSecHand;
|
||||||
widget["showSecHand"] = m_attr.showSecHand;
|
json["path"] = m_attr.path;
|
||||||
widget["path"] = m_attr.path;
|
json["name"] = m_attr.name;
|
||||||
widget["name"] = m_attr.name;
|
json["selfCreateDialName"] = QString("%1-%2-%3-%4-%5.png").arg((int)zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
|
||||||
widget["selfCreateDialName"] = m_attr.selfCreateDialName;
|
json["bCustomDial"] = m_attr.hasDialImg;
|
||||||
widget["bCustomDial"] = m_attr.hasDialImg;
|
addBaseAttr(json);
|
||||||
json["widget"] = widget;
|
|
||||||
json["play"] = JObj{{"duration", m_attr.playDuration}};
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,11 @@ public:
|
||||||
QColor secHandColor;//秒针颜色
|
QColor secHandColor;//秒针颜色
|
||||||
int hhLen{50}, mhLen{75}, shLen{100};
|
int hhLen{50}, mhLen{75}, shLen{100};
|
||||||
int hhWidth{15}, mhWidth{10}, shWidth{5};
|
int hhWidth{15}, mhWidth{10}, shWidth{5};
|
||||||
// r/2, r / 20
|
|
||||||
// r*3/4, r / 30
|
|
||||||
// r, r / 40
|
|
||||||
QString text;//标题
|
QString text;//标题
|
||||||
QFont textFont = qfont("Arial", 12);//标题字体
|
QFont textFont = qfont("Arial", 12);//标题字体
|
||||||
QColor textColor;//标题字体颜色
|
QColor textColor;//标题字体颜色
|
||||||
int playDuration{10};//
|
|
||||||
QString path;
|
QString path;
|
||||||
QString name;
|
QString name;
|
||||||
QString selfCreateDialName;
|
|
||||||
bool hasDialImg{false};
|
bool hasDialImg{false};
|
||||||
bool showSecHand{true};
|
bool showSecHand{true};
|
||||||
};
|
};
|
||||||
|
@ -52,10 +47,6 @@ protected:
|
||||||
void paintDial(QPainter *painter);
|
void paintDial(QPainter *painter);
|
||||||
void paintText(QPainter *painter);
|
void paintText(QPainter *painter);
|
||||||
|
|
||||||
qreal radius() const {
|
|
||||||
return (qMin(rect().width(), rect().height()) - qMax(m_attr.minMarkSize, m_attr.hourMarkSize)) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cal();
|
void cal();
|
||||||
|
|
||||||
Data m_attr;
|
Data m_attr;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct Initer {
|
||||||
};
|
};
|
||||||
EBase::EBase(EBase *multiWin) : mMultiWin(multiWin) {
|
EBase::EBase(EBase *multiWin) : mMultiWin(multiWin) {
|
||||||
static struct Initer aaa;
|
static struct Initer aaa;
|
||||||
if(mMultiWin == nullptr) {
|
if(mMultiWin == 0) {
|
||||||
setFlag(ItemIsMovable);
|
setFlag(ItemIsMovable);
|
||||||
setFlag(ItemIsSelectable);
|
setFlag(ItemIsSelectable);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,15 @@ EBase::EBase(EBase *multiWin) : mMultiWin(multiWin) {
|
||||||
|
|
||||||
void EBase::setBaseAttr(const JObj &json) {
|
void EBase::setBaseAttr(const JObj &json) {
|
||||||
mStartTime = json["startTime"].toInt();
|
mStartTime = json["startTime"].toInt();
|
||||||
|
mDuration = json["duration"].toInt();
|
||||||
|
if(mDuration==0) {
|
||||||
|
mDuration = json["play"]["playDuration"].toInt();
|
||||||
|
if(mDuration==0) mDuration = json["play"]["duration"].toInt(10);
|
||||||
|
}
|
||||||
|
mEntryEffect = json["entryEffect"].toStr();
|
||||||
|
mExitEffect = json["exitEffect"].toStr();
|
||||||
|
mEntryDur = json["entryDur"].toInt();
|
||||||
|
mExitDur = json["exitDur"].toInt();
|
||||||
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());
|
||||||
|
@ -57,24 +66,29 @@ void EBase::setBaseAttr(const JObj &json) {
|
||||||
void EBase::addBaseAttr(JObj &obj) const {
|
void EBase::addBaseAttr(JObj &obj) const {
|
||||||
auto ele = mMultiWin ? mMultiWin : this;
|
auto ele = mMultiWin ? mMultiWin : this;
|
||||||
int bdWidth = ele->bdImgIdx > -1 ? borderImgs[ele->bdImgIdx].img.height() : 0;
|
int bdWidth = ele->bdImgIdx > -1 ? borderImgs[ele->bdImgIdx].img.height() : 0;
|
||||||
obj.insert("startTime", mStartTime);
|
|
||||||
obj.insert("innerX", ((int)ele->x())+bdWidth);
|
|
||||||
obj.insert("innerY", ((int)ele->y())+bdWidth);
|
|
||||||
obj.insert("innerW", ((int)ele->mWidth)-bdWidth-bdWidth);
|
|
||||||
obj.insert("innerH", ((int)ele->mHeight)-bdWidth-bdWidth);
|
|
||||||
JObj geometry;
|
JObj geometry;
|
||||||
geometry["order"] = zValue();
|
geometry["order"] = zValue();
|
||||||
geometry["x"] = (int)ele->x();
|
geometry["x"] = (int)ele->x();
|
||||||
geometry["y"] = (int)ele->y();
|
geometry["y"] = (int)ele->y();
|
||||||
geometry["w"] = (int)ele->mWidth;
|
geometry["w"] = (int)ele->mWidth;
|
||||||
geometry["h"] = (int)ele->mHeight;
|
geometry["h"] = (int)ele->mHeight;
|
||||||
|
obj.insert("geometry", geometry);
|
||||||
|
obj.insert("innerX", ((int)ele->x())+bdWidth);
|
||||||
|
obj.insert("innerY", ((int)ele->y())+bdWidth);
|
||||||
|
obj.insert("innerW", ((int)ele->mWidth)-bdWidth-bdWidth);
|
||||||
|
obj.insert("innerH", ((int)ele->mHeight)-bdWidth-bdWidth);
|
||||||
|
obj.insert("startTime", mStartTime);
|
||||||
|
obj.insert("duration", mDuration);
|
||||||
|
obj.insert("entryEffect", mEntryEffect);
|
||||||
|
obj.insert("exitEffect", mExitEffect);
|
||||||
|
obj.insert("entryDur", mEntryDur);
|
||||||
|
obj.insert("exitDur", mExitDur);
|
||||||
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()};
|
||||||
obj["borderEff"] = bdEff.isEmpty() ? JValue() : bdEff;
|
obj["borderEff"] = bdEff.isEmpty() ? JValue() : bdEff;
|
||||||
obj["borderSpeed"] = bdSpeed;
|
obj["borderSpeed"] = bdSpeed;
|
||||||
}
|
}
|
||||||
obj.insert("geometry", geometry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF EBase::innerRect() const {
|
QRectF EBase::innerRect() const {
|
||||||
|
@ -509,25 +523,24 @@ void EBase::clearSnap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
if(mMultiWin!=nullptr) return;
|
|
||||||
auto hBox = new QHBoxLayout();
|
|
||||||
hBox->addWidget(new QLabel(tr("Area")));
|
|
||||||
|
|
||||||
auto line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
hBox->addWidget(line,1);
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
auto spacing = vBox->spacing();
|
auto spacing = vBox->spacing();
|
||||||
if(spacing < 0) spacing = 0;
|
if(spacing < 0) spacing = 0;
|
||||||
|
if(mMultiWin==0) {
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Area"));
|
||||||
|
|
||||||
|
auto line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
vBox->addSpacing(-spacing-2);
|
vBox->addSpacing(-spacing-2);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
hBox->addWidget(new QLabel(tr("X")+": "));
|
hBox->addLabel(tr("X")+": ");
|
||||||
|
|
||||||
auto fdX = new QSpinBox();
|
auto fdX = new QSpinBox;
|
||||||
fdX->setRange(0, 999999);
|
fdX->setRange(0, 999999);
|
||||||
fdX->setValue(x());
|
fdX->setValue(x());
|
||||||
connect(fdX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdX](int value) {
|
connect(fdX, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdX](int value) {
|
||||||
|
@ -544,8 +557,8 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
|
|
||||||
hBox->addSpacing(10);
|
hBox->addSpacing(10);
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("Y")+": "));
|
hBox->addLabel(tr("Y")+": ");
|
||||||
auto fdY = new QSpinBox();
|
auto fdY = new QSpinBox;
|
||||||
fdY->setRange(0, 999999);
|
fdY->setRange(0, 999999);
|
||||||
fdY->setValue(y());
|
fdY->setValue(y());
|
||||||
connect(fdY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdY](int value) {
|
connect(fdY, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdY](int value) {
|
||||||
|
@ -561,12 +574,11 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
hBox->addWidget(fdY);
|
hBox->addWidget(fdY);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
hBox->addWidget(new QLabel(tr("W")+": "));
|
hBox->addLabel(tr("W")+": ");
|
||||||
auto fdW = new QSpinBox();
|
|
||||||
|
auto fdW = new QSpinBox;
|
||||||
fdW->setRange(6, 999999);
|
fdW->setRange(6, 999999);
|
||||||
fdW->setValue(mWidth);
|
fdW->setValue(mWidth);
|
||||||
connect(fdW, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdW](int value) {
|
connect(fdW, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdW](int value) {
|
||||||
|
@ -582,8 +594,8 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
hBox->addWidget(fdW);
|
hBox->addWidget(fdW);
|
||||||
|
|
||||||
hBox->addSpacing(10);
|
hBox->addSpacing(10);
|
||||||
hBox->addWidget(new QLabel(tr("H")+": "));
|
hBox->addLabel(tr("H")+": ");
|
||||||
auto fdH = new QSpinBox();
|
auto fdH = new QSpinBox;
|
||||||
fdH->setRange(6, 999999);
|
fdH->setRange(6, 999999);
|
||||||
fdH->setValue(mHeight);
|
fdH->setValue(mHeight);
|
||||||
connect(fdH, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdH](int value) {
|
connect(fdH, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdH](int value) {
|
||||||
|
@ -599,7 +611,6 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
hBox->addWidget(fdH);
|
hBox->addWidget(fdH);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addSpacing(-spacing);
|
vBox->addSpacing(-spacing);
|
||||||
|
|
||||||
connect(this, &EBase::xChanged, fdX, [this, fdX] {
|
connect(this, &EBase::xChanged, fdX, [this, fdX] {
|
||||||
|
@ -621,19 +632,19 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
fdH->blockSignals(false);
|
fdH->blockSignals(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addWidget(new QLabel(tr("Border")));
|
|
||||||
|
|
||||||
line = new QFrame();
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Border"));
|
||||||
|
|
||||||
|
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);
|
|
||||||
vBox->addSpacing(-spacing-2);
|
vBox->addSpacing(-spacing-2);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
hBox = new HBox(vBox);
|
||||||
hBox->setSpacing(0);
|
hBox->setSpacing(2);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
auto borderFd = new QComboBox;
|
auto borderFd = new QComboBox;
|
||||||
|
@ -653,9 +664,10 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
});
|
});
|
||||||
hBox->addWidget(borderFd);
|
hBox->addWidget(borderFd);
|
||||||
|
|
||||||
hBox->addSpacing(6);
|
hBox->addStretch();
|
||||||
hBox->addWidget(new QLabel(tr("Effect")+":"));
|
hBox->addLabel(tr("Effect"));
|
||||||
auto borderEffFd = new QComboBox();
|
|
||||||
|
auto borderEffFd = new QComboBox;
|
||||||
borderEffFd->addItem(tr("Rotate"), "rotate");
|
borderEffFd->addItem(tr("Rotate"), "rotate");
|
||||||
borderEffFd->addItem(tr("Blink"), "blink");
|
borderEffFd->addItem(tr("Blink"), "blink");
|
||||||
borderEffFd->addItem(tr("None"), "");
|
borderEffFd->addItem(tr("None"), "");
|
||||||
|
@ -671,9 +683,10 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
});
|
});
|
||||||
hBox->addWidget(borderEffFd);
|
hBox->addWidget(borderEffFd);
|
||||||
|
|
||||||
hBox->addSpacing(6);
|
hBox->addStretch();
|
||||||
hBox->addWidget(new QLabel(tr("Speed")+":"));
|
hBox->addLabel(tr("Speed"));
|
||||||
auto borderSpeedFd = new QComboBox();
|
|
||||||
|
auto borderSpeedFd = new QComboBox;
|
||||||
borderSpeedFd->addItem(tr("Slow"), 1);
|
borderSpeedFd->addItem(tr("Slow"), 1);
|
||||||
borderSpeedFd->addItem(tr("Moderate"), 2);
|
borderSpeedFd->addItem(tr("Moderate"), 2);
|
||||||
borderSpeedFd->addItem(tr("Fast"), 3);
|
borderSpeedFd->addItem(tr("Fast"), 3);
|
||||||
|
@ -688,6 +701,160 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
});
|
});
|
||||||
hBox->addWidget(borderSpeedFd);
|
hBox->addWidget(borderSpeedFd);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
}
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
if(mType!=Window) {
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Play Time"));
|
||||||
|
|
||||||
|
auto line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
vBox->addSpacing(-spacing-2);
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->setSpacing(4);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
if(mMultiWin==0) {
|
||||||
|
hBox->addLabel(tr("Start"));
|
||||||
|
|
||||||
|
auto fdStart = new QSpinBox;
|
||||||
|
fdStart->setRange(0, 9999);
|
||||||
|
fdStart->setValue(mStartTime);
|
||||||
|
hBox->addWidget(fdStart);
|
||||||
|
hBox->addLabel(tr("s"));
|
||||||
|
hBox->addStretch();
|
||||||
|
}
|
||||||
|
|
||||||
|
hBox->addLabel(tr("Duration"));
|
||||||
|
|
||||||
|
fdDuration = new QSpinBox;
|
||||||
|
fdDuration->setRange(1, 9999);
|
||||||
|
fdDuration->setValue(mDuration);
|
||||||
|
hBox->addWidget(fdDuration);
|
||||||
|
hBox->addLabel(tr("s"));
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Effect"));
|
||||||
|
|
||||||
|
line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
vBox->addSpacing(-spacing-2);
|
||||||
|
|
||||||
|
auto grid = new Grid(vBox);
|
||||||
|
grid->setSpacing(4);
|
||||||
|
int ccc = 0;
|
||||||
|
grid->setColumnStretch(ccc++, 1);
|
||||||
|
grid->addLabel(tr("Entry"), 0, ccc++, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto fdEntryEff = new QComboBox;
|
||||||
|
fdEntryEff->addItem(tr("None"), "");
|
||||||
|
fdEntryEff->addItem(tr("Random"), "Random");
|
||||||
|
fdEntryEff->addItem(tr("Expand horizontal"), "EXPAND_HOR");
|
||||||
|
fdEntryEff->addItem(tr("Expand vertical"), "EXPAND_VER");
|
||||||
|
fdEntryEff->addItem(tr("Expand to left"), "EXPAND_LEFT");
|
||||||
|
fdEntryEff->addItem(tr("Expand to top"), "EXPAND_TOP");
|
||||||
|
fdEntryEff->addItem(tr("Expand to right"), "EXPAND_RIGHT");
|
||||||
|
fdEntryEff->addItem(tr("Expand to bottom"), "EXPAND_BOTTOM");
|
||||||
|
fdEntryEff->addItem(tr("Zoom in"), "ZOOM");
|
||||||
|
fdEntryEff->addItem(tr("Zoom in from left-top"), "ZOOM_TL");
|
||||||
|
fdEntryEff->addItem(tr("Zoom in from right-top"), "ZOOM_TR");
|
||||||
|
fdEntryEff->addItem(tr("Zoom in from right-bottom"), "ZOOM_BR");
|
||||||
|
fdEntryEff->addItem(tr("Zoom in from left-bottom"), "ZOOM_BL");
|
||||||
|
fdEntryEff->addItem(tr("Rotate zoom"), "ROTATE");
|
||||||
|
fdEntryEff->addItem(tr("Rotate zoom reverse"), "ROTATE_R");
|
||||||
|
fdEntryEff->addItem(tr("Fade in"), "FADE");
|
||||||
|
fdEntryEff->addItem(tr("Move to left"), "MOVE_LEFT");
|
||||||
|
fdEntryEff->addItem(tr("Move to top"), "MOVE_TOP");
|
||||||
|
fdEntryEff->addItem(tr("Move to right"), "MOVE_RIGHT");
|
||||||
|
fdEntryEff->addItem(tr("Move to bottom"), "MOVE_BOTTOM");
|
||||||
|
SetCurData(fdEntryEff, mEntryEffect);
|
||||||
|
connect(fdEntryEff, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=] {
|
||||||
|
mEntryEffect = fdEntryEff->currentData().toString();
|
||||||
|
});
|
||||||
|
grid->addWidget(fdEntryEff, 0, ccc++);
|
||||||
|
grid->setColumnStretch(ccc++, 1);
|
||||||
|
|
||||||
|
grid->addLabel(tr("Dur"), 0, ccc++, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto fdEntryDur = new QSpinBox;
|
||||||
|
fdEntryDur->setRange(1, 99);
|
||||||
|
fdEntryDur->setValue(mEntryDur);
|
||||||
|
connect(fdEntryDur, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
mEntryDur = value;
|
||||||
|
if(mDuration < value) {
|
||||||
|
mDuration = value;
|
||||||
|
fdDuration->setValue(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
grid->addWidget(fdEntryDur, 0, ccc++);
|
||||||
|
grid->addLabel(tr("s"), 0, ccc++);
|
||||||
|
grid->setColumnStretch(ccc, 1);
|
||||||
|
|
||||||
|
ccc = 1;
|
||||||
|
grid->addLabel(tr("Exit"), 1, ccc++, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto fdExitEff = new QComboBox;
|
||||||
|
fdExitEff->addItem(tr("None"), "");
|
||||||
|
fdExitEff->addItem(tr("Random"), "Random");
|
||||||
|
fdExitEff->addItem(tr("Expand horizontal"), "EXPAND_HOR");
|
||||||
|
fdExitEff->addItem(tr("Expand vertical"), "EXPAND_VER");
|
||||||
|
fdExitEff->addItem(tr("Expand to left"), "EXPAND_LEFT");
|
||||||
|
fdExitEff->addItem(tr("Expand to top"), "EXPAND_TOP");
|
||||||
|
fdExitEff->addItem(tr("Expand to right"), "EXPAND_RIGHT");
|
||||||
|
fdExitEff->addItem(tr("Expand to bottom"), "EXPAND_BOTTOM");
|
||||||
|
fdExitEff->addItem(tr("Zoom out"), "ZOOM");
|
||||||
|
fdExitEff->addItem(tr("Zoom out to left-top"), "ZOOM_TL");
|
||||||
|
fdExitEff->addItem(tr("Zoom out to right-top"), "ZOOM_TR");
|
||||||
|
fdExitEff->addItem(tr("Zoom out to right-bottom"), "ZOOM_BR");
|
||||||
|
fdExitEff->addItem(tr("Zoom out to left-bottom"), "ZOOM_BL");
|
||||||
|
fdExitEff->addItem(tr("Rotate zoom"), "ROTATE");
|
||||||
|
fdExitEff->addItem(tr("Rotate zoom reverse"), "ROTATE_R");
|
||||||
|
fdExitEff->addItem(tr("Fade out"), "FADE");
|
||||||
|
fdExitEff->addItem(tr("Move to left"), "MOVE_LEFT");
|
||||||
|
fdExitEff->addItem(tr("Move to top"), "MOVE_TOP");
|
||||||
|
fdExitEff->addItem(tr("Move to right"), "MOVE_RIGHT");
|
||||||
|
fdExitEff->addItem(tr("Move to bottom"), "MOVE_BOTTOM");
|
||||||
|
SetCurData(fdExitEff, mExitEffect);
|
||||||
|
connect(fdExitEff, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=] {
|
||||||
|
mExitEffect = fdExitEff->currentData().toString();
|
||||||
|
});
|
||||||
|
grid->addWidget(fdExitEff, 1, ccc++);
|
||||||
|
ccc++;
|
||||||
|
|
||||||
|
grid->addLabel(tr("Dur"), 1, ccc++, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto fdExitDur = new QSpinBox;
|
||||||
|
fdExitDur->setRange(1, 99);
|
||||||
|
fdExitDur->setValue(mExitDur);
|
||||||
|
connect(fdExitDur, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
mExitDur = value;
|
||||||
|
if(mDuration < value) {
|
||||||
|
mDuration = value;
|
||||||
|
fdDuration->setValue(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
grid->addWidget(fdExitDur, 1, ccc++);
|
||||||
|
grid->addLabel(tr("s"), 1, ccc++);
|
||||||
|
|
||||||
|
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
mDuration = value;
|
||||||
|
if(mEntryDur > value) {
|
||||||
|
mEntryDur = value;
|
||||||
|
fdEntryDur->setValue(value);
|
||||||
|
}
|
||||||
|
if(mExitDur > value) {
|
||||||
|
mExitDur = value;
|
||||||
|
fdExitDur->setValue(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
#include "gutil/qjson.h"
|
#include "gutil/qjson.h"
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QSpinBox>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#define m_handleLen 10
|
#define m_handleLen 10
|
||||||
|
@ -13,7 +14,7 @@ class EBase : public QGraphicsObject {
|
||||||
public:
|
public:
|
||||||
enum ElementType {
|
enum ElementType {
|
||||||
Text = QGraphicsItem::UserType + 1,
|
Text = QGraphicsItem::UserType + 1,
|
||||||
Photo, Video, Gif, Audio,
|
Image, Video, Gif, Audio,
|
||||||
DClock, AClock, Timer, Environ, Window, Web
|
DClock, AClock, Timer, Environ, Window, Web
|
||||||
};
|
};
|
||||||
Q_ENUM(ElementType)
|
Q_ENUM(ElementType)
|
||||||
|
@ -43,10 +44,13 @@ public:
|
||||||
QRectF innerRect() const;
|
QRectF innerRect() const;
|
||||||
QRectF rect() const { return innerRect(); }
|
QRectF rect() const { return innerRect(); }
|
||||||
|
|
||||||
int mType{-1};
|
int mType = -1;
|
||||||
EBase *mMultiWin{nullptr};
|
EBase *mMultiWin = 0;
|
||||||
qreal mWidth{0.0}, mHeight{0.0};
|
qreal mWidth = 0, mHeight = 0;
|
||||||
int mStartTime{0};
|
QSpinBox *fdDuration = 0;
|
||||||
|
int mStartTime = 0, mDuration = 10;
|
||||||
|
QString mEntryEffect, mExitEffect;
|
||||||
|
int mEntryDur = 1, mExitDur = 1;
|
||||||
signals:
|
signals:
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ EDClock::EDClock(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
m_attr.dateStyle = widget["dateStyle"].toInt();
|
m_attr.dateStyle = widget["dateStyle"].toInt();
|
||||||
m_attr.timeStyle = widget["timeStyle"].toInt();
|
m_attr.timeStyle = widget["timeStyle"].toInt();
|
||||||
m_attr.multiline = widget["multiline"].toBool();
|
m_attr.multiline = widget["multiline"].toBool();
|
||||||
m_attr.playDuration = json["play"]["duration"].toInt();
|
|
||||||
isSingleMD = m_attr.dateStyle==1||m_attr.dateStyle==2||m_attr.dateStyle==4||m_attr.dateStyle==6||m_attr.dateStyle==8||m_attr.dateStyle==10||m_attr.dateStyle==12;
|
isSingleMD = m_attr.dateStyle==1||m_attr.dateStyle==2||m_attr.dateStyle==4||m_attr.dateStyle==6||m_attr.dateStyle==8||m_attr.dateStyle==10||m_attr.dateStyle==12;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -419,35 +418,8 @@ QWidget* EDClock::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdColor);
|
hBox->addWidget(fdColor);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
|
||||||
|
|
||||||
line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
hBox->addWidget(line, 1);
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto fdDuration = new QSpinBox();
|
|
||||||
fdDuration->setRange(1, 99999);
|
|
||||||
fdDuration->setValue(m_attr.playDuration);
|
|
||||||
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
m_attr.playDuration = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdDuration);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
@ -480,6 +452,5 @@ JObj EDClock::attrJson() const{
|
||||||
addBaseAttr(oRoot);
|
addBaseAttr(oRoot);
|
||||||
oRoot["elementType"] = "DClock";
|
oRoot["elementType"] = "DClock";
|
||||||
oRoot["widget"] = oWidget;
|
oRoot["widget"] = oWidget;
|
||||||
oRoot["play"] = JObj{{"duration", m_attr.playDuration}};
|
|
||||||
return oRoot;
|
return oRoot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ public:
|
||||||
bool multiline;
|
bool multiline;
|
||||||
int dateStyle;
|
int dateStyle;
|
||||||
int timeStyle;
|
int timeStyle;
|
||||||
int playDuration = 10;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit EDClock(EBase *multiWin = nullptr);
|
explicit EDClock(EBase *multiWin = nullptr);
|
||||||
|
|
|
@ -14,91 +14,97 @@
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
JObj EEnviron::genProg(const JObj &json, const QString &dstDir, const QString &srcPageDir) {
|
JObj EEnviron::genProg(const JValue &json, const QString &dstDir, const QString &srcPageDir) {
|
||||||
JObj res;
|
JObj res;
|
||||||
res["_type"] = "EnvironmentalMonitoring";
|
res["_type"] = "EnvironmentalMonitoring";
|
||||||
res["name"] = "EnvironmentalMonitoring";
|
res["name"] = "EnvironmentalMonitoring";
|
||||||
res["id"] = "";
|
|
||||||
const auto items = json["items"].toObj();
|
const auto items = json["items"].toObj();
|
||||||
if(! items.empty()) {
|
if(! items.empty()) {
|
||||||
auto title = json["title"].toString();
|
res["backColor"] = json["backColor"];
|
||||||
res["bTitle"] = ! title.isEmpty();
|
res["bSingleScroll"] = json["isSingleLine"];
|
||||||
res["bTemperature"] = items["temp"]["has"];
|
auto scrollSpeed = json["scrollSpeed"].toInt();
|
||||||
|
if(scrollSpeed && json["isSingleLine"].toBool()) {
|
||||||
|
res["scrollSpeed"] = scrollSpeed;
|
||||||
|
res["iScrollSpeed"] = 1000 / scrollSpeed;
|
||||||
|
}
|
||||||
|
res["timeSpan"] = json["duration"];
|
||||||
|
res["alignType"] = json["align"];
|
||||||
res["temperatureCompensation"] = json["tempCompen"];
|
res["temperatureCompensation"] = json["tempCompen"];
|
||||||
res["temperatureStyle"] = json["useFahrenheit"].toInt();
|
res["temperatureStyle"] = json["useFahrenheit"].toInt();
|
||||||
|
QColor color = json["textColor"].toString();
|
||||||
|
auto font = qfont(json["fontFamily"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
||||||
|
font.setUnderline(json["fontUnderline"].toBool());
|
||||||
|
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
|
QFontMetrics metric(font);
|
||||||
|
res["spaceWidth"] = metric.horizontalAdvance(" ");
|
||||||
|
auto title = json["title"].toString();
|
||||||
|
if(! title.isEmpty()) Tools::saveImg(dstDir, metric, font, color, res, title, "title");
|
||||||
|
JObj values;
|
||||||
|
for(auto &str : str0_9) Tools::saveImg(dstDir, metric, font, color, values, str, str);
|
||||||
|
Tools::saveImg(dstDir, metric, font, color, values, ".", ".");
|
||||||
|
Tools::saveImg(dstDir, metric, font, color, values, "-", "-");
|
||||||
|
res["values"] = values;
|
||||||
|
|
||||||
|
JArray oitems;
|
||||||
|
std::unordered_map<QString, QString> unitMap;
|
||||||
|
auto itemMap = genItemMap();
|
||||||
|
for(auto &pair : items) {
|
||||||
|
if(! pair.second["has"].toBool()) continue;
|
||||||
|
oitems->push_back(JObj{{"name", pair.first}});
|
||||||
|
auto oitem = oitems->back().toObj();
|
||||||
|
Tools::saveImg(dstDir, metric, font, color, oitem, pair.second["label"].toString(), "label");
|
||||||
|
auto unit = itemMap[pair.first].unit;
|
||||||
|
if(unit.isEmpty()) continue;
|
||||||
|
auto &url = unitMap[unit];
|
||||||
|
if(url.isEmpty()) url = Tools::saveImg(dstDir, metric, font, color, unit);
|
||||||
|
oitem["unit"] = url;
|
||||||
|
}
|
||||||
|
res["items"] = oitems;
|
||||||
|
|
||||||
|
res["以下字段用来兼容旧播放器"] = 0;
|
||||||
|
res["bTitle"] = ! title.isEmpty();
|
||||||
|
res["bgColor"] = Tools::color2Int(json["backColor"].toString());
|
||||||
|
res["bTemperature"] = items["temperature"]["has"];
|
||||||
res["bHumidity"] = items["humidity"]["has"];
|
res["bHumidity"] = items["humidity"]["has"];
|
||||||
res["bNoise"] = items["noise"]["has"];
|
res["bNoise"] = items["noise"]["has"];
|
||||||
res["bWindSpeed"] = items["windSpeed"]["has"];
|
res["bWindSpeed"] = items["windSpeed"]["has"];
|
||||||
res["bWindDirection"] = items["windDirection"]["has"];
|
res["bWindDirection"] = items["windDirection"]["has"];
|
||||||
res["bPM25"] = items["PM2.5"]["has"];
|
res["bPM25"] = items["pm2.5"]["has"];
|
||||||
res["bPM10"] = items["PM10"]["has"];
|
res["bPM10"] = items["pm10"]["has"];
|
||||||
for(auto item = items.find("SO₂"); item!=items.end(); ++item) res["has"+item->first.left(1).toUpper()+item->first.mid(1)] = item->second["has"];
|
JArray arrayPics;
|
||||||
res["backColor"] = json["backColor"];
|
for(auto &str : str0_9) Tools::saveImg2(dstDir, metric, font, color, arrayPics, str, str);
|
||||||
res["bgColor"] = Tools::color2Int(json["backColor"].toString());
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, title, "labeltitle");
|
||||||
res["bSingleScroll"] = json["isSingleLine"];
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["temperature"]["label"].toString(), "labeltemperature");
|
||||||
res["iScrollSpeed"] = json["scrollSpeed"];
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["humidity"]["label"].toString(), "labelhumidity");
|
||||||
res["timeSpan"] = json["duration"];
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["noise"]["label"].toString(), "labelnoise");
|
||||||
res["alignType"] = json["align"];
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["windSpeed"]["label"].toString(), "labelwindSpeed");
|
||||||
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["windDirection"]["label"].toString(), "labelwindDirection");
|
||||||
QColor textColor = json["textColor"].toString();
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["pm10"]["label"].toString(), "labelpm10");
|
||||||
auto font = qfont(json["fontFamily"].toString(), json["fontSize"].toInt(), json["fontBold"].toBool(), json["fontItalic"].toBool());
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, items["pm2.5"]["label"].toString(), "labelpm25");
|
||||||
font.setUnderline(json["fontUnderline"].toBool());
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "℃", "unit_celsius");
|
||||||
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "℉", "unit_fahrenheit");
|
||||||
QFontMetricsF metricF(font);
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "%", "unit_humidity");
|
||||||
res["spaceWidth"] = metricF.horizontalAdvance(" ");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "dB", "unit_noise");
|
||||||
QFontMetrics metric(font);
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "m/s", "unit_windspeed");
|
||||||
QColor color(textColor);
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "μg/m³", "unit_pm10");
|
||||||
JArray imgs;
|
arrayPics.append(arrayPics->back());
|
||||||
for(auto str : str0_9) Tools::saveImg2(dstDir, metric, font, color, imgs, str, str);
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, "-", "minus_sign");
|
||||||
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("N"), "N");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, title, "labeltitle");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("N")+tr("NE"), "NNE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["temp"]["label"].toString(), "labeltemperature");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("NE"), "NE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["humidity"]["label"].toString(), "labelhumidity");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("E")+tr("NE"), "ENE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["noise"]["label"].toString(), "labelnoise");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("E"), "E");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["windSpeed"]["label"].toString(), "labelwindSpeed");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("E")+tr("SE"), "ESE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["windDirection"]["label"].toString(), "labelwindDirection");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("SE"), "SE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["PM2.5"]["label"].toString(), "labelpm25");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("S")+tr("SE"), "SSE");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["PM10"]["label"].toString(), "labelpm10");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("S"), "S");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["SO₂"]["label"].toString(), "label_SO₂");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("S")+tr("SW"), "SSW");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["NO₂"]["label"].toString(), "label_NO₂");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("SW"), "SW");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["CO"]["label"].toString(), "label_CO");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("W")+tr("SW"), "WSW");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["O₃"]["label"].toString(), "label_O₃");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("W"), "W");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["pressure"]["label"].toString(), "label_pressure");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("W")+tr("NW"), "WNW");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["rainfall"]["label"].toString(), "label_rainfall");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("NW"), "NW");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["radiation"]["label"].toString(), "label_radiation");
|
Tools::saveImg2(dstDir, metric, font, color, arrayPics, tr("N")+tr("NW"), "NNW");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, items["beam"]["label"].toString(), "label_beam");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "℃", "unit_celsius");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "℉", "unit_fahrenheit");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "%", "unit_humidity");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "dB", "unit_noise");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "m/s", "unit_windspeed");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "μg/m³", "unit_pm25");
|
|
||||||
auto img = imgs->back().toObj();
|
|
||||||
img["name"] = "unit_pm10";
|
|
||||||
imgs.append(img);
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "ppb", "unit_ppb");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "hpa", "unit_hpa");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "mm", "unit_mm");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "W/m²", "unit_W/m²");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "lux", "unit_lux");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "minus_sign");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("north"), "N");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("north")+tr("east")+tr("north"), "NNE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("north"), "NE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("east")+tr("north"), "ENE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east"), "E");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("east")+tr("south"), "ESE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("south"), "SE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("south")+tr("east")+tr("south"), "SSE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("south"), "S");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("south")+tr("west")+tr("south"), "SSW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("south"), "SW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("west")+tr("south"), "WSW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west"), "W");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("west")+tr("north"), "WNW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("north"), "NW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("north")+tr("west")+tr("north"), "NNW");
|
|
||||||
|
|
||||||
JObj arrayPic;
|
JObj arrayPic;
|
||||||
arrayPic["name"] = "previewTmp";
|
arrayPic["name"] = "previewTmp";
|
||||||
QString srcFile = srcPageDir+"/previewTmp.png";
|
QString srcFile = srcPageDir+"/previewTmp.png";
|
||||||
|
@ -108,83 +114,9 @@ JObj EEnviron::genProg(const JObj &json, const QString &dstDir, const QString &s
|
||||||
srcQFile.copy(dstDir+"/"+id);
|
srcQFile.copy(dstDir+"/"+id);
|
||||||
arrayPic["id"] = id;
|
arrayPic["id"] = id;
|
||||||
}
|
}
|
||||||
imgs.append(arrayPic);
|
arrayPics.append(arrayPic);
|
||||||
res["iPicCount"] = (int)imgs.size();
|
res["arrayPics"] = arrayPics;
|
||||||
res["arrayPics"] = imgs;
|
res["旧播放器兼容结束"] = 0;
|
||||||
} else {
|
|
||||||
auto widget = json["widget"];
|
|
||||||
res["timeSpan"] = json["play"]["duration"].toInt();
|
|
||||||
res["alignType"] = widget["alignType"].toInt();
|
|
||||||
res["bHumidity"] = widget["bHumidity"].toBool();
|
|
||||||
res["bNoise"] = widget["bNoise"].toBool();
|
|
||||||
res["bPM10"] = widget["bPM10"].toBool();
|
|
||||||
res["bPM25"] = widget["bPM25"].toBool();
|
|
||||||
res["bTemperature"] = widget["bTemperature"].toBool();
|
|
||||||
auto title = widget["labelTitle"].toString();
|
|
||||||
res["bTitle"] = ! title.isEmpty();
|
|
||||||
res["bWindDirection"] = widget["bWindDirection"].toBool();
|
|
||||||
res["bWindSpeed"] = widget["bWindSpeed"].toBool();
|
|
||||||
res["temperatureCompensation"] = widget["temperatureCompensation"].toInt();
|
|
||||||
res["temperatureStyle"] = widget["temperatureStyle"].toInt();
|
|
||||||
res["bgColor"] = widget["cBackground"].toInt();
|
|
||||||
res["bSingleScroll"] = widget["bPaomadeng"].toBool();
|
|
||||||
res["iScrollSpeed"] = widget["scrollSpeed"].toInt();
|
|
||||||
|
|
||||||
auto textColor = Tools::int2Color(widget["textColor"].toInt());
|
|
||||||
auto font = qfont(widget["fontFamily"].toString(), widget["fontSize"].toInt(), widget["fontBold"].toBool(), widget["fontItalics"].toBool());
|
|
||||||
font.setUnderline(widget["fontUnderline"].toBool());
|
|
||||||
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
|
||||||
QFontMetricsF metricF(font);
|
|
||||||
res["spaceWidth"] = metricF.horizontalAdvance(" ");
|
|
||||||
QFontMetrics metric(font);
|
|
||||||
QColor color(textColor);
|
|
||||||
JArray imgs;
|
|
||||||
for(auto str : str0_9) Tools::saveImg2(dstDir, metric, font, color, imgs, str, str);
|
|
||||||
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, title, "labeltitle");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelTemperature"].toString(), "labeltemperature");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelHumidity"].toString(), "labelhumidity");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelNoise"].toString(), "labelnoise");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelWindSpeed"].toString(), "labelwindSpeed");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelWindDirection"].toString(), "labelwindDirection");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelPM25"].toString(), "labelpm25");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, widget["labelPM10"].toString(), "labelpm10");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "℃", "unit_celsius");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "℉", "unit_fahrenheit");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "%", "unit_humidity");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "dB", "unit_noise");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "m/s", "unit_windspeed");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "μg/m³", "unit_pm10");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "μg/m³", "unit_pm25");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "minus_sign");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("north"), "N");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("north")+tr("east")+tr("north"), "NNE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("north"), "NE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("east")+tr("north"), "ENE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east"), "E");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("east")+tr("south"), "ESE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("east")+tr("south"), "SE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("south")+tr("east")+tr("south"), "SSE");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("south"), "S");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("south")+tr("west")+tr("south"), "SSW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("south"), "SW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("west")+tr("south"), "WSW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west"), "W");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("west")+tr("north"), "WNW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("west")+tr("north"), "NW");
|
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, tr("north")+tr("west")+tr("north"), "NNW");
|
|
||||||
JObj arrayPic;
|
|
||||||
arrayPic["name"] = "previewTmp";
|
|
||||||
QString srcFile = srcPageDir+"/previewTmp.png";
|
|
||||||
QFile srcQFile(srcFile);
|
|
||||||
if(srcQFile.exists()) {
|
|
||||||
QString id = Tools::fileMd5(srcFile);
|
|
||||||
srcQFile.copy(dstDir+"/"+id);
|
|
||||||
arrayPic["id"] = id;
|
|
||||||
}
|
|
||||||
imgs.append(arrayPic);
|
|
||||||
res["iPicCount"] = (int)imgs.size();
|
|
||||||
res["arrayPics"] = imgs;
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +139,6 @@ EEnviron::EEnviron(const JObj &json, EBase *multiWin): EBase(multiWin){
|
||||||
iter->second.has = jitem.second["has"].toBool();
|
iter->second.has = jitem.second["has"].toBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
duration = json["duration"].toInt();
|
|
||||||
backColor = json["backColor"].toStr("#00000000");
|
backColor = json["backColor"].toStr("#00000000");
|
||||||
textColor = json["textColor"].toStr("#ff000000");
|
textColor = json["textColor"].toStr("#ff000000");
|
||||||
tempCompen = json["tempCompen"].toInt();
|
tempCompen = json["tempCompen"].toInt();
|
||||||
|
@ -245,7 +176,6 @@ EEnviron::EEnviron(const JObj &json, EBase *multiWin): EBase(multiWin){
|
||||||
item->second.label = item->second.text+": ";
|
item->second.label = item->second.text+": ";
|
||||||
item->second.has = false;
|
item->second.has = false;
|
||||||
}
|
}
|
||||||
duration = json["play"]["duration"].toInt();
|
|
||||||
backColor = Tools::int2Color(widget["cBackground"].toInt());
|
backColor = Tools::int2Color(widget["cBackground"].toInt());
|
||||||
textColor = Tools::int2Color(widget["textColor"].toInt());
|
textColor = Tools::int2Color(widget["textColor"].toInt());
|
||||||
tempCompen = widget["temperatureCompensation"].toInt();
|
tempCompen = widget["temperatureCompensation"].toInt();
|
||||||
|
@ -309,7 +239,7 @@ void EEnviron::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
if(isSingleLine) {
|
if(isSingleLine) {
|
||||||
if(timer_id==0) {
|
if(timer_id==0) {
|
||||||
scroll_off = innerRect().width();
|
scroll_off = innerRect().width();
|
||||||
timer_id = startTimer(scrollSpeed, Qt::PreciseTimer);
|
timer_id = startTimer(1000/scrollSpeed, Qt::PreciseTimer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(timer_id!=0) {
|
if(timer_id!=0) {
|
||||||
|
@ -508,7 +438,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdSpeed);
|
hBox->addWidget(fdSpeed);
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("ms/pixel")));
|
hBox->addLabel("px/s");
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
line = new QFrame;
|
line = new QFrame;
|
||||||
|
@ -598,30 +528,6 @@ QWidget* EEnviron::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdBack);
|
hBox->addWidget(fdBack);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
|
||||||
|
|
||||||
line = new QFrame;
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
hBox->addWidget(line, 1);
|
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto fdDuration = new QSpinBox();
|
|
||||||
fdDuration->setRange(1, 99999);
|
|
||||||
fdDuration->setValue(duration);
|
|
||||||
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
|
||||||
duration = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdDuration);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +556,6 @@ JObj EEnviron::attrJson() const{
|
||||||
json["textColor"] = textColor.name(QColor::HexArgb);
|
json["textColor"] = textColor.name(QColor::HexArgb);
|
||||||
json["backColor"] = backColor.name(QColor::HexArgb);
|
json["backColor"] = backColor.name(QColor::HexArgb);
|
||||||
json["idDir"] = QString("env-%1-%2-%3-%4-%5").arg((int) zValue()).arg((int) x()).arg((int) y()).arg((int) mWidth).arg((int) mHeight);
|
json["idDir"] = QString("env-%1-%2-%3-%4-%5").arg((int) zValue()).arg((int) x()).arg((int) y()).arg((int) mWidth).arg((int) mHeight);
|
||||||
json["duration"] = duration;
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,35 +13,38 @@ struct EnvironItem {
|
||||||
class EEnviron : public EBase {
|
class EEnviron : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LinkedMap<QString, EnvironItem> itemMap {
|
static LinkedMap<QString, EnvironItem> genItemMap() {
|
||||||
{"temp", {tr("Temperature"), "℃"}},
|
return LinkedMap<QString, EnvironItem> {
|
||||||
|
{"temperature", {tr("Temperature"), "℃"}},
|
||||||
{"humidity", {tr("Humidity"), "%"}},
|
{"humidity", {tr("Humidity"), "%"}},
|
||||||
{"noise", {tr("Noise"), "dB"}},
|
{"noise", {tr("Noise"), "dB"}},
|
||||||
{"windSpeed", {tr("Wind Speed"), "m/s"}},
|
{"windSpeed", {tr("Wind Speed"), "m/s"}},
|
||||||
{"windDirection", {tr("Wind Direction")}},
|
{"windDirection", {tr("Wind Direction")}},
|
||||||
{"PM2.5", {"PM2.5", "μg/m³"}},
|
{"pm2.5", {"PM2.5", "μg/m³"}},
|
||||||
{"PM10", {"PM10", "μg/m³"}},
|
{"pm10", {"PM10", "μg/m³"}},
|
||||||
{"SO₂", {"SO₂", "ppb"}},
|
{"SO2", {"SO₂", "ppb"}},
|
||||||
{"NO₂", {"NO₂", "ppb"}},
|
{"NO2", {"NO₂", "ppb"}},
|
||||||
{"CO", {"CO", "ppb"}},
|
{"CO", {"CO", "ppb"}},
|
||||||
{"O₃", {"O₃", "ppb"}},
|
{"O3", {"O₃", "ppb"}},
|
||||||
{"pressure", {tr("Pressure"), "hpa"}},
|
{"pressure", {tr("Pressure"), "hPa"}},
|
||||||
{"rainfall", {tr("Rainfall"), "mm"}},
|
{"rainfall", {tr("Rainfall"), "mm"}},
|
||||||
{"radiation", {tr("Radiation"), "W/m²"}},
|
{"radiation", {tr("Radiation"), "W/m²"}},
|
||||||
{"beam", {tr("Beam"), "lux"}}
|
{"beam", {tr("Beam"), "lux"}},
|
||||||
|
{"CO2", {"CO₂", "ppm"}}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
LinkedMap<QString, EnvironItem> itemMap = genItemMap();
|
||||||
QString title;
|
QString title;
|
||||||
QColor textColor = Qt::red;
|
QColor textColor = Qt::red;
|
||||||
QColor backColor = Qt::transparent;
|
QColor backColor = Qt::transparent;
|
||||||
QFont font = qfont("Arial", 12);
|
QFont font = qfont("Arial", 12);
|
||||||
int tempCompen = 0;
|
int tempCompen = 0;
|
||||||
int align = 0;
|
int align = 0;
|
||||||
int duration = 10;
|
int scrollSpeed = 30;
|
||||||
int scrollSpeed = 33;
|
|
||||||
bool useFahrenheit = false;
|
bool useFahrenheit = false;
|
||||||
bool isSingleLine = false;
|
bool isSingleLine = false;
|
||||||
|
|
||||||
static JObj genProg(const JObj &, const QString &, const QString &);
|
static JObj genProg(const JValue &, const QString &, const QString &);
|
||||||
|
|
||||||
explicit EEnviron(EBase *multiWin = nullptr);
|
explicit EEnviron(EBase *multiWin = nullptr);
|
||||||
explicit EEnviron(const JObj &json, EBase *multiWin = nullptr);
|
explicit EEnviron(const JObj &json, EBase *multiWin = nullptr);
|
||||||
|
|
|
@ -42,9 +42,6 @@ EGif *EGif::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
||||||
movie->jumpToFrame(0);
|
movie->jumpToFrame(0);
|
||||||
auto ins = new EGif(movie, dir, name, pageItem, multiWin);
|
auto ins = new EGif(movie, dir, name, pageItem, multiWin);
|
||||||
ins->setBaseAttr(json);
|
ins->setBaseAttr(json);
|
||||||
auto play = json["play"];
|
|
||||||
ins->mDuration = play["playDuration"].toInt();
|
|
||||||
ins->mPlayTimes = play["playTimes"].toInt();
|
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,46 +141,6 @@ QWidget* EGif::attrWgt() {
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
|
||||||
|
|
||||||
line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
hBox->addWidget(line, 1);
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto wPlayDuration = new QSpinBox();
|
|
||||||
wPlayDuration->setRange(1, 99999);
|
|
||||||
wPlayDuration->setValue(mDuration);
|
|
||||||
connect(wPlayDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
mDuration = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(wPlayDuration);
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Times")));
|
|
||||||
|
|
||||||
auto wPlayTimes = new QSpinBox();
|
|
||||||
wPlayTimes->setRange(1, 99999);
|
|
||||||
wPlayTimes->setValue(mPlayTimes);
|
|
||||||
connect(wPlayTimes, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
mPlayTimes = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(wPlayTimes);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
@ -206,9 +163,5 @@ JObj EGif::attrJson() const {
|
||||||
{"file", mName},
|
{"file", mName},
|
||||||
{"path", mDir}
|
{"path", mDir}
|
||||||
};
|
};
|
||||||
oRoot["play"] = JObj{
|
|
||||||
{"playDuration", mDuration},
|
|
||||||
{"playTimes", mPlayTimes}
|
|
||||||
};
|
|
||||||
return oRoot;
|
return oRoot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,7 @@ public slots:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PageListItem *mPageItem;
|
PageListItem *mPageItem;
|
||||||
int mDuration = 10;
|
SyncTimer* timer = 0;
|
||||||
int mPlayTimes = 1;
|
|
||||||
SyncTimer* timer = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EGIF_H
|
#endif // EGIF_H
|
||||||
|
|
|
@ -27,13 +27,13 @@ EMultiWin::EMultiWin(const JObj &json, PageListItem *pageItem) : mPageItem(pageI
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
auto elements = json["elements"].toArray();
|
auto elements = json["elements"].toArray();
|
||||||
index = json["index"].toInt();
|
index = json["index"].toInt();
|
||||||
for(auto element : elements) {
|
for(auto &element : elements) {
|
||||||
QString type = element["elementType"].toString();
|
QString type = element["elementType"].toString();
|
||||||
EBase *inner = nullptr;
|
EBase *inner = nullptr;
|
||||||
if(type=="Text") inner = new EText(element.toObj(), this);
|
if(type=="Text") inner = new EText(element.toObj(), this);
|
||||||
else if(type=="Photo") inner = EPhoto::create(element.toObj(), pageItem, this);
|
else if(type=="Image"||type=="Photo") inner = EPhoto::create(element.toObj(), pageItem, this);
|
||||||
else if(type=="Gif") inner = EGif::create(element.toObj(), pageItem, this);
|
else if(type=="Gif") inner = EGif::create(element.toObj(), pageItem, this);
|
||||||
else if(type=="Movie") inner = EVideo::create(element.toObj(), pageItem, this);
|
else if(type=="Video"||type=="Movie") inner = EVideo::create(element.toObj(), pageItem, this);
|
||||||
else if(type=="DClock") inner = new EDClock(element.toObj(), this);
|
else if(type=="DClock") inner = new EDClock(element.toObj(), this);
|
||||||
else if(type=="AClock") inner = new EAClock(element.toObj(), this);
|
else if(type=="AClock") inner = new EAClock(element.toObj(), this);
|
||||||
else if(type=="Temp") inner = new EEnviron(element.toObj(), this);
|
else if(type=="Temp") inner = new EEnviron(element.toObj(), this);
|
||||||
|
@ -127,7 +127,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
|
|
||||||
auto menu = new QMenu();
|
auto menu = new QMenu();
|
||||||
menu->addAction(QIcon(":/res/program/Text.png"), tr("Text"))->setData(EBase::Text);
|
menu->addAction(QIcon(":/res/program/Text.png"), tr("Text"))->setData(EBase::Text);
|
||||||
menu->addAction(QIcon(":/res/program/Photo.png"), tr("Photo"))->setData(EBase::Photo);
|
menu->addAction(QIcon(":/res/program/Photo.png"), tr("Photo"))->setData(EBase::Image);
|
||||||
menu->addAction(QIcon(":/res/program/Movie.png"), tr("Video"))->setData(EBase::Video);
|
menu->addAction(QIcon(":/res/program/Movie.png"), tr("Video"))->setData(EBase::Video);
|
||||||
menu->addAction(QIcon(":/res/program/Gif.png"), tr("Gif"))->setData(EBase::Gif);
|
menu->addAction(QIcon(":/res/program/Gif.png"), tr("Gif"))->setData(EBase::Gif);
|
||||||
menu->addAction(QIcon(":/res/program/DClock.png"), tr("DClock"))->setData(EBase::DClock);
|
menu->addAction(QIcon(":/res/program/DClock.png"), tr("DClock"))->setData(EBase::DClock);
|
||||||
|
@ -138,7 +138,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
int order = listWgt->count();
|
int order = listWgt->count();
|
||||||
EBase *ele = 0;
|
EBase *ele = 0;
|
||||||
QListWidgetItem *item = 0;
|
QListWidgetItem *item = 0;
|
||||||
if(type==EBase::Photo) {
|
if(type==EBase::Image) {
|
||||||
auto files = QFileDialog::getOpenFileNames(wgtAttr, tr("Select File"), gFileHome, EPhoto::filters());
|
auto files = QFileDialog::getOpenFileNames(wgtAttr, tr("Select File"), gFileHome, EPhoto::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto ePhoto = EPhoto::create(files[i], mPageItem, this);
|
auto ePhoto = EPhoto::create(files[i], mPageItem, this);
|
||||||
|
@ -277,7 +277,7 @@ QWidget* EMultiWin::attrWgt() {
|
||||||
QListWidgetItem *item = 0;
|
QListWidgetItem *item = 0;
|
||||||
int type = inner->type();
|
int type = inner->type();
|
||||||
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
|
if(type==EBase::Text) item = new QListWidgetItem(QIcon(":/res/program/Text.png"), tr("Text"));
|
||||||
else if(type==EBase::Photo) item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+static_cast<EPhoto*>(inner)->mName);
|
else if(type==EBase::Image) item = new QListWidgetItem(QIcon(":/res/program/Photo.png"), tr("Photo")+" "+static_cast<EPhoto*>(inner)->mName);
|
||||||
else if(type==EBase::Video) item = new QListWidgetItem(QIcon(":/res/program/Movie.png"), tr("Video")+" "+static_cast<EVideo*>(inner)->mRawName);
|
else if(type==EBase::Video) item = new QListWidgetItem(QIcon(":/res/program/Movie.png"), tr("Video")+" "+static_cast<EVideo*>(inner)->mRawName);
|
||||||
else if(type==EBase::Gif) item = new QListWidgetItem(QIcon(":/res/program/Gif.png"), tr("Gif")+" "+static_cast<EGif*>(inner)->mName);
|
else if(type==EBase::Gif) item = new QListWidgetItem(QIcon(":/res/program/Gif.png"), tr("Gif")+" "+static_cast<EGif*>(inner)->mName);
|
||||||
else if(type==EBase::DClock) item = new QListWidgetItem(QIcon(":/res/program/DClock.png"), tr("DClock"));
|
else if(type==EBase::DClock) item = new QListWidgetItem(QIcon(":/res/program/DClock.png"), tr("DClock"));
|
||||||
|
|
|
@ -22,8 +22,8 @@ EPhoto *EPhoto::create(const QString &file, PageListItem *pageItem, EBase *multi
|
||||||
}
|
}
|
||||||
EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
auto dir = widget["path"].toString();
|
auto dir = (widget.isNull() ? json["dir"] : widget["path"]).toString();
|
||||||
auto name = widget["file"].toString();
|
auto name = (widget.isNull() ? json["name"] : widget["file"]).toString();
|
||||||
if(! QFileInfo(dir).isDir()) dir = pageItem->mPageDir;
|
if(! QFileInfo(dir).isDir()) dir = pageItem->mPageDir;
|
||||||
QString file = dir + "/" + name;
|
QString file = dir + "/" + name;
|
||||||
QFileInfo fileInfo(file);
|
QFileInfo fileInfo(file);
|
||||||
|
@ -35,35 +35,23 @@ EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin
|
||||||
else return nullptr;
|
else return nullptr;
|
||||||
}
|
}
|
||||||
auto img = QImage(file);
|
auto img = QImage(file);
|
||||||
if(img.isNull()) return nullptr;
|
if(img.isNull()) return 0;
|
||||||
auto ins = new EPhoto(img, dir, name, pageItem, multiWin);
|
auto ins = new EPhoto(img, dir, name, pageItem, multiWin);
|
||||||
ins->setBaseAttr(json);
|
ins->setBaseAttr(json);
|
||||||
auto play = json["play"];
|
|
||||||
ins->mDuration = play["playDuration"].toInt();
|
|
||||||
ins->mEnterStyle = play["enterStyle"].toInt();
|
|
||||||
ins->mEnterDuration = play["enterDuration"].toInt();
|
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
|
|
||||||
EPhoto::EPhoto(const QImage &img, const QString &dir, const QString &name, PageListItem *pageItem, EBase *multiWin) : EBase(multiWin), img(img), mDir(dir), mName(name), mPageItem(pageItem) {
|
EPhoto::EPhoto(const QImage &img, const QString &dir, const QString &name, PageListItem *pageItem, EBase *multiWin) : EBase(multiWin), img(img), mDir(dir), mName(name), mPageItem(pageItem) {
|
||||||
mType = EBase::Photo;
|
mType = EBase::Image;
|
||||||
scaleImgIfNeed();
|
scaleImgIfNeed();
|
||||||
}
|
}
|
||||||
JObj EPhoto::attrJson() const {
|
JObj EPhoto::attrJson() const {
|
||||||
JObj oRoot;
|
JObj json;
|
||||||
addBaseAttr(oRoot);
|
addBaseAttr(json);
|
||||||
oRoot["elementType"] = "Photo";
|
json["elementType"] = "Image";
|
||||||
oRoot["widget"] = JObj{
|
json["dir"] = mDir;
|
||||||
{"path", mDir},
|
json["name"] = mName;
|
||||||
{"file", mName}
|
return json;
|
||||||
};
|
|
||||||
oRoot["play"] = JObj{
|
|
||||||
{"playDuration", mDuration},
|
|
||||||
{"playTimes", 1},
|
|
||||||
{"enterStyle", mEnterStyle},
|
|
||||||
{"enterDuration", mEnterDuration}
|
|
||||||
};
|
|
||||||
return oRoot;
|
|
||||||
}
|
}
|
||||||
void EPhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void EPhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
painter->drawImage(innerRect(), img);
|
painter->drawImage(innerRect(), img);
|
||||||
|
@ -95,14 +83,14 @@ bool EPhoto::save(const QString &pageDir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* EPhoto::attrWgt() {
|
QWidget* EPhoto::attrWgt() {
|
||||||
auto wgtAttr = new QWidget();
|
auto wgtAttr = new QWidget;
|
||||||
auto vBox = new QVBoxLayout(wgtAttr);
|
auto vBox = new VBox(wgtAttr);
|
||||||
vBox->setContentsMargins(6, 0, 6, 0);
|
vBox->setContentsMargins(6, 0, 6, 0);
|
||||||
if(mMultiWin) vBox->setSpacing(3);
|
if(mMultiWin) vBox->setSpacing(3);
|
||||||
|
|
||||||
addBaseAttrWgt(vBox);
|
addBaseAttrWgt(vBox);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout();
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
hBox->addWidget(new QLabel(tr("Basic Properties")));
|
||||||
|
|
||||||
auto line = new QFrame();
|
auto line = new QFrame();
|
||||||
|
@ -110,9 +98,7 @@ QWidget* EPhoto::attrWgt() {
|
||||||
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();
|
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("File")));
|
hBox->addWidget(new QLabel(tr("File")));
|
||||||
|
|
||||||
|
@ -143,86 +129,98 @@ QWidget* EPhoto::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(bnSelectFile);
|
hBox->addWidget(bnSelectFile);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
// hBox = new HBox(vBox);
|
||||||
|
// hBox->addWidget(new QLabel(tr("Play Properties")));
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
// line = new QFrame();
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
// line->setFrameShape(QFrame::HLine);
|
||||||
|
// line->setFrameShadow(QFrame::Sunken);
|
||||||
|
// hBox->addWidget(line, 1);
|
||||||
|
|
||||||
line = new QFrame();
|
// hBox = new HBox(vBox);
|
||||||
line->setFrameShape(QFrame::HLine);
|
// hBox->setSpacing(2);
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
// hBox->addSpacing(6);
|
||||||
hBox->addWidget(line, 1);
|
// hBox->addWidget(new QLabel(tr("Entry Effect")));
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
// auto fdEntryEff = new QComboBox;
|
||||||
|
// fdEntryEff->addItem(tr("None"), "");
|
||||||
|
// fdEntryEff->addItem(tr("Move to left"), "moving_left");
|
||||||
|
// fdEntryEff->addItem(tr("Move to top"), "moving_top");
|
||||||
|
// fdEntryEff->addItem(tr("Move to right"), "moving_right");
|
||||||
|
// fdEntryEff->addItem(tr("Move to bottom"), "moving_bottom");
|
||||||
|
// fdEntryEff->addItem(tr("Alpha in"), "alpha_in");
|
||||||
|
// fdEntryEff->addItem(tr("Zoom in"), "zoom_in");
|
||||||
|
// fdEntryEff->addItem(tr("Zoom in from left-top"), "zoom_in_left_top");
|
||||||
|
// fdEntryEff->addItem(tr("Zoom in from right-top"), "zoom_in_right_top");
|
||||||
|
// fdEntryEff->addItem(tr("Zoom in from right-bottom"), "zoom_in_right_bottom");
|
||||||
|
// fdEntryEff->addItem(tr("Zoom in from left-bottom"), "zoom_in_left_bottom");
|
||||||
|
// fdEntryEff->addItem(tr("Rotate to right"), "rotate_right");
|
||||||
|
// fdEntryEff->addItem(tr("Rotate to left"), "rotate_left");
|
||||||
|
// fdEntryEff->addItem(tr("Random"), "Random");
|
||||||
|
// SetCurData(fdEntryEff, mEntryEffect);
|
||||||
|
// connect(fdEntryEff, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=] {
|
||||||
|
// mEntryEffect = fdEntryEff->currentData().toString();
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(fdEntryEff);
|
||||||
|
// hBox->addStretch();
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
// hBox->addLabel(tr("Dur"));
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto fdDuration = new QSpinBox();
|
// auto fdEntryDur = new QSpinBox;
|
||||||
fdDuration->setRange(1, 99999);
|
// fdEntryDur->setRange(1, 99);
|
||||||
fdDuration->setValue(mDuration);
|
// fdEntryDur->setValue(mEntryDur);
|
||||||
hBox->addWidget(fdDuration);
|
// connect(fdEntryDur, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
||||||
|
// mEntryDur = value;
|
||||||
|
// if(mDuration < value) {
|
||||||
|
// mDuration = value;
|
||||||
|
// fdDuration->setValue(value);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(fdEntryDur);
|
||||||
|
// hBox->addLabel(tr("s"));
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
// hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
// hBox->setSpacing(2);
|
||||||
|
// hBox->addSpacing(6);
|
||||||
|
// hBox->addWidget(new QLabel(tr("Exit Effect")));
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
// auto fdExitEff = new QComboBox;
|
||||||
|
// fdExitEff->addItem(tr("None"), "");
|
||||||
|
// fdExitEff->addItem(tr("Move to left"), "moving_left");
|
||||||
|
// fdExitEff->addItem(tr("Move to top"), "moving_top");
|
||||||
|
// fdExitEff->addItem(tr("Move to right"), "moving_right");
|
||||||
|
// fdExitEff->addItem(tr("Move to bottom"), "moving_bottom");
|
||||||
|
// fdExitEff->addItem(tr("Alpha out"), "alpha_out");
|
||||||
|
// fdExitEff->addItem(tr("Zoom out"), "zoom_out");
|
||||||
|
// fdExitEff->addItem(tr("Zoom out to left-top"), "zoom_out_left_top");
|
||||||
|
// fdExitEff->addItem(tr("Zoom out to right-top"), "zoom_out_right_top");
|
||||||
|
// fdExitEff->addItem(tr("Zoom out to right-bottom"), "zoom_out_right_bottom");
|
||||||
|
// fdExitEff->addItem(tr("Zoom out to left-bottom"), "zoom_out_left_bottom");
|
||||||
|
// fdExitEff->addItem(tr("Rotate to right"), "rotate_right");
|
||||||
|
// fdExitEff->addItem(tr("Rotate to left"), "rotate_left");
|
||||||
|
// fdExitEff->addItem(tr("Random"), "Random");
|
||||||
|
// SetCurData(fdExitEff, mExitEffect);
|
||||||
|
// connect(fdExitEff, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=] {
|
||||||
|
// mExitEffect = fdExitEff->currentData().toString();
|
||||||
|
// });
|
||||||
|
// hBox->addWidget(fdExitEff);
|
||||||
|
// hBox->addStretch();
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
// hBox->addLabel(tr("Dur"));
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Enter Style")));
|
|
||||||
|
|
||||||
auto wEnterStyle = new QComboBox();
|
// auto fdExitDur = new QSpinBox;
|
||||||
wEnterStyle->addItem(tr("None"));
|
// fdExitDur->setRange(1, 99);
|
||||||
wEnterStyle->addItem(tr("Alpha In"));
|
// fdExitDur->setValue(mExitDur);
|
||||||
wEnterStyle->addItem(tr("Moving to left"));
|
// connect(fdExitDur, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
||||||
wEnterStyle->addItem(tr("Moving to right"));
|
// mExitDur = value;
|
||||||
wEnterStyle->addItem(tr("Moving to top"));
|
// if(mDuration < value) {
|
||||||
wEnterStyle->addItem(tr("Move to bottom"));
|
// mDuration = value;
|
||||||
wEnterStyle->addItem(tr("Zoom In"));
|
// fdDuration->setValue(value);
|
||||||
wEnterStyle->addItem(tr("Zoom In to left_bottom"));
|
// }
|
||||||
wEnterStyle->addItem(tr("Zoom In to left_top"));
|
// });
|
||||||
wEnterStyle->addItem(tr("Zoom In to right_top"));
|
// hBox->addWidget(fdExitDur);
|
||||||
wEnterStyle->addItem(tr("Zoom In to right bottom"));
|
// hBox->addLabel(tr("s"));
|
||||||
wEnterStyle->addItem(tr("Rotate to right"));
|
|
||||||
wEnterStyle->addItem(tr("Rotate to left"));
|
|
||||||
wEnterStyle->setCurrentIndex(mEnterStyle);
|
|
||||||
connect(wEnterStyle, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int value) {
|
|
||||||
mEnterStyle = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(wEnterStyle);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Enter Duration")));
|
|
||||||
|
|
||||||
auto fdEnterDuration = new QSpinBox();
|
|
||||||
fdEnterDuration->setRange(1, 99999);
|
|
||||||
fdEnterDuration->setValue(mEnterDuration);
|
|
||||||
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdEnterDuration](int value){
|
|
||||||
mDuration = value;
|
|
||||||
if(mEnterDuration > value) {
|
|
||||||
mEnterDuration = value;
|
|
||||||
fdEnterDuration->setValue(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connect(fdEnterDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdDuration](int value){
|
|
||||||
mEnterDuration = value;
|
|
||||||
if(mDuration < value) {
|
|
||||||
mDuration = value;
|
|
||||||
fdDuration->setValue(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdEnterDuration);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,16 +6,6 @@
|
||||||
|
|
||||||
class EPhoto : public EBase {
|
class EPhoto : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
enum EnterStyle {
|
|
||||||
NoneStyle = 0,
|
|
||||||
Expanding2Left,
|
|
||||||
Expanding2Right,
|
|
||||||
Expanding2Top,
|
|
||||||
Expanding2Bottom,
|
|
||||||
ExpandingFromCenter
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QString filters() { return tr("Images (*.png *.jpg *.jpeg *.bmp)"); }
|
static QString filters() { return tr("Images (*.png *.jpg *.jpeg *.bmp)"); }
|
||||||
static EPhoto *create(const QString &file, PageListItem *pageItem, EBase *multiWin = nullptr);
|
static EPhoto *create(const QString &file, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
|
@ -25,7 +15,7 @@ public:
|
||||||
|
|
||||||
void scaleImgIfNeed();
|
void scaleImgIfNeed();
|
||||||
|
|
||||||
int type() const override { return EBase::Photo; }
|
int type() const override { return EBase::Image; }
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() const override;
|
||||||
void freeFiles() override;
|
void freeFiles() override;
|
||||||
|
@ -34,13 +24,9 @@ public:
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
|
|
||||||
QImage img;
|
QImage img;
|
||||||
QString mDir;
|
QString mDir, mName;
|
||||||
QString mName;
|
|
||||||
protected:
|
protected:
|
||||||
PageListItem *mPageItem;
|
PageListItem *mPageItem;
|
||||||
int mDuration = 10;
|
|
||||||
int mEnterStyle = 0;
|
|
||||||
int mEnterDuration = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EPHOTO_H
|
#endif // EPHOTO_H
|
||||||
|
|
|
@ -22,40 +22,42 @@
|
||||||
#include <QLabel>
|
#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"};
|
||||||
|
|
||||||
EText::EText(EBase *multiWin) : EBase(multiWin) {
|
EText::EText(EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::Text;
|
mType = EBase::Text;
|
||||||
m_attr.text = "<body>"+tr("Enter your text")+"</body>";
|
text = "<body>"+tr("Enter your text")+"</body>";
|
||||||
connect(this, &EText::sizeChanged, this, &EText::updImg);
|
connect(this, &EText::sizeChanged, this, &EText::updImg);
|
||||||
updImg();
|
updImg();
|
||||||
}
|
}
|
||||||
EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::Text;
|
mType = EBase::Text;
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
setElement(json, m_attr);
|
auto widget = json["widget"];
|
||||||
|
if(widget.isNull()) widget = json;
|
||||||
|
text = widget["text"].toString();
|
||||||
|
align = (Qt::Alignment) widget["align"].toInt();
|
||||||
|
backColor = widget["backColor"].toString("#00000000");
|
||||||
|
auto play = json["play"];
|
||||||
|
if(play.isNull()) {
|
||||||
|
playMode = json["playMode"].toString();
|
||||||
|
if(playMode=="Scroll") {
|
||||||
|
direction = json["direction"].toString();
|
||||||
|
speed = json["speed"].toInt();
|
||||||
|
headTailSpacing = json["headTailSpacing"].toInt();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playMode = playModes[play["style"].toInt()];
|
||||||
|
auto rolling = play["rolling"];
|
||||||
|
QString ds[]{"left", "top", "right", "bottom"};
|
||||||
|
direction = ds[rolling["rollingStyle"].toInt()];
|
||||||
|
speed = 1000/rolling["rollingSpeed"].toInt(33);
|
||||||
|
headTailSpacing = rolling["headTailSpacing"].toInt();
|
||||||
|
}
|
||||||
connect(this, &EText::sizeChanged, this, &EText::updImg);
|
connect(this, &EText::sizeChanged, this, &EText::updImg);
|
||||||
updImg();
|
updImg();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EText::setElement(const JObj &json, Data &attr) {
|
|
||||||
auto widget = json["widget"];
|
|
||||||
attr.text = widget["text"].toString();
|
|
||||||
attr.align = static_cast<Qt::Alignment>(widget["align"].toInt());
|
|
||||||
attr.backColor = widget["backColor"].toString("#00000000");
|
|
||||||
auto play = json["play"];
|
|
||||||
attr.playMode = play["style"].toInt();
|
|
||||||
auto turning = play["turning"];
|
|
||||||
attr.flip.effect = turning["strEffect"].toString();
|
|
||||||
attr.flip.pageDuration = turning["iEffectTime"].toInt();
|
|
||||||
attr.flip.effectDuration = turning["iEffectSpeed"].toInt();
|
|
||||||
auto rolling = play["rolling"];
|
|
||||||
attr.scroll.effect = rolling["rollingStyle"].toInt();
|
|
||||||
attr.scroll.effectSpeed = rolling["rollingSpeed"].toInt();
|
|
||||||
attr.scroll.headTailSpacing = rolling["headTailSpacing"].toInt();
|
|
||||||
attr.scroll.duration = rolling["playDuration"].toInt();
|
|
||||||
attr.duration = play["static"]["playDuration"].toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
class TTextEdit : public QTextEdit {
|
class TTextEdit : public QTextEdit {
|
||||||
public:
|
public:
|
||||||
TTextEdit() {}
|
TTextEdit() {}
|
||||||
|
@ -194,12 +196,12 @@ QWidget* EText::attrWgt() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdTextColor);
|
hBox->addWidget(fdTextColor);
|
||||||
|
|
||||||
auto fdBackColor = new LoColorSelector("B", m_attr.backColor);
|
auto fdBackColor = new LoColorSelector("B", backColor);
|
||||||
fdBackColor->setToolTip(tr("Back Color"));
|
fdBackColor->setToolTip(tr("Back Color"));
|
||||||
fdBackColor->setFixedSize(30, 30);
|
fdBackColor->setFixedSize(30, 30);
|
||||||
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||||
if(! color.isValid()) return;
|
if(! color.isValid()) return;
|
||||||
m_attr.backColor = color;
|
backColor = color;
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdBackColor);
|
hBox->addWidget(fdBackColor);
|
||||||
|
@ -272,12 +274,12 @@ QWidget* EText::attrWgt() {
|
||||||
lb->setToolTip(lb->text());
|
lb->setToolTip(lb->text());
|
||||||
hBox->addWidget(lb);
|
hBox->addWidget(lb);
|
||||||
|
|
||||||
auto fdLineSpacing = new QSpinBox();
|
auto fdLineSpacing = new QSpinBox;
|
||||||
fdLineSpacing->setRange(-99, 999);
|
fdLineSpacing->setRange(-99, 999);
|
||||||
connect(fdLineSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdText](int value) {
|
connect(fdLineSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this, fdText](int value) {
|
||||||
QTextBlockFormat fmt;
|
QTextBlockFormat fmt;
|
||||||
fmt.setLineHeight(value, QTextBlockFormat::LineDistanceHeight);
|
fmt.setLineHeight(value, QTextBlockFormat::LineDistanceHeight);
|
||||||
QTextCursor 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();
|
||||||
|
@ -286,11 +288,11 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
auto wTextAlignH = new QButtonGroup(wgtAttr);
|
auto fdAlignH = new QButtonGroup(wgtAttr);
|
||||||
wTextAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
fdAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
||||||
wTextAlignH->addButton(wTextAlignHC, Qt::AlignHCenter);
|
fdAlignH->addButton(wTextAlignHC, Qt::AlignHCenter);
|
||||||
wTextAlignH->addButton(wTextAlignHR, Qt::AlignRight);
|
fdAlignH->addButton(wTextAlignHR, Qt::AlignRight);
|
||||||
connect(wTextAlignH, &QButtonGroup::idClicked, this, [this, fdText](int value) {
|
connect(fdAlignH, &QButtonGroup::idClicked, this, [this, fdText](int value) {
|
||||||
QTextBlockFormat fmt;
|
QTextBlockFormat fmt;
|
||||||
fmt.setAlignment((Qt::Alignment) value);
|
fmt.setAlignment((Qt::Alignment) value);
|
||||||
QTextCursor cursor = fdText->textCursor();
|
QTextCursor cursor = fdText->textCursor();
|
||||||
|
@ -298,16 +300,16 @@ QWidget* EText::attrWgt() {
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto wTextAlignV = new QButtonGroup(wgtAttr);
|
auto fdAlignV = new QButtonGroup(wgtAttr);
|
||||||
wTextAlignV->addButton(wTextAlignVT, Qt::AlignTop);
|
fdAlignV->addButton(wTextAlignVT, Qt::AlignTop);
|
||||||
wTextAlignV->addButton(wTextAlignVC, Qt::AlignVCenter);
|
fdAlignV->addButton(wTextAlignVC, Qt::AlignVCenter);
|
||||||
wTextAlignV->addButton(wTextAlignVB, Qt::AlignBottom);
|
fdAlignV->addButton(wTextAlignVB, Qt::AlignBottom);
|
||||||
connect(wTextAlignV, &QButtonGroup::idClicked, this, [this](int value) {
|
connect(fdAlignV, &QButtonGroup::idClicked, this, [this](int value) {
|
||||||
m_attr.align = (Qt::Alignment) value;
|
align = (Qt::Alignment) value;
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto v_align = m_attr.align & Qt::AlignVertical_Mask;
|
auto v_align = align & Qt::AlignVertical_Mask;
|
||||||
if(v_align==Qt::AlignTop) wTextAlignVT->setChecked(true);
|
if(v_align==Qt::AlignTop) wTextAlignVT->setChecked(true);
|
||||||
if(v_align==Qt::AlignVCenter) wTextAlignVC->setChecked(true);
|
if(v_align==Qt::AlignVCenter) wTextAlignVC->setChecked(true);
|
||||||
if(v_align==Qt::AlignBottom) wTextAlignVB->setChecked(true);
|
if(v_align==Qt::AlignBottom) wTextAlignVB->setChecked(true);
|
||||||
|
@ -326,9 +328,9 @@ QWidget* EText::attrWgt() {
|
||||||
fdText->setPalette(pal);
|
fdText->setPalette(pal);
|
||||||
fdText->setFrameShape(QFrame::NoFrame);
|
fdText->setFrameShape(QFrame::NoFrame);
|
||||||
fdText->setAcceptRichText(false);
|
fdText->setAcceptRichText(false);
|
||||||
fdText->setHtml(m_attr.text);
|
fdText->setHtml(text);
|
||||||
connect(fdText, &QTextEdit::textChanged, this, [this, fdText] {
|
connect(fdText, &QTextEdit::textChanged, this, [this, fdText] {
|
||||||
m_attr.text = fdText->toHtml();
|
text = fdText->toHtml();
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
connect(fdText, &QTextEdit::currentCharFormatChanged, this, [=](const QTextCharFormat &format) {
|
connect(fdText, &QTextEdit::currentCharFormatChanged, this, [=](const QTextCharFormat &format) {
|
||||||
|
@ -339,6 +341,19 @@ QWidget* EText::attrWgt() {
|
||||||
fdTextColor->blockSignals(true);
|
fdTextColor->blockSignals(true);
|
||||||
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);
|
||||||
|
fdLetterSpacing->setValue(format.fontLetterSpacing());
|
||||||
|
fdLetterSpacing->blockSignals(false);
|
||||||
|
|
||||||
|
auto cursor = fdText->textCursor();
|
||||||
|
auto blockFormat = cursor.blockFormat();
|
||||||
|
auto btn = fdAlignH->button(blockFormat.alignment() & Qt::AlignHorizontal_Mask);
|
||||||
|
if(btn) btn->setChecked(true);
|
||||||
|
|
||||||
|
fdLineSpacing->blockSignals(true);
|
||||||
|
fdLineSpacing->setValue(blockFormat.lineHeightType()==QTextBlockFormat::LineDistanceHeight ? blockFormat.lineHeight() : 0);
|
||||||
|
fdLineSpacing->blockSignals(false);
|
||||||
});
|
});
|
||||||
vBox->addWidget(fdText);
|
vBox->addWidget(fdText);
|
||||||
|
|
||||||
|
@ -424,232 +439,110 @@ QWidget* EText::attrWgt() {
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
auto fdPlayStyle = new QButtonGroup(wgtAttr);
|
auto fdPlayStyle = new QButtonGroup(wgtAttr);
|
||||||
fdPlayStyle->addButton(fdFlip, EText::Flip);
|
fdPlayStyle->addButton(fdFlip, 0);
|
||||||
fdPlayStyle->addButton(fdScroll, EText::Scroll);
|
fdPlayStyle->addButton(fdScroll, 1);
|
||||||
fdPlayStyle->addButton(fdStatic, EText::Static);
|
fdPlayStyle->addButton(fdStatic, 2);
|
||||||
if(m_attr.playMode==EText::Flip) fdFlip->setChecked(true);
|
if(playMode=="Flip") fdFlip->setChecked(true);
|
||||||
else if(m_attr.playMode==EText::Scroll) fdScroll->setChecked(true);
|
else if(playMode=="Scroll") fdScroll->setChecked(true);
|
||||||
else if(m_attr.playMode==EText::Static) fdStatic->setChecked(true);
|
else if(playMode=="Static") fdStatic->setChecked(true);
|
||||||
|
|
||||||
auto wgtAttrFlip = new QWidget();
|
auto wgtAttrFlip = new QWidget;
|
||||||
auto fdDur = new QTimeEdit(QTime::fromMSecsSinceStartOfDay(m_attr.flip.pageDuration * mImgs.size() * 1000));
|
auto wgtAttrScroll = new QWidget;
|
||||||
auto fdPageDur = new QTimeEdit(QTime::fromMSecsSinceStartOfDay(m_attr.flip.pageDuration * 1000));
|
|
||||||
{
|
{
|
||||||
auto vBox = new QVBoxLayout(wgtAttrFlip);
|
auto vBox = new VBox(wgtAttrScroll);
|
||||||
vBox->setContentsMargins(2, 0, 2, 0);
|
vBox->setContentsMargins(2, 0, 2, 0);
|
||||||
vBox->setSpacing(3);
|
vBox->setSpacing(3);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
auto hBox = new HBox(vBox);
|
||||||
|
auto label = new QLabel(tr("Head-Tail Spacing"));
|
||||||
auto label = new QLabel(tr("Play Duration"));
|
|
||||||
label->setMinimumWidth(100);
|
label->setMinimumWidth(100);
|
||||||
hBox->addWidget(label);
|
hBox->addWidget(label);
|
||||||
|
|
||||||
fdDur->setReadOnly(true);
|
auto fdHeadTailSpacing = new QSpinBox;
|
||||||
fdDur->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
fdHeadTailSpacing->setRange(0, 9999);
|
||||||
fdDur->setDisplayFormat("H:mm:ss");
|
fdHeadTailSpacing->setValue(headTailSpacing);
|
||||||
fdDur->setStyleSheet("QTimeEdit{background-color:#ddd;}");
|
connect(fdHeadTailSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
||||||
hBox->addWidget(fdDur);
|
headTailSpacing = value;
|
||||||
hBox->addStretch();
|
updImg();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
label = new QLabel(tr("Duration/Page"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
fdPageDur->setDisplayFormat("H:mm:ss");
|
|
||||||
fdPageDur->setCurrentSection(QTimeEdit::SecondSection);
|
|
||||||
hBox->addWidget(fdPageDur);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
label = new QLabel(tr("Entrance Effect"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto fdEff = new QComboBox();
|
|
||||||
fdEff->addItem(tr("no"), "no");
|
|
||||||
fdEff->addItem(tr("random"), "random");
|
|
||||||
fdEff->addItem(tr("right to left"), "right to left");
|
|
||||||
fdEff->addItem(tr("bottom to top"), "bottom to top");
|
|
||||||
fdEff->addItem(tr("left to right"), "left to right");
|
|
||||||
fdEff->addItem(tr("top to bottom"), "top to bottom");
|
|
||||||
int idx = fdEff->findData(m_attr.flip.effect);
|
|
||||||
if(idx!=-1) fdEff->setCurrentIndex(idx);
|
|
||||||
connect(fdEff, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this, fdEff] {
|
|
||||||
m_attr.flip.effect = fdEff->currentData().toString();
|
|
||||||
update();
|
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdEff);
|
hBox->addWidget(fdHeadTailSpacing);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
label = new QLabel(tr("Effect time"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto wEffectSpeed = new QSpinBox();
|
|
||||||
wEffectSpeed->setValue(m_attr.flip.effectDuration);
|
|
||||||
hBox->addWidget(wEffectSpeed);
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
|
||||||
|
|
||||||
connect(fdPageDur, &QTimeEdit::timeChanged, this, [=](const QTime &time) {
|
|
||||||
int effDur = wEffectSpeed->value();
|
|
||||||
int pageDur = time.msecsSinceStartOfDay()/1000;
|
|
||||||
if(pageDur < effDur) {
|
|
||||||
QMessageBox::warning(wgtAttr, tr("Tip Info"), tr("Effect time cannot be longer than duration time"));
|
|
||||||
pageDur = effDur;
|
|
||||||
fdPageDur->setTime(QTime::fromMSecsSinceStartOfDay(pageDur*1000));
|
|
||||||
fdPageDur->setFocus();
|
|
||||||
}
|
|
||||||
m_attr.flip.pageDuration = pageDur;
|
|
||||||
fdDur->setTime(QTime::fromMSecsSinceStartOfDay(pageDur * mImgs.size() * 1000));
|
|
||||||
});
|
|
||||||
connect(wEffectSpeed, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [=](int value) {
|
|
||||||
int pageDur = fdPageDur->time().msecsSinceStartOfDay()/1000;
|
|
||||||
if(value > pageDur) {
|
|
||||||
QMessageBox::warning(wgtAttr, tr("Tip Info"), tr("Effect time cannot be longer than duration time"));
|
|
||||||
if(pageDur>1) value = pageDur-1;
|
|
||||||
else value = 0;
|
|
||||||
wEffectSpeed->setValue(value);
|
|
||||||
wEffectSpeed->setFocus();
|
|
||||||
}
|
|
||||||
m_attr.flip.effectDuration = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
auto wgtAttrScroll = new QWidget();
|
|
||||||
{
|
|
||||||
auto vBox = new QVBoxLayout(wgtAttrScroll);
|
|
||||||
vBox->setContentsMargins(2, 0, 2, 0);
|
|
||||||
vBox->setSpacing(3);
|
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
auto label = new QLabel(tr("Play Duration"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto timeEdit = new QTimeEdit(QTime::fromMSecsSinceStartOfDay(m_attr.scroll.duration*1000));
|
|
||||||
timeEdit->setDisplayFormat("H:mm:ss");
|
|
||||||
timeEdit->setCurrentSectionIndex(2);
|
|
||||||
connect(timeEdit, &QTimeEdit::timeChanged, this, [this](const QTime &time) {
|
|
||||||
m_attr.scroll.duration = time.msecsSinceStartOfDay()/1000;
|
|
||||||
});
|
|
||||||
hBox->addWidget(timeEdit);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
label = new QLabel(tr("Head-Tail Spacing"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto wHeadTailSpacing = new QSpinBox;
|
|
||||||
wHeadTailSpacing->setRange(0, 9999);
|
|
||||||
wHeadTailSpacing->setValue(m_attr.scroll.headTailSpacing);
|
|
||||||
connect(wHeadTailSpacing, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
m_attr.scroll.headTailSpacing = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(wHeadTailSpacing);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
label = new QLabel(tr("Scroll Style"));
|
label = new QLabel(tr("Scroll Style"));
|
||||||
label->setMinimumWidth(100);
|
label->setMinimumWidth(100);
|
||||||
hBox->addWidget(label);
|
hBox->addWidget(label);
|
||||||
|
|
||||||
auto wRollingStyle = new QComboBox;
|
auto fdDirection = new QComboBox;
|
||||||
wRollingStyle->addItem(tr("Right -> Left"));
|
fdDirection->addItem(tr("Right -> Left"), "left");
|
||||||
wRollingStyle->addItem(tr("Bottom -> Top"));
|
fdDirection->addItem(tr("Bottom -> Top"), "top");
|
||||||
wRollingStyle->addItem(tr("Left -> Right"));
|
fdDirection->addItem(tr("Left -> Right"), "right");
|
||||||
wRollingStyle->addItem(tr("Top -> Bottom"));
|
fdDirection->addItem(tr("Top -> Bottom"), "bottom");
|
||||||
wRollingStyle->setCurrentIndex(m_attr.scroll.effect);
|
SetCurData(fdDirection, direction);
|
||||||
connect(wRollingStyle, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int index) {
|
connect(fdDirection, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=] {
|
||||||
m_attr.scroll.effect = index;
|
direction = fdDirection->currentData().toString();
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
hBox->addWidget(wRollingStyle);
|
hBox->addWidget(fdDirection);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
|
|
||||||
label = new QLabel(tr("Scroll Speed"));
|
label = new QLabel(tr("Scroll Speed"));
|
||||||
label->setMinimumWidth(100);
|
label->setMinimumWidth(100);
|
||||||
hBox->addWidget(label);
|
hBox->addWidget(label);
|
||||||
|
|
||||||
auto wRollingSpeed = new QSpinBox();
|
auto fd = new QComboBox;
|
||||||
wRollingSpeed->setMaximum(9999);
|
fd->setEditable(true);
|
||||||
wRollingSpeed->setValue(m_attr.scroll.effectSpeed);
|
fd->setMinimumWidth(50);
|
||||||
connect(wRollingSpeed, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
fd->addItem("600");
|
||||||
m_attr.scroll.effectSpeed = value;
|
fd->addItem("540");
|
||||||
});
|
fd->addItem("480");
|
||||||
hBox->addWidget(wRollingSpeed);
|
fd->addItem("420");
|
||||||
hBox->addStretch();
|
fd->addItem("360");
|
||||||
|
fd->addItem("300");
|
||||||
vBox->addLayout(hBox);
|
fd->addItem("240");
|
||||||
vBox->addStretch();
|
fd->addItem("180");
|
||||||
|
fd->addItem("120");
|
||||||
|
fd->addItem("60");
|
||||||
|
fd->addItem("30");
|
||||||
|
fd->setMaxVisibleItems(fd->count());
|
||||||
|
auto text = QString::number(speed);
|
||||||
|
if(SetCurText(fd, text)==-1) {
|
||||||
|
SetCurText(fd, "60");
|
||||||
|
fd->setCurrentText(text);
|
||||||
}
|
}
|
||||||
auto wgtAttrStatic = new QWidget();
|
connect(fd, &QComboBox::editTextChanged, this, [=](const QString &text) {
|
||||||
{
|
bool ok;
|
||||||
auto vBox = new QVBoxLayout(wgtAttrStatic);
|
auto speed = text.toInt(&ok);
|
||||||
vBox->setContentsMargins(2, 0, 2, 0);
|
if(ok) this->speed = speed;
|
||||||
vBox->setSpacing(3);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
auto label = new QLabel(tr("Play Duration"));
|
|
||||||
label->setMinimumWidth(100);
|
|
||||||
hBox->addWidget(label);
|
|
||||||
|
|
||||||
auto timeEdit = new QTimeEdit(QTime::fromMSecsSinceStartOfDay(m_attr.duration*1000));
|
|
||||||
timeEdit->setDisplayFormat("H:mm:ss");
|
|
||||||
timeEdit->setCurrentSectionIndex(2);
|
|
||||||
connect(timeEdit, &QTimeEdit::timeChanged, this, [this](const QTime &time) {
|
|
||||||
m_attr.duration = time.msecsSinceStartOfDay() / 1000;
|
|
||||||
});
|
});
|
||||||
hBox->addWidget(timeEdit);
|
hBox->addWidget(fd);
|
||||||
|
hBox->addLabel("px/s");
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
}
|
}
|
||||||
auto stackBox = new QStackedLayout;
|
auto stackBox = new QStackedLayout;
|
||||||
vBox->addLayout(stackBox);
|
vBox->addLayout(stackBox);
|
||||||
stackBox->addWidget(wgtAttrFlip);
|
stackBox->addWidget(wgtAttrFlip);
|
||||||
stackBox->addWidget(wgtAttrScroll);
|
stackBox->addWidget(wgtAttrScroll);
|
||||||
stackBox->addWidget(wgtAttrStatic);
|
stackBox->addWidget(new QWidget);
|
||||||
stackBox->setCurrentIndex(m_attr.playMode);
|
auto idx = std::find(playModes, playModes+3, playMode)-playModes;
|
||||||
connect(fdPlayStyle, &QButtonGroup::idToggled, this, [this, stackBox, pageInfoWgt](int value, bool checked) {
|
if(idx>2) idx = 0;
|
||||||
|
stackBox->setCurrentIndex(idx);
|
||||||
|
connect(fdPlayStyle, &QButtonGroup::idToggled, this, [=](int value, bool checked) {
|
||||||
if(! checked) return;
|
if(! checked) return;
|
||||||
m_attr.playMode = value;
|
playMode = playModes[value];
|
||||||
updImg();
|
updImg();
|
||||||
stackBox->setCurrentIndex(value);
|
stackBox->setCurrentIndex(value);
|
||||||
pageInfoWgt->setVisible(value==Flip);
|
pageInfoWgt->setVisible(playMode=="Flip");
|
||||||
});
|
});
|
||||||
connect(this, &EText::updPageCnt, wgtAttr, [this, fdPageCnt, fdPageIdx, fdPageDur, fdDur] {
|
connect(this, &EText::updPageCnt, wgtAttr, [=] {
|
||||||
fdPageCnt->setText(QString::number(mImgs.size()));
|
fdPageCnt->setText(QString::number(mImgs.size()));
|
||||||
fdPageIdx->setRange(1, mImgs.size());
|
fdPageIdx->setRange(1, mImgs.size());
|
||||||
fdPageIdx->setValue(1);
|
fdPageIdx->setValue(1);
|
||||||
fdDur->setTime(QTime::fromMSecsSinceStartOfDay(fdPageDur->time().msecsSinceStartOfDay() * mImgs.size()));
|
|
||||||
});
|
});
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
@ -663,41 +556,31 @@ bool EText::save(const QString &pageDir) {
|
||||||
JObj EText::attrJson() const {
|
JObj EText::attrJson() const {
|
||||||
JArray files;
|
JArray files;
|
||||||
for(int i=0; i<mImgs.count(); i++) files.append(QString("text%1.png").arg(i)); //上下滚动,生成一张纵向长图
|
for(int i=0; i<mImgs.count(); i++) files.append(QString("text%1.png").arg(i)); //上下滚动,生成一张纵向长图
|
||||||
JObj obj;
|
JObj obj{
|
||||||
addBaseAttr(obj);
|
{"elementType", "Text"},
|
||||||
obj["elementType"] = "Text";
|
{"playMode", playMode},
|
||||||
obj["widget"] = JObj{
|
{"text", text},
|
||||||
{"text", m_attr.text},
|
{"align", (int) align},
|
||||||
{"align", (int) m_attr.align},
|
{"backColor", backColor.name(QColor::HexArgb)},
|
||||||
{"backColor", m_attr.backColor.name(QColor::HexArgb)},
|
|
||||||
{"files", files},
|
{"files", files},
|
||||||
{"idDir", QString("%1-%2-%3-%4-%5").arg(zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight)}
|
{"idDir", QString("%1-%2-%3-%4-%5").arg(zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight)}
|
||||||
};
|
};
|
||||||
obj["play"] = JObj{
|
addBaseAttr(obj);
|
||||||
{"style", m_attr.playMode},
|
if(playMode=="Scroll") {
|
||||||
{"turning", JObj{
|
obj["direction"] = direction;
|
||||||
{"strEffect", m_attr.flip.effect},
|
obj["speed"] = speed;
|
||||||
{"iEffectTime", m_attr.flip.pageDuration},
|
obj["headTailSpacing"] = headTailSpacing;
|
||||||
{"iEffectSpeed", m_attr.flip.effectDuration}
|
}
|
||||||
}},
|
|
||||||
{"rolling", JObj{
|
|
||||||
{"rollingStyle", m_attr.scroll.effect},
|
|
||||||
{"rollingSpeed", m_attr.scroll.effectSpeed},
|
|
||||||
{"headTailSpacing", m_attr.scroll.headTailSpacing},
|
|
||||||
{"playDuration", m_attr.scroll.duration}
|
|
||||||
}},
|
|
||||||
{"static", JObj{{"playDuration", m_attr.duration}}}
|
|
||||||
};
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
|
void EText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
|
||||||
painter->save();
|
painter->save();
|
||||||
auto rect = innerRect();
|
auto rect = innerRect();
|
||||||
if(m_attr.playMode!=EText::Flip) curIdx = 0;
|
if(playMode!="Flip") curIdx = 0;
|
||||||
else if(curIdx>=mImgs.size()) curIdx = mImgs.size() - 1;
|
else if(curIdx>=mImgs.size()) curIdx = mImgs.size() - 1;
|
||||||
else if(curIdx < 0) curIdx = 0;
|
else if(curIdx < 0) curIdx = 0;
|
||||||
if(m_attr.playMode==EText::Scroll) painter->drawImage(rect.x(), rect.y(), mImgs[0], 0, 0, rect.width(), rect.height());
|
if(playMode=="Scroll") painter->drawImage(rect.x(), rect.y(), mImgs[0], 0, 0, rect.width(), rect.height());
|
||||||
else painter->drawImage(rect.x(), rect.y(), mImgs[curIdx]);
|
else painter->drawImage(rect.x(), rect.y(), mImgs[curIdx]);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
EBase::paint(painter, option, widget);
|
EBase::paint(painter, option, widget);
|
||||||
|
@ -716,25 +599,25 @@ void EText::updImg() {
|
||||||
if(! gTextAntialiasing) font.setStyleStrategy(QFont::NoAntialias);
|
if(! gTextAntialiasing) font.setStyleStrategy(QFont::NoAntialias);
|
||||||
doc.setDefaultFont(font);
|
doc.setDefaultFont(font);
|
||||||
doc.setDefaultStyleSheet("body {color: #fff;}");
|
doc.setDefaultStyleSheet("body {color: #fff;}");
|
||||||
doc.setHtml(m_attr.text);
|
if(playMode=="Flip") {
|
||||||
if(m_attr.playMode==EText::Flip) {
|
doc.setHtml(text);
|
||||||
doc.setPageSize(innerRect.size());
|
doc.setPageSize(innerRect.size());
|
||||||
auto pageHeight = height;
|
auto pageHeight = height;
|
||||||
auto pageCnt = doc.pageCount();
|
auto pageCnt = doc.pageCount();
|
||||||
QImage img(width, pageHeight*pageCnt, QImage::Format_ARGB32);
|
QImage img(width, pageHeight*pageCnt, QImage::Format_ARGB32);
|
||||||
img.fill(m_attr.backColor);
|
img.fill(backColor);
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
doc.drawContents(&painter);
|
doc.drawContents(&painter);
|
||||||
}
|
}
|
||||||
if(pageCnt > 1) {
|
if(pageCnt > 1) {
|
||||||
check:
|
check:
|
||||||
for(int y=pageHeight-1; y<img.height(); y+=pageHeight) for(int x=0; x<width; x++) if(img.pixelColor(x, y)!=m_attr.backColor) {
|
for(int y=pageHeight-1; y<img.height(); y+=pageHeight) for(int x=0; x<width; x++) if(img.pixelColor(x, y)!=backColor) {
|
||||||
pageHeight *= 2;
|
pageHeight *= 2;
|
||||||
doc.setPageSize(QSizeF(width, pageHeight));
|
doc.setPageSize(QSizeF(width, pageHeight));
|
||||||
pageCnt = doc.pageCount();
|
pageCnt = doc.pageCount();
|
||||||
img = QImage(width, pageHeight*pageCnt, QImage::Format_ARGB32);
|
img = QImage(width, pageHeight*pageCnt, QImage::Format_ARGB32);
|
||||||
img.fill(m_attr.backColor);
|
img.fill(backColor);
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
doc.drawContents(&painter);
|
doc.drawContents(&painter);
|
||||||
|
@ -743,7 +626,7 @@ void EText::updImg() {
|
||||||
else goto forend;
|
else goto forend;
|
||||||
}
|
}
|
||||||
if(pageCnt > 1) {
|
if(pageCnt > 1) {
|
||||||
for(int y=img.height()-pageHeight; y<img.height(); y++) for(int x=0; x<width; x++) if(img.pixelColor(x, y)!=m_attr.backColor) goto forend;
|
for(int y=img.height()-pageHeight; y<img.height(); y++) for(int x=0; x<width; x++) if(img.pixelColor(x, y)!=backColor) goto forend;
|
||||||
pageCnt--;
|
pageCnt--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,19 +640,35 @@ void EText::updImg() {
|
||||||
rect.translate(0, pageHeight);
|
rect.translate(0, pageHeight);
|
||||||
}
|
}
|
||||||
emit updPageCnt();
|
emit updPageCnt();
|
||||||
} else if(m_attr.playMode==EText::Scroll) {//生成一张大图
|
} else if(playMode=="Scroll") {//生成一张大图
|
||||||
if(m_attr.scroll.effect==0||m_attr.scroll.effect==2) width = qMax(width, ((int)doc.idealWidth()) + m_attr.scroll.headTailSpacing);
|
if(direction=="left" || direction=="right") {
|
||||||
else {
|
doc.setHtml(text.replace("<p ", "<span ").replace("</p>", "</span>").replace("<br />", " "));
|
||||||
|
width = ceil(doc.idealWidth()) + headTailSpacing;
|
||||||
|
} else {
|
||||||
doc.setTextWidth(width);
|
doc.setTextWidth(width);
|
||||||
height = doc.size().height() + m_attr.scroll.headTailSpacing;
|
doc.setHtml(text);
|
||||||
|
height = doc.size().height() + headTailSpacing;
|
||||||
}
|
}
|
||||||
QImage img(width, height, QImage::Format_ARGB32);
|
QImage img(width, height, QImage::Format_ARGB32);
|
||||||
img.fill(m_attr.backColor);
|
img.fill(backColor);
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
doc.drawContents(&painter);
|
doc.drawContents(&painter);
|
||||||
}
|
}
|
||||||
if(m_attr.scroll.effect==0||m_attr.scroll.effect==2) alignV(img);
|
if(direction=="left" || direction=="right") {
|
||||||
|
alignV(img);
|
||||||
|
if(width < innerRect.width()) {
|
||||||
|
auto newWidth = width*2;
|
||||||
|
while(newWidth<innerRect.width()) newWidth += width;
|
||||||
|
QImage newImg(newWidth, height, QImage::Format_ARGB32);
|
||||||
|
newImg.fill(Qt::transparent);
|
||||||
|
{
|
||||||
|
QPainter painter(&newImg);
|
||||||
|
for(int x=0; x<newWidth; x+=width) painter.drawImage(x, 0, img);
|
||||||
|
}
|
||||||
|
img = newImg;
|
||||||
|
}
|
||||||
|
}
|
||||||
mImgs.clear();
|
mImgs.clear();
|
||||||
mImgs.append(img);
|
mImgs.append(img);
|
||||||
// if(img.width()<=8192) mImgs.append(img);
|
// if(img.width()<=8192) mImgs.append(img);
|
||||||
|
@ -784,10 +683,11 @@ void EText::updImg() {
|
||||||
// mImgs.append(imgpart);
|
// mImgs.append(imgpart);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else if(m_attr.playMode==EText::Static) {//生成一张图
|
} else if(playMode=="Static") {//生成一张图
|
||||||
|
doc.setHtml(text);
|
||||||
doc.setTextWidth(width);
|
doc.setTextWidth(width);
|
||||||
QImage img(width, height, QImage::Format_ARGB32);
|
QImage img(width, height, QImage::Format_ARGB32);
|
||||||
img.fill(m_attr.backColor);
|
img.fill(backColor);
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
doc.drawContents(&painter);
|
doc.drawContents(&painter);
|
||||||
|
@ -801,26 +701,26 @@ void EText::updImg() {
|
||||||
void EText::alignV(QImage &img, int cutHeight) {
|
void EText::alignV(QImage &img, int cutHeight) {
|
||||||
int width = img.width(), height = img.height();
|
int width = img.width(), height = img.height();
|
||||||
if(cutHeight==0) cutHeight = height;
|
if(cutHeight==0) cutHeight = height;
|
||||||
if(m_attr.align & Qt::AlignTop) {
|
if(align & Qt::AlignTop) {
|
||||||
int ss = 0;
|
int ss = 0;
|
||||||
for(; ss<height; ss++) for(int i=0; i<width; i++) if(img.pixelColor(i, ss)!=m_attr.backColor) goto l12;
|
for(; ss<height; ss++) for(int i=0; i<width; i++) if(img.pixelColor(i, ss)!=backColor) goto l12;
|
||||||
if(cutHeight==height) return;
|
if(cutHeight==height) return;
|
||||||
ss = 0;
|
ss = 0;
|
||||||
l12:
|
l12:
|
||||||
img = copy(img, 0, ss, width, cutHeight);
|
img = copy(img, 0, ss, width, cutHeight);
|
||||||
} else if(m_attr.align & Qt::AlignVCenter) {
|
} else if(align & Qt::AlignVCenter) {
|
||||||
int ss = 0, ee = height - 1;
|
int ss = 0, ee = height - 1;
|
||||||
for(; ss<height; ss++) for(int i=0; i<width; i++) if(img.pixelColor(i, ss)!=m_attr.backColor) goto l2;
|
for(; ss<height; ss++) for(int i=0; i<width; i++) if(img.pixelColor(i, ss)!=backColor) goto l2;
|
||||||
if(cutHeight==height) return;
|
if(cutHeight==height) return;
|
||||||
ss = 0;
|
ss = 0;
|
||||||
goto l3;
|
goto l3;
|
||||||
l2:
|
l2:
|
||||||
for(; ee>ss; ee--) for(int i=0; i<width; i++) if(img.pixelColor(i, ee)!=m_attr.backColor) goto l3;
|
for(; ee>ss; ee--) for(int i=0; i<width; i++) if(img.pixelColor(i, ee)!=backColor) goto l3;
|
||||||
l3:
|
l3:
|
||||||
img = copy(img, 0, (ss+ee-cutHeight+2)/2, width, cutHeight);
|
img = copy(img, 0, (ss+ee-cutHeight+2)/2, width, cutHeight);
|
||||||
} else if(m_attr.align & Qt::AlignBottom) {
|
} else if(align & Qt::AlignBottom) {
|
||||||
int ee = height - 1;
|
int ee = height - 1;
|
||||||
for(; ee>=0; ee--) for(int i=0; i<width; i++) if(img.pixelColor(i, ee)!=m_attr.backColor) goto l32;
|
for(; ee>=0; ee--) for(int i=0; i<width; i++) if(img.pixelColor(i, ee)!=backColor) goto l32;
|
||||||
if(cutHeight==height) return;
|
if(cutHeight==height) return;
|
||||||
ee = height - 1;
|
ee = height - 1;
|
||||||
l32:
|
l32:
|
||||||
|
@ -830,7 +730,7 @@ void EText::alignV(QImage &img, int cutHeight) {
|
||||||
|
|
||||||
QImage EText::copy(QImage &img, int x, int y, int w, int h) {
|
QImage EText::copy(QImage &img, int x, int y, int w, int h) {
|
||||||
QImage imgpart(w, h, QImage::Format_ARGB32);
|
QImage imgpart(w, h, QImage::Format_ARGB32);
|
||||||
imgpart.fill(m_attr.backColor);
|
imgpart.fill(backColor);
|
||||||
{
|
{
|
||||||
QPainter painter(&imgpart);
|
QPainter painter(&imgpart);
|
||||||
painter.drawImage(-x, -y, img);
|
painter.drawImage(-x, -y, img);
|
||||||
|
|
|
@ -6,30 +6,6 @@
|
||||||
class EText : public EBase {
|
class EText : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum PlayMode {Flip, Scroll, Static};
|
|
||||||
struct Flip {
|
|
||||||
int pageDuration{10};
|
|
||||||
QString effect{"no"};
|
|
||||||
int effectDuration{3};
|
|
||||||
};
|
|
||||||
struct Scroll {
|
|
||||||
int duration{30};
|
|
||||||
int effect{0};
|
|
||||||
int effectSpeed{50};
|
|
||||||
int headTailSpacing{10};
|
|
||||||
};
|
|
||||||
struct Data {
|
|
||||||
QString text;
|
|
||||||
Qt::Alignment align;
|
|
||||||
QColor backColor{Qt::transparent};
|
|
||||||
int playMode{Flip};
|
|
||||||
int duration{10};
|
|
||||||
struct Flip flip;
|
|
||||||
struct Scroll scroll;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void setElement(const JObj &json, Data &attr);
|
|
||||||
|
|
||||||
explicit EText(EBase *multiWin = nullptr);
|
explicit EText(EBase *multiWin = nullptr);
|
||||||
explicit EText(const JObj &json, EBase *multiWin = nullptr);
|
explicit EText(const JObj &json, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
|
@ -39,6 +15,14 @@ public:
|
||||||
bool save(const QString &pRoot) override;
|
bool save(const QString &pRoot) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() const override;
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
Qt::Alignment align;
|
||||||
|
QColor backColor{Qt::transparent};
|
||||||
|
QString playMode = "Flip";
|
||||||
|
QString direction = "left";
|
||||||
|
int speed = 60;
|
||||||
|
int headTailSpacing{10};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updImg();
|
void updImg();
|
||||||
signals:
|
signals:
|
||||||
|
@ -48,7 +32,6 @@ private:
|
||||||
void alignV(QImage &, int h=0);
|
void alignV(QImage &, int h=0);
|
||||||
QImage copy(QImage &img, int x, int y, int w, int h);
|
QImage copy(QImage &img, int x, int y, int w, int h);
|
||||||
|
|
||||||
Data m_attr;
|
|
||||||
QList<QImage> mImgs;
|
QList<QImage> mImgs;
|
||||||
int curIdx{0};
|
int curIdx{0};
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,6 @@ ETimer::ETimer(EBase *multiWin) : EBase(multiWin) {
|
||||||
attr.font = qfont("Arial", 12);
|
attr.font = qfont("Arial", 12);
|
||||||
attr.textColor = Qt::red;
|
attr.textColor = Qt::red;
|
||||||
attr.backColor = Qt::transparent;
|
attr.backColor = Qt::transparent;
|
||||||
attr.duration = 10;
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +47,6 @@ ETimer::ETimer(const JObj &json, EBase *multiWin) : EBase(multiWin){
|
||||||
attr.textColor = json["textColor"].toString();
|
attr.textColor = json["textColor"].toString();
|
||||||
auto color = json["backColor"].toString();
|
auto color = json["backColor"].toString();
|
||||||
attr.backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
attr.backColor = color.isEmpty() ? QColor(0,0,0,0) : color;
|
||||||
attr.duration = json["duration"].toInt();
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,35 +290,8 @@ QWidget* ETimer::attrWgt() {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdBackColor);
|
hBox->addWidget(fdBackColor);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
|
||||||
|
|
||||||
line = new QFrame();
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
|
||||||
hBox->addWidget(line, 1);
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto fdDuration = new QSpinBox();
|
|
||||||
fdDuration->setRange(1, 99999);
|
|
||||||
fdDuration->setValue(attr.duration);
|
|
||||||
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
attr.duration = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdDuration);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
@ -344,6 +315,5 @@ JObj ETimer::attrJson() const {
|
||||||
obj["fontUnderline"] = attr.font.underline();
|
obj["fontUnderline"] = attr.font.underline();
|
||||||
obj["textColor"] = attr.textColor.name();
|
obj["textColor"] = attr.textColor.name();
|
||||||
obj["backColor"] = attr.backColor.alpha()==0 ? "" : attr.backColor.name();
|
obj["backColor"] = attr.backColor.alpha()==0 ? "" : attr.backColor.name();
|
||||||
obj["duration"] = attr.duration;
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ public:
|
||||||
QString text;
|
QString text;
|
||||||
QColor textColor;
|
QColor textColor;
|
||||||
QColor backColor;
|
QColor backColor;
|
||||||
int duration = 10;
|
|
||||||
bool isDown;
|
bool isDown;
|
||||||
bool isMultiline;
|
bool isMultiline;
|
||||||
bool hasDay;
|
bool hasDay;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "globaldefine.h"
|
#include "globaldefine.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
|
||||||
#include "base/ffutil.h"
|
#include "base/ffutil.h"
|
||||||
#include "videosplitthread.h"
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
|
@ -17,7 +15,7 @@ EVideo *EVideo::create(const QString &file, PageListItem *pageItem, EBase *multi
|
||||||
int64_t dur;
|
int64_t dur;
|
||||||
AVCodecID codecId;
|
AVCodecID codecId;
|
||||||
QImage img;
|
QImage img;
|
||||||
QString err = videoInfo(file.toUtf8(), img, &dur, &codecId);
|
auto err = videoInfo(file.toUtf8(), img, &dur, &codecId);
|
||||||
if(! err.isEmpty()) {
|
if(! err.isEmpty()) {
|
||||||
QMessageBox::critical(pageItem->listWidget(), "Video Error", err+"\n"+file);
|
QMessageBox::critical(pageItem->listWidget(), "Video Error", err+"\n"+file);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -28,10 +26,13 @@ EVideo *EVideo::create(const QString &file, PageListItem *pageItem, EBase *multi
|
||||||
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;
|
||||||
return new EVideo(outInfo.absolutePath(), outInfo.fileName(), rawInfo.absolutePath(), rawName, img, dur/1000000, pageItem, multiWin);
|
auto ins = new EVideo(outInfo.absolutePath(), outInfo.fileName(), rawInfo.absolutePath(), rawName, img, pageItem, multiWin);
|
||||||
|
ins->mDuration = round(dur*0.000001);
|
||||||
|
return ins;
|
||||||
}
|
}
|
||||||
EVideo *EVideo::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin) {
|
||||||
auto widget = json["widget"];
|
auto widget = ele["widget"];
|
||||||
|
if(widget.isNull()) widget = ele;
|
||||||
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;
|
||||||
|
@ -41,21 +42,22 @@ EVideo *EVideo::create(const JObj &json, PageListItem *pageItem, EBase *multiWin
|
||||||
else return 0;
|
else return 0;
|
||||||
int64_t dur;
|
int64_t dur;
|
||||||
QImage img;
|
QImage img;
|
||||||
QString err = videoInfo(file.toUtf8(), img, &dur, 0);
|
auto err = videoInfo(file.toUtf8(), img, &dur, 0);
|
||||||
if(! err.isEmpty()) return 0;
|
if(! err.isEmpty()) return 0;
|
||||||
auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, dur/1000000, pageItem, multiWin);
|
dur = round(dur*0.000001);
|
||||||
ins->setBaseAttr(json);
|
auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, pageItem, multiWin);
|
||||||
auto play = json["play"];
|
ins->setBaseAttr(ele);
|
||||||
ins->playDuration = play["playDuration"].toInt();
|
if(ins->mDuration < 4) ins->mDuration = dur;
|
||||||
ins->playTimes = play["playTimes"].toInt();
|
auto play = ele["play"];
|
||||||
if(ins->playDuration < 4) ins->playDuration = dur/1000000;
|
ins->playTimes = (play.isNull() ? ele : play)["playTimes"].toInt(1);
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
JObj EVideo::genProg(const JObj &ele, const QString &dstDir, ProgItem *progItem) {
|
JObj EVideo::genProg(const JValue &ele, const QString &dstDir, ProgItem *progItem) {
|
||||||
auto widget = ele["widget"];
|
auto widget = ele["widget"];
|
||||||
|
if(widget.isNull()) widget = ele;
|
||||||
auto path = widget["path"].toString();
|
auto path = widget["path"].toString();
|
||||||
auto name = widget["file"].toString();
|
auto name = widget["file"].toString();
|
||||||
if(progItem->mMaxWidth) name += "-square.mp4";
|
//if(progItem->maxLen) name += "-square.mp4";
|
||||||
QString srcFile = path + "/" + name;
|
QString srcFile = path + "/" + name;
|
||||||
QFileInfo srcInfo(srcFile);
|
QFileInfo srcInfo(srcFile);
|
||||||
if(! srcInfo.isFile()) return JObj();
|
if(! srcInfo.isFile()) return JObj();
|
||||||
|
@ -67,22 +69,13 @@ JObj EVideo::genProg(const JObj &ele, const QString &dstDir, ProgItem *progItem)
|
||||||
oRes["id"] = id;
|
oRes["id"] = id;
|
||||||
oRes["md5"] = id;
|
oRes["md5"] = id;
|
||||||
oRes["name"] = name;
|
oRes["name"] = name;
|
||||||
oRes["size"] = srcInfo.size();
|
|
||||||
QString suffix = srcInfo.suffix().toLower();
|
|
||||||
oRes["fileExt"] = suffix;
|
|
||||||
oRes["mime"] = "video/"+suffix;
|
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
oRes["timeSpan"] = play["playDuration"].toInt() * play["playTimes"].toInt();
|
oRes["timeSpan"] = play.isNull() ? ele["duration"].toInt() * ele["playTimes"].toInt() : play["playDuration"].toInt() * play["playTimes"].toInt();
|
||||||
oRes["enabled"] = true;
|
|
||||||
oRes["entryEffect"] = "None";
|
|
||||||
oRes["exitEffect"] = "None";
|
|
||||||
oRes["entryEffectTimeSpan"] = 0;
|
|
||||||
oRes["exitEffectTimeSpan"] = 0;
|
|
||||||
return oRes;
|
return oRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
EVideo::EVideo(const QString &dir, const QString &name, const QString &rawDir, const QString &rawName, QImage &coverImg, int dur, 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), playDuration(dur), mPageItem(pageItem) {
|
: EBase(multiWin), mDir(dir), mName(name), mRawDir(rawDir), mRawName(rawName), mCoverImg(coverImg), mPageItem(pageItem) {
|
||||||
mType = EBase::Video;
|
mType = EBase::Video;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +124,31 @@ QWidget* EVideo::attrWgt() {
|
||||||
auto bnSelectFile = new QPushButton("...");
|
auto bnSelectFile = new QPushButton("...");
|
||||||
bnSelectFile->setFixedWidth(30);
|
bnSelectFile->setFixedWidth(30);
|
||||||
bnSelectFile->setObjectName("bnSelectFile");
|
bnSelectFile->setObjectName("bnSelectFile");
|
||||||
|
connect(bnSelectFile, &QPushButton::clicked, this, [=] {
|
||||||
|
auto rawFile = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), gFileHome, EVideo::filters());
|
||||||
|
if(rawFile.isEmpty()) return;
|
||||||
|
QFileInfo rawInfo(rawFile);
|
||||||
|
int64_t dur;
|
||||||
|
AVCodecID codecId;
|
||||||
|
auto err = videoInfo(rawFile.toUtf8(), mCoverImg, &dur, &codecId);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
QMessageBox::critical(wgtAttr, "Video Error", err+"\n"+rawFile);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
mRawDir = rawInfo.absolutePath();
|
||||||
|
mRawName = rawInfo.fileName();
|
||||||
|
gFileHome = mRawDir;
|
||||||
|
fdFileName->setText(mRawName);
|
||||||
|
mDuration = round(dur*0.000001);
|
||||||
|
fdDuration->setValue(mDuration);
|
||||||
|
auto outFile = transcoding(wgtAttr, rawFile, mRawName, mPageItem->mPageDir, mCoverImg.width(), mCoverImg.height(), codecId);
|
||||||
|
if(outFile.isEmpty()) return;
|
||||||
|
QFile oldfile(mDir+"/"+mName);
|
||||||
|
if(oldfile.exists()) oldfile.remove();
|
||||||
|
QFileInfo outInfo(outFile);
|
||||||
|
mDir = outInfo.absolutePath();
|
||||||
|
mName = outInfo.fileName();
|
||||||
|
});
|
||||||
hBox->addWidget(bnSelectFile);
|
hBox->addWidget(bnSelectFile);
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
@ -162,48 +180,6 @@ QWidget* EVideo::attrWgt() {
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")));
|
|
||||||
|
|
||||||
auto fdDuration = new QSpinBox();
|
|
||||||
fdDuration->setRange(1, 99999);
|
|
||||||
fdDuration->setValue(playDuration);
|
|
||||||
connect(fdDuration, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
playDuration = value;
|
|
||||||
});
|
|
||||||
connect(bnSelectFile, &QPushButton::clicked, this, [=] {
|
|
||||||
auto rawFile = QFileDialog::getOpenFileName(wgtAttr, tr("Select File"), gFileHome, EVideo::filters());
|
|
||||||
if(rawFile.isEmpty()) return;
|
|
||||||
QFileInfo rawInfo(rawFile);
|
|
||||||
int64_t dur;
|
|
||||||
AVCodecID codecId;
|
|
||||||
QString err = videoInfo(rawFile.toUtf8(), mCoverImg, &dur, &codecId);
|
|
||||||
if(! err.isEmpty()) {
|
|
||||||
QMessageBox::critical(wgtAttr, "Video Error", err+"\n"+rawFile);
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
mRawDir = rawInfo.absolutePath();
|
|
||||||
mRawName = rawInfo.fileName();
|
|
||||||
gFileHome = mRawDir;
|
|
||||||
fdFileName->setText(mRawName);
|
|
||||||
playDuration = dur/1000000;
|
|
||||||
fdDuration->setValue(playDuration);
|
|
||||||
auto outFile = transcoding(wgtAttr, rawFile, mRawName, mPageItem->mPageDir, mCoverImg.width(), mCoverImg.height(), codecId);
|
|
||||||
if(outFile.isEmpty()) return;
|
|
||||||
QFile oldfile(mDir+"/"+mName);
|
|
||||||
if(oldfile.exists()) oldfile.remove();
|
|
||||||
QFileInfo outInfo(outFile);
|
|
||||||
mDir = outInfo.absolutePath();
|
|
||||||
mName = outInfo.fileName();
|
|
||||||
});
|
|
||||||
hBox->addWidget(fdDuration);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
hBox = new QHBoxLayout();
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addWidget(new QLabel(tr("Play Times")));
|
hBox->addWidget(new QLabel(tr("Play Times")));
|
||||||
|
@ -231,45 +207,41 @@ bool EVideo::save(const QString &pageDir) {
|
||||||
else return false;
|
else return false;
|
||||||
QFile(oldFile).copy(saveFile);
|
QFile(oldFile).copy(saveFile);
|
||||||
mDir = pageDir;
|
mDir = pageDir;
|
||||||
if(gProgItem->mMaxWidth) {
|
// if(gProgItem->maxLen) {
|
||||||
auto waitingDlg = new WaitingDlg(mPageItem->listWidget()->window(), "正在转码视频 ...");
|
// auto waitingDlg = new WaitingDlg(mPageItem->listWidget()->window(), "正在转码视频 ...");
|
||||||
auto thread = new VideoSplitThread(mWidth, mHeight, gProgItem->mMaxWidth, gProgItem->mHeight, gProgItem->mSplitWidths, pos(), saveFile.toUtf8());
|
// auto thread = new VideoSplitThread(mWidth, mHeight, gProgItem->maxLen, gProgItem->isVer ? gProgItem->mWidth : gProgItem->mHeight, gProgItem->partLens, gProgItem->isVer, pos(), saveFile.toUtf8());
|
||||||
connect(thread, &VideoSplitThread::emErr, this, [=](QString err) {
|
// connect(thread, &VideoSplitThread::emErr, this, [=](QString err) {
|
||||||
waitingDlg->close();
|
// waitingDlg->close();
|
||||||
if(! err.isEmpty()) QMessageBox::critical(mPageItem->listWidget()->window(), "Video trans error", err+"\n"+saveFile);
|
// if(! err.isEmpty()) QMessageBox::critical(mPageItem->listWidget()->window(), "Video trans error", err+"\n"+saveFile);
|
||||||
});
|
// });
|
||||||
connect(thread, &VideoSplitThread::emProgress, this, [saveFile, waitingDlg](int progress) {
|
// connect(thread, &VideoSplitThread::emProgress, this, [saveFile, waitingDlg](int progress) {
|
||||||
waitingDlg->fdText->setText(QString("正在转码视频 %1%").arg(progress));
|
// waitingDlg->fdText->setText(QString("正在转码视频 %1%").arg(progress));
|
||||||
});
|
// });
|
||||||
thread->start();
|
// thread->start();
|
||||||
waitingDlg->exec();
|
// waitingDlg->exec();
|
||||||
}
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EVideo::attrJson() const {
|
JObj EVideo::attrJson() const {
|
||||||
JObj oRoot;
|
JObj obj{
|
||||||
addBaseAttr(oRoot);
|
{"elementType", "Video"},
|
||||||
oRoot["elementType"] = "Movie";
|
|
||||||
oRoot["widget"] = JObj{
|
|
||||||
{"path", mDir},
|
{"path", mDir},
|
||||||
{"file", mName},
|
{"file", mName},
|
||||||
{"pathRaw", mRawDir},
|
{"pathRaw", mRawDir},
|
||||||
{"fileRaw", mRawName}
|
{"fileRaw", mRawName},
|
||||||
};
|
|
||||||
oRoot["play"] = JObj{
|
|
||||||
{"playDuration", playDuration},
|
|
||||||
{"playTimes", playTimes}
|
{"playTimes", playTimes}
|
||||||
};
|
};
|
||||||
return oRoot;
|
addBaseAttr(obj);
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EVideo::transcoding(QWidget *parent, QString rawFile, QString rawName, QString dir, int w, int h, AVCodecID codec_id) {
|
QString EVideo::transcoding(QWidget *parent, QString rawFile, QString rawName, QString dir, int w, int h, AVCodecID codec_id) {
|
||||||
if(gProgItem->mMaxWidth) {
|
// if(gProgItem->maxLen) {
|
||||||
auto outFile = dir+"/"+rawName;
|
// auto outFile = dir+"/"+rawName;
|
||||||
QFile::copy(rawFile, outFile);
|
// QFile::copy(rawFile, outFile);
|
||||||
return outFile;
|
// return outFile;
|
||||||
}
|
// }
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
int rawMax = qMax(w, h);
|
int rawMax = qMax(w, h);
|
||||||
if(settings.value("VideoCompress", true).toBool() && rawMax > 1360 && (w > gProgItem->mWidth || h > gProgItem->mHeight)) {
|
if(settings.value("VideoCompress", true).toBool() && rawMax > 1360 && (w > gProgItem->mWidth || h > gProgItem->mHeight)) {
|
||||||
|
|
|
@ -21,9 +21,9 @@ 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 JObj &, const QString &, ProgItem *mProgItem);
|
static JObj genProg(const JValue &, const QString &, ProgItem *mProgItem);
|
||||||
|
|
||||||
explicit EVideo(const QString &, const QString &, const QString &, const QString &, QImage &img, int dur, PageListItem *pageItem, EBase *multiWin = nullptr);
|
explicit EVideo(const QString &, const QString &, const QString &, const QString &, QImage &img, PageListItem *pageItem, EBase *multiWin = nullptr);
|
||||||
|
|
||||||
int type() const override { return EBase::Video; }
|
int type() const override { return EBase::Video; }
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
@ -38,7 +38,6 @@ public:
|
||||||
QImage mCoverImg;
|
QImage mCoverImg;
|
||||||
protected:
|
protected:
|
||||||
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
||||||
int playDuration = 10;
|
|
||||||
int playTimes = 1;
|
int playTimes = 1;
|
||||||
PageListItem *mPageItem;
|
PageListItem *mPageItem;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,13 +7,11 @@
|
||||||
|
|
||||||
EWeb::EWeb(EBase *multiWin) : EBase(multiWin) {
|
EWeb::EWeb(EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::Web;
|
mType = EBase::Web;
|
||||||
duration = 10;
|
|
||||||
}
|
}
|
||||||
EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
EWeb::EWeb(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::Web;
|
mType = EBase::Web;
|
||||||
setBaseAttr(json);
|
setBaseAttr(json);
|
||||||
url = json["url"].toString();
|
url = json["url"].toString();
|
||||||
duration = json["duration"].toInt(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
|
void EWeb::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
|
||||||
|
@ -56,23 +54,6 @@ QWidget* EWeb::attrWgt() {
|
||||||
connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &text) {
|
connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &text) {
|
||||||
url = text;
|
url = text;
|
||||||
});
|
});
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addWidget(new QLabel(tr("Play Duration")+": "));
|
|
||||||
|
|
||||||
auto dur_fd = new QSpinBox();
|
|
||||||
dur_fd->setRange(1, 99999);
|
|
||||||
dur_fd->setValue(duration);
|
|
||||||
connect(dur_fd, (void(QSpinBox::*)(int))&QSpinBox::valueChanged, this, [this](int value) {
|
|
||||||
duration = value;
|
|
||||||
});
|
|
||||||
hBox->addWidget(dur_fd);
|
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("s")));
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
|
@ -83,6 +64,5 @@ JObj EWeb::attrJson() const {
|
||||||
addBaseAttr(oRoot);
|
addBaseAttr(oRoot);
|
||||||
oRoot["elementType"] = "Web";
|
oRoot["elementType"] = "Web";
|
||||||
oRoot["url"] = url;
|
oRoot["url"] = url;
|
||||||
oRoot["duration"] = duration;
|
|
||||||
return oRoot;
|
return oRoot;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ public:
|
||||||
JObj attrJson() const override;
|
JObj attrJson() const override;
|
||||||
|
|
||||||
QString url;
|
QString url;
|
||||||
int duration = 10;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EWEB_H
|
#endif // EWEB_H
|
||||||
|
|
|
@ -62,19 +62,18 @@ void GenTmpThread::run() {
|
||||||
return a["order"].toInt() < b["order"].toInt();
|
return a["order"].toInt() < b["order"].toInt();
|
||||||
});
|
});
|
||||||
JArray items;
|
JArray items;
|
||||||
for(auto pageJson : pageJsons) {
|
for(auto &pageJson : pageJsons) {
|
||||||
srcPageDir = srcDir + "/" + pageJson["name"].toString();
|
srcPageDir = srcDir + "/" + pageJson["name"].toString();
|
||||||
items.append(cvtPage(pageJson, proJson));
|
items.append(cvtPage(pageJson));
|
||||||
}
|
}
|
||||||
JObj json;
|
JObj json;
|
||||||
json["_type"] = "PlayXixunTask";
|
json["_type"] = "PlayXixunTask";
|
||||||
json["id"] = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
|
||||||
json["preDownloadURL"] = "http://192.168.8.202:23412/file/download?id=";
|
|
||||||
json["notificationURL"] = "http://192.168.8.202:23412/test";
|
|
||||||
json["task"] = JObj{
|
json["task"] = JObj{
|
||||||
{"_id", QUuid::createUuid().toString(QUuid::WithoutBraces)},
|
|
||||||
{"name", prog_name},
|
{"name", prog_name},
|
||||||
{"cmdId", QUuid::createUuid().toString(QUuid::WithoutBraces)},
|
{"width", proJson["resolution"]["w"]},
|
||||||
|
{"height", proJson["resolution"]["h"]},
|
||||||
|
{"partLengths", proJson["splitWidths"]},
|
||||||
|
{"isVertical", proJson["isVer"]},
|
||||||
{"items", items}
|
{"items", items}
|
||||||
};
|
};
|
||||||
QFile program(dstDir + "/program");
|
QFile program(dstDir + "/program");
|
||||||
|
@ -102,7 +101,7 @@ void GenTmpThread::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//此处需要把幻灯片中的元素按层顺序排序,再放入layers中,每个元素对一个layer。ewindow中的多个顺序元素为一个层上的时间轴上的素材
|
//此处需要把幻灯片中的元素按层顺序排序,再放入layers中,每个元素对一个layer。ewindow中的多个顺序元素为一个层上的时间轴上的素材
|
||||||
JObj GenTmpThread::cvtPage(const JObj &pageJson, const JObj &proJson) {
|
JObj GenTmpThread::cvtPage(const JObj &pageJson) {
|
||||||
auto audios = pageJson("audios").toArray();
|
auto audios = pageJson("audios").toArray();
|
||||||
auto sourceRepeat = pageJson["loop"].toBool();
|
auto sourceRepeat = pageJson["loop"].toBool();
|
||||||
JArray sources;
|
JArray sources;
|
||||||
|
@ -112,23 +111,19 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson, const JObj &proJson) {
|
||||||
if(dur==0) continue;
|
if(dur==0) continue;
|
||||||
auto name = audio["name"].toString();
|
auto name = audio["name"].toString();
|
||||||
if(name.isEmpty()) continue;
|
if(name.isEmpty()) continue;
|
||||||
QString file = audio["dir"].toString()+"/"+name;
|
auto file = audio["dir"].toString()+"/"+name;
|
||||||
QFileInfo srcInfo(file);
|
QFileInfo srcInfo(file);
|
||||||
if(! srcInfo.isFile()) continue;
|
if(! srcInfo.isFile()) continue;
|
||||||
QString id = Tools::fileMd5(file);
|
auto id = Tools::fileMd5(file);
|
||||||
if(id.isEmpty()) continue;
|
if(id.isEmpty()) continue;
|
||||||
QFile::copy(file, dstDir+"/"+id);
|
QFile::copy(file, dstDir+"/"+id);
|
||||||
JObj source;
|
JObj source;
|
||||||
source.insert("_type", "Audio");
|
source.insert("_type", "Audio");
|
||||||
source["id"] = id;
|
source["id"] = id;
|
||||||
source["md5"] = id;
|
source["md5"] = id;
|
||||||
source["name"] = name;
|
|
||||||
source["size"] = srcInfo.size();
|
|
||||||
source["fileExt"] = srcInfo.suffix().toLower();
|
|
||||||
source["timeSpan"] = dur;
|
source["timeSpan"] = dur;
|
||||||
source["playTime"] = start;
|
source["playTime"] = start;
|
||||||
source["vol"] = audio["vol"].toInt();
|
source["vol"] = audio["vol"].toInt();
|
||||||
source["enabled"] = true;
|
|
||||||
source["left"] = -1;
|
source["left"] = -1;
|
||||||
source["top"] = -1;
|
source["top"] = -1;
|
||||||
source["width"] = 1;
|
source["width"] = 1;
|
||||||
|
@ -140,54 +135,16 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson, const JObj &proJson) {
|
||||||
if(! sources.empty()) layers.append(JObj{{"repeat", sourceRepeat}, {"sources", sources}});
|
if(! sources.empty()) layers.append(JObj{{"repeat", sourceRepeat}, {"sources", sources}});
|
||||||
|
|
||||||
auto elements = pageJson["elements"].toArray();
|
auto elements = pageJson["elements"].toArray();
|
||||||
for(auto &ele : elements) {
|
for(const auto &ele : elements) {
|
||||||
auto type = ele["elementType"].toString();
|
auto type = ele["elementType"].toString();
|
||||||
auto geometry = ele["geometry"];
|
auto geometry = ele["geometry"];
|
||||||
JArray sources;
|
sources = type=="Window" ? genSources(QString(), ele["elements"].toArray(), geometry) : genSources(type, JArray{ele}, geometry);
|
||||||
if(type=="Window") {
|
|
||||||
auto elements = ele["elements"].toArray();
|
|
||||||
auto left = geometry["x"];
|
|
||||||
auto top = geometry["y"];
|
|
||||||
auto width = geometry["w"];
|
|
||||||
auto height = geometry["h"];
|
|
||||||
QList<JObj> eles;
|
|
||||||
for(auto &value : elements) eles.append(value.toObj());
|
|
||||||
int playTime = 0;
|
|
||||||
for(const auto &ele : eles) {
|
|
||||||
auto source = cvtEle(ele["elementType"].toString(), ele);
|
|
||||||
if(source.empty()) continue;
|
|
||||||
source["left"] = left;
|
|
||||||
source["top"] = top;
|
|
||||||
source["width"] = width;
|
|
||||||
source["height"] = height;
|
|
||||||
source["playTime"] = playTime;
|
|
||||||
playTime += source["timeSpan"].toInt();
|
|
||||||
sources.append(source);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
auto source = cvtEle(type, ele.toObj());
|
|
||||||
if(! source.empty()) {
|
|
||||||
if(mProgItem->mMaxWidth && (type=="Photo" || type=="Movie")) {
|
|
||||||
source["left"] = 0;
|
|
||||||
source["top"] = 0;
|
|
||||||
source["width"] = mProgItem->mMaxWidth;
|
|
||||||
source["height"] = mProgItem->mHeight * mProgItem->mSplitWidths.size();
|
|
||||||
} else {
|
|
||||||
source["left"] = geometry["x"];
|
|
||||||
source["top"] = geometry["y"];
|
|
||||||
source["width"] = geometry["w"];
|
|
||||||
source["height"] = geometry["h"];
|
|
||||||
}
|
|
||||||
source["playTime"] = 0;
|
|
||||||
sources.append(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(! sources.empty()) {
|
if(! sources.empty()) {
|
||||||
JObj layer{{"repeat", sourceRepeat}, {"sources", sources}};
|
JObj layer{{"repeat", sourceRepeat}, {"sources", sources}};
|
||||||
auto border = ele["border"].toString();
|
auto border = ele["border"].toString();
|
||||||
if(! border.isEmpty()) {
|
if(! border.isEmpty()) {
|
||||||
QString bdSrc = "borders/"+border;
|
auto bdSrc = "borders/"+border;
|
||||||
QString id = Tools::fileMd5(bdSrc);
|
auto id = Tools::fileMd5(bdSrc);
|
||||||
QFile::copy(bdSrc, dstDir+"/"+id);
|
QFile::copy(bdSrc, dstDir+"/"+id);
|
||||||
auto borderSize = ele["borderSize"];
|
auto borderSize = ele["borderSize"];
|
||||||
if(borderSize.isNull()){
|
if(borderSize.isNull()){
|
||||||
|
@ -217,7 +174,6 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson, const JObj &proJson) {
|
||||||
schedule["endDate"] = validDate["end"];
|
schedule["endDate"] = validDate["end"];
|
||||||
schedule["timeType"] = "All";
|
schedule["timeType"] = "All";
|
||||||
schedule["filterType"] = "None";
|
schedule["filterType"] = "None";
|
||||||
schedule["monthFilter"] = JArray();
|
|
||||||
schedule["weekFilter"] = JArray();
|
schedule["weekFilter"] = JArray();
|
||||||
schedules.append(schedule);
|
schedules.append(schedule);
|
||||||
}
|
}
|
||||||
|
@ -235,147 +191,164 @@ JObj GenTmpThread::cvtPage(const JObj &pageJson, const JObj &proJson) {
|
||||||
auto weekly = plan["weekly"];
|
auto weekly = plan["weekly"];
|
||||||
schedule["weekFilter"] = weekly;
|
schedule["weekFilter"] = weekly;
|
||||||
schedule["filterType"] = weekly.toArray().empty() ? "None" : "Week";
|
schedule["filterType"] = weekly.toArray().empty() ? "None" : "Week";
|
||||||
schedule["monthFilter"] = JArray();
|
|
||||||
schedules.append(schedule);
|
schedules.append(schedule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return JObj{
|
return JObj{
|
||||||
{"_id", QUuid::createUuid().toString(QUuid::WithoutBraces)},
|
{"repeatTimes", pageJson["repeat"]},
|
||||||
{"priority", 0},
|
|
||||||
{"version", 0},
|
|
||||||
{"schedules", schedules},
|
{"schedules", schedules},
|
||||||
{"_program", JObj{
|
{"_program", JObj{
|
||||||
{"_id", QUuid::createUuid().toString(QUuid::WithoutBraces)},
|
|
||||||
{"totalSize", 0},
|
|
||||||
{"name", pageJson["name"].toString()},
|
{"name", pageJson["name"].toString()},
|
||||||
{"width", proJson["resolution"]["w"]},
|
|
||||||
{"height", proJson["resolution"]["h"]},
|
|
||||||
{"splitWidths", proJson["splitWidths"]},
|
|
||||||
{"_company", "alahover"},
|
|
||||||
{"_department", "alahover"},
|
|
||||||
{"_role", "alahover"},
|
|
||||||
{"_user", "alahover"},
|
|
||||||
{"__v", 0},
|
|
||||||
{"dateCreated", pageJson["last_edit"]},
|
|
||||||
{"layers", layers}
|
{"layers", layers}
|
||||||
}},
|
}}
|
||||||
{"repeatTimes", pageJson["repeat"]}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj GenTmpThread::cvtEle(const QString &type, const JObj &ele) {
|
JArray GenTmpThread::genSources(QString type, const JArray &eles, const JValue &geometry) {
|
||||||
if(type=="Text") return convertText(ele);
|
JArray sources;
|
||||||
else if(type=="Photo") return convertPhoto(ele);
|
auto needType = type.isEmpty();
|
||||||
else if(type=="Movie") return EVideo::genProg(ele, dstDir, mProgItem);
|
for(const auto &ele : eles) {
|
||||||
else if(type=="Gif") return convertGif(ele);
|
JObj source;
|
||||||
else if(type=="DClock") return convertDClock(ele);
|
if(needType) type = ele["elementType"].toString();
|
||||||
else if(type=="AClock") return convertAClock(ele);
|
if(type=="Text") source = genText(ele, sources);
|
||||||
else if(type=="Temp") return EEnviron::genProg(ele, dstDir, srcPageDir);
|
else if(type=="Image"||type=="Photo") source = genImage(ele);
|
||||||
else if(type=="Web") return convertWeb(ele);
|
else if(type=="Video"||type=="Movie") source = EVideo::genProg(ele, dstDir, mProgItem);
|
||||||
else if(type=="Timer") return convertTimer(ele);
|
else if(type=="Gif") source = convertGif(ele);
|
||||||
return JObj();
|
else if(type=="DClock") source = convertDClock(ele);
|
||||||
|
else if(type=="AClock") source = convertAClock(ele);
|
||||||
|
else if(type=="Temp") source = EEnviron::genProg(ele, dstDir, srcPageDir);
|
||||||
|
else if(type=="Web") source = convertWeb(ele);
|
||||||
|
else if(type=="Timer") source = convertTimer(ele);
|
||||||
|
if(! source.empty()) {
|
||||||
|
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
||||||
|
source["entryEffect"] = ele["entryEffect"];
|
||||||
|
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["exitEffectTimeSpan"] = ele["exitDur"];
|
||||||
|
sources.append(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto startTime = needType ? 0 : eles[0]["startTime"].toInt();
|
||||||
|
for(auto &ss : sources) {
|
||||||
|
auto source = ss.toObj();
|
||||||
|
source["left"] = geometry["x"];
|
||||||
|
source["top"] = geometry["y"];
|
||||||
|
source["width"] = geometry["w"];
|
||||||
|
source["height"] = geometry["h"];
|
||||||
|
source["playTime"] = startTime;
|
||||||
|
startTime += source["timeSpan"].toInt();
|
||||||
|
}
|
||||||
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj GenTmpThread::convertText(const JObj &json) {
|
JObj GenTmpThread::genText(const JValue &ele, JArray &sources) {
|
||||||
EText::Data attr;
|
auto widget = ele["widget"];
|
||||||
EText::setElement(json, attr);
|
if(widget.isNull()) widget = ele;
|
||||||
JObj source;
|
auto play = ele["play"];
|
||||||
auto type = mProgItem->mMaxWidth ? "SplitText" : "MultiPng";
|
QString playMode, direction;
|
||||||
source["_type"] = type;
|
int speed;
|
||||||
source["name"] = type;
|
if(play.isNull()) {
|
||||||
source["id"] = res_id++;
|
playMode = ele["playMode"].toString();
|
||||||
auto widget = json["widget"];
|
direction = ele["direction"].toString();
|
||||||
|
speed = ele["speed"].toInt();
|
||||||
QTextEdit fdText;
|
} else {
|
||||||
auto ft = fdText.font();
|
QString playModes[]{"Flip", "Scroll", "Static"};
|
||||||
ft.setFamilies({"Arial","黑体"});
|
playMode = playModes[play["style"].toInt()];
|
||||||
ft.setPixelSize(16);
|
auto rolling = play["rolling"];
|
||||||
fdText.setFont(ft);
|
QString ds[]{"left", "top", "right", "bottom"};
|
||||||
auto pal = fdText.palette();
|
direction = ds[rolling["rollingStyle"].toInt()];
|
||||||
pal.setColor(QPalette::Base, Qt::black);
|
speed = 1000/rolling["rollingSpeed"].toInt(33);
|
||||||
pal.setColor(QPalette::Text, Qt::white);
|
|
||||||
fdText.setPalette(pal);
|
|
||||||
fdText.setHtml(widget["text"].toStr());
|
|
||||||
source["text"] = fdText.toPlainText();
|
|
||||||
auto cursor = fdText.textCursor();
|
|
||||||
cursor.movePosition(QTextCursor::End);
|
|
||||||
auto format = cursor.charFormat();
|
|
||||||
source["fontSize"] = format.font().pixelSize();
|
|
||||||
auto foreground = format.foreground();
|
|
||||||
source["textColor"] = (foreground.style()==Qt::NoBrush ? Qt::white : foreground.color()).name(QColor::HexArgb);
|
|
||||||
source["backColor"] = widget["backColor"];
|
|
||||||
|
|
||||||
JArray srcFiles = widget["files"].toArray();
|
|
||||||
source["iPicCount"] = (int)srcFiles.size();
|
|
||||||
if(attr.playMode==EText::Flip) {
|
|
||||||
source["playMode"] = "Flip";
|
|
||||||
source["timeSpan"] = attr.flip.pageDuration * (int)srcFiles.size();
|
|
||||||
if(attr.flip.effectDuration >= attr.flip.pageDuration) attr.flip.effectDuration = attr.flip.pageDuration / 2;
|
|
||||||
} else if(attr.playMode==EText::Scroll) {
|
|
||||||
source["playMode"] = "Scroll";
|
|
||||||
source["timeSpan"] = attr.scroll.duration;
|
|
||||||
} else if(attr.playMode==EText::Static) {
|
|
||||||
source["playMode"] = "Static";
|
|
||||||
source["timeSpan"] = attr.duration;
|
|
||||||
}
|
}
|
||||||
JArray arrayPics;
|
auto filenames = widget["files"];
|
||||||
auto filePrefix = srcPageDir+"/"+widget["idDir"].toString()+"/";
|
auto filePrefix = srcPageDir+"/"+widget["idDir"].toString()+"/";
|
||||||
for(int i=0; i<(int)srcFiles.size(); i++) {
|
|
||||||
auto srcFile = filePrefix + srcFiles[i].toString();
|
auto isScroll = playMode=="Scroll";
|
||||||
QFile srcQFile(srcFile);
|
if(isScroll) {
|
||||||
if(! srcQFile.exists()) continue;
|
JObj source;
|
||||||
|
source["_type"] = "MultiPng";
|
||||||
|
source["playMode"] = playMode;
|
||||||
|
JArray arrayPics;
|
||||||
|
for(auto &filename : filenames) {
|
||||||
|
auto file = filePrefix + filename.toString();
|
||||||
|
QFile qFile(file);
|
||||||
|
if(! qFile.exists()) continue;
|
||||||
|
auto id = Tools::fileMd5(file);
|
||||||
|
qFile.copy(dstDir+"/"+id);
|
||||||
|
|
||||||
JObj arrayPic;
|
JObj arrayPic;
|
||||||
auto id = Tools::fileMd5(srcFile);
|
|
||||||
srcQFile.copy(dstDir+"/"+id);
|
|
||||||
arrayPic["id"] = id;
|
arrayPic["id"] = id;
|
||||||
arrayPic["mime"] = "image/png";
|
if(direction=="left") arrayPic["effect"] = "right to left";
|
||||||
if(attr.playMode==EText::Flip) {
|
else if(direction=="top") arrayPic["effect"] = "bottom to top";
|
||||||
arrayPic["effect"] = attr.flip.effect;
|
else if(direction=="right") arrayPic["effect"] = "left to right";
|
||||||
arrayPic["effectSpeed"] = attr.flip.effectDuration;
|
else if(direction=="bottom") arrayPic["effect"] = "top to bottom";
|
||||||
arrayPic["picDuration"] = attr.flip.pageDuration;
|
arrayPic["scrollSpeed"] = speed;
|
||||||
} else if(attr.playMode==EText::Scroll) {
|
arrayPic["effectSpeed"] = 1000 / speed;
|
||||||
if(attr.scroll.effect==0) arrayPic["effect"] = "right to left";
|
|
||||||
else if(attr.scroll.effect==1) arrayPic["effect"] = "bottom to top";
|
|
||||||
else if(attr.scroll.effect==2) arrayPic["effect"] = "left to right";
|
|
||||||
else if(attr.scroll.effect==3) arrayPic["effect"] = "top to bottom";
|
|
||||||
arrayPic["effectSpeed"] = attr.scroll.effectSpeed;
|
|
||||||
arrayPic["picDuration"] = 0;
|
arrayPic["picDuration"] = 0;
|
||||||
} else if(attr.playMode==EText::Static) {
|
|
||||||
arrayPic["effect"] = "no";
|
|
||||||
arrayPic["effectSpeed"] = 0;
|
|
||||||
arrayPic["picDuration"] = attr.duration;
|
|
||||||
}
|
|
||||||
arrayPics.append(arrayPic);
|
arrayPics.append(arrayPic);
|
||||||
}
|
}
|
||||||
source["arrayPics"] = arrayPics;
|
source["arrayPics"] = arrayPics;
|
||||||
return source;
|
return source;
|
||||||
|
} else {
|
||||||
|
auto duration = ele["duration"].toInt();
|
||||||
|
for(auto &filename : filenames) {
|
||||||
|
auto file = filePrefix + filename.toString();
|
||||||
|
QFile qFile(file);
|
||||||
|
if(! qFile.exists()) continue;
|
||||||
|
auto id = Tools::fileMd5(file);
|
||||||
|
qFile.copy(dstDir+"/"+id);
|
||||||
|
|
||||||
|
JObj source;
|
||||||
|
source["_type"] = "Image";
|
||||||
|
source["id"] = id;
|
||||||
|
source["md5"] = id;
|
||||||
|
source["timeSpan"] = duration;
|
||||||
|
source["entryEffect"] = ele["entryEffect"];
|
||||||
|
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["exitEffectTimeSpan"] = ele["exitDur"];
|
||||||
|
sources.append(source);
|
||||||
|
}
|
||||||
|
return JObj();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//转换图片
|
//转换图片
|
||||||
JObj GenTmpThread::convertPhoto(const JObj &ele){
|
JObj GenTmpThread::genImage(const JValue &ele) {
|
||||||
auto widget = ele["widget"];
|
auto widget = ele["widget"];
|
||||||
auto name = widget["file"].toString();
|
auto name = widget.isNull() ? ele["name"].toString() : widget["file"].toString();
|
||||||
QString srcFile = widget["path"].toString() + "/" + name;
|
auto srcFile = (widget.isNull() ? ele["dir"] : widget["path"]).toString() + "/" + name;
|
||||||
QFileInfo srcInfo(srcFile);
|
QFileInfo srcInfo(srcFile);
|
||||||
JObj source;
|
JObj source;
|
||||||
if(! srcInfo.isFile()) return source;
|
if(! srcInfo.isFile()) return source;
|
||||||
QImage img(srcFile);
|
QImage img(srcFile);
|
||||||
auto geometry = ele["geometry"];
|
auto geometry = ele["geometry"];
|
||||||
auto x = geometry["x"].toInt();
|
|
||||||
auto y = geometry["y"].toInt();
|
|
||||||
auto width = geometry["w"].toInt();
|
auto width = geometry["w"].toInt();
|
||||||
auto height = geometry["h"].toInt();
|
auto height = geometry["h"].toInt();
|
||||||
if(mProgItem->mMaxWidth) {
|
/*if(mProgItem->maxLen) {
|
||||||
auto scaled = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
auto scaled = img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
QImage square(gProgItem->mMaxWidth, gProgItem->mHeight*gProgItem->mSplitWidths.size(), QImage::Format_ARGB32);
|
QImage square(gProgItem->isVer ? gProgItem->mWidth*gProgItem->partLens.size() : gProgItem->maxLen, gProgItem->isVer ? gProgItem->maxLen : gProgItem->mHeight*gProgItem->partLens.size(), QImage::Format_ARGB32);
|
||||||
square.fill(0);
|
square.fill(0);
|
||||||
QPainter painter(&square);
|
QPainter painter(&square);
|
||||||
QPointF pos(x, y);
|
QPointF pos(x, y);
|
||||||
painter.drawImage(pos, scaled, QRectF(0, 0, gProgItem->mSplitWidths[0]-pos.x(), height));
|
auto end = (int)gProgItem->partLens.size();
|
||||||
auto end = gProgItem->mSplitWidths.size();
|
if(gProgItem->isVer) {
|
||||||
|
painter.drawImage(pos, scaled, QRectF(0, 0, width, gProgItem->partLens[0]-pos.y()));
|
||||||
for(int i=1; i<end; i++) {
|
for(int i=1; i<end; i++) {
|
||||||
pos.rx() -= gProgItem->mSplitWidths[i-1];
|
pos.ry() -= gProgItem->partLens[i-1];
|
||||||
|
pos.rx() += gProgItem->mWidth;
|
||||||
|
painter.drawImage(pos, scaled, QRectF(0, 0, width, gProgItem->partLens[i]-pos.y()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
painter.drawImage(pos, scaled, QRectF(0, 0, gProgItem->partLens[0]-pos.x(), height));
|
||||||
|
for(int i=1; i<end; i++) {
|
||||||
|
pos.rx() -= gProgItem->partLens[i-1];
|
||||||
pos.ry() += gProgItem->mHeight;
|
pos.ry() += gProgItem->mHeight;
|
||||||
painter.drawImage(pos, scaled, QRectF(0, 0, gProgItem->mSplitWidths[i]-pos.x(), height));
|
painter.drawImage(pos, scaled, QRectF(0, 0, gProgItem->partLens[i]-pos.x(), height));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
QBuffer buf;
|
QBuffer buf;
|
||||||
square.save(&buf, "PNG");
|
square.save(&buf, "PNG");
|
||||||
|
@ -388,11 +361,7 @@ JObj GenTmpThread::convertPhoto(const JObj &ele){
|
||||||
file.close();
|
file.close();
|
||||||
source["id"] = md5;
|
source["id"] = md5;
|
||||||
source["md5"] = md5;
|
source["md5"] = md5;
|
||||||
source["size"] = buf.size();
|
} else */if(img.width() > width*2 && img.height() > height*2) {
|
||||||
source["name"] = srcInfo.baseName()+".png";
|
|
||||||
source["fileExt"] = "png";
|
|
||||||
source["mime"] = "image/png";
|
|
||||||
} else if(img.width() > width*2 && img.height() > height*2) {
|
|
||||||
QBuffer buf;
|
QBuffer buf;
|
||||||
img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(&buf, "PNG");
|
img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(&buf, "PNG");
|
||||||
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||||
|
@ -404,39 +373,20 @@ JObj GenTmpThread::convertPhoto(const JObj &ele){
|
||||||
file.close();
|
file.close();
|
||||||
source["id"] = md5;
|
source["id"] = md5;
|
||||||
source["md5"] = md5;
|
source["md5"] = md5;
|
||||||
source["size"] = buf.size();
|
|
||||||
source["name"] = srcInfo.baseName()+".png";
|
|
||||||
source["fileExt"] = "png";
|
|
||||||
source["mime"] = "image/png";
|
|
||||||
} else {
|
} else {
|
||||||
auto md5 = Tools::fileMd5(srcFile);
|
auto md5 = Tools::fileMd5(srcFile);
|
||||||
if(md5.isEmpty()) return source;
|
if(md5.isEmpty()) return source;
|
||||||
QFile::copy(srcFile, dstDir+"/"+md5);
|
QFile::copy(srcFile, dstDir+"/"+md5);
|
||||||
source["id"] = md5;
|
source["id"] = md5;
|
||||||
source["md5"] = md5;
|
source["md5"] = md5;
|
||||||
source["size"] = srcInfo.size();
|
|
||||||
source["name"] = name;
|
|
||||||
QString sufLower = srcInfo.suffix().toLower();
|
|
||||||
source["fileExt"] = sufLower;
|
|
||||||
source["mime"] = "image/"+(sufLower=="jpg" ? "jpeg" : sufLower);
|
|
||||||
}
|
}
|
||||||
source["_type"] = "Image";
|
source["_type"] = "Image";
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
source["timeSpan"] = play["playDuration"];
|
source["timeSpan"] = play.isNull() ? ele["duration"] : play["playDuration"];
|
||||||
source["enabled"] = true;
|
|
||||||
source["enabledBy"] = "";
|
|
||||||
source["oldFilePath"] = "";
|
|
||||||
static const int effSize = 13;
|
|
||||||
static const int effs[effSize] = {0,1,3,4,5,6,7,9,10,11,12,17,18};
|
|
||||||
int enterStyle = play["enterStyle"].toInt();
|
|
||||||
source["entryEffect"] = enterStyle < effSize ? effs[enterStyle] : 0;
|
|
||||||
source["exitEffect"] = 0;
|
|
||||||
source["entryEffectTimeSpan"] = play["enterDuration"];
|
|
||||||
source["exitEffectTimeSpan"] = 0;
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
//转换图片
|
//转换图片
|
||||||
JObj GenTmpThread::convertGif(const JObj &json) {
|
JObj GenTmpThread::convertGif(const JValue &json) {
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
auto path = widget["path"].toString();
|
auto path = widget["path"].toString();
|
||||||
auto name = widget["file"].toString();
|
auto name = widget["file"].toString();
|
||||||
|
@ -450,26 +400,15 @@ JObj GenTmpThread::convertGif(const JObj &json) {
|
||||||
oRes["_type"] = "Image";
|
oRes["_type"] = "Image";
|
||||||
oRes["id"] = id;
|
oRes["id"] = id;
|
||||||
oRes["md5"] = id;
|
oRes["md5"] = id;
|
||||||
oRes["name"] = name;
|
oRes["fileExt"] = srcInfo.suffix().toLower();
|
||||||
oRes["size"] = srcInfo.size();
|
|
||||||
QString suffix = srcInfo.suffix().toLower();
|
|
||||||
oRes["fileExt"] = suffix;
|
|
||||||
oRes["mime"] = "image/gif";
|
|
||||||
auto play = json["play"];
|
auto play = json["play"];
|
||||||
oRes["timeSpan"] = play["playDuration"].toInt() * play["playTimes"].toInt();
|
oRes["timeSpan"] = (play.isNull() ? json["duration"] : play["playDuration"]).toInt() * play["playTimes"].toInt(1);
|
||||||
oRes["enabled"] = true;
|
|
||||||
oRes["entryEffect"] = "None";
|
|
||||||
oRes["exitEffect"] = "None";
|
|
||||||
oRes["entryEffectTimeSpan"] = 0;
|
|
||||||
oRes["exitEffectTimeSpan"] = 0;
|
|
||||||
return oRes;
|
return oRes;
|
||||||
}
|
}
|
||||||
JObj GenTmpThread::convertDClock(const JObj &json){
|
JObj GenTmpThread::convertDClock(const JValue &json){
|
||||||
JObj oRes;
|
JObj oRes;
|
||||||
oRes["_type"] = "DigitalClockNew";
|
oRes["_type"] = "DigitalClockNew";
|
||||||
oRes["name"] = "DigitalClockNew";
|
oRes["name"] = "DigitalClockNew";
|
||||||
oRes["id"] = "";
|
|
||||||
oRes["timeSpan"] = json["play"]["duration"];
|
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
oRes["timeZone"] = widget["timeZone"];
|
oRes["timeZone"] = widget["timeZone"];
|
||||||
oRes["timezone"] = 8;//兼容旧播放器
|
oRes["timezone"] = 8;//兼容旧播放器
|
||||||
|
@ -486,11 +425,6 @@ JObj GenTmpThread::convertDClock(const JObj &json){
|
||||||
oRes["dateStyle"] = widget["dateStyle"];
|
oRes["dateStyle"] = widget["dateStyle"];
|
||||||
oRes["timeStyle"] = widget["timeStyle"];
|
oRes["timeStyle"] = widget["timeStyle"];
|
||||||
oRes["multiline"] = widget["multiline"];
|
oRes["multiline"] = widget["multiline"];
|
||||||
oRes["fontSize"] = widget["font"]["size"];
|
|
||||||
oRes["entryEffect"] = "None";
|
|
||||||
oRes["exitEffect"] = "None";
|
|
||||||
oRes["entryEffectTimeSpan"] = 0;
|
|
||||||
oRes["exitEffectTimeSpan"] = 0;
|
|
||||||
|
|
||||||
auto fontVal = widget["font"];
|
auto fontVal = widget["font"];
|
||||||
auto textColor = Tools::int2Color(fontVal["color"].toInt());
|
auto textColor = Tools::int2Color(fontVal["color"].toInt());
|
||||||
|
@ -501,12 +435,11 @@ JObj GenTmpThread::convertDClock(const JObj &json){
|
||||||
font.setUnderline(fontVal["underline"].toBool());
|
font.setUnderline(fontVal["underline"].toBool());
|
||||||
|
|
||||||
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
QFontMetricsF metricF(font);
|
|
||||||
oRes["spaceWidth"] = metricF.horizontalAdvance(" ");
|
|
||||||
QFontMetrics metric(font);
|
QFontMetrics metric(font);
|
||||||
|
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(auto &str : str0_9) Tools::saveImg2(dstDir, metric, font, color, imgs, str, str);
|
||||||
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");
|
||||||
|
@ -522,12 +455,12 @@ JObj GenTmpThread::convertDClock(const JObj &json){
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, ":", "maohao");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, ":", "maohao");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "/", "xiegang");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "/", "xiegang");
|
||||||
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "hengxian");
|
Tools::saveImg2(dstDir, metric, font, color, imgs, "-", "hengxian");
|
||||||
oRes["iPicCount"] = (int)imgs.size();
|
|
||||||
oRes["arrayPics"] = imgs;
|
oRes["arrayPics"] = imgs;
|
||||||
return oRes;
|
return oRes;
|
||||||
}
|
}
|
||||||
JObj GenTmpThread::convertAClock(const JObj &json) {
|
JObj GenTmpThread::convertAClock(const JValue &json) {
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
|
if(widget.isNull()) widget = json;
|
||||||
QString srcFile = srcPageDir + "/" + widget["selfCreateDialName"].toString();
|
QString srcFile = srcPageDir + "/" + widget["selfCreateDialName"].toString();
|
||||||
QFile srcQFile(srcFile);
|
QFile srcQFile(srcFile);
|
||||||
if(! srcQFile.exists()) return JObj();
|
if(! srcQFile.exists()) return JObj();
|
||||||
|
@ -537,9 +470,6 @@ JObj GenTmpThread::convertAClock(const JObj &json) {
|
||||||
oRes["_type"] = "AnalogClock";
|
oRes["_type"] = "AnalogClock";
|
||||||
oRes["id"] = id;
|
oRes["id"] = id;
|
||||||
oRes["md5"] = id;
|
oRes["md5"] = id;
|
||||||
oRes["mime"] = "image/png";
|
|
||||||
oRes["name"] = "001";
|
|
||||||
oRes["timeSpan"] = json["play"]["duration"];
|
|
||||||
oRes["shade"] = 0;//表盘形状
|
oRes["shade"] = 0;//表盘形状
|
||||||
oRes["opacity"] = 1;//透明度
|
oRes["opacity"] = 1;//透明度
|
||||||
oRes["showBg"] = false;//是否显示背景色
|
oRes["showBg"] = false;//是否显示背景色
|
||||||
|
@ -567,35 +497,28 @@ JObj GenTmpThread::convertAClock(const JObj &json) {
|
||||||
oRes["pinStyle"] = 1;
|
oRes["pinStyle"] = 1;
|
||||||
oRes["showSecond"] = widget["showSecHand"];
|
oRes["showSecond"] = widget["showSecHand"];
|
||||||
oRes["timeZone"] = widget["timeZone"];
|
oRes["timeZone"] = widget["timeZone"];
|
||||||
//下同Video
|
|
||||||
oRes["entryEffect"] = "None";
|
|
||||||
oRes["exitEffect"] = "None";
|
|
||||||
oRes["entryEffectTimeSpan"] = 0;
|
|
||||||
oRes["exitEffectTimeSpan"] = 0 ;
|
|
||||||
return oRes;
|
return oRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj GenTmpThread::convertWeb(const JObj &res) {
|
JObj GenTmpThread::convertWeb(const JValue &res) {
|
||||||
JObj dst;
|
JObj dst;
|
||||||
dst["_type"] = "WebURL";
|
dst["_type"] = "WebURL";
|
||||||
dst["id"] = "";
|
|
||||||
dst["name"] = "WebURL";
|
dst["name"] = "WebURL";
|
||||||
dst["url"] = res["url"];
|
dst["url"] = res["url"];
|
||||||
dst["timeSpan"] = res["duration"];
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
JObj GenTmpThread::convertTimer(const JObj &json) {
|
JObj GenTmpThread::convertTimer(const JValue &json) {
|
||||||
JObj oRes;
|
JObj oRes;
|
||||||
oRes["_type"] = "Timer";
|
oRes["_type"] = "Timer";
|
||||||
oRes["name"] = "Timer";
|
oRes["name"] = "Timer";
|
||||||
oRes["id"] = "";
|
|
||||||
oRes["targetTime"] = json["targetTime"];
|
oRes["targetTime"] = json["targetTime"];
|
||||||
oRes["isDown"] = json["isDown"];
|
oRes["isDown"] = json["isDown"];
|
||||||
oRes["hasDay"] = json["hasDay"];
|
oRes["hasDay"] = json["hasDay"];
|
||||||
oRes["hasHour"] = json["hasHour"];
|
oRes["hasHour"] = json["hasHour"];
|
||||||
oRes["hasMin"] = json["hasMin"];
|
oRes["hasMin"] = json["hasMin"];
|
||||||
oRes["hasSec"] = json["hasSec"];
|
oRes["hasSec"] = json["hasSec"];
|
||||||
oRes["isMultiline"] = json["isMultiline"];
|
auto isMultiline = json["isMultiline"].toBool();
|
||||||
|
oRes["isMultiline"] = isMultiline;
|
||||||
auto text = json["text"].toString();
|
auto text = json["text"].toString();
|
||||||
oRes["text"] = text;
|
oRes["text"] = text;
|
||||||
QFont font(json["font"].toString());
|
QFont font(json["font"].toString());
|
||||||
|
@ -611,23 +534,25 @@ JObj GenTmpThread::convertTimer(const JObj &json) {
|
||||||
auto textColor = json["textColor"].toString();
|
auto textColor = json["textColor"].toString();
|
||||||
oRes["textColor"] = textColor;
|
oRes["textColor"] = textColor;
|
||||||
oRes["backColor"] = json["backColor"];
|
oRes["backColor"] = json["backColor"];
|
||||||
oRes["timeSpan"] = json["duration"];
|
|
||||||
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
font.setStyleStrategy(gTextAntialiasing ? QFont::PreferAntialias : QFont::NoAntialias);
|
||||||
QFontMetricsF metricF(font);
|
|
||||||
oRes["spaceWidth"] = metricF.horizontalAdvance(" ");
|
|
||||||
QFontMetrics metric(font);
|
QFontMetrics metric(font);
|
||||||
|
oRes["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(auto &str : str0_9) Tools::saveImg(dstDir, metric, font, color, imgs, str, str);
|
||||||
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");
|
||||||
Tools::saveImg(dstDir, metric, font, color, imgs, tr("sec"), "sec");
|
Tools::saveImg(dstDir, metric, font, color, imgs, tr("sec"), "sec");
|
||||||
if(! text.isEmpty()) {
|
if(! text.isEmpty()) {
|
||||||
|
QSize size;
|
||||||
|
if(isMultiline) {
|
||||||
auto innerW = json["innerW"].toInt();
|
auto innerW = json["innerW"].toInt();
|
||||||
auto innerH = json["innerH"].toInt();
|
auto innerH = json["innerH"].toInt();
|
||||||
auto rect = metric.boundingRect(0, 0, innerW, innerH, Qt::AlignCenter | Qt::TextWordWrap, text);
|
auto rect = metric.boundingRect(0, 0, innerW, innerH, Qt::AlignCenter | Qt::TextWordWrap, text);
|
||||||
QImage img(qMin(rect.width(), innerW), qMin(rect.height(), innerH), QImage::Format_ARGB32);
|
size = {qMin(rect.width(), innerW), qMin(rect.height(), innerH)};
|
||||||
|
} else size = {metric.horizontalAdvance(text), metric.lineSpacing()};
|
||||||
|
QImage img(size, QImage::Format_ARGB32);
|
||||||
img.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
|
|
|
@ -14,15 +14,15 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void run() override;
|
virtual void run() override;
|
||||||
|
|
||||||
JObj cvtPage(const JObj &, const JObj &);
|
JObj cvtPage(const JObj &);
|
||||||
JObj cvtEle(const QString &type, const JObj &json);
|
JArray genSources(QString type, const JArray &eles, const JValue &);
|
||||||
JObj convertText(const JObj &json);
|
JObj genText(const JValue &json, JArray &);
|
||||||
JObj convertPhoto(const JObj &json);
|
JObj genImage(const JValue &json);
|
||||||
JObj convertGif(const JObj &json);
|
JObj convertGif(const JValue &json);
|
||||||
JObj convertDClock(const JObj &json);
|
JObj convertDClock(const JValue &json);
|
||||||
JObj convertAClock(const JObj &json);
|
JObj convertAClock(const JValue &json);
|
||||||
JObj convertWeb(const JObj &json);
|
JObj convertWeb(const JValue &json);
|
||||||
JObj convertTimer(const JObj &json);
|
JObj convertTimer(const JValue &json);
|
||||||
signals:
|
signals:
|
||||||
void onErr(QString);
|
void onErr(QString);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -43,9 +43,9 @@ PageListItem::PageListItem(const JObj &attr, const QString &pageDir) : mAttr(att
|
||||||
auto type = ele["elementType"].toStr();
|
auto type = ele["elementType"].toStr();
|
||||||
EBase *element = 0;
|
EBase *element = 0;
|
||||||
if(type=="Text") element = new EText(ele.toObj());
|
if(type=="Text") element = new EText(ele.toObj());
|
||||||
else if(type=="Photo") element = EPhoto::create(ele.toObj(), this);
|
else if(type=="Image"||type=="Photo") element = EPhoto::create(ele.toObj(), this);
|
||||||
else if(type=="Gif") element = EGif::create(ele.toObj(), this);
|
else if(type=="Gif") element = EGif::create(ele.toObj(), this);
|
||||||
else if(type=="Movie") element = EVideo::create(ele.toObj(), this);
|
else if(type=="Video"||type=="Movie") element = EVideo::create(ele.toObj(), this);
|
||||||
else if(type=="DClock") element = new EDClock(ele.toObj());
|
else if(type=="DClock") element = new EDClock(ele.toObj());
|
||||||
else if(type=="AClock") element = new EAClock(ele.toObj());
|
else if(type=="AClock") element = new EAClock(ele.toObj());
|
||||||
else if(type=="Temp") element = new EEnviron(ele.toObj());
|
else if(type=="Temp") element = new EEnviron(ele.toObj());
|
||||||
|
@ -284,7 +284,7 @@ QPushButton[ssName="weeklySelector"]:checked {
|
||||||
btnAdd->setIcon(QIcon(":/res/program/Add.png"));
|
btnAdd->setIcon(QIcon(":/res/program/Add.png"));
|
||||||
btnAdd->setProperty("style","multiTool");
|
btnAdd->setProperty("style","multiTool");
|
||||||
|
|
||||||
mAudiosList = new QListWidget();
|
mAudiosList = new QListWidget;
|
||||||
connect(btnAdd, &QPushButton::clicked, mAttrWgt, [this, fdTtlDur] {
|
connect(btnAdd, &QPushButton::clicked, mAttrWgt, [this, fdTtlDur] {
|
||||||
auto files = QFileDialog::getOpenFileNames(mAttrWgt, tr("Select File"), gFileHome);
|
auto files = QFileDialog::getOpenFileNames(mAttrWgt, tr("Select File"), gFileHome);
|
||||||
int durs = fdTtlDur->text().toInt();
|
int durs = fdTtlDur->text().toInt();
|
||||||
|
@ -296,7 +296,7 @@ QPushButton[ssName="weeklySelector"]:checked {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QFileInfo fInfo(files[i]);
|
QFileInfo fInfo(files[i]);
|
||||||
AudioInfo info{fInfo.absolutePath(), fInfo.fileName(), (int)(dur/1000000)};
|
AudioInfo info{fInfo.absolutePath(), fInfo.fileName(), (int)round(dur*0.000001)};
|
||||||
auto item = new QListWidgetItem(QIcon(":/res/program/Audio.png"), info.name);
|
auto item = new QListWidgetItem(QIcon(":/res/program/Audio.png"), info.name);
|
||||||
item->setData(Qt::UserRole, QVariant::fromValue(info));
|
item->setData(Qt::UserRole, QVariant::fromValue(info));
|
||||||
mAudiosList->addItem(item);
|
mAudiosList->addItem(item);
|
||||||
|
|
|
@ -64,8 +64,6 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
// });
|
// });
|
||||||
// connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
// connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
||||||
// connect(saveThread, &QThread::finished, this, [this] {
|
// connect(saveThread, &QThread::finished, this, [this] {
|
||||||
// mProgItem->m_last = QDateTime::currentDateTime();
|
|
||||||
// mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
|
||||||
// mProgItem->onSetProgram();
|
// mProgItem->onSetProgram();
|
||||||
// });
|
// });
|
||||||
// saveThread->start();
|
// saveThread->start();
|
||||||
|
@ -81,8 +79,6 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
// connect(saveThread, SIGNAL(finished()), dlgTip, SLOT(unlock()));//显示正在保存提示对话框
|
// connect(saveThread, SIGNAL(finished()), dlgTip, SLOT(unlock()));//显示正在保存提示对话框
|
||||||
// connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
// connect(saveThread, SIGNAL(finished()), saveThread, SLOT(deleteLater()));
|
||||||
// connect(saveThread, &QThread::finished, this, [this] {
|
// connect(saveThread, &QThread::finished, this, [this] {
|
||||||
// mProgItem->m_last = QDateTime::currentDateTime();
|
|
||||||
// mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
|
||||||
// mProgItem->onSetProgram();
|
// mProgItem->onSetProgram();
|
||||||
// });
|
// });
|
||||||
// saveThread->start();
|
// saveThread->start();
|
||||||
|
@ -90,43 +86,56 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
// close();
|
// close();
|
||||||
// setWindowTitle(progName);
|
// setWindowTitle(progName);
|
||||||
// mProgItem->mProgPanel->onCreateNewProgramOnOpenEditProgramWidget(progName, QSize(mProgItem->mWidth, mProgItem->mHeight), mProgItem->mRemark, mProgItem->mSplitWidths, mProgItem->mMaxWidth);
|
// mProgItem->mProgPanel->onCreateNewProgramOnOpenEditProgramWidget(progName, QSize(mProgItem->mWidth, mProgItem->mHeight), mProgItem->mRemark, mProgItem->mSplitWidths, mProgItem->mMaxWidth);
|
||||||
|
// void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &partLengths, int max)
|
||||||
|
// {
|
||||||
|
// if(checkIfNameRepeated(name)) return;
|
||||||
|
// auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, partLengths, max, mProgTree);
|
||||||
|
// item->save();//保存pro.json
|
||||||
|
// if(mProgTree->fdCheckAll->checkState()==Qt::Checked) {
|
||||||
|
// mProgTree->fdCheckAll->blockSignals(true);
|
||||||
|
// mProgTree->fdCheckAll->setCheckState(Qt::PartiallyChecked);
|
||||||
|
// mProgTree->fdCheckAll->blockSignals(false);
|
||||||
|
// }
|
||||||
|
// auto editor = new ProgEditorWin(item, this);
|
||||||
|
// editor->show();
|
||||||
|
// }
|
||||||
// });
|
// });
|
||||||
// toolBar->addAction(action);
|
// toolBar->addAction(action);
|
||||||
action = new QAction(QIcon(":/res/program/Setting.png"), tr("Setting"));
|
action = new QAction(QIcon(":/res/program/Setting.png"), tr("Setting"));
|
||||||
connect(action, &QAction::triggered, this, [this] {
|
connect(action, &QAction::triggered, this, [this] {
|
||||||
QString widthsStr;
|
QString widthsStr;
|
||||||
for(auto &width : mProgItem->mSplitWidths) {
|
for(auto &width : mProgItem->partLens) {
|
||||||
if(! widthsStr.isEmpty()) widthsStr.append(" ");
|
if(! widthsStr.isEmpty()) widthsStr.append(" ");
|
||||||
widthsStr.append(QString::number(width));
|
widthsStr.append(QString::number(width));
|
||||||
}
|
}
|
||||||
ProgCreateDlg dlg(mProgItem->mName, mProgItem->mWidth, mProgItem->mHeight, mProgItem->mRemark, widthsStr, this);
|
ProgCreateDlg dlg(mProgItem->mName, mProgItem->mWidth, mProgItem->mHeight, mProgItem->mRemark, widthsStr, mProgItem->isVer, this);
|
||||||
if(dlg.exec() != QDialog::Accepted) return;
|
if(dlg.exec() != QDialog::Accepted) return;
|
||||||
mProgItem->mWidth = dlg.fdWidth->value();
|
mProgItem->mWidth = dlg.fdWidth->value();
|
||||||
mProgItem->mHeight = dlg.fdHeight->value();
|
mProgItem->mHeight = dlg.fdHeight->value();
|
||||||
mProgItem->mRemark = dlg.fdRemark->toPlainText();
|
mProgItem->mRemark = dlg.fdRemark->toPlainText();
|
||||||
mProgItem->mSplitWidths.clear();
|
mProgItem->partLens.clear();
|
||||||
mProgItem->mMaxWidth = 0;
|
mProgItem->maxLen = 0;
|
||||||
|
mProgItem->isVer = dlg.fdVer->isChecked();
|
||||||
|
auto len = mProgItem->isVer ? mProgItem->mHeight : mProgItem->mWidth;
|
||||||
if(dlg.fdIsUltraLong->isChecked()) {
|
if(dlg.fdIsUltraLong->isChecked()) {
|
||||||
auto splitWidths = dlg.fdSplitWidths->text().split(" ", Qt::SkipEmptyParts);
|
auto partLengths = dlg.fdSplitWidths->text().split(" ", Qt::SkipEmptyParts);
|
||||||
int ttl = 0;
|
int ttl = 0;
|
||||||
for(auto &splitWidth : splitWidths) {
|
for(auto &partLength : partLengths) {
|
||||||
int val = splitWidth.toInt();
|
int val = partLength.toInt();
|
||||||
if(val==0) continue;
|
if(val==0) continue;
|
||||||
if(mProgItem->mMaxWidth < val) mProgItem->mMaxWidth = val;
|
if(mProgItem->maxLen < val) mProgItem->maxLen = val;
|
||||||
mProgItem->mSplitWidths.append(val);
|
|
||||||
ttl += val;
|
ttl += val;
|
||||||
if(ttl>=mProgItem->mWidth) break;
|
mProgItem->partLens.emplace_back(val);
|
||||||
|
if(ttl>=len) break;
|
||||||
}
|
}
|
||||||
if(mProgItem->mMaxWidth) {
|
if(mProgItem->maxLen) {
|
||||||
while(ttl < mProgItem->mWidth) {
|
while(ttl < len) {
|
||||||
mProgItem->mSplitWidths.append(mProgItem->mMaxWidth);
|
mProgItem->partLens.push_back(mProgItem->maxLen);
|
||||||
ttl += mProgItem->mMaxWidth;
|
ttl += mProgItem->maxLen;
|
||||||
}
|
}
|
||||||
if(ttl > mProgItem->mWidth) mProgItem->mSplitWidths.last() -= ttl - mProgItem->mWidth;
|
if(ttl > len) mProgItem->partLens.back() -= ttl - len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mProgItem->m_last = QDateTime::currentDateTime();
|
|
||||||
mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
|
||||||
mProgItem->onSetProgram();
|
mProgItem->onSetProgram();
|
||||||
for(int i=0; i<listPage->count(); i++) {
|
for(int i=0; i<listPage->count(); i++) {
|
||||||
auto page = (PageListItem*) listPage->item(i);
|
auto page = (PageListItem*) listPage->item(i);
|
||||||
|
@ -147,7 +156,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
toolBar->addSeparator();
|
toolBar->addSeparator();
|
||||||
|
|
||||||
if(progItem->mSplitWidths.isEmpty()) {
|
if(progItem->partLens.empty()) {
|
||||||
action = new QAction(QIcon(":/res/program/Window.png"), tr("MuliContentWindow"));
|
action = new QAction(QIcon(":/res/program/Window.png"), tr("MuliContentWindow"));
|
||||||
action->setToolTip(tr("In this window, a plurality of different program materials can be added and played according to the order of joining the list;"));
|
action->setToolTip(tr("In this window, a plurality of different program materials can be added and played according to the order of joining the list;"));
|
||||||
action->setData(EBase::Window);
|
action->setData(EBase::Window);
|
||||||
|
@ -158,12 +167,11 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
action->setData(EBase::Text);
|
action->setData(EBase::Text);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
action = new QAction(QIcon(":/res/program/Photo.png"), tr("Photo"));
|
action = new QAction(QIcon(":/res/program/Photo.png"), tr("Photo"));
|
||||||
action->setData(EBase::Photo);
|
action->setData(EBase::Image);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
action = new QAction(QIcon(":/res/program/Movie.png"), tr("Video"));
|
action = new QAction(QIcon(":/res/program/Movie.png"), tr("Video"));
|
||||||
action->setData(EBase::Video);
|
action->setData(EBase::Video);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
if(progItem->mSplitWidths.isEmpty()) {
|
|
||||||
action = new QAction(QIcon(":/res/program/Gif.png"), tr("Gif"));
|
action = new QAction(QIcon(":/res/program/Gif.png"), tr("Gif"));
|
||||||
action->setData(EBase::Gif);
|
action->setData(EBase::Gif);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
|
@ -182,7 +190,6 @@ 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/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");
|
||||||
|
@ -238,9 +245,14 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
auto prog = JFrom(value, &jsErr);
|
auto prog = JFrom(value, &jsErr);
|
||||||
if(! jsErr.isEmpty()) return;
|
if(! jsErr.isEmpty()) return;
|
||||||
int www = mProgItem->mWidth, hhh = mProgItem->mHeight;
|
int www = mProgItem->mWidth, hhh = mProgItem->mHeight;
|
||||||
if(mProgItem->mMaxWidth) {
|
if(mProgItem->maxLen) {
|
||||||
www = mProgItem->mMaxWidth;
|
if(mProgItem->isVer) {
|
||||||
hhh *= mProgItem->mSplitWidths.size();
|
hhh = mProgItem->maxLen;
|
||||||
|
www *= mProgItem->partLens.size();
|
||||||
|
} else {
|
||||||
|
www = mProgItem->maxLen;
|
||||||
|
hhh *= mProgItem->partLens.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PlayWin::self = PlayWin::newIns(www, hhh, mProgItem->mProgDir+"_tmp", prog);
|
PlayWin::self = PlayWin::newIns(www, hhh, mProgItem->mProgDir+"_tmp", prog);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +288,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
if(mNewEleX+iNewWidth>mProgItem->mWidth) mNewEleX=0;
|
if(mNewEleX+iNewWidth>mProgItem->mWidth) mNewEleX=0;
|
||||||
if(mNewEleY+iNewHeight>mProgItem->mHeight) mNewEleY=0;
|
if(mNewEleY+iNewHeight>mProgItem->mHeight) mNewEleY=0;
|
||||||
auto type = data.toInt();
|
auto type = data.toInt();
|
||||||
if(type==EBase::Photo) {
|
if(type==EBase::Image) {
|
||||||
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EPhoto::filters());
|
auto files = QFileDialog::getOpenFileNames(this, tr("Select File"), gFileHome, EPhoto::filters());
|
||||||
for(int i=0; i<files.count(); i++) {
|
for(int i=0; i<files.count(); i++) {
|
||||||
auto ePhoto = EPhoto::create(files[i], mPageItem);
|
auto ePhoto = EPhoto::create(files[i], mPageItem);
|
||||||
|
@ -558,8 +570,6 @@ bool ProgEditorWin::isProgChanged() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void ProgEditorWin::closeEvent(QCloseEvent *event) {
|
void ProgEditorWin::closeEvent(QCloseEvent *event) {
|
||||||
mProgItem->m_last = QDateTime::currentDateTime();
|
|
||||||
mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
|
||||||
mProgItem->onSetProgram();
|
mProgItem->onSetProgram();
|
||||||
if(isProgChanged()) {
|
if(isProgChanged()) {
|
||||||
auto res = QMessageBox::question(this, tr("Tip Info"), tr("Do you want to save the modifications?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
|
auto res = QMessageBox::question(this, tr("Tip Info"), tr("Do you want to save the modifications?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
|
||||||
|
@ -621,8 +631,6 @@ void ProgEditorWin::onSave() {
|
||||||
if(save()) waitingDlg->success();
|
if(save()) waitingDlg->success();
|
||||||
else waitingDlg->close();
|
else waitingDlg->close();
|
||||||
waitingDlg->exec();
|
waitingDlg->exec();
|
||||||
mProgItem->m_last = QDateTime::currentDateTime();
|
|
||||||
mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
|
||||||
mProgItem->onSetProgram();
|
mProgItem->onSetProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +655,7 @@ void ProgEditorWin::onAddPage() {
|
||||||
if(listPage->count()==5) for(int i=0; i<4; i++) ((PageListItem*)listPage->item(i))->fdIdx->setNum(i+1);
|
if(listPage->count()==5) for(int i=0; i<4; i++) ((PageListItem*)listPage->item(i))->fdIdx->setNum(i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remarks, QString widths, QWidget *parent) : QDialog(parent) {
|
ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remarks, QString widths, bool isVer, QWidget *parent) : QDialog(parent) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -701,7 +709,7 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
|
||||||
hBox->addWidget(label);
|
hBox->addWidget(label);
|
||||||
|
|
||||||
fdRemark = new QTextEdit(remarks);
|
fdRemark = new QTextEdit(remarks);
|
||||||
fdRemark->setFixedSize(300, 80);
|
fdRemark->setFixedHeight(80);
|
||||||
hBox->addWidget(fdRemark);
|
hBox->addWidget(fdRemark);
|
||||||
|
|
||||||
vBox->addSpacing(6);
|
vBox->addSpacing(6);
|
||||||
|
@ -710,11 +718,20 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
|
||||||
hBox->addSpacing(72);
|
hBox->addSpacing(72);
|
||||||
|
|
||||||
fdIsUltraLong = new QCheckBox(tr("Ultra-Long Screen Split"));
|
fdIsUltraLong = new QCheckBox(tr("Ultra-Long Screen Split"));
|
||||||
if(! widths.isEmpty()) fdIsUltraLong->setChecked(true);
|
|
||||||
hBox->addWidget(fdIsUltraLong);
|
hBox->addWidget(fdIsUltraLong);
|
||||||
|
|
||||||
|
fdHor = new QRadioButton(tr("Horizontal"));
|
||||||
|
hBox->addWidget(fdHor);
|
||||||
|
|
||||||
|
fdVer = new QRadioButton(tr("Vertical"));
|
||||||
|
hBox->addWidget(fdVer);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
if(isVer) fdVer->setChecked(true);
|
||||||
|
else fdHor->setChecked(true);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
auto lbSplitWidth = new QLabel(tr("Part Width"));
|
auto lbSplitWidth = new QLabel(tr("Lengths of Parts"));
|
||||||
lbSplitWidth->setMinimumWidth(90);
|
lbSplitWidth->setMinimumWidth(90);
|
||||||
lbSplitWidth->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
lbSplitWidth->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
hBox->addWidget(lbSplitWidth);
|
hBox->addWidget(lbSplitWidth);
|
||||||
|
@ -722,6 +739,16 @@ ProgCreateDlg::ProgCreateDlg(QString name, int width, int height, QString remark
|
||||||
fdSplitWidths = new QLineEdit(widths.isEmpty() ? "1920" : widths);
|
fdSplitWidths = new QLineEdit(widths.isEmpty() ? "1920" : widths);
|
||||||
fdSplitWidths->setPlaceholderText("1920");
|
fdSplitWidths->setPlaceholderText("1920");
|
||||||
hBox->addWidget(fdSplitWidths);
|
hBox->addWidget(fdSplitWidths);
|
||||||
|
|
||||||
|
connect(fdIsUltraLong, &QCheckBox::toggled, this, [=](bool checked) {
|
||||||
|
fdHor->setVisible(checked);
|
||||||
|
fdVer->setVisible(checked);
|
||||||
|
lbSplitWidth->setVisible(checked);
|
||||||
|
fdSplitWidths->setVisible(checked);
|
||||||
|
});
|
||||||
|
if(widths.isEmpty()) fdIsUltraLong->toggled(false);
|
||||||
|
else fdIsUltraLong->setChecked(true);
|
||||||
|
|
||||||
if(! gWidthSplit) {
|
if(! gWidthSplit) {
|
||||||
fdIsUltraLong->setVisible(false);
|
fdIsUltraLong->setVisible(false);
|
||||||
lbSplitWidth->setVisible(false);
|
lbSplitWidth->setVisible(false);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define PROGEDITORWIN_H
|
#define PROGEDITORWIN_H
|
||||||
#include "program/pageeditor.h"
|
#include "program/pageeditor.h"
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QRadioButton>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
@ -36,12 +37,13 @@ private:
|
||||||
class ProgCreateDlg : public QDialog {
|
class ProgCreateDlg : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ProgCreateDlg(QString name, int width, int height, QString remarks, QString, QWidget *parent = nullptr);
|
ProgCreateDlg(QString name, int width, int height, QString remarks, QString, bool isVer, QWidget *parent = nullptr);
|
||||||
QLineEdit *fdName;
|
QLineEdit *fdName;
|
||||||
QSpinBox *fdWidth;
|
QSpinBox *fdWidth;
|
||||||
QSpinBox *fdHeight;
|
QSpinBox *fdHeight;
|
||||||
QTextEdit *fdRemark;
|
QTextEdit *fdRemark;
|
||||||
QCheckBox *fdIsUltraLong;
|
QCheckBox *fdIsUltraLong;
|
||||||
|
QRadioButton *fdHor, *fdVer;
|
||||||
QLineEdit *fdSplitWidths;
|
QLineEdit *fdSplitWidths;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,27 +13,9 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStorageInfo>
|
#include <QStorageInfo>
|
||||||
|
|
||||||
ProgItem::ProgItem(const QString &progsDir, const QString &name, int w, int h, const QString &remarks, QList<int> &splitWidths, int maxWidth, LoQTreeWidget *tree) : TreeWidgetItem(tree),
|
ProgItem::ProgItem(const QString &progsDir, const QString &name, int w, int h, const QString &remarks, std::vector<int> &partLens, int maxLen, bool isVer, LoQTreeWidget *tree) : TreeWidgetItem(tree),
|
||||||
mName(name), mWidth(w), mHeight(h), mRemark(remarks), mSplitWidths(splitWidths), mMaxWidth(maxWidth), mProgsDir(progsDir) {
|
mName(name), mWidth(w), mHeight(h), mRemark(remarks), partLens(partLens), maxLen(maxLen), isVer(isVer), mProgsDir(progsDir) {
|
||||||
m_last = QDateTime::currentDateTime();
|
setText("lasttime", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
mProgDir = progsDir + "/" + mName;
|
|
||||||
m_orgName = mName;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProgItem::ProgItem(const QString &progsDir, const QJsonObject &json, LoQTreeWidget *tree) : TreeWidgetItem(tree), mProgsDir(progsDir) {
|
|
||||||
mName = json["name"].toString();
|
|
||||||
mWidth = json["resolution"]["w"].toInt();
|
|
||||||
mHeight = json["resolution"]["h"].toInt();
|
|
||||||
mRemark = json["remarks"].toString();
|
|
||||||
auto splitWidths = json["splitWidths"].toArray();
|
|
||||||
foreach(auto splitWidth, splitWidths) {
|
|
||||||
int width = splitWidth.toInt();
|
|
||||||
if(mMaxWidth < width) mMaxWidth = width;
|
|
||||||
mSplitWidths.append(width);
|
|
||||||
}
|
|
||||||
m_fsize = json["file_size"].toDouble();
|
|
||||||
m_last = QDateTime::fromString(json["last_edit"].toString(), "yyyy-MM-dd hh:mm:ss");
|
|
||||||
mProgDir = progsDir + "/" + mName;
|
mProgDir = progsDir + "/" + mName;
|
||||||
m_orgName = mName;
|
m_orgName = mName;
|
||||||
init();
|
init();
|
||||||
|
@ -52,23 +34,22 @@ void ProgItem::init() {
|
||||||
setText("name", mName);
|
setText("name", mName);
|
||||||
setText("resolution", QString("%1 x %2").arg(mWidth).arg(mHeight));
|
setText("resolution", QString("%1 x %2").arg(mWidth).arg(mHeight));
|
||||||
setText("size", m_fsize<=0 ? "100B" : byteSizeStr(m_fsize));
|
setText("size", m_fsize<=0 ? "100B" : byteSizeStr(m_fsize));
|
||||||
setText("lasttime", m_last.toString("yyyy-MM-dd hh:mm:ss"));
|
|
||||||
|
|
||||||
m_bnName = new QPushButton(mName);
|
btnName = new QPushButton(mName);
|
||||||
m_bnName->setFont(ft);
|
btnName->setFont(ft);
|
||||||
m_bnName->setCursor(QCursor(Qt::PointingHandCursor));
|
btnName->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
m_bnName->setStyleSheet(R"delimiter(
|
btnName->setStyleSheet(R"delimiter(
|
||||||
QPushButton{border-radius: 4px;}
|
QPushButton{border-radius: 4px;}
|
||||||
QPushButton:hover {
|
QPushButton:hover {
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
)delimiter");
|
)delimiter");
|
||||||
QObject::connect(m_bnName, &QPushButton::clicked, treeWidget(), [=] {
|
QObject::connect(btnName, &QPushButton::clicked, treeWidget(), [=] {
|
||||||
auto editor = new ProgEditorWin(this, treeWidget()->parentWidget());
|
auto editor = new ProgEditorWin(this, treeWidget()->parentWidget());
|
||||||
editor->show();
|
editor->show();
|
||||||
});
|
});
|
||||||
setCellWidget("name", m_bnName);
|
setCellWidget("name", btnName);
|
||||||
|
|
||||||
auto btnExport = new QPushButton;
|
auto btnExport = new QPushButton;
|
||||||
btnExport->setCursor(QCursor(Qt::PointingHandCursor));
|
btnExport->setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
|
@ -177,19 +158,20 @@ void ProgItem::save() {
|
||||||
|
|
||||||
dRoot = QDir(mProgDir);
|
dRoot = QDir(mProgDir);
|
||||||
if(dRoot.exists()) {
|
if(dRoot.exists()) {
|
||||||
QJsonObject obj;
|
JObj json;
|
||||||
obj["name"] = mName;
|
json["name"] = mName;
|
||||||
obj["resolution"] = QJsonObject{{"w", mWidth}, {"h", mHeight}};
|
json["resolution"] = JObj{{"w", mWidth}, {"h", mHeight}};
|
||||||
obj["remarks"] = mRemark;
|
json["remarks"] = mRemark;
|
||||||
QJsonArray splitWidths;
|
json["isVer"] = isVer;
|
||||||
foreach(auto splitWidth, mSplitWidths) splitWidths.append(splitWidth);
|
JArray partLens;
|
||||||
obj["splitWidths"] = splitWidths;
|
for(auto partLen : this->partLens) partLens.append(partLen);
|
||||||
obj["file_size"] = m_fsize;
|
json["splitWidths"] = partLens;
|
||||||
obj["last_edit"] = m_last.toString("yyyy-MM-dd hh:mm:ss");
|
json["file_size"] = m_fsize;
|
||||||
QFile f(mProgDir + "/pro.json");
|
QFile file(mProgDir + "/pro.json");
|
||||||
f.open(QIODevice::WriteOnly);
|
if(file.open(QIODevice::WriteOnly)) {
|
||||||
f.write(QJsonDocument(obj).toJson());
|
file.write(JToBytes(json, "\n"));
|
||||||
f.close();
|
file.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +181,10 @@ void ProgItem::del() {
|
||||||
}
|
}
|
||||||
//设置列表项的值
|
//设置列表项的值
|
||||||
void ProgItem::onSetProgram() {
|
void ProgItem::onSetProgram() {
|
||||||
m_bnName->setText(mName);
|
btnName->setText(mName);
|
||||||
|
m_fsize = dirFileSize(mProgDir);
|
||||||
setText("resolution", QString("%1 x %2").arg(mWidth).arg(mHeight));
|
setText("resolution", QString("%1 x %2").arg(mWidth).arg(mHeight));
|
||||||
setText("size", byteSizeStr(m_fsize<=0 ? 100 : m_fsize));
|
setText("size", byteSizeStr(m_fsize<=0 ? 100 : m_fsize));
|
||||||
setText("lasttime", m_last.toString("yyyy-MM-dd hh:mm:ss"));
|
setText("lasttime", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
class ProgPanel;
|
class ProgPanel;
|
||||||
class ProgItem : public TreeWidgetItem {
|
class ProgItem : public TreeWidgetItem {
|
||||||
public:
|
public:
|
||||||
explicit ProgItem(const QString &progsDir, const QString &name, int w, int h, const QString & remarks, QList<int> &splitWidths, int, LoQTreeWidget *parent);
|
using TreeWidgetItem::TreeWidgetItem;
|
||||||
explicit ProgItem(const QString &progsDir, const QJsonObject &json, LoQTreeWidget *parent);
|
explicit ProgItem(const QString &progsDir, const QString &name, int w, int h, const QString & remarks, std::vector<int> &, int, bool isVer, LoQTreeWidget *parent);
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
void del();
|
void del();
|
||||||
|
@ -19,14 +19,13 @@ public:
|
||||||
int mWidth;
|
int mWidth;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
QString mRemark;
|
QString mRemark;
|
||||||
QList<int> mSplitWidths;
|
std::vector<int> partLens;
|
||||||
int mMaxWidth{0};
|
int maxLen = 0;
|
||||||
|
bool isVer = false;
|
||||||
QString mProgsDir;
|
QString mProgsDir;
|
||||||
QString mProgDir;
|
QString mProgDir;
|
||||||
qint64 m_fsize{0};
|
qint64 m_fsize = 0;
|
||||||
QDateTime m_last;
|
QPushButton *btnName;
|
||||||
QPushButton *m_bnName;
|
|
||||||
private:
|
|
||||||
void init();
|
void init();
|
||||||
QString m_orgName;
|
QString m_orgName;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,7 +50,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
item->isSending = true;
|
item->isSending = true;
|
||||||
item->setText(remarks, "");
|
item->setText(remarks, "");
|
||||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", item->text("ip"), 3333);
|
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", item->text("ip"), 3333);
|
||||||
connect(sendProg, &SendProgThread::emErr, item->fdProgress, [=](QString strTip) {
|
connect(sendProg, &SendProgThread::emErr, item, [=](QString strTip) {
|
||||||
item->isSending = false;
|
item->isSending = false;
|
||||||
if(strTip=="OK") {
|
if(strTip=="OK") {
|
||||||
item->setCheckState("id", Qt::Unchecked);
|
item->setCheckState("id", Qt::Unchecked);
|
||||||
|
@ -112,7 +112,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
||||||
item->btnUnlock = new QPushButton;
|
item->btnUnlock = new QPushButton;
|
||||||
item->btnUnlock->setMaximumHeight(36);
|
item->btnUnlock->setMaximumHeight(36);
|
||||||
item->setCellWidget("encrypt", item->btnUnlock);
|
item->setCellWidget("encrypt", item->btnUnlock);
|
||||||
connect(item->btnUnlock, &QPushButton::clicked, item->btnUnlock, [=] {
|
connect(item->btnUnlock, &QPushButton::clicked, item, [=] {
|
||||||
if(! item->isLocked) return;
|
if(! item->isLocked) return;
|
||||||
bool ok;
|
bool ok;
|
||||||
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
auto pwd = QInputDialog::getText(this, tr("Input password"), tr("Input password"), QLineEdit::Password, QString(), &ok);
|
||||||
|
@ -206,7 +206,7 @@ void SendProgramDialog::sendNext() {
|
||||||
item->isSending = true;
|
item->isSending = true;
|
||||||
mWaitCnt--;
|
mWaitCnt--;
|
||||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", item->text("ip"), 3333);
|
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", item->text("ip"), 3333);
|
||||||
connect(sendProg, &SendProgThread::emErr, item->fdProgress, [=](QString strTip) {
|
connect(sendProg, &SendProgThread::emErr, item, [=](QString strTip) {
|
||||||
item->isSending = false;
|
item->isSending = false;
|
||||||
if(strTip=="OK") {
|
if(strTip=="OK") {
|
||||||
item->setCheckState("id", Qt::Unchecked);
|
item->setCheckState("id", Qt::Unchecked);
|
||||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
||||||
QString m_strUrl;
|
QString m_strUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SendProgramItem : public TreeWidgetItem {
|
class SendProgramItem : public TreeWidgetItem, public QObject {
|
||||||
public:
|
public:
|
||||||
using TreeWidgetItem::TreeWidgetItem;
|
using TreeWidgetItem::TreeWidgetItem;
|
||||||
void setResult(QString tip, QColor color) {
|
void setResult(QString tip, QColor color) {
|
||||||
|
|
|
@ -121,7 +121,7 @@ void SendProgThread::run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//4.发送协商列表应答里的文件
|
//4.发送协商列表应答里的文件
|
||||||
long long sentBytes = 0;
|
int64_t sentBytes = 0;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
for(auto &info : fileInfos) if(info.isFile()) {
|
for(auto &info : fileInfos) if(info.isFile()) {
|
||||||
auto baseName = info.baseName();
|
auto baseName = info.baseName();
|
||||||
|
|
|
@ -12,7 +12,7 @@ static void imgCleanupHandler(void *info) {
|
||||||
delete [] (uchar*)info;
|
delete [] (uchar*)info;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoSplitThread::VideoSplitThread(int elew, int eleh, int dpw, int sph, QList<int> &widths, QPointF pos, QByteArray file) : mEleW(elew), mEleH(eleh), mDPW(dpw), mSPH(sph), mWidths(widths), pos(pos), file(file) {
|
VideoSplitThread::VideoSplitThread(int elew, int eleh, int maxLen, int sph, std::vector<int> &widths, bool isVer, QPointF pos, QByteArray file) : mEleW(elew), mEleH(eleh), maxLen(maxLen), mSPH(sph), mWidths(widths), pos(pos), file(file), isVer(isVer) {
|
||||||
connect(this, &QThread::finished, this, &QThread::deleteLater);
|
connect(this, &QThread::finished, this, &QThread::deleteLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,13 @@ void VideoSplitThread::run() {
|
||||||
outPar->codec_type = AVMEDIA_TYPE_VIDEO;
|
outPar->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||||
outPar->codec_id = AV_CODEC_ID_H264;
|
outPar->codec_id = AV_CODEC_ID_H264;
|
||||||
outPar->format = AV_PIX_FMT_YUV420P;
|
outPar->format = AV_PIX_FMT_YUV420P;
|
||||||
outPar->width = mDPW;
|
if(isVer) {
|
||||||
|
outPar->height = maxLen;
|
||||||
|
outPar->width = mSPH*mWidths.size();
|
||||||
|
} else {
|
||||||
|
outPar->width = maxLen;
|
||||||
outPar->height = mSPH*mWidths.size();
|
outPar->height = mSPH*mWidths.size();
|
||||||
|
}
|
||||||
|
|
||||||
auto encoder = avcodec_find_encoder(outPar->codec_id);
|
auto encoder = avcodec_find_encoder(outPar->codec_id);
|
||||||
if(encoder==0) {
|
if(encoder==0) {
|
||||||
|
@ -150,12 +155,21 @@ void VideoSplitThread::run() {
|
||||||
} else {
|
} else {
|
||||||
sws_scale(sws_ctx, frm->data, frm->linesize, 0, de_ctx->height, img_data, img_linesize);
|
sws_scale(sws_ctx, frm->data, frm->linesize, 0, de_ctx->height, img_data, img_linesize);
|
||||||
auto apos = pos;
|
auto apos = pos;
|
||||||
|
if(isVer) {
|
||||||
|
painter.drawImage(apos, img, QRectF(0, 0, img.width(), mWidths[0]-apos.y()));
|
||||||
|
for(int i=1; i<(int)mWidths.size(); i++) {
|
||||||
|
apos.ry() -= mWidths[i-1];
|
||||||
|
apos.rx() += mSPH;
|
||||||
|
painter.drawImage(apos, img, QRectF(0, 0, img.width(), mWidths[i]-apos.y()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
painter.drawImage(apos, img, QRectF(0, 0, mWidths[0]-apos.x(), img.height()));
|
painter.drawImage(apos, img, QRectF(0, 0, mWidths[0]-apos.x(), img.height()));
|
||||||
for(int i=1; i<mWidths.size(); i++) {
|
for(int i=1; i<(int)mWidths.size(); i++) {
|
||||||
apos.rx() -= mWidths[i-1];
|
apos.rx() -= mWidths[i-1];
|
||||||
apos.ry() += mSPH;
|
apos.ry() += mSPH;
|
||||||
painter.drawImage(apos, img, QRectF(0, 0, mWidths[i]-apos.x(), img.height()));
|
painter.drawImage(apos, img, QRectF(0, 0, mWidths[i]-apos.x(), img.height()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
auto pts = frm->pts;
|
auto pts = frm->pts;
|
||||||
auto dur = frm->pkt_duration;
|
auto dur = frm->pkt_duration;
|
||||||
av_frame_unref(frm);
|
av_frame_unref(frm);
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
class VideoSplitThread : public QThread {
|
class VideoSplitThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VideoSplitThread(int elew, int eleh, int dpw, int sph, QList<int> &, QPointF pos, QByteArray file);
|
VideoSplitThread(int elew, int eleh, int maxLen, int sph, std::vector<int> &, bool, QPointF pos, QByteArray file);
|
||||||
int mEleW, mEleH, mDPW, mSPH;
|
int mEleW, mEleH, maxLen, mSPH;
|
||||||
QList<int> mWidths;
|
std::vector<int> mWidths;
|
||||||
QPointF pos;
|
QPointF pos;
|
||||||
QByteArray file;
|
QByteArray file;
|
||||||
|
bool isVer;
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
##×¢ÊÍ
|
||||||
|
#×¢ÊÍ
|
||||||
|
# 0 - DSI; 1 - EDP; 2 - LVDS; 3 - RGB
|
||||||
|
panel-type = 3;
|
||||||
|
|
||||||
|
# panel info
|
||||||
|
unprepare-delay-ms = 20;
|
||||||
|
enable-delay-ms = 20;
|
||||||
|
disable-delay-ms = 20;
|
||||||
|
prepare-delay-ms = 20;
|
||||||
|
reset-delay-ms = 100;
|
||||||
|
init-delay-ms = 100;
|
||||||
|
width-mm = 150;
|
||||||
|
height-mm = 120;
|
||||||
|
|
||||||
|
# panel timing
|
||||||
|
clock-frequency = 81120000;
|
||||||
|
hactive = 1024;
|
||||||
|
hfront-porch = 5;
|
||||||
|
hsync-len = 5;
|
||||||
|
hback-porch = 6;
|
||||||
|
vactive = 1280;
|
||||||
|
vfront-porch = 5;
|
||||||
|
vsync-len = 5;
|
||||||
|
vback-porch = 10;
|
||||||
|
hsync-active = 0;
|
||||||
|
vsync-active = 0;
|
||||||
|
de-active = 0;
|
||||||
|
pixelclk-active = 0;
|
||||||
|
|
||||||
|
# for dsi panel
|
||||||
|
#dsi,flags = 0;
|
||||||
|
#dsi,format = 0;
|
||||||
|
#dsi,lanes = 4;
|
||||||
|
#panel-init-sequence = 29 00 06 14 01 08 00 00 00 ff aa 01 02 03 04 05 06 07 ff aa AA bb ff;
|
|
@ -0,0 +1,35 @@
|
||||||
|
##×¢ÊÍ
|
||||||
|
#×¢ÊÍ
|
||||||
|
# 0 - DSI; 1 - EDP; 2 - LVDS; 3 - RGB
|
||||||
|
panel-type = 3;
|
||||||
|
|
||||||
|
# panel info
|
||||||
|
unprepare-delay-ms = 20;
|
||||||
|
enable-delay-ms = 20;
|
||||||
|
disable-delay-ms = 20;
|
||||||
|
prepare-delay-ms = 20;
|
||||||
|
reset-delay-ms = 100;
|
||||||
|
init-delay-ms = 100;
|
||||||
|
width-mm = 150;
|
||||||
|
height-mm = 120;
|
||||||
|
|
||||||
|
# panel timing
|
||||||
|
clock-frequency = 81120000;
|
||||||
|
hactive = 1280;
|
||||||
|
hfront-porch = 5;
|
||||||
|
hsync-len = 5;
|
||||||
|
hback-porch = 10;
|
||||||
|
vactive = 1024;
|
||||||
|
vfront-porch = 5;
|
||||||
|
vsync-len = 5;
|
||||||
|
vback-porch = 6;
|
||||||
|
hsync-active = 0;
|
||||||
|
vsync-active = 0;
|
||||||
|
de-active = 0;
|
||||||
|
pixelclk-active = 0;
|
||||||
|
|
||||||
|
# for dsi panel
|
||||||
|
#dsi,flags = 0;
|
||||||
|
#dsi,format = 0;
|
||||||
|
#dsi,lanes = 4;
|
||||||
|
#panel-init-sequence = 29 00 06 14 01 08 00 00 00 ff aa 01 02 03 04 05 06 07 ff aa AA bb ff;
|
|
@ -0,0 +1,35 @@
|
||||||
|
##×¢ÊÍ
|
||||||
|
#×¢ÊÍ
|
||||||
|
# 0 - DSI; 1 - EDP; 2 - LVDS; 3 - RGB
|
||||||
|
panel-type = 3;
|
||||||
|
|
||||||
|
# panel info
|
||||||
|
unprepare-delay-ms = 20;
|
||||||
|
enable-delay-ms = 20;
|
||||||
|
disable-delay-ms = 20;
|
||||||
|
prepare-delay-ms = 20;
|
||||||
|
reset-delay-ms = 100;
|
||||||
|
init-delay-ms = 100;
|
||||||
|
width-mm = 154;
|
||||||
|
height-mm = 86;
|
||||||
|
|
||||||
|
# panel timing
|
||||||
|
clock-frequency = 80250000;
|
||||||
|
hactive = 1536;
|
||||||
|
hfront-porch = 48;
|
||||||
|
hsync-len = 32;
|
||||||
|
hback-porch = 80;
|
||||||
|
vactive = 768;
|
||||||
|
vfront-porch = 3;
|
||||||
|
vsync-len = 10;
|
||||||
|
vback-porch = 9;
|
||||||
|
hsync-active = 0;
|
||||||
|
vsync-active = 0;
|
||||||
|
de-active = 0;
|
||||||
|
pixelclk-active = 0;
|
||||||
|
|
||||||
|
# for dsi panel
|
||||||
|
#dsi,flags = 0;
|
||||||
|
#dsi,format = 0;
|
||||||
|
#dsi,lanes = 4;
|
||||||
|
#panel-init-sequence = 29 00 06 14 01 08 00 00 00 ff aa 01 02 03 04 05 06 07 ff aa AA bb ff;
|
|
@ -58,6 +58,31 @@ void Tools::mergeFormat(QTextEdit *textEdit, const QTextCharFormat &fmt) {
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
cursor.mergeCharFormat(fmt);
|
cursor.mergeCharFormat(fmt);
|
||||||
}
|
}
|
||||||
|
QString Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, const QString& str) {
|
||||||
|
if(str.isEmpty()) return QString();
|
||||||
|
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
||||||
|
img.fill(Qt::transparent);
|
||||||
|
{
|
||||||
|
QPainter painter(&img);
|
||||||
|
painter.setFont(font);
|
||||||
|
painter.setPen(color);
|
||||||
|
QTextOption opt(Qt::AlignCenter);
|
||||||
|
opt.setWrapMode(QTextOption::NoWrap);
|
||||||
|
painter.drawText(QRectF(0, 0, img.width(), img.height()), str, opt);
|
||||||
|
}
|
||||||
|
QByteArray data;
|
||||||
|
QBuffer buffer(&data);
|
||||||
|
buffer.open(QIODevice::WriteOnly);
|
||||||
|
if(! img.save(&buffer, "PNG")) return QString();
|
||||||
|
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||||
|
cryptoHash.addData(data);
|
||||||
|
auto md5 = QString::fromLatin1(cryptoHash.result().toHex());
|
||||||
|
QFile file(dir+"/"+md5);
|
||||||
|
if(! file.open(QFile::WriteOnly)) return QString();
|
||||||
|
file.write(data);
|
||||||
|
file.close();
|
||||||
|
return md5;
|
||||||
|
}
|
||||||
void Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, JObj& imgs, const QString& str, const QString& name) {
|
void Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, JObj& imgs, const QString& str, const QString& name) {
|
||||||
if(str.isEmpty()) return;
|
if(str.isEmpty()) return;
|
||||||
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
||||||
|
@ -85,11 +110,12 @@ void Tools::saveImg(const QString& dir, const QFontMetrics& metric, const QFont&
|
||||||
}
|
}
|
||||||
void Tools::saveImg2(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, JArray& imgs, const QString& str, const QString& name) {
|
void Tools::saveImg2(const QString& dir, const QFontMetrics& metric, const QFont& font, const QColor& color, JArray& imgs, const QString& str, const QString& name) {
|
||||||
JObj obj{
|
JObj obj{
|
||||||
{"name", name},
|
{"name", name}
|
||||||
{"mime", "image/png"}
|
|
||||||
};
|
};
|
||||||
if(! str.isEmpty()) {
|
if(! str.isEmpty()) {
|
||||||
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
QImage img(metric.horizontalAdvance(str), metric.lineSpacing(), QImage::Format_ARGB32);
|
||||||
|
obj.insert("picWidth", img.width());
|
||||||
|
obj.insert("picHeight", img.height());
|
||||||
img.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
{
|
{
|
||||||
QPainter painter(&img);
|
QPainter painter(&img);
|
||||||
|
@ -103,16 +129,14 @@ void Tools::saveImg2(const QString& dir, const QFontMetrics& metric, const QFont
|
||||||
QBuffer buffer(&data);
|
QBuffer buffer(&data);
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
if(img.save(&buffer, "PNG")) {
|
if(img.save(&buffer, "PNG")) {
|
||||||
obj.insert("picWidth", img.width());
|
|
||||||
obj.insert("picHeight", img.height());
|
|
||||||
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||||
cryptoHash.addData(data);
|
cryptoHash.addData(data);
|
||||||
auto md5 = QString::fromLatin1(cryptoHash.result().toHex());
|
auto md5 = QString::fromLatin1(cryptoHash.result().toHex());
|
||||||
|
obj.insert("id", md5);
|
||||||
QFile file(dir+"/"+md5);
|
QFile file(dir+"/"+md5);
|
||||||
if(file.open(QFile::WriteOnly)) {
|
if(file.open(QFile::WriteOnly)) {
|
||||||
file.write(data);
|
file.write(data);
|
||||||
file.close();
|
file.close();
|
||||||
obj.insert("id", md5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ public:
|
||||||
static void mergeFormat(QTextEdit *textEdit, const QTextCharFormat &format);
|
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 void saveImg(const QString&, const QFontMetrics&, const QFont&, const QColor&, JObj&, const QString&, const QString&);
|
static void saveImg(const QString&, const QFontMetrics&, const QFont&, const QColor&, JObj&, const QString&, const QString&);
|
||||||
static void saveImg2(const QString&, const QFontMetrics&, const QFont&, const QColor&, JArray&, const QString&, const QString&);
|
static void saveImg2(const QString&, const QFontMetrics&, const QFont&, const QColor&, JArray&, const QString&, const QString&);
|
||||||
static QColor int2Color(int value);
|
static QColor int2Color(int value);
|
||||||
|
@ -44,7 +45,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
virtual void timerEvent(QTimerEvent *event);
|
virtual void timerEvent(QTimerEvent *event);
|
||||||
private:
|
private:
|
||||||
Tools(QObject *parent = nullptr) : QObject(parent) {
|
Tools(QObject *parent = 0) : QObject(parent) {
|
||||||
timer_id = startTimer(500, Qt::PreciseTimer);
|
timer_id = startTimer(500, Qt::PreciseTimer);
|
||||||
};
|
};
|
||||||
int timer_id;
|
int timer_id;
|
||||||
|
|
2306
LedOK/ts/app_en.ts
2306
LedOK/ts/app_en.ts
File diff suppressed because it is too large
Load Diff
2312
LedOK/ts/app_ja.ts
2312
LedOK/ts/app_ja.ts
File diff suppressed because it is too large
Load Diff
2256
LedOK/ts/app_pt.ts
2256
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