ledok
BIN
LedOK/AdbWinApi.dll
Normal file
BIN
LedOK/AdbWinUsbApi.dll
Normal file
|
|
@ -27,7 +27,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 = 2.0.3
|
VERSION = 2.0.4
|
||||||
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
|
||||||
msvc {
|
msvc {
|
||||||
contains(QT_ARCH, i386) {
|
contains(QT_ARCH, i386) {
|
||||||
|
|
@ -77,6 +77,9 @@ win32 {
|
||||||
copy.files += $$files(ffmpeg$$DIR_SUFFIX/bin/*.dll)
|
copy.files += $$files(ffmpeg$$DIR_SUFFIX/bin/*.dll)
|
||||||
copy.files += 7z/7z.dll
|
copy.files += 7z/7z.dll
|
||||||
copy.files += 7z/7z.exe
|
copy.files += 7z/7z.exe
|
||||||
|
copy.files += adb.exe
|
||||||
|
copy.files += AdbWinApi.dll
|
||||||
|
copy.files += AdbWinUsbApi.dll
|
||||||
|
|
||||||
copy.path = $$OUT_PWD
|
copy.path = $$OUT_PWD
|
||||||
copydir.path = $$OUT_PWD
|
copydir.path = $$OUT_PWD
|
||||||
|
|
@ -120,6 +123,7 @@ SOURCES += \
|
||||||
base/locolorselector.cpp \
|
base/locolorselector.cpp \
|
||||||
base/loqtitlebar.cpp \
|
base/loqtitlebar.cpp \
|
||||||
base/loqtreewidget.cpp \
|
base/loqtreewidget.cpp \
|
||||||
|
device/badpointdetectdialog.cpp \
|
||||||
device/progressesdlg.cpp \
|
device/progressesdlg.cpp \
|
||||||
gutil/qcore.cpp \
|
gutil/qcore.cpp \
|
||||||
gutil/qwaitingdlg.cpp \
|
gutil/qwaitingdlg.cpp \
|
||||||
|
|
@ -188,6 +192,7 @@ HEADERS += \
|
||||||
base/locolorselector.h \
|
base/locolorselector.h \
|
||||||
base/loqtitlebar.h \
|
base/loqtitlebar.h \
|
||||||
base/loqtreewidget.h \
|
base/loqtreewidget.h \
|
||||||
|
device/badpointdetectdialog.h \
|
||||||
device/progressesdlg.h \
|
device/progressesdlg.h \
|
||||||
gutil/qcore.h \
|
gutil/qcore.h \
|
||||||
gutil/qwaitingdlg.h \
|
gutil/qwaitingdlg.h \
|
||||||
|
|
|
||||||
|
|
@ -466,8 +466,9 @@ QFont Format::font() const
|
||||||
{
|
{
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamily(fontName());
|
font.setFamily(fontName());
|
||||||
if (fontSize() > 0)
|
auto size = fontSize();
|
||||||
font.setPointSize(fontSize());
|
if(size==0) size = 11;
|
||||||
|
font.setPointSize(size);
|
||||||
font.setBold(fontBold());
|
font.setBold(fontBold());
|
||||||
font.setItalic(fontItalic());
|
font.setItalic(fontItalic());
|
||||||
font.setUnderline(fontUnderline() != FontUnderlineNone);
|
font.setUnderline(fontUnderline() != FontUnderlineNone);
|
||||||
|
|
|
||||||
BIN
LedOK/adb.exe
Normal file
|
|
@ -15,7 +15,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
||||||
#endif
|
#endif
|
||||||
auto vBox = new QVBoxLayout(this);
|
auto vBox = new QVBoxLayout(this);
|
||||||
auto hBox = new QHBoxLayout();
|
auto hBox = new QHBoxLayout();
|
||||||
auto label = new QLabel(tr("Old password"));
|
auto label = new QLabel(translate("","Old password"));
|
||||||
hBox->addWidget(label);
|
hBox->addWidget(label);
|
||||||
|
|
||||||
fdOld = new QLineEdit();
|
fdOld = new QLineEdit();
|
||||||
|
|
@ -25,7 +25,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
||||||
vBox->addLayout(hBox);
|
vBox->addLayout(hBox);
|
||||||
|
|
||||||
hBox = new QHBoxLayout();
|
hBox = new QHBoxLayout();
|
||||||
auto label_2 = new QLabel(tr("New password"));
|
auto label_2 = new QLabel(translate("","New password"));
|
||||||
hBox->addWidget(label_2);
|
hBox->addWidget(label_2);
|
||||||
|
|
||||||
fdNew = new QLineEdit();
|
fdNew = new QLineEdit();
|
||||||
|
|
@ -47,7 +47,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
||||||
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
connect(btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
||||||
QString pwdOld = fdOld->text();
|
auto pwdOld = fdOld->text();
|
||||||
if(pwdOld.isEmpty()) {
|
if(pwdOld.isEmpty()) {
|
||||||
QMessageBox::warning(this, translate("","Tip"), tr("Please input old password"));
|
QMessageBox::warning(this, translate("","Tip"), tr("Please input old password"));
|
||||||
fdOld->setFocus();
|
fdOld->setFocus();
|
||||||
|
|
@ -55,21 +55,21 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
||||||
}
|
}
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
auto pwdRaw = settings.value("advUiPs");
|
auto pwdRaw = settings.value("advUiPs");
|
||||||
QString pwd = pwdRaw.isNull() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toString().toLatin1()));
|
auto pwd = pwdRaw.isNull() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toString().toLatin1()));
|
||||||
if(pwd != pwdOld) {
|
if(pwd != pwdOld) {
|
||||||
QMessageBox::critical(this, translate("","Tip"), tr("Old password is wrong"));
|
QMessageBox::critical(this, translate("","Tip"), tr("Old password is wrong"));
|
||||||
fdOld->setFocus();
|
fdOld->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString pwdNew = fdNew->text();
|
auto pwdNew = fdNew->text();
|
||||||
if(pwdNew.length() < 3 && ! pwdNew.isEmpty()) {
|
if(pwdNew.length() < 3 && ! pwdNew.isEmpty()) {
|
||||||
QMessageBox::warning(this, translate("","Tip"), tr("Please enter a password with more than 3 characters"));
|
QMessageBox::warning(this, translate("","Tip"), tr("Please enter a password with more than 3 characters"));
|
||||||
fdNew->setFocus();
|
fdNew->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString pwdAgn = fdAgn->text();
|
auto pwdAgn = fdAgn->text();
|
||||||
if(pwdAgn != pwdNew) {
|
if(pwdAgn != pwdNew) {
|
||||||
QMessageBox::warning(this, translate("","Tip"), tr("The new password is not consistent in two times"));
|
QMessageBox::warning(this, translate("","Tip"), translate("","Two passwords are not same"));
|
||||||
fdAgn->setFocus();
|
fdAgn->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ LoColorSelector::LoColorSelector(const QString &text, const QColor &color, QWidg
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
void LoColorSelector::init() {
|
void LoColorSelector::init() {
|
||||||
connect(this, &QPushButton::clicked, this, [this]{
|
connect(this, &QPushButton::clicked, this, [=]{
|
||||||
QColorDialog colorDlg(this);
|
QColorDialog colorDlg(this);
|
||||||
colorDlg.setOption(QColorDialog::ShowAlphaChannel);
|
colorDlg.setOption(QColorDialog::ShowAlphaChannel);
|
||||||
colorDlg.setOption(QColorDialog::DontUseNativeDialog);
|
colorDlg.setOption(QColorDialog::DontUseNativeDialog);
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
class LoColorSelector : public QPushButton {
|
class LoColorSelector : public QPushButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LoColorSelector(QWidget *parent = nullptr);
|
explicit LoColorSelector(QWidget *parent = 0);
|
||||||
explicit LoColorSelector(const QString &text, const QColor &color = Qt::transparent, QWidget *parent = nullptr);
|
explicit LoColorSelector(const QString &text, const QColor &color = Qt::transparent, QWidget *parent = 0);
|
||||||
void init();
|
void init();
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
|
||||||
|
|
|
||||||
BIN
LedOK/borders/Frame 6.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
LedOK/borders/Ma_5.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
LedOK/borders/frame 0.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
LedOK/borders/frame 1.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
LedOK/borders/frame 2.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
LedOK/borders/frame 3.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
LedOK/borders/frame 4.png
Normal file
|
After Width: | Height: | Size: 528 B |
|
|
@ -74,8 +74,6 @@ LoColorSelector {
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
padding: 3px 6px;
|
|
||||||
max-height: 30px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
310
LedOK/device/badpointdetectdialog.cpp
Normal file
|
|
@ -0,0 +1,310 @@
|
||||||
|
#include "badpointdetectdialog.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "gutil/qgui.h"
|
||||||
|
#include "gutil/qnetwork.h"
|
||||||
|
#include "gutil/qwaitingdlg.h"
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QHttpMultiPart>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
BadPointDetectDialog::BadPointDetectDialog(QWidget *parent) : QDialog(parent) {
|
||||||
|
resize(1280, 720);
|
||||||
|
setWindowFlag(Qt::WindowMaximizeButtonHint);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Bad Point Detection"));
|
||||||
|
|
||||||
|
auto vBox = new VBox(this);
|
||||||
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
|
auto tab = new QTabWidget;
|
||||||
|
vBox->addWidget(tab);
|
||||||
|
|
||||||
|
auto badPointPanel = new QWidget;
|
||||||
|
tab->addTab(badPointPanel, tr("Bad Point Detection"));
|
||||||
|
|
||||||
|
vBox = new VBox(badPointPanel);
|
||||||
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel(tr("Port"));
|
||||||
|
|
||||||
|
auto bnPort1 = new QRadioButton(tr("Port")+"1");
|
||||||
|
bnPort1->setChecked(true);
|
||||||
|
auto bnPort2 = new QRadioButton(tr("Port")+"2");
|
||||||
|
hBox->addWidget(bnPort1);
|
||||||
|
hBox->addWidget(bnPort2);
|
||||||
|
|
||||||
|
auto bnDetect = new QPushButton(tr("Detect"));
|
||||||
|
hBox->addWidget(bnDetect);
|
||||||
|
hBox->addSpacing(20);
|
||||||
|
|
||||||
|
auto bnUpload = new QPushButton(tr("Upload Point Table"));
|
||||||
|
hBox->addWidget(bnUpload);
|
||||||
|
|
||||||
|
auto bnCheck = new QPushButton(tr("Check If Has"));
|
||||||
|
hBox->addWidget(bnCheck);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
auto lbInfo = vBox->addLabel();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
auto edCoordinates = new QTextEdit;
|
||||||
|
edCoordinates->setReadOnly(true);
|
||||||
|
edCoordinates->setMaximumWidth(200);
|
||||||
|
hBox->addWidget(edCoordinates);
|
||||||
|
|
||||||
|
auto table = new TableWidget;
|
||||||
|
table->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
table->setColWidth(20)->setRowHeight(20);
|
||||||
|
table->setShowGrid(true);
|
||||||
|
hBox->addWidget(table);
|
||||||
|
|
||||||
|
connect(bnDetect, &QPushButton::clicked, this, [=] {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "IsHaveTable");
|
||||||
|
json.insert("_type", "IsHaveTable");
|
||||||
|
json.insert("port", bnPort2->isChecked() ? 1 : 0);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Detect")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
{
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
if(! json["isHave"].toBool()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, translate("","Error"), "It hasn't a Point Table, please upload one");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetBoxSize");
|
||||||
|
json.insert("_type", "GetBoxSize");
|
||||||
|
json.insert("port", bnPort2->isChecked() ? 1 : 0);
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
auto width = json["width"].toInt();
|
||||||
|
auto height = json["height"].toInt();
|
||||||
|
table->clear();
|
||||||
|
table->setColumnCount(width);
|
||||||
|
table->setRowCount(height);
|
||||||
|
edCoordinates->setPlainText(tr("Coordinates")+":");
|
||||||
|
lbInfo->clear();
|
||||||
|
if(width==0 || height==0) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, translate("","Error"), "width==0 or height==0");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "StartPointCheck");
|
||||||
|
json.insert("_type", "StartPointCheck");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetSpotCheckData");
|
||||||
|
json.insert("_type", "GetSpotCheckData");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->success();
|
||||||
|
auto pointCheckData = json["pointCheckData"];
|
||||||
|
int rgbCnt = 0, rCnt = 0, gCnt = 0, bCnt = 0;
|
||||||
|
for(auto &line : pointCheckData) {
|
||||||
|
auto str = line.toStr();
|
||||||
|
auto coors = str.split("-", Qt::SkipEmptyParts);
|
||||||
|
if(coors.size()<2) continue;
|
||||||
|
auto bad = new BadPointWgt;
|
||||||
|
if(coors.size()==2) {
|
||||||
|
rgbCnt++;
|
||||||
|
bad->rgb = true;
|
||||||
|
} else {
|
||||||
|
if(str.contains("R")) {rCnt++;bad->r = true;}
|
||||||
|
if(str.contains("G")) {gCnt++;bad->g = true;}
|
||||||
|
if(str.contains("B")) {bCnt++;bad->b = true;}
|
||||||
|
}
|
||||||
|
table->setCellWidget(coors[1].toInt(), coors[0].toInt(), bad);
|
||||||
|
edCoordinates->append(str);
|
||||||
|
}
|
||||||
|
lbInfo->setText(tr("Size")+": "+QString::number(width)+" x "+QString::number(height)+" "+tr("Bad Point")+" "+tr("Total")+": "+QString::number(rgbCnt+rCnt+gCnt+bCnt)+" RGB: "+QString::number(rgbCnt)+" R: "+QString::number(rCnt)+" G: "+QString::number(gCnt)+" B: "+QString::number(bCnt));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(bnUpload, &QPushButton::clicked, this, [=] {
|
||||||
|
auto file = QFileDialog::getOpenFileName(this, "Open file", gApkHome, tr("Point Table")+" (*.xml)");
|
||||||
|
if(file.isEmpty()) return;
|
||||||
|
QFileInfo info(file);
|
||||||
|
gApkHome = info.absolutePath();
|
||||||
|
QFile qfile(file);
|
||||||
|
if(! qfile.exists()) return;
|
||||||
|
if(! qfile.open(QIODevice::ReadOnly)) return;
|
||||||
|
auto fileData = qfile.readAll();
|
||||||
|
qfile.close();
|
||||||
|
if(fileData.size() != qfile.size()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), tr("Failed to Read File"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto nameBytes = file.toUtf8();
|
||||||
|
auto Boundary = "----QtLedOK_.oOo._"+QUuid::createUuid().toByteArray(QUuid::WithoutBraces);
|
||||||
|
QByteArray data;
|
||||||
|
data.append("--").append(Boundary).append("\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\n10005\r\n");
|
||||||
|
data.append("--").append(Boundary).append("\r\nContent-Disposition: form-data; name=\"").append(nameBytes).append("\"; filename=\"").append(nameBytes).append("\"\r\n\r\n").append(fileData).append("\r\n");
|
||||||
|
data.append("--").append(Boundary).append("--\r\n");
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Uploading"));
|
||||||
|
waitingDlg->show();
|
||||||
|
auto card = gSelCards[0];
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/upload?type=badPoint_upload").type("multipart/form-data; boundary="+Boundary).post(data);
|
||||||
|
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
auto err = errStrWithData(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
waitingDlg->close();
|
||||||
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
waitingDlg->success();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
connect(bnCheck, &QPushButton::clicked, this, [=] {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "IsHaveTable");
|
||||||
|
json.insert("_type", "IsHaveTable");
|
||||||
|
json.insert("port", bnPort2->isChecked() ? 1 : 0);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Check")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->close();
|
||||||
|
if(json["isHave"].toBool()) QMessageBox::information(this, translate("","Info"), "Yes, it has");
|
||||||
|
else QMessageBox::critical(this, translate("","Info"), "No, it hasn't");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
auto sensorsPanel = new QWidget;
|
||||||
|
tab->addTab(sensorsPanel, tr("Sensors"));
|
||||||
|
|
||||||
|
vBox = new VBox(sensorsPanel);
|
||||||
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
|
auto bnRelayOn = new QPushButton(tr("Relay On"));
|
||||||
|
hBox->addWidget(bnRelayOn);
|
||||||
|
auto bnRelayOff = new QPushButton(tr("Relay Off"));
|
||||||
|
hBox->addWidget(bnRelayOff);
|
||||||
|
connect(bnRelayOn, &QPushButton::clicked, this, [=] {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "ControllerRecCardRelaySwitch");
|
||||||
|
json.insert("_type", "ControllerRecCardRelaySwitch");
|
||||||
|
json.insert("isSwitch", true);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Get")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
});
|
||||||
|
connect(bnRelayOff, &QPushButton::clicked, this, [=] {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "ControllerRecCardRelaySwitch");
|
||||||
|
json.insert("_type", "ControllerRecCardRelaySwitch");
|
||||||
|
json.insert("isSwitch", false);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Get")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
auto bnSensorDataGet = new QPushButton(tr("Get Sensor Data"));
|
||||||
|
hBox->addWidget(bnSensorDataGet);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
auto edInfo = new QTextEdit;
|
||||||
|
vBox->addWidget(edInfo);
|
||||||
|
vBox->addStretch();
|
||||||
|
|
||||||
|
connect(bnSensorDataGet, &QPushButton::clicked, this, [=] {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetRecCardInfo");
|
||||||
|
json.insert("_type", "GetRecCardInfo");
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Get Rece Card Info")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->success();
|
||||||
|
edInfo->clear();
|
||||||
|
edInfo->append(tr("Temperature")+": "+json["temperature"].toDouble());
|
||||||
|
edInfo->append(tr("Humidity")+": "+json["humidity"].toDouble());
|
||||||
|
edInfo->append(tr("Voltage")+": "+json["voltage"].toDouble());
|
||||||
|
edInfo->append(tr("Light")+": "+json["light"].toInt());
|
||||||
|
edInfo->append(tr("Has Smoke")+": "+json["isSmoke"].toBool());
|
||||||
|
edInfo->append(tr("Power")+" 1: "+json["power1"].toBool());
|
||||||
|
edInfo->append(tr("Power")+" 2: "+json["power2"].toBool());
|
||||||
|
edInfo->append(tr("Power")+" 3: "+json["power3"].toBool());
|
||||||
|
edInfo->append(tr("Power")+" 4: "+json["power4"].toBool());
|
||||||
|
edInfo->append(tr("Power")+" 5: "+json["power5"].toBool());
|
||||||
|
edInfo->append(tr("Door Open")+" 5: "+json["isOpen"].toBool());
|
||||||
|
edInfo->append(tr("Relay On")+" 5: "+json["relaySwitch"].toBool());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
setModal(true);
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BadPointDetectDialog::keyPressEvent(QKeyEvent *event) {
|
||||||
|
if(event->key() == Qt::Key_F3) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#define Distance 6
|
||||||
|
void BadPointWgt::paintEvent(QPaintEvent *) {
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.translate(10, 9);
|
||||||
|
QPen pen;
|
||||||
|
pen.setCapStyle(Qt::RoundCap);
|
||||||
|
if(rgb) {
|
||||||
|
pen.setWidth(18);
|
||||||
|
pen.setColor(Qt::black);
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawPoint(0, 0);
|
||||||
|
} else {
|
||||||
|
pen.setWidth(9);
|
||||||
|
if(r) {
|
||||||
|
pen.setColor(Qt::red);
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawPoint(QPointF(-sin(60*3.14159265/180)*Distance, -sin(30*3.14159265/180)*Distance));
|
||||||
|
}
|
||||||
|
if(g) {
|
||||||
|
pen.setColor(QColor(0x00cc00));
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawPoint(QPointF(sin(60*3.14159265/180)*Distance, -sin(30*3.14159265/180)*Distance));
|
||||||
|
}
|
||||||
|
if(b) {
|
||||||
|
pen.setColor(Qt::blue);
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawPoint(0, Distance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
LedOK/device/badpointdetectdialog.h
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef BADPOINTDET_H
|
||||||
|
#define BADPOINTDET_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class BadPointWgt : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BadPointWgt(QWidget *parent = 0) : QWidget(parent){}
|
||||||
|
|
||||||
|
bool rgb = false, r=false, g=false, b=false;
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *ev) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BadPointDetectDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit BadPointDetectDialog(QWidget *parent = 0);
|
||||||
|
protected:
|
||||||
|
virtual void keyPressEvent(QKeyEvent *ev);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BADPOINTDET_H
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include <QDateEdit>
|
||||||
|
|
||||||
CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
@ -1299,6 +1300,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
grpG12 = new QGroupBox;
|
grpG12 = new QGroupBox;
|
||||||
{
|
{
|
||||||
auto hBox = new HBox(grpG12);
|
auto hBox = new HBox(grpG12);
|
||||||
|
hBox->setSpacing(2);
|
||||||
|
|
||||||
auto edG12Reso = new QComboBox;
|
auto edG12Reso = new QComboBox;
|
||||||
edG12Reso->setMinimumWidth(160);
|
edG12Reso->setMinimumWidth(160);
|
||||||
|
|
@ -1316,18 +1318,46 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
edG12Reso->addItem("1280x720P50", "1280x720@50.00-1720-1760-1980-725-730-750-5-74250");
|
edG12Reso->addItem("1280x720P50", "1280x720@50.00-1720-1760-1980-725-730-750-5-74250");
|
||||||
edG12Reso->addItem("720x576P50", "720x576@50.00-732-796-864-581-586-625-a-27000");
|
edG12Reso->addItem("720x576P50", "720x576@50.00-732-796-864-581-586-625-a-27000");
|
||||||
edG12Reso->addItem("720x480P60", "720x480@59.94-736-798-858-489-495-525-a-27000");
|
edG12Reso->addItem("720x480P60", "720x480@59.94-736-798-858-489-495-525-a-27000");
|
||||||
|
edG12Reso->addItem("Custom", "Custom");
|
||||||
hBox->addWidget(edG12Reso);
|
hBox->addWidget(edG12Reso);
|
||||||
|
|
||||||
|
auto cosWidth = new QLineEdit;
|
||||||
|
cosWidth->setMaximumWidth(40);
|
||||||
|
hBox->addWidget(cosWidth);
|
||||||
|
auto cuslb1 = hBox->addLabel("x");
|
||||||
|
auto cosHeight = new QLineEdit;
|
||||||
|
cosHeight->setMaximumWidth(40);
|
||||||
|
hBox->addWidget(cosHeight);
|
||||||
|
auto cuslb2 = hBox->addLabel("FPS");
|
||||||
|
auto cosFPS = new QLineEdit;
|
||||||
|
cosFPS->setMaximumWidth(30);
|
||||||
|
hBox->addWidget(cosFPS);
|
||||||
|
hBox->addSpacing(2);
|
||||||
|
|
||||||
|
connect(edG12Reso, &QComboBox::currentTextChanged, this, [=](const QString &text) {
|
||||||
|
auto isShow = text=="Custom";
|
||||||
|
cosWidth->setVisible(isShow);
|
||||||
|
cosHeight->setVisible(isShow);
|
||||||
|
cosFPS->setVisible(isShow);
|
||||||
|
cuslb1->setVisible(isShow);
|
||||||
|
cuslb2->setVisible(isShow);
|
||||||
|
});
|
||||||
|
emit edG12Reso->currentTextChanged("");
|
||||||
|
|
||||||
btnSets.push_back(btn = new QPushButton);
|
btnSets.push_back(btn = new QPushButton);
|
||||||
connect(btn, &QPushButton::clicked, this, [=] {
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto screenSize = edG12Reso->currentData().toString();
|
||||||
|
if(screenSize=="Custom") {
|
||||||
JObj json;
|
JObj json;
|
||||||
json.insert("_id", "SetScreenSizeTo3568");
|
json.insert("_id", "CustomHdmiResolution");
|
||||||
json.insert("_type", "SetScreenSizeTo3568");
|
json.insert("_type", "CustomHdmiResolution");
|
||||||
json.insert("screenSize", edG12Reso->currentData().toString());
|
json.insert("width", cosWidth->text().toInt());
|
||||||
|
json.insert("height", cosHeight->text().toInt());
|
||||||
|
json.insert("frame", cosFPS->text().toDouble());
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, translate("","Setting ")+translate("","Screen Size")+" 3568 ...");
|
auto waitingDlg = new WaitingDlg(this, translate("","Setting ")+translate("","Screen Size")+" 3568 ...");
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
|
|
@ -1339,6 +1369,23 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
Def_CtrlSetMulti(translate("","Set ")+translate("","Screen Size")+" 3568")
|
Def_CtrlSetMulti(translate("","Set ")+translate("","Screen Size")+" 3568")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetScreenSizeTo3568");
|
||||||
|
json.insert("_type", "SetScreenSizeTo3568");
|
||||||
|
json.insert("screenSize", screenSize);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, translate("","Setting ")+translate("","Screen Size")+" 3568 ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
Def_CtrlSetMulti(translate("","Set ")+translate("","Screen Size")+" 3568")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btn);
|
hBox->addWidget(btn);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
@ -2461,6 +2508,150 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
line->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
line->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||||
vBox->addWidget(line);
|
vBox->addWidget(line);
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel("Launch Launcher:");
|
||||||
|
auto edLauLauYes = new QRadioButton("ON");
|
||||||
|
auto edLauLauNo = new QRadioButton("OFF");
|
||||||
|
hBox->addWidget(edLauLauYes);
|
||||||
|
hBox->addWidget(edLauLauNo);
|
||||||
|
btnSets.push_back(btn = new QPushButton);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(! edLauLauYes->isChecked() && ! edLauLauNo->isChecked()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select a value"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetLauncherStartState");
|
||||||
|
json.insert("_type", "SetLauncherStartState");
|
||||||
|
json.insert("isStart", edLauLauYes->isChecked());
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("SetLauncherStartState"));
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
Def_CtrlSetMulti(tr("SetLauncherStartState"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btn);
|
||||||
|
|
||||||
|
btnGets.push_back(btn = new QPushButton);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetLauncherStartState");
|
||||||
|
json.insert("_type", "GetLauncherStartState");
|
||||||
|
edLauLauYes->setChecked(false);
|
||||||
|
edLauLauNo->setChecked(false);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("GetLauncherStartState")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->success();
|
||||||
|
(json["isStart"].toBool() ? edLauLauYes : edLauLauNo)->setChecked(true);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
if(err.isEmpty()) {
|
||||||
|
err = (json["isStart"].toBool() ? edLauLauYes : edLauLauNo)->text();
|
||||||
|
}
|
||||||
|
gFdResInfo->append(card.id+" "+tr("GetLauncherStartState")+" "+err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btn);
|
||||||
|
hBox->addSpacing(20);
|
||||||
|
|
||||||
|
|
||||||
|
hBox->addLabel("Bypass Mode:");
|
||||||
|
auto edBypassYes = new QRadioButton("ON");
|
||||||
|
auto edBypassNo = new QRadioButton("OFF");
|
||||||
|
hBox->addWidget(edBypassYes);
|
||||||
|
hBox->addWidget(edBypassNo);
|
||||||
|
auto btnGrpBypass = new QButtonGroup(hBox);
|
||||||
|
btnGrpBypass->addButton(edBypassYes, 0);
|
||||||
|
btnGrpBypass->addButton(edBypassNo, 1);
|
||||||
|
btnSets.push_back(btn = new QPushButton);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(! edBypassYes->isChecked() && ! edBypassNo->isChecked()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select a value"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetByPassModel");
|
||||||
|
json.insert("_type", "SetByPassModel");
|
||||||
|
json.insert("model", edBypassYes->isChecked() ? 1 : 0);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Set Bypass Mode"));
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
Def_CtrlSetMulti(tr("Set Bypass Mode"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btn);
|
||||||
|
|
||||||
|
btnGets.push_back(btn = new QPushButton);
|
||||||
|
connect(btn, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetByPassModel");
|
||||||
|
json.insert("_type", "GetByPassModel");
|
||||||
|
edBypassYes->setChecked(false);
|
||||||
|
edBypassNo->setChecked(false);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Get Bypass Mode")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->success();
|
||||||
|
(json["isStart"].toBool() ? edBypassYes : edBypassNo)->setChecked(true);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
if(err.isEmpty()) {
|
||||||
|
err = (json["model"].toInt()==1 ? edBypassYes : edBypassNo)->text();
|
||||||
|
}
|
||||||
|
gFdResInfo->append(card.id+" "+tr("Get Bypass Mode")+" "+err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(btn);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
grpM80 = new QGroupBox;
|
grpM80 = new QGroupBox;
|
||||||
{
|
{
|
||||||
|
|
@ -2490,7 +2681,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "SetSpecialResolution");
|
json.insert("_id", "SetSpecialResolution");
|
||||||
json.insert("_type", "SetSpecialResolution");
|
json.insert("_type", "SetSpecialResolution");
|
||||||
json.insert("displayResolution", fdM80Resolu->currentText()); //显示分辨率
|
json.insert("displayResolution", fdM80Resolu->currentText()); //显示分辨率
|
||||||
|
|
@ -2516,7 +2707,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetSpecialResolution");
|
json.insert("_id", "GetSpecialResolution");
|
||||||
json.insert("_type", "GetSpecialResolution");
|
json.insert("_type", "GetSpecialResolution");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
|
@ -2532,8 +2723,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||||
QJsonDocument json;
|
JValue json;
|
||||||
QString err = checkReplyForJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = tr("totalResolution")+"["+json["totalResolution"].toString()+"], "+tr("strCurDisplayResolution")+"["+json["displayResolution"].toString()+"]";
|
if(err.isEmpty()) err = tr("totalResolution")+"["+json["totalResolution"].toString()+"], "+tr("strCurDisplayResolution")+"["+json["displayResolution"].toString()+"]";
|
||||||
gFdResInfo->append(cardId+" "+tr("GetSpecialResolution")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("GetSpecialResolution")+" "+err);
|
||||||
});
|
});
|
||||||
|
|
@ -2549,7 +2740,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "CleanDisplayScreenSize");
|
json.insert("_id", "CleanDisplayScreenSize");
|
||||||
json.insert("_type", "CleanDisplayScreenSize");
|
json.insert("_type", "CleanDisplayScreenSize");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
|
@ -2885,30 +3076,75 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addLabel("ADB");
|
||||||
|
auto bnADBOpen = new QPushButton("Open");
|
||||||
|
auto bnADBClose = new QPushButton("Close");
|
||||||
|
hBox->addWidget(bnADBOpen);
|
||||||
|
hBox->addWidget(bnADBClose);
|
||||||
|
|
||||||
fdIsOpenADB = new QCheckBox;
|
connect(bnADBOpen, &QPushButton::clicked, this, [=] {
|
||||||
connect(fdIsOpenADB, &QCheckBox::toggled, this, [this](bool checked) {
|
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "OpenAdb");
|
json.insert("_id", "OpenAdb");
|
||||||
json.insert("_type", "OpenAdb");
|
json.insert("_type", "OpenAdb");
|
||||||
json.insert("open", checked);
|
json.insert("open", true);
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("OpenAdb")+" ...");
|
auto waitingDlg = new WaitingDlg(this, "Opening ADB ...");
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
Def_CtrlSetMulti(tr("OpenAdb"))
|
Def_CtrlSetMulti("Open ADB")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vBox->addWidget(fdIsOpenADB);
|
connect(bnADBClose, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "OpenAdb");
|
||||||
|
json.insert("_type", "OpenAdb");
|
||||||
|
json.insert("open", false);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, "Closing ADB ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
Def_CtrlSetMulti("Close ADB")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
auto bnConnect = new QPushButton("Connect");
|
||||||
|
auto bnDisconnect = new QPushButton("Disconnect");
|
||||||
|
hBox->addWidget(bnConnect);
|
||||||
|
hBox->addWidget(bnDisconnect);
|
||||||
|
connect(bnConnect, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OpenCMD({"/K", "adb", "connect", gSelCards[0].ip});
|
||||||
|
});
|
||||||
|
connect(bnDisconnect, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OpenCMD({"/K", "adb", "disconnect", gSelCards[0].ip});
|
||||||
|
});
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
|
|
||||||
|
|
@ -3193,9 +3429,12 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||||
|
|
||||||
for(auto btn : btnSets) btn->setProperty("ssType", "progManageTool");
|
for(auto btn : btnSets) btn->setProperty("ssType", "progManageTool");
|
||||||
for(auto btn : btnGets) btn->setProperty("ssType", "progManageTool");
|
for(auto btn : btnGets) btn->setProperty("ssType", "progManageTool");
|
||||||
|
#ifdef leyide
|
||||||
|
isPassed = true;
|
||||||
|
#else
|
||||||
if(QSettings().value("advUiPs", "888").toString().isEmpty()) isPassed = true;
|
if(QSettings().value("advUiPs", "888").toString().isEmpty()) isPassed = true;
|
||||||
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
|
#endif
|
||||||
|
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [=] {
|
||||||
if(isVisible()) init();
|
if(isVisible()) init();
|
||||||
});
|
});
|
||||||
transUi();
|
transUi();
|
||||||
|
|
@ -3364,7 +3603,6 @@ void CtrlAdvancedPanel::transUi() {
|
||||||
lbBaudModel->setText(tr("Model"));
|
lbBaudModel->setText(tr("Model"));
|
||||||
lbUart->setText(tr("Uart"));
|
lbUart->setText(tr("Uart"));
|
||||||
lbBaud->setText(tr("Baud"));
|
lbBaud->setText(tr("Baud"));
|
||||||
fdIsOpenADB->setText(tr("Open ADB"));
|
|
||||||
btnSendCustomJson->setText(translate("","Send"));
|
btnSendCustomJson->setText(translate("","Send"));
|
||||||
btnCustomJsonGet->setText(translate("","Get"));
|
btnCustomJsonGet->setText(translate("","Get"));
|
||||||
|
|
||||||
|
|
@ -3381,7 +3619,7 @@ void CtrlAdvancedPanel::transUi() {
|
||||||
lbScreenWidth->setText(tr("Screen Width(pixel)"));
|
lbScreenWidth->setText(tr("Screen Width(pixel)"));
|
||||||
fdCompanyId->setPlaceholderText(tr("Compant ID"));
|
fdCompanyId->setPlaceholderText(tr("Compant ID"));
|
||||||
|
|
||||||
btnWareUpdate->setText(tr("Firmware Management"));
|
btnWareUpdate->setText(tr("Firmware Manager"));
|
||||||
lbWareTip->setText("(APK / FPGA "+tr("update or uninstall")+")");
|
lbWareTip->setText("(APK / FPGA "+tr("update or uninstall")+")");
|
||||||
btnApkCheck->setText(tr("Check Apk"));
|
btnApkCheck->setText(tr("Check Apk"));
|
||||||
btnGetLog->setText(tr("Check Log"));
|
btnGetLog->setText(tr("Check Log"));
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ private:
|
||||||
QGroupBox *grpBoxHiddenSettings;
|
QGroupBox *grpBoxHiddenSettings;
|
||||||
QPushButton *btnSysUpd, *btnMcuUpd, *btnMcuGet;
|
QPushButton *btnSysUpd, *btnMcuUpd, *btnMcuGet;
|
||||||
QLabel *lbRotate, *lbChargingStation, *lbBaudCfg, *lbBaudModel, *lbUart, *lbBaud;
|
QLabel *lbRotate, *lbChargingStation, *lbBaudCfg, *lbBaudModel, *lbUart, *lbBaud;
|
||||||
QCheckBox *fdIsOpenADB;
|
|
||||||
QLabel *lbCustomJson;
|
QLabel *lbCustomJson;
|
||||||
QTextEdit *fdCustomJson;
|
QTextEdit *fdCustomJson;
|
||||||
QPushButton *btnSendCustomJson, *btnCustomJsonGet;
|
QPushButton *btnSendCustomJson, *btnCustomJsonGet;
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
fdBrightTip->setWordWrap(true);
|
fdBrightTip->setWordWrap(true);
|
||||||
vBox->addWidget(fdBrightTip);
|
vBox->addWidget(fdBrightTip);
|
||||||
|
|
||||||
auto hBox = new QHBoxLayout;
|
auto hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
lbSensi = new QLabel;
|
lbSensi = new QLabel;
|
||||||
|
|
@ -82,15 +82,15 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
});
|
});
|
||||||
hBox->addWidget(lbSensiValue);
|
hBox->addWidget(lbSensiValue);
|
||||||
|
|
||||||
btnSensiSet = new QPushButton;
|
auto bn = new QPushButton;
|
||||||
btnSensiSet->setMinimumSize(60, 30);
|
btnSets.push_back(bn);
|
||||||
btnSensiSet->setProperty("ssType", "progManageTool");
|
bn->setMinimumSize(60, 30);
|
||||||
connect(btnSensiSet, &QPushButton::clicked, this, [this] {
|
connect(bn, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "SetBrightnessSensitivity");
|
json.insert("_id", "SetBrightnessSensitivity");
|
||||||
json.insert("_type", "SetBrightnessSensitivity");
|
json.insert("_type", "SetBrightnessSensitivity");
|
||||||
json.insert("sensitivity", fdSensi->value());
|
json.insert("sensitivity", fdSensi->value());
|
||||||
|
|
@ -106,17 +106,16 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnSensiSet);
|
hBox->addWidget(bn);
|
||||||
|
|
||||||
btnSensiGet = new QPushButton;
|
btnGets.push_back(bn = new QPushButton);
|
||||||
btnSensiGet->setMinimumSize(60, 30);
|
bn->setMinimumSize(60, 30);
|
||||||
btnSensiGet->setProperty("ssType", "progManageTool");
|
connect(bn, &QPushButton::clicked, this, [this] {
|
||||||
connect(btnSensiGet, &QPushButton::clicked, this, [this] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetBrightnessSensitivity");
|
json.insert("_id", "GetBrightnessSensitivity");
|
||||||
json.insert("_type", "GetBrightnessSensitivity");
|
json.insert("_type", "GetBrightnessSensitivity");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
|
@ -129,9 +128,9 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
|
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
|
||||||
|
|
@ -140,44 +139,40 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnSensiGet);
|
hBox->addWidget(bn);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
lbMinBright = new QLabel;
|
lbMinBright = hBox->addLabel();
|
||||||
lbMinBright->setMinimumWidth(120);
|
lbMinBright->setMinimumWidth(120);
|
||||||
lbMinBright->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
lbMinBright->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
hBox->addWidget(lbMinBright);
|
|
||||||
|
|
||||||
fdMinBright = new QSlider(Qt::Horizontal);
|
edMinBright = new QSlider(Qt::Horizontal);
|
||||||
fdMinBright->setRange(1, 100);
|
edMinBright->setRange(1, 100);
|
||||||
hBox->addWidget(fdMinBright);
|
hBox->addWidget(edMinBright);
|
||||||
|
|
||||||
auto lbMinBrightValue = new QLabel(QString::number(fdMinBright->value())+"%");
|
auto lbMinBrightValue = hBox->addLabel(QString::number(edMinBright->value())+"%");
|
||||||
lbMinBrightValue->setMinimumWidth(40);
|
lbMinBrightValue->setMinimumWidth(40);
|
||||||
lbMinBrightValue->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
lbMinBrightValue->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
connect(fdMinBright, &QSlider::valueChanged, lbSensiValue, [lbMinBrightValue](int value) {
|
connect(edMinBright, &QSlider::valueChanged, lbSensiValue, [lbMinBrightValue](int value) {
|
||||||
lbMinBrightValue->setText(QString::number(value)+"%");
|
lbMinBrightValue->setText(QString::number(value)+"%");
|
||||||
});
|
});
|
||||||
hBox->addWidget(lbMinBrightValue);
|
|
||||||
|
|
||||||
btnMinBrightSet = new QPushButton;
|
btnSets.push_back(bn = new QPushButton);
|
||||||
btnMinBrightSet->setMinimumSize(60, 30);
|
bn->setMinimumSize(60, 30);
|
||||||
btnMinBrightSet->setProperty("ssType", "progManageTool");
|
connect(bn, &QPushButton::clicked, this, [=] {
|
||||||
connect(btnMinBrightSet, &QPushButton::clicked, this, [this] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "SetMinBrightness");
|
json.insert("_id", "SetMinBrightness");
|
||||||
json.insert("_type", "SetMinBrightness");
|
json.insert("_type", "SetMinBrightness");
|
||||||
auto brightPercent = fdMinBright->value();
|
auto brightPercent = edMinBright->value();
|
||||||
if(! isAdaptToOld) json.insert("minBrightnessPercentage", brightPercent);
|
if(! isAdaptToOld) json.insert("minBrightnessPercentage", brightPercent);
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
if(isAdaptToOld) json.insert("brightness", (brightPercent * gSelCards[0].BrightnessLevel + 50) / 100);
|
if(isAdaptToOld) json.insert("brightness", (brightPercent * gSelCards[0].BrightnessLevel + 50) / 100);
|
||||||
|
|
@ -193,17 +188,16 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnMinBrightSet);
|
hBox->addWidget(bn);
|
||||||
|
|
||||||
btnMinBrightGet = new QPushButton;
|
btnGets.push_back(bn = new QPushButton);
|
||||||
btnMinBrightGet->setMinimumSize(60, 30);
|
bn->setMinimumSize(60, 30);
|
||||||
btnMinBrightGet->setProperty("ssType", "progManageTool");
|
connect(bn, &QPushButton::clicked, this, [=] {
|
||||||
connect(btnMinBrightGet, &QPushButton::clicked, this, [this] {
|
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetMinBrightness");
|
json.insert("_id", "GetMinBrightness");
|
||||||
json.insert("_type", "GetMinBrightness");
|
json.insert("_type", "GetMinBrightness");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
|
@ -215,11 +209,11 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
auto value = json["minBrightnessPercentage"].toInt(-1);
|
auto value = json["minBrightnessPercentage"].toInt(-1);
|
||||||
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
||||||
fdMinBright->setValue(value);
|
edMinBright->setValue(value);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
auto brightLevel = card.BrightnessLevel;
|
auto brightLevel = card.BrightnessLevel;
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
|
@ -235,10 +229,99 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnMinBrightGet);
|
hBox->addWidget(bn);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
lbMaxBright = hBox->addLabel();
|
||||||
|
lbMaxBright->setMinimumWidth(120);
|
||||||
|
lbMaxBright->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
edMaxBright = new QSlider(Qt::Horizontal);
|
||||||
|
edMaxBright->setRange(1, 100);
|
||||||
|
hBox->addWidget(edMaxBright);
|
||||||
|
|
||||||
|
auto lbMaxBrightValue = hBox->addLabel(QString::number(edMaxBright->value())+"%");
|
||||||
|
lbMaxBrightValue->setMinimumWidth(40);
|
||||||
|
lbMaxBrightValue->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
connect(edMaxBright, &QSlider::valueChanged, lbSensiValue, [=](int value) {
|
||||||
|
lbMaxBrightValue->setText(QString::number(value)+"%");
|
||||||
|
});
|
||||||
|
|
||||||
|
btnSets.push_back(bn = new QPushButton);
|
||||||
|
bn->setMinimumSize(60, 30);
|
||||||
|
connect(bn, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto isAdaptToOld = fdAdaptToOld->isChecked();
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "SetMaxBrightness");
|
||||||
|
json.insert("_type", "SetMaxBrightness");
|
||||||
|
auto brightPercent = edMaxBright->value();
|
||||||
|
if(! isAdaptToOld) json.insert("maxBrightnessPercentage", brightPercent);
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
if(isAdaptToOld) json.insert("brightness", (brightPercent * gSelCards[0].BrightnessLevel + 50) / 100);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("SetMaxBrightness")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSetReqAfter
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
if(isAdaptToOld) json.insert("brightness", (brightPercent * card.BrightnessLevel + 50) / 100);
|
||||||
|
Def_CtrlSetMulti(tr("SetMaxBrightness"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(bn);
|
||||||
|
|
||||||
|
btnGets.push_back(bn = new QPushButton);
|
||||||
|
bn->setMinimumSize(60, 30);
|
||||||
|
connect(bn, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetMaxBrightness");
|
||||||
|
json.insert("_type", "GetMaxBrightness");
|
||||||
|
if(gSelCards.count() == 1) {
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("GetMaxBrightness")+" ...");
|
||||||
|
Def_CtrlReqPre
|
||||||
|
auto brightLevel = card.BrightnessLevel;
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
Def_CtrlSingleGetReply
|
||||||
|
waitingDlg->success();
|
||||||
|
auto value = json["maxBrightnessPercentage"].toInt(-1);
|
||||||
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
||||||
|
edMaxBright->setValue(value);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
for(auto &card : gSelCards) {
|
||||||
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
|
auto cardId = card.id;
|
||||||
|
auto brightLevel = card.BrightnessLevel;
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
if(err.isEmpty()) {
|
||||||
|
auto value = json["maxBrightnessPercentage"].toInt(-1);
|
||||||
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
||||||
|
err = QString::number(value)+"%";
|
||||||
|
}
|
||||||
|
gFdResInfo->append(cardId+" "+tr("GetMaxBrightness")+" "+err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hBox->addWidget(bn);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
|
|
||||||
line = new QFrame;
|
line = new QFrame;
|
||||||
|
|
@ -251,7 +334,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
fdSensiTypeTip->setWordWrap(true);
|
fdSensiTypeTip->setWordWrap(true);
|
||||||
vBox->addWidget(fdSensiTypeTip);
|
vBox->addWidget(fdSensiTypeTip);
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
fdR68 = new QRadioButton("R68/RL3");
|
fdR68 = new QRadioButton("R68/RL3");
|
||||||
|
|
@ -303,9 +386,10 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
auto rr = fdRL2->isChecked() ? 2 : 3;
|
||||||
QJsonArray values;
|
QJsonArray values;
|
||||||
for(int j=0; j<255; j++) {
|
for(int j=0; j<255; j++) {
|
||||||
auto val = sheet->read(3, j+3).toString();
|
auto val = sheet->read(rr, j+3).toString();
|
||||||
if(val.isEmpty()) {
|
if(val.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), "Cell is empty at 3, "+QString::number(j+3));
|
QMessageBox::information(this, translate("","Tip"), "Cell is empty at 3, "+QString::number(j+3));
|
||||||
return;
|
return;
|
||||||
|
|
@ -379,10 +463,9 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
hBox->addWidget(btnTableGet);
|
hBox->addWidget(btnTableGet);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
vBox->addLayout(hBox);
|
|
||||||
|
|
||||||
|
|
||||||
hBox = new QHBoxLayout;
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
lbCurBright = new QLabel;
|
lbCurBright = new QLabel;
|
||||||
|
|
@ -421,7 +504,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [reply, card] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
|
@ -434,7 +517,6 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
hBox->addWidget(btnCurBrightGet);
|
hBox->addWidget(btnCurBrightGet);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
vBox->addLayout(hBox);
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -797,6 +879,9 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
||||||
if(checked) stack->setCurrentIndex(idx);
|
if(checked) stack->setCurrentIndex(idx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for(auto btn : btnSets) btn->setProperty("ssType", "progManageTool");
|
||||||
|
for(auto btn : btnGets) btn->setProperty("ssType", "progManageTool");
|
||||||
|
|
||||||
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
|
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
|
||||||
if(isVisible()) init();
|
if(isVisible()) init();
|
||||||
});
|
});
|
||||||
|
|
@ -835,8 +920,8 @@ void CtrlBrightPanel::init() {
|
||||||
json = JObj();
|
json = JObj();
|
||||||
json.insert("_id", "GetBrightnessSensitivity");
|
json.insert("_id", "GetBrightnessSensitivity");
|
||||||
json.insert("_type", "GetBrightnessSensitivity");
|
json.insert("_type", "GetBrightnessSensitivity");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
|
@ -850,14 +935,26 @@ void CtrlBrightPanel::init() {
|
||||||
json = JObj();
|
json = JObj();
|
||||||
json.insert("_id", "GetMinBrightness");
|
json.insert("_id", "GetMinBrightness");
|
||||||
json.insert("_type", "GetMinBrightness");
|
json.insert("_type", "GetMinBrightness");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
auto value = json["minBrightnessPercentage"].toInt(-1);
|
auto value = json["minBrightnessPercentage"].toInt(-1);
|
||||||
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
||||||
fdMinBright->setValue(value);
|
edMinBright->setValue(value);
|
||||||
|
});
|
||||||
|
json = JObj();
|
||||||
|
json.insert("_id", "GetMaxBrightness");
|
||||||
|
json.insert("_type", "GetMaxBrightness");
|
||||||
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
if(! err.isEmpty()) return;
|
||||||
|
auto value = json["maxBrightnessPercentage"].toInt(-1);
|
||||||
|
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / card.BrightnessLevel);
|
||||||
|
edMaxBright->setValue(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -866,6 +963,9 @@ void CtrlBrightPanel::changeEvent(QEvent *event) {
|
||||||
if(event->type() == QEvent::LanguageChange) transUi();
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
}
|
}
|
||||||
void CtrlBrightPanel::transUi() {
|
void CtrlBrightPanel::transUi() {
|
||||||
|
for(auto btn : btnSets) btn->setText(translate("","Set"));
|
||||||
|
for(auto btn : btnGets) btn->setText(translate("","Get"));
|
||||||
|
|
||||||
lbTitle->setText(tr("Brightness Config"));
|
lbTitle->setText(tr("Brightness Config"));
|
||||||
radioAuto->setText(tr("Auto"));
|
radioAuto->setText(tr("Auto"));
|
||||||
radioManual->setText(tr("Manual"));
|
radioManual->setText(tr("Manual"));
|
||||||
|
|
@ -875,15 +975,12 @@ void CtrlBrightPanel::transUi() {
|
||||||
fdBrightTip->setText(tr("BrightTip1"));
|
fdBrightTip->setText(tr("BrightTip1"));
|
||||||
fdSensiTypeTip->setText(tr("BrightTip2"));
|
fdSensiTypeTip->setText(tr("BrightTip2"));
|
||||||
lbSensi->setText(tr("Sensitivity"));
|
lbSensi->setText(tr("Sensitivity"));
|
||||||
lbMinBright->setText(tr("Minbrightness"));
|
lbMinBright->setText(tr("Min Brightness"));
|
||||||
btnMinBrightSet->setText(translate("","Set"));
|
lbMaxBright->setText(tr("Max Brightness"));
|
||||||
btnSensiSet->setText(translate("","Set"));
|
|
||||||
btnUpload->setText(tr("Upload File"));
|
btnUpload->setText(tr("Upload File"));
|
||||||
btnMinBrightGet->setText(translate("","Readback"));
|
|
||||||
btnSensiGet->setText(translate("","Readback"));
|
|
||||||
btnTableGet->setText(translate("","Readback"));
|
btnTableGet->setText(translate("","Readback"));
|
||||||
btnCurBrightGet->setText(translate("","Refresh"));
|
btnCurBrightGet->setText(translate("","Refresh"));
|
||||||
lbCurBright->setText(tr("Cur Brigntness")+": ");
|
lbCurBright->setText(tr("Ambient Brigntness")+": ");
|
||||||
|
|
||||||
lbFixedBright->setText(tr("Brightness value"));
|
lbFixedBright->setText(tr("Brightness value"));
|
||||||
btnFixedSet->setText(translate("","Set"));
|
btnFixedSet->setText(translate("","Set"));
|
||||||
|
|
|
||||||
|
|
@ -23,21 +23,16 @@ private:
|
||||||
bool restoreScheduleJson(JValue &, int);
|
bool restoreScheduleJson(JValue &, int);
|
||||||
void getScheduleJson(QJsonObject &, int);
|
void getScheduleJson(QJsonObject &, int);
|
||||||
QLabel *lbTitle;
|
QLabel *lbTitle;
|
||||||
QRadioButton *radioAuto;
|
QRadioButton *radioAuto, *radioManual, *radioSchedule;
|
||||||
QRadioButton *radioManual;
|
|
||||||
QRadioButton *radioSchedule;
|
|
||||||
QCheckBox *fdAdaptToOld;
|
QCheckBox *fdAdaptToOld;
|
||||||
char mSensi{-1};
|
char mSensi = -1;
|
||||||
char mTask{-1};
|
char mTask = -1;
|
||||||
|
|
||||||
|
std::vector<QPushButton *> btnSets, btnGets;
|
||||||
QLabel *lbSensi;
|
QLabel *lbSensi;
|
||||||
QSlider *fdSensi;
|
QSlider *fdSensi;
|
||||||
QLabel *lbMinBright;
|
QLabel *lbMinBright, *lbMaxBright;
|
||||||
QSlider *fdMinBright;
|
QSlider *edMinBright, *edMaxBright;
|
||||||
QPushButton *btnSensiSet;
|
|
||||||
QPushButton *btnSensiGet;
|
|
||||||
QPushButton *btnMinBrightSet;
|
|
||||||
QPushButton *btnMinBrightGet;
|
|
||||||
QRadioButton *fdR68;
|
QRadioButton *fdR68;
|
||||||
QRadioButton *fdRL2;
|
QRadioButton *fdRL2;
|
||||||
QPushButton *btnUpload;
|
QPushButton *btnUpload;
|
||||||
|
|
|
||||||
|
|
@ -59,16 +59,6 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
|
|
||||||
hBox->addSpacing(20);
|
hBox->addSpacing(20);
|
||||||
|
|
||||||
edAutoSwitch = new QCheckBox;
|
|
||||||
edAutoSwitch->setChecked(true);
|
|
||||||
hBox->addWidget(edAutoSwitch);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
vBox->addSpacing(20);
|
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
|
||||||
hBox->addStretch();
|
|
||||||
|
|
||||||
btnSyncSet = new QPushButton;
|
btnSyncSet = new QPushButton;
|
||||||
btnSyncSet->setMinimumSize(60, 30);
|
btnSyncSet->setMinimumSize(60, 30);
|
||||||
btnSyncSet->setProperty("ssType", "progManageTool");
|
btnSyncSet->setProperty("ssType", "progManageTool");
|
||||||
|
|
@ -98,36 +88,78 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(id) {
|
// if(id) {
|
||||||
json = JObj();
|
// json = JObj();
|
||||||
|
// json.insert("_id", "AutoSyncSwitch");
|
||||||
|
// json.insert("_type", "AutoSyncSwitch");
|
||||||
|
// json.insert("isAuto", edAutoSwitch->isChecked());
|
||||||
|
// if(gSelCards.count() == 1) {
|
||||||
|
// if(gSelCards[0].id.startsWith("g", Qt::CaseInsensitive)
|
||||||
|
// || gSelCards[0].id.startsWith("m8h", Qt::CaseInsensitive)
|
||||||
|
// || gSelCards[0].id.startsWith("m8s", Qt::CaseInsensitive)
|
||||||
|
// || gSelCards[0].id.startsWith("y8h", Qt::CaseInsensitive)
|
||||||
|
// ) {
|
||||||
|
// auto waitingDlg = new WaitingDlg(this, tr("SyncSwitch"));
|
||||||
|
// Def_CtrlReqPre
|
||||||
|
// connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
// Def_CtrlSetReqAfter
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// for(auto &card : gSelCards) if(card.id.startsWith("g", Qt::CaseInsensitive)
|
||||||
|
// || card.id.startsWith("m8h", Qt::CaseInsensitive)
|
||||||
|
// || card.id.startsWith("m8s", Qt::CaseInsensitive)
|
||||||
|
// || card.id.startsWith("y8h", Qt::CaseInsensitive)
|
||||||
|
// ) {
|
||||||
|
// Def_CtrlSetMulti(tr("SyncSwitch"))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnSyncSet);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
vBox->addSpacing(20);
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
edAutoSwitch = new QCheckBox;
|
||||||
|
edAutoSwitch->setChecked(true);
|
||||||
|
hBox->addWidget(edAutoSwitch);
|
||||||
|
|
||||||
|
btnAutoSet = new QPushButton;
|
||||||
|
btnAutoSet->setMinimumSize(60, 30);
|
||||||
|
btnAutoSet->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnAutoSet, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
json.insert("_id", "AutoSyncSwitch");
|
json.insert("_id", "AutoSyncSwitch");
|
||||||
json.insert("_type", "AutoSyncSwitch");
|
json.insert("_type", "AutoSyncSwitch");
|
||||||
json.insert("isAuto", edAutoSwitch->isChecked());
|
json.insert("isAuto", edAutoSwitch->isChecked());
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
if(gSelCards[0].id.startsWith("g", Qt::CaseInsensitive)
|
|
||||||
|| gSelCards[0].id.startsWith("m8h", Qt::CaseInsensitive)
|
|
||||||
|| gSelCards[0].id.startsWith("m8s", Qt::CaseInsensitive)
|
|
||||||
|| gSelCards[0].id.startsWith("y8h", Qt::CaseInsensitive)
|
|
||||||
) {
|
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("SyncSwitch"));
|
auto waitingDlg = new WaitingDlg(this, tr("SyncSwitch"));
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
Def_CtrlSetReqAfter
|
Def_CtrlSetReqAfter
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) if(card.id.startsWith("g", Qt::CaseInsensitive)
|
for(auto &card : gSelCards) {
|
||||||
|| card.id.startsWith("m8h", Qt::CaseInsensitive)
|
|
||||||
|| card.id.startsWith("m8s", Qt::CaseInsensitive)
|
|
||||||
|| card.id.startsWith("y8h", Qt::CaseInsensitive)
|
|
||||||
) {
|
|
||||||
Def_CtrlSetMulti(tr("SyncSwitch"))
|
Def_CtrlSetMulti(tr("SyncSwitch"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
hBox->addWidget(btnSyncSet);
|
hBox->addWidget(btnAutoSet);
|
||||||
hBox->addSpacing(20);
|
hBox->addStretch();
|
||||||
|
|
||||||
|
vBox->addSpacing(20);
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
btnSyncGet = new QPushButton;
|
btnSyncGet = new QPushButton;
|
||||||
btnSyncGet->setMinimumSize(60, 30);
|
btnSyncGet->setMinimumSize(60, 30);
|
||||||
|
|
@ -390,6 +422,7 @@ void CtrlHdmiPanel::transUi() {
|
||||||
|
|
||||||
fdAsync->setText(tr("Async"));
|
fdAsync->setText(tr("Async"));
|
||||||
btnSyncSet->setText(translate("","Set"));
|
btnSyncSet->setText(translate("","Set"));
|
||||||
|
btnAutoSet->setText(translate("","Set"));
|
||||||
btnSyncGet->setText(translate("","Readback"));
|
btnSyncGet->setText(translate("","Readback"));
|
||||||
|
|
||||||
tableSche->setHeaderText("start", tr("Start Time"));
|
tableSche->setHeaderText("start", tr("Start Time"));
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ private:
|
||||||
QLabel *lbHdmiCfg;
|
QLabel *lbHdmiCfg;
|
||||||
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
|
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
|
||||||
QCheckBox *edAutoSwitch;
|
QCheckBox *edAutoSwitch;
|
||||||
QPushButton *btnSyncSet, *btnSyncGet;
|
QPushButton *btnSyncSet, *btnAutoSet, *btnSyncGet;
|
||||||
|
|
||||||
TableWidget *tableSche;
|
TableWidget *tableSche;
|
||||||
QPushButton *btnScheAdd;
|
QPushButton *btnScheAdd;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include "ctrlnetworkpanel.h"
|
#include "ctrlnetworkpanel.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "tools.h"
|
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
|
|
@ -101,7 +100,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnLanSet = new QPushButton;
|
btnLanSet = new QPushButton;
|
||||||
btnLanSet->setMinimumSize(QSize(60, 30));
|
btnLanSet->setMinimumSize(QSize(60, 30));
|
||||||
btnLanSet->setProperty("ssType", "progManageTool");
|
btnLanSet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnLanSet, &QPushButton::clicked, this, [this] {
|
connect(btnLanSet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
|
|
@ -164,7 +163,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
btnLanGet = new QPushButton;
|
btnLanGet = new QPushButton;
|
||||||
btnLanGet->setMinimumSize(QSize(60, 30));
|
btnLanGet->setMinimumSize(QSize(60, 30));
|
||||||
btnLanGet->setProperty("ssType", "progManageTool");
|
btnLanGet->setProperty("ssType", "progManageTool");
|
||||||
connect(btnLanGet, &QPushButton::clicked, this, [this] {
|
connect(btnLanGet, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
if(gSelCards.isEmpty()) {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
|
|
@ -175,7 +174,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("GetEthernet"));
|
auto waitingDlg = new WaitingDlg(this, tr("GetEthernet"));
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
if(json["dhcp"].toBool()) {
|
if(json["dhcp"].toBool()) {
|
||||||
|
|
@ -192,9 +191,9 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(err.isEmpty()) err = json["dhcp"].toBool() ? tr("DHCP IP") : tr("STATIC IP");
|
if(err.isEmpty()) err = json["dhcp"].toBool() ? tr("DHCP IP") : tr("STATIC IP");
|
||||||
|
|
@ -227,7 +226,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
auto vvv = new VBox(hBox);
|
auto vvv = new VBox(hBox);
|
||||||
auto hBox = new HBox(vvv);
|
auto hBox = new HBox(vvv);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
hBox->addWidget(fdIsWifi = new QCheckBox);
|
hBox->addWidget(edIsWifi = new QCheckBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
|
@ -251,13 +250,13 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
JObj json;
|
||||||
json.insert("_id", "GetWifiList");
|
json.insert("_id", "GetWifiList");
|
||||||
json.insert("_type", "GetWifiList");
|
json.insert("_type", "GetWifiList");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("GetWifiList")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("GetWifiList")+" ...");
|
||||||
Def_CtrlReqPre
|
Def_CtrlReqPre
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
auto wifis = json["wifiList"].toArray();
|
auto wifis = json["wifiList"].toArray();
|
||||||
|
|
@ -294,7 +293,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto isWifi = fdIsWifi->isChecked();
|
auto isWifi = edIsWifi->isChecked();
|
||||||
JObj json;
|
JObj json;
|
||||||
json.insert("_id", "SetSwitchWiFi");
|
json.insert("_id", "SetSwitchWiFi");
|
||||||
json.insert("_type", "SetSwitchWiFi");
|
json.insert("_type", "SetSwitchWiFi");
|
||||||
|
|
@ -313,7 +312,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
if(isWifi) {
|
if(isWifi) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||||
ConnReply(reply, waitingDlg) [=] {
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
|
@ -337,7 +336,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
else waitingDlg->success();
|
else waitingDlg->success();
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
if(isWifi) {
|
if(isWifi) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||||
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||||
|
|
@ -371,7 +370,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
auto vvv = new VBox(hBox);
|
auto vvv = new VBox(hBox);
|
||||||
auto hBox = new HBox(vvv);
|
auto hBox = new HBox(vvv);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
hBox->addWidget(fdIsAP = new QCheckBox);
|
hBox->addWidget(edIsHotspot = new QCheckBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
|
@ -400,10 +399,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox = new HBox(vvv);
|
hBox = new HBox(vvv);
|
||||||
|
hBox->addSpacing(86);
|
||||||
auto lll = new QLabel;
|
|
||||||
lll->setMinimumWidth(80);
|
|
||||||
hBox->addWidget(lll);
|
|
||||||
|
|
||||||
auto edIs2_4G = new QRadioButton("2.4G");
|
auto edIs2_4G = new QRadioButton("2.4G");
|
||||||
edIs2_4G->setChecked(true);
|
edIs2_4G->setChecked(true);
|
||||||
|
|
@ -424,7 +420,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto isAp = fdIsAP->isChecked();
|
auto isAp = edIsHotspot->isChecked();
|
||||||
|
auto hotspotPswd = edHotspotPswd->text();
|
||||||
|
if(isAp && (hotspotPswd.size()<8 || !isStrongPswd(hotspotPswd))) {
|
||||||
|
QMessageBox::warning(this, translate("","Tip"), translate("","The password must have 8 characters at least and contain numbers, uppercase and lowercase letters"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
JObj jsonG;
|
JObj jsonG;
|
||||||
jsonG.insert("_id", "ControllerWifiSwitch");
|
jsonG.insert("_id", "ControllerWifiSwitch");
|
||||||
jsonG.insert("_type", "ControllerWifiSwitch");
|
jsonG.insert("_type", "ControllerWifiSwitch");
|
||||||
|
|
@ -435,12 +436,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
json.insert("_type", "ConfigurationHotSpot");
|
json.insert("_type", "ConfigurationHotSpot");
|
||||||
json.insert("apName", edHotspotName->text());
|
json.insert("apName", edHotspotName->text());
|
||||||
json.insert("apBand", edIs5G->isChecked() ? 1 : 0);
|
json.insert("apBand", edIs5G->isChecked() ? 1 : 0);
|
||||||
json.insert("password", edHotspotPswd->text());
|
json.insert("password", hotspotPswd);
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("Config Hotspot")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("Config Hotspot")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
if(isG) {
|
if(isG) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||||
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||||
|
|
@ -466,7 +467,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
} else waitingDlg->success();
|
} else waitingDlg->success();
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
if(isG) {
|
if(isG) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||||
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||||
|
|
@ -491,7 +492,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
vvv->addStretch();
|
vvv->addStretch();
|
||||||
}
|
}
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
fdIsWifi->setChecked(true);
|
edIsWifi->setChecked(true);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
@ -511,18 +512,18 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
jsonG.insert("_id", "GetWifiSwitchState");
|
jsonG.insert("_id", "GetWifiSwitchState");
|
||||||
jsonG.insert("_type", "GetWifiSwitchState");
|
jsonG.insert("_type", "GetWifiSwitchState");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
auto waitingDlg = new WaitingDlg(this, tr("Get AP or WiFi")+" ...");
|
auto waitingDlg = new WaitingDlg(this, tr("Get Hotspot or WiFi")+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto card = gSelCards[0];
|
auto card = gSelCards[0];
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||||
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
Def_CtrlSingleGetReply
|
Def_CtrlSingleGetReply
|
||||||
waitingDlg->success();
|
waitingDlg->success();
|
||||||
if(isG) {
|
if(isG) {
|
||||||
fdIsWifi->setChecked(json["wifiEnable"].toBool());
|
edIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||||
fdIsAP->setChecked(json["apEnable"].toBool());
|
edIsHotspot->setChecked(json["apEnable"].toBool());
|
||||||
edWifiName->setCurrentText(json["wifiName"].toString());
|
edWifiName->setCurrentText(json["wifiName"].toString());
|
||||||
edHotspotName->setText(json["hotSpotName"].toString());
|
edHotspotName->setText(json["hotSpotName"].toString());
|
||||||
edIs5G->setChecked(json["apBand"].toBool());
|
edIs5G->setChecked(json["apBand"].toBool());
|
||||||
|
|
@ -530,15 +531,15 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
edWifiName->setCurrentText(json["wifi"].toString());
|
edWifiName->setCurrentText(json["wifi"].toString());
|
||||||
auto hotSpots = json["hotSpots"].toString();
|
auto hotSpots = json["hotSpots"].toString();
|
||||||
edHotspotName->setText(hotSpots);
|
edHotspotName->setText(hotSpots);
|
||||||
fdIsWifi->setChecked(hotSpots.isEmpty());
|
edIsWifi->setChecked(hotSpots.isEmpty());
|
||||||
fdIsAP->setChecked(! hotSpots.isEmpty());
|
edIsHotspot->setChecked(! hotSpots.isEmpty());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
|
@ -555,7 +556,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
||||||
if(! hotSpots.isEmpty()) err += " "+tr("ApName")+":"+hotSpots;
|
if(! hotSpots.isEmpty()) err += " "+tr("ApName")+":"+hotSpots;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gFdResInfo->append(cardId+" "+tr("Get AP or WiFi")+" "+err);
|
gFdResInfo->append(cardId+" "+tr("Get Hotspot or WiFi")+" "+err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -981,8 +982,8 @@ void CtrlNetworkPanel::init() {
|
||||||
JObj json;
|
JObj json;
|
||||||
json.insert("_id", "GetEthernet");
|
json.insert("_id", "GetEthernet");
|
||||||
json.insert("_type", "GetEthernet");
|
json.insert("_type", "GetEthernet");
|
||||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
|
|
@ -1013,7 +1014,7 @@ void CtrlNetworkPanel::init() {
|
||||||
for(JValue &wifi : wifis) edWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
|
for(JValue &wifi : wifis) edWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
|
||||||
{
|
{
|
||||||
JObj json;
|
JObj json;
|
||||||
auto isG = card.id.startsWith("g", Qt::CaseInsensitive);
|
auto isG = card.id.startsWith("g", Qt::CaseInsensitive) || card.id.startsWith("m8h", Qt::CaseInsensitive);
|
||||||
if(isG) {
|
if(isG) {
|
||||||
json.insert("_id", "GetWifiSwitchState");
|
json.insert("_id", "GetWifiSwitchState");
|
||||||
json.insert("_type", "GetWifiSwitchState");
|
json.insert("_type", "GetWifiSwitchState");
|
||||||
|
|
@ -1027,8 +1028,8 @@ void CtrlNetworkPanel::init() {
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
if(! err.isEmpty()) return;
|
if(! err.isEmpty()) return;
|
||||||
if(isG) {
|
if(isG) {
|
||||||
fdIsWifi->setChecked(json["wifiEnable"].toBool());
|
edIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||||
fdIsAP->setChecked(json["apEnable"].toBool());
|
edIsHotspot->setChecked(json["apEnable"].toBool());
|
||||||
edWifiName->setCurrentText(json["wifiName"].toString());
|
edWifiName->setCurrentText(json["wifiName"].toString());
|
||||||
edHotspotName->setText(json["hotSpotName"].toString());
|
edHotspotName->setText(json["hotSpotName"].toString());
|
||||||
edIs5G->setChecked(json["apBand"].toBool());
|
edIs5G->setChecked(json["apBand"].toBool());
|
||||||
|
|
@ -1036,8 +1037,8 @@ void CtrlNetworkPanel::init() {
|
||||||
edWifiName->setCurrentText(json["wifi"].toString());
|
edWifiName->setCurrentText(json["wifi"].toString());
|
||||||
auto hotspots = json["hotSpots"].toString();
|
auto hotspots = json["hotSpots"].toString();
|
||||||
edHotspotName->setText(hotspots);
|
edHotspotName->setText(hotspots);
|
||||||
fdIsWifi->setChecked(hotspots.isEmpty());
|
edIsWifi->setChecked(hotspots.isEmpty());
|
||||||
fdIsAP->setChecked(! hotspots.isEmpty());
|
edIsHotspot->setChecked(! hotspots.isEmpty());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1046,7 +1047,7 @@ void CtrlNetworkPanel::init() {
|
||||||
json = JObj();
|
json = JObj();
|
||||||
json.insert("_id", "GetSwitchSimData");
|
json.insert("_id", "GetSwitchSimData");
|
||||||
json.insert("_type", "GetSwitchSimData");
|
json.insert("_type", "GetSwitchSimData");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
JValue json;
|
JValue json;
|
||||||
auto err = errStrWithJson(reply, &json);
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
|
@ -1060,7 +1061,7 @@ void CtrlNetworkPanel::init() {
|
||||||
json = JObj();
|
json = JObj();
|
||||||
json.insert("_id", "GetAPNList");
|
json.insert("_id", "GetAPNList");
|
||||||
json.insert("_type", "GetAPNList");
|
json.insert("_type", "GetAPNList");
|
||||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
QJsonDocument json;
|
QJsonDocument json;
|
||||||
auto err = checkReplyForJson(reply, &json);
|
auto err = checkReplyForJson(reply, &json);
|
||||||
|
|
@ -1104,9 +1105,9 @@ void CtrlNetworkPanel::changeEvent(QEvent *event) {
|
||||||
void CtrlNetworkPanel::transUi() {
|
void CtrlNetworkPanel::transUi() {
|
||||||
lbLanCfg->setText(tr("Wire Enther(RJ45) Configuration"));
|
lbLanCfg->setText(tr("Wire Enther(RJ45) Configuration"));
|
||||||
fdSpecifyIp->setText(tr("Specify IP"));
|
fdSpecifyIp->setText(tr("Specify IP"));
|
||||||
lbHotspotName->setText(tr("AP name"));
|
lbHotspotName->setText(tr("Hotspot Name"));
|
||||||
labelGateway->setText(tr("Gateway"));
|
labelGateway->setText(tr("Gateway"));
|
||||||
lbWifiName->setText(tr("WiFi name"));
|
lbWifiName->setText(tr("WiFi Name"));
|
||||||
labelIpAddress->setText(tr("IP Address"));
|
labelIpAddress->setText(tr("IP Address"));
|
||||||
lbHotspotPswd->setText(tr("Password"));
|
lbHotspotPswd->setText(tr("Password"));
|
||||||
labelDnsAddress->setText(tr("DNS Address"));
|
labelDnsAddress->setText(tr("DNS Address"));
|
||||||
|
|
@ -1118,12 +1119,12 @@ void CtrlNetworkPanel::transUi() {
|
||||||
btnLanSet->setText(translate("","Set"));
|
btnLanSet->setText(translate("","Set"));
|
||||||
btnWiFiGet->setText(translate("","Readback"));
|
btnWiFiGet->setText(translate("","Readback"));
|
||||||
btnLanGet->setText(translate("","Readback"));
|
btnLanGet->setText(translate("","Readback"));
|
||||||
fdIsWifi->setText(tr("Enable WiFi"));
|
edIsWifi->setText(tr("Enable WiFi"));
|
||||||
fdIsAP->setText(tr("Enable AP"));
|
edIsHotspot->setText(tr("Enable Hotspot"));
|
||||||
lbWifiCfg->setText(tr("WiFi Config"));
|
lbWifiCfg->setText(tr("WiFi Config"));
|
||||||
edHotspotPswd->setPlaceholderText(translate("","Input Password"));
|
edHotspotPswd->setPlaceholderText(translate("","Input Password"));
|
||||||
edWifiPswd->setPlaceholderText(translate("","Input Password"));
|
edWifiPswd->setPlaceholderText(translate("","Input Password"));
|
||||||
edHotspotName->setPlaceholderText(tr("Input ap name"));
|
edHotspotName->setPlaceholderText(tr("Input Hotspot Name"));
|
||||||
lbCellularConfig->setText(tr("Cellular Config"));
|
lbCellularConfig->setText(tr("Cellular Config"));
|
||||||
lbCheckStatusTip->setText(tr("Through the check status button"));
|
lbCheckStatusTip->setText(tr("Through the check status button"));
|
||||||
fdEnableCellular->setText(tr("Enable Cellular Data"));
|
fdEnableCellular->setText(tr("Enable Cellular Data"));
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ private:
|
||||||
QRadioButton *edIs5G;
|
QRadioButton *edIs5G;
|
||||||
QLabel *lbWifiPswd;
|
QLabel *lbWifiPswd;
|
||||||
|
|
||||||
QCheckBox *fdIsWifi, *fdIsAP;
|
QCheckBox *edIsWifi, *edIsHotspot;
|
||||||
QLineEdit *edWifiPswd;
|
QLineEdit *edWifiPswd;
|
||||||
QPushButton *btnScan;
|
QPushButton *btnScan;
|
||||||
QPushButton *btnWiFiSet, *btnHotspotSet, *btnWiFiGet;
|
QPushButton *btnWiFiSet, *btnHotspotSet, *btnWiFiGet;
|
||||||
|
|
|
||||||
|
|
@ -249,10 +249,10 @@ void CtrlPwdPanel::changeEvent(QEvent *event) {
|
||||||
void CtrlPwdPanel::transUi() {
|
void CtrlPwdPanel::transUi() {
|
||||||
lbPwdConfig->setText(tr("Set Password"));
|
lbPwdConfig->setText(tr("Set Password"));
|
||||||
lbOldPwd->setText(tr("Original password"));
|
lbOldPwd->setText(tr("Original password"));
|
||||||
lbNewPwd->setText(tr("New password"));
|
lbNewPwd->setText(translate("","New password"));
|
||||||
lbPwdAgain->setText(tr("Enter again"));
|
lbPwdAgain->setText(tr("Enter again"));
|
||||||
fdOldPwd->setPlaceholderText(tr("original password"));
|
fdOldPwd->setPlaceholderText(tr("original password"));
|
||||||
fdNewPwd->setPlaceholderText(tr("New password"));
|
fdNewPwd->setPlaceholderText(translate("","New password"));
|
||||||
fdPwdAgain->setPlaceholderText(tr("Repeat new password"));
|
fdPwdAgain->setPlaceholderText(tr("Repeat new password"));
|
||||||
btnPwdSet->setText(tr("Set encryption"));
|
btnPwdSet->setText(tr("Set encryption"));
|
||||||
btnPwdClear->setText(tr("Cancel encryption"));
|
btnPwdClear->setText(tr("Cancel encryption"));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ctrltestpanel.h"
|
#include "ctrltestpanel.h"
|
||||||
#include "tools.h"
|
#include "badpointdetectdialog.h"
|
||||||
|
#include "main.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "gutil/qwaitingdlg.h"
|
#include "gutil/qwaitingdlg.h"
|
||||||
|
|
@ -15,14 +16,27 @@
|
||||||
CtrlTestPanel::CtrlTestPanel() {
|
CtrlTestPanel::CtrlTestPanel() {
|
||||||
auto vBox = new VBox(this);
|
auto vBox = new VBox(this);
|
||||||
|
|
||||||
labelTestScreen = new QLabel;
|
lbTestScreen = vBox->addLabel();
|
||||||
labelTestScreen->setAlignment(Qt::AlignCenter);
|
lbTestScreen->setAlignment(Qt::AlignCenter);
|
||||||
vBox->addWidget(labelTestScreen);
|
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
auto vv = new VBox(hBox);
|
auto vv = new VBox(hBox);
|
||||||
|
|
||||||
|
btnBadPoint = new QPushButton;
|
||||||
|
btnBadPoint->setMinimumSize(100, 30);
|
||||||
|
btnBadPoint->setProperty("ssType", "progManageTool");
|
||||||
|
connect(btnBadPoint, &QPushButton::clicked, this, [=] {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new BadPointDetectDialog(this);
|
||||||
|
});
|
||||||
|
vv->addWidget(btnBadPoint);
|
||||||
|
|
||||||
groupBox = new QGroupBox;
|
groupBox = new QGroupBox;
|
||||||
|
vv->addWidget(groupBox);
|
||||||
|
|
||||||
auto vvv = new VBox(groupBox);
|
auto vvv = new VBox(groupBox);
|
||||||
auto hhh = new HBox(vvv);
|
auto hhh = new HBox(vvv);
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
|
|
@ -85,9 +99,10 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
pushButtonStartLine->setMaximumSize(QSize(80, 16777215));
|
pushButtonStartLine->setMaximumSize(QSize(80, 16777215));
|
||||||
vvv->addWidget(pushButtonStartLine, 0, Qt::AlignHCenter);
|
vvv->addWidget(pushButtonStartLine, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
vv->addWidget(groupBox);
|
|
||||||
|
|
||||||
groupBox_2 = new QGroupBox;
|
groupBox_2 = new QGroupBox;
|
||||||
|
vv->addWidget(groupBox_2);
|
||||||
|
|
||||||
vvv = new VBox(groupBox_2);
|
vvv = new VBox(groupBox_2);
|
||||||
checkBoxShowInfo = new QCheckBox;
|
checkBoxShowInfo = new QCheckBox;
|
||||||
|
|
||||||
|
|
@ -142,9 +157,10 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
pushButtonStartGray->setMaximumSize(QSize(80, 16777215));
|
pushButtonStartGray->setMaximumSize(QSize(80, 16777215));
|
||||||
vvv->addWidget(pushButtonStartGray, 0, Qt::AlignHCenter);
|
vvv->addWidget(pushButtonStartGray, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
vv->addWidget(groupBox_2);
|
|
||||||
|
|
||||||
groupBox_3 = new QGroupBox;
|
groupBox_3 = new QGroupBox;
|
||||||
|
vv->addWidget(groupBox_3);
|
||||||
|
|
||||||
vvv = new VBox(groupBox_3);
|
vvv = new VBox(groupBox_3);
|
||||||
|
|
||||||
checkBoxGradient = new QCheckBox;
|
checkBoxGradient = new QCheckBox;
|
||||||
|
|
@ -172,7 +188,6 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
|
|
||||||
vvv->addWidget(pushButtonStartColor, 0, Qt::AlignHCenter);
|
vvv->addWidget(pushButtonStartColor, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
vv->addWidget(groupBox_3);
|
|
||||||
|
|
||||||
hhh = new HBox(vv);
|
hhh = new HBox(vv);
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
|
|
@ -237,13 +252,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
btnAnycastReset->setFixedSize(60, 30);
|
btnAnycastReset->setFixedSize(60, 30);
|
||||||
btnAnycastReset->setProperty("ssType", "progManageTool");
|
btnAnycastReset->setProperty("ssType", "progManageTool");
|
||||||
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
|
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SendAnycastCmd(0);
|
SendAnycastCmd(0);
|
||||||
fdAnycast->setText("- "+tr("Loop Mode")+" -");
|
|
||||||
btnAnycast->setEnabled(false);
|
|
||||||
});
|
});
|
||||||
gridLayout->addWidget(btnAnycastReset, 3, 2, 1, 1);
|
gridLayout->addWidget(btnAnycastReset, 3, 2, 1, 1);
|
||||||
|
|
||||||
|
|
@ -252,13 +261,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
||||||
btnAnycast->setMinimumHeight(36);
|
btnAnycast->setMinimumHeight(36);
|
||||||
btnAnycast->setProperty("ssType", "progManageTool");
|
btnAnycast->setProperty("ssType", "progManageTool");
|
||||||
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
||||||
if(gSelCards.isEmpty()) {
|
|
||||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SendAnycastCmd(fdAnycast->text().toInt());
|
SendAnycastCmd(fdAnycast->text().toInt());
|
||||||
fdAnycast->setText(tr("Anycast")+" - "+fdAnycast->text());
|
|
||||||
btnAnycast->setEnabled(false);
|
|
||||||
});
|
});
|
||||||
vv->addWidget(btnAnycast);
|
vv->addWidget(btnAnycast);
|
||||||
vv->addStretch();
|
vv->addStretch();
|
||||||
|
|
@ -423,7 +426,8 @@ void CtrlTestPanel::changeEvent(QEvent *event) {
|
||||||
if(event->type() == QEvent::LanguageChange) transUi();
|
if(event->type() == QEvent::LanguageChange) transUi();
|
||||||
}
|
}
|
||||||
void CtrlTestPanel::transUi() {
|
void CtrlTestPanel::transUi() {
|
||||||
labelTestScreen->setText(tr("Test Screen"));
|
lbTestScreen->setText(tr("Test Screen"));
|
||||||
|
btnBadPoint->setText(tr("Bad Point Detection"));
|
||||||
groupBox->setTitle(tr("Line test"));
|
groupBox->setTitle(tr("Line test"));
|
||||||
radioButtonRed->setText(tr("Red"));
|
radioButtonRed->setText(tr("Red"));
|
||||||
radioButtonGreen->setText(tr("Green"));
|
radioButtonGreen->setText(tr("Green"));
|
||||||
|
|
@ -464,6 +468,10 @@ void CtrlTestPanel::transUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
|
if(gSelCards.isEmpty()) {
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
||||||
tempStreadPakcet.ucCommType = 0x97;
|
tempStreadPakcet.ucCommType = 0x97;
|
||||||
tempStreadPakcet.iBaoLiu = 0;
|
tempStreadPakcet.iBaoLiu = 0;
|
||||||
|
|
@ -476,9 +484,13 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
auto data = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
auto data = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
||||||
auto action = progIdx==0 ? tr("Reset loop mode") : tr("Anycast");
|
auto action = progIdx==0 ? tr("Reset loop mode") : tr("Anycast");
|
||||||
if(gSelCards.count() == 1) {
|
if(gSelCards.count() == 1) {
|
||||||
|
auto card = gSelCards[0];
|
||||||
|
if(card.hasPassword && card.isLocked) {
|
||||||
|
QMessageBox::warning(this, translate("","Tip"), tr("This screen is encrypted"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto waitingDlg = new WaitingDlg(this, action+" ...");
|
auto waitingDlg = new WaitingDlg(this, action+" ...");
|
||||||
waitingDlg->show();
|
waitingDlg->show();
|
||||||
auto card = gSelCards[0];
|
|
||||||
auto tcp = new TcpSocket;
|
auto tcp = new TcpSocket;
|
||||||
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
||||||
tcp->abort();
|
tcp->abort();
|
||||||
|
|
@ -505,8 +517,12 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
tcp->startTimer(10000);
|
tcp->startTimer(10000);
|
||||||
} else {
|
} else {
|
||||||
for(auto &card : gSelCards) {
|
for(auto &card : gSelCards) {
|
||||||
auto tcp = new TcpSocket;
|
|
||||||
auto cardId = card.id;
|
auto cardId = card.id;
|
||||||
|
if(card.hasPassword && card.isLocked) {
|
||||||
|
gFdResInfo->append(cardId+" "+action+" "+tr("This screen is encrypted"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto tcp = new TcpSocket;
|
||||||
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
connect(tcp, &QTcpSocket::connected, tcp, [=] {
|
||||||
tcp->stopTimer();
|
tcp->stopTimer();
|
||||||
tcp->write(data);
|
tcp->write(data);
|
||||||
|
|
@ -527,4 +543,6 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||||
tcp->startTimer(10000);
|
tcp->startTimer(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fdAnycast->setText(progIdx==0 ? ("- "+tr("Loop Mode")+" -") : (tr("Anycast")+" - "+fdAnycast->text()));
|
||||||
|
btnAnycast->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,15 @@ class CtrlTestPanel : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CtrlTestPanel();
|
explicit CtrlTestPanel();
|
||||||
|
signals:
|
||||||
|
void sigSend(QJsonObject &,QString);
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *) override;
|
void changeEvent(QEvent *) override;
|
||||||
void transUi();
|
void transUi();
|
||||||
signals:
|
|
||||||
void sigSend(QJsonObject &,QString);
|
|
||||||
private:
|
|
||||||
void SendAnycastCmd(int);
|
void SendAnycastCmd(int);
|
||||||
|
|
||||||
QLabel *labelTestScreen;
|
QLabel *lbTestScreen;
|
||||||
|
QPushButton *btnBadPoint;
|
||||||
QGroupBox *groupBox;
|
QGroupBox *groupBox;
|
||||||
QRadioButton *radioButtonRed;
|
QRadioButton *radioButtonRed;
|
||||||
QRadioButton *radioButtonGreen;
|
QRadioButton *radioButtonGreen;
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,17 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
auto btnSelectFpga = new QPushButton(tr("Select Fpga"));
|
auto btnSelectFpga = new QPushButton(tr("Select Fpga"));
|
||||||
hBox->addWidget(btnSelectFpga);
|
hBox->addWidget(btnSelectFpga);
|
||||||
|
|
||||||
auto fdFileName = new QLineEdit;
|
auto edFileName = new QLineEdit;
|
||||||
fdFileName->setReadOnly(true);
|
edFileName->setReadOnly(true);
|
||||||
fdFileName->setMinimumWidth(200);
|
edFileName->setMinimumWidth(200);
|
||||||
hBox->addWidget(fdFileName);
|
hBox->addWidget(edFileName);
|
||||||
|
|
||||||
connect(btnSelectApk, &QPushButton::clicked, this, [=] {
|
connect(btnSelectApk, &QPushButton::clicked, this, [=] {
|
||||||
auto aaa = QFileDialog::getOpenFileName(this, "Open file", gApkHome, "apk package (*.apk *.zip)");
|
auto aaa = QFileDialog::getOpenFileName(this, "Open file", gApkHome, "apk package (*.apk *.zip)");
|
||||||
if(aaa.isEmpty()) return;
|
if(aaa.isEmpty()) return;
|
||||||
QFileInfo info(filePath = aaa);
|
QFileInfo info(filePath = aaa);
|
||||||
gApkHome = info.absolutePath();
|
gApkHome = info.absolutePath();
|
||||||
fdFileName->setText(info.fileName());
|
edFileName->setText(info.fileName());
|
||||||
fileId = "";
|
fileId = "";
|
||||||
});
|
});
|
||||||
connect(btnSelectFpga, &QPushButton::clicked, this, [=] {
|
connect(btnSelectFpga, &QPushButton::clicked, this, [=] {
|
||||||
|
|
@ -54,7 +54,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
if(aaa.isEmpty()) return;
|
if(aaa.isEmpty()) return;
|
||||||
QFileInfo info(filePath = aaa);
|
QFileInfo info(filePath = aaa);
|
||||||
gApkHome = info.absolutePath();
|
gApkHome = info.absolutePath();
|
||||||
fdFileName->setText(info.fileName());
|
edFileName->setText(info.fileName());
|
||||||
fileId = "";
|
fileId = "";
|
||||||
});
|
});
|
||||||
connect(btnSelectOnlineApk, &QPushButton::clicked, this, [=] {
|
connect(btnSelectOnlineApk, &QPushButton::clicked, this, [=] {
|
||||||
|
|
@ -103,7 +103,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
}
|
}
|
||||||
connect(table, &TreeWidget::itemDoubleClicked, &dlg, [=, &dlg](QTreeWidgetItem *itm) {
|
connect(table, &TreeWidget::itemDoubleClicked, &dlg, [=, &dlg](QTreeWidgetItem *itm) {
|
||||||
auto item = (TreeWidgetItem*) itm;
|
auto item = (TreeWidgetItem*) itm;
|
||||||
fdFileName->setText(item->text("name"));
|
edFileName->setText(item->text("name"));
|
||||||
fileId = item->data(0).toString();
|
fileId = item->data(0).toString();
|
||||||
filePath = "";
|
filePath = "";
|
||||||
dlg.accept();
|
dlg.accept();
|
||||||
|
|
@ -119,7 +119,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
QMessageBox::warning(&dlg, "Warning", tr("Please select a file"));
|
QMessageBox::warning(&dlg, "Warning", tr("Please select a file"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fdFileName->setText(item->text("name"));
|
edFileName->setText(item->text("name"));
|
||||||
fileId = item->data(0).toString();
|
fileId = item->data(0).toString();
|
||||||
filePath = "";
|
filePath = "";
|
||||||
dlg.accept();
|
dlg.accept();
|
||||||
|
|
@ -132,7 +132,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
||||||
|
|
||||||
auto btnUpdate = new QPushButton(tr("Upgrade"));
|
auto btnUpdate = new QPushButton(tr("Upgrade"));
|
||||||
connect(btnUpdate, &QPushButton::clicked, this, [=] {
|
connect(btnUpdate, &QPushButton::clicked, this, [=] {
|
||||||
auto fileName = fdFileName->text();
|
auto fileName = edFileName->text();
|
||||||
if(fileName.length() < 3) return;
|
if(fileName.length() < 3) return;
|
||||||
int cnt = table->topLevelItemCount();
|
int cnt = table->topLevelItemCount();
|
||||||
QList<UpdateApkItem *> items;
|
QList<UpdateApkItem *> items;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class UpdateApkItem;
|
||||||
class UpgradeApkDialog : public QDialog {
|
class UpgradeApkDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit UpgradeApkDialog(QWidget *parent = nullptr);
|
explicit UpgradeApkDialog(QWidget *parent = 0);
|
||||||
void sendProgress(UpdateApkItem *item);
|
void sendProgress(UpdateApkItem *item);
|
||||||
|
|
||||||
QString filePath, fileId;
|
QString filePath, fileId;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef QCORE_H
|
#ifndef QCORE_H
|
||||||
#define QCORE_H
|
#define QCORE_H
|
||||||
#include <QThread>
|
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#define ToStr QString::number
|
#define ToStr QString::number
|
||||||
|
|
@ -42,6 +44,17 @@ inline int wait(int msec, QObject *context = 0, QEventLoop::ProcessEventsFlags f
|
||||||
return loop.exec(flags);
|
return loop.exec(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void OpenCMD(const QStringList &arguments) {
|
||||||
|
QProcess process;
|
||||||
|
process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments *args) {
|
||||||
|
args->flags |= CREATE_NEW_CONSOLE;
|
||||||
|
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES;
|
||||||
|
});
|
||||||
|
process.setProgram("cmd");
|
||||||
|
process.setArguments(arguments);
|
||||||
|
process.startDetached();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
inline QThread *ThreadStart(Func &&f) {
|
inline QThread *ThreadStart(Func &&f) {
|
||||||
QThread* thread = QThread::create(f);
|
QThread* thread = QThread::create(f);
|
||||||
|
|
|
||||||
|
|
@ -72,13 +72,26 @@ inline QFont qfont(const QString& family, int pixelSize, bool bold = false, bool
|
||||||
if(italic) ft.setItalic(true);
|
if(italic) ft.setItalic(true);
|
||||||
return ft;
|
return ft;
|
||||||
}
|
}
|
||||||
|
inline QColor BrushToColor(const QBrush& brush, const QColor& defColor = QColor()) {
|
||||||
|
return brush.style()==Qt::NoBrush ? defColor : brush.color();
|
||||||
|
}
|
||||||
inline void gAppendText(QTextEdit *wgt, const QString& text, const QColor &color) {
|
inline void gAppendText(QTextEdit *wgt, const QString& text, const QColor &color) {
|
||||||
auto c0 = wgt->textColor();
|
auto c0 = wgt->textColor();
|
||||||
wgt->setTextColor(color);
|
wgt->setTextColor(color);
|
||||||
wgt->append(text);
|
wgt->append(text);
|
||||||
wgt->setTextColor(c0);
|
wgt->setTextColor(c0);
|
||||||
}
|
}
|
||||||
|
class EmitCloseWidget : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using QWidget::QWidget;
|
||||||
|
signals:
|
||||||
|
void onClose(void *event);
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event) override {
|
||||||
|
emit onClose(event);
|
||||||
|
};
|
||||||
|
};
|
||||||
class VBox : public QBoxLayout {
|
class VBox : public QBoxLayout {
|
||||||
public:
|
public:
|
||||||
VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {}
|
VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {}
|
||||||
|
|
@ -442,6 +455,7 @@ public:
|
||||||
horizontalHeader()->setSectionResizeMode(mode);
|
horizontalHeader()->setSectionResizeMode(mode);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
using QTableWidget::setRowHeight;
|
||||||
auto setRowHeight(int value) {
|
auto setRowHeight(int value) {
|
||||||
if(verticalHeader()->minimumSectionSize() > value) verticalHeader()->setMinimumSectionSize(value);
|
if(verticalHeader()->minimumSectionSize() > value) verticalHeader()->setMinimumSectionSize(value);
|
||||||
verticalHeader()->setDefaultSectionSize(value);
|
verticalHeader()->setDefaultSectionSize(value);
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,12 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication::setStyle("Fusion");
|
QApplication::setStyle("Fusion");
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
#ifndef leyide
|
||||||
QSplashScreen splash(QPixmap(":/res/splash.png"));
|
QSplashScreen splash(QPixmap(":/res/splash.png"));
|
||||||
splash.show();
|
splash.show();
|
||||||
splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white);
|
splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white);
|
||||||
app.processEvents();
|
app.processEvents();
|
||||||
|
#endif
|
||||||
QFile file(":/css.css");
|
QFile file(":/css.css");
|
||||||
if(file.exists() && file.open(QFile::ReadOnly)) {
|
if(file.exists() && file.open(QFile::ReadOnly)) {
|
||||||
app.setStyleSheet(file.readAll());
|
app.setStyleSheet(file.readAll());
|
||||||
|
|
@ -76,8 +77,8 @@ int main(int argc, char *argv[]) {
|
||||||
plt.setBrush(QPalette::Inactive, QPalette::HighlightedText, plt.brush(QPalette::Active, QPalette::HighlightedText));
|
plt.setBrush(QPalette::Inactive, QPalette::HighlightedText, plt.brush(QPalette::Active, QPalette::HighlightedText));
|
||||||
app.setPalette(plt);
|
app.setPalette(plt);
|
||||||
|
|
||||||
QTranslator qtTrans;
|
//QTranslator qtTrans;
|
||||||
if(qtTrans.load(QLocale(), "qt", "_", "translations")) QCoreApplication::installTranslator(&qtTrans);
|
//if(qtTrans.load(QLocale(), "qt", "_", "translations")) QCoreApplication::installTranslator(&qtTrans);
|
||||||
|
|
||||||
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||||
|
|
||||||
|
|
@ -86,7 +87,9 @@ int main(int argc, char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
MainWindow win;
|
MainWindow win;
|
||||||
win.show();
|
win.show();
|
||||||
|
#ifndef leyide
|
||||||
splash.finish(&win);
|
splash.finish(&win);
|
||||||
|
#endif
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,14 @@ inline QRect CenterRect(qreal width, qreal height, int maxW, int maxH) {
|
||||||
}
|
}
|
||||||
return QRect((maxW - width) / 2, (maxH - height) / 2, width, height);
|
return QRect((maxW - width) / 2, (maxH - height) / 2, width, height);
|
||||||
}
|
}
|
||||||
|
inline bool containsCharInRange(const QString &str, char start, char end) {
|
||||||
|
for(auto ch : str) if(ch>=start && ch<=end) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inline bool isStrongPswd(const QString &pswd) {
|
||||||
|
return containsCharInRange(pswd,'0','9') && containsCharInRange(pswd,'A','Z') && containsCharInRange(pswd,'a','z');
|
||||||
|
}
|
||||||
|
|
||||||
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
|
QString checkReply(QNetworkReply *, QJsonDocument * = 0);
|
||||||
QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
|
QString errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
|
||||||
QString errStrWithJson(QNetworkReply *, QString errField);
|
QString errStrWithJson(QNetworkReply *, QString errField);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "devicepanel.h"
|
#include "devicepanel.h"
|
||||||
#include "gutil/qnetwork.h"
|
#include "gutil/qnetwork.h"
|
||||||
#include "device/upgradeapkdialog.h"
|
#include "device/upgradeapkdialog.h"
|
||||||
|
#include "gutil/qwaitingdlg.h"
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
@ -19,6 +20,11 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
|
|
||||||
|
#include <QNetworkConfigurationManager>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <WLANAPI.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
extern QPoint gPlayPos;
|
extern QPoint gPlayPos;
|
||||||
|
|
||||||
QString gApkHome;
|
QString gApkHome;
|
||||||
|
|
@ -75,7 +81,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
langGrp = new QActionGroup(menuLang);
|
langGrp = new QActionGroup(menuLang);
|
||||||
connect(menuLang, &QMenu::triggered, this, [this](QAction* action) {
|
connect(menuLang, &QMenu::triggered, this, [this](QAction* action) {
|
||||||
auto lanName = action->objectName();
|
auto lanName = action->objectName();
|
||||||
qInfo() << "load translators" << lanName << translator.load("app_"+lanName, ":/i18n");
|
qInfo() << "load QT Translator" << lanName << qtTranslator.load("qt_"+lanName, QApplication::applicationDirPath()+"/translations");
|
||||||
|
qInfo() << "load APP Translator" << lanName << appTranslator.load("app_"+lanName, ":/i18n");
|
||||||
});
|
});
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
@ -181,7 +188,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
#endif
|
#endif
|
||||||
actLan->setChecked(true);
|
actLan->setChecked(true);
|
||||||
emit menuLang->triggered(actLan);
|
emit menuLang->triggered(actLan);
|
||||||
QCoreApplication::installTranslator(&translator);
|
QCoreApplication::installTranslator(&qtTranslator);
|
||||||
|
QCoreApplication::installTranslator(&appTranslator);
|
||||||
|
|
||||||
auto geo = settings.value("MainGeo").toRect();
|
auto geo = settings.value("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);
|
||||||
|
|
@ -227,12 +235,13 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
|
|
||||||
auto menu_setting = new QMenu;
|
auto menu_setting = new QMenu;
|
||||||
|
|
||||||
actFirmware = new QAction(tr("firmware manager"));
|
actFirmware = new QAction(tr("Firmware Manager"));
|
||||||
connect(actFirmware, &QAction::triggered, this, [this] {
|
connect(actFirmware, &QAction::triggered, this, [this] {
|
||||||
new UpgradeApkDialog(this);
|
new UpgradeApkDialog(this);
|
||||||
});
|
});
|
||||||
|
#ifndef leyide
|
||||||
menu_setting->addAction(actFirmware);
|
menu_setting->addAction(actFirmware);
|
||||||
|
#endif
|
||||||
actPreferences = new QAction(tr("Preferences"));
|
actPreferences = new QAction(tr("Preferences"));
|
||||||
connect(actPreferences, &QAction::triggered, this, [this] {
|
connect(actPreferences, &QAction::triggered, this, [this] {
|
||||||
QDialog dlg(this);
|
QDialog dlg(this);
|
||||||
|
|
@ -674,6 +683,117 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gTick = new Tick(this);
|
gTick = new Tick(this);
|
||||||
|
|
||||||
|
auto timer = new QTimer(this);
|
||||||
|
connect(timer, &QTimer::timeout, this, [=] {
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "GetApInfo");
|
||||||
|
json.insert("_type", "GetApInfo");
|
||||||
|
auto reply = NetReq("http://192.168.43.1:2016/settings").timeout(8000).post(json);
|
||||||
|
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||||
|
JValue json;
|
||||||
|
auto err = errStrWithJson(reply, &json);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
qDebug()<<"GetApInfo Error"<<err;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug()<<"GetApInfo"<<json;
|
||||||
|
auto connCount = json["connectionCount"].toInt();
|
||||||
|
if(connCount<=3) return;
|
||||||
|
auto pswd = json["apPassword"].toStr();
|
||||||
|
if(isStrongPswd(pswd)) return;
|
||||||
|
auto apName = json["apName"].toStr();
|
||||||
|
|
||||||
|
timer->stop();
|
||||||
|
auto dlg = new QDialog;
|
||||||
|
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
dlg->setWindowFlag(Qt::WindowCloseButtonHint, false);
|
||||||
|
dlg->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
|
dlg->setModal(true);
|
||||||
|
dlg->setWindowTitle("Change Hotspot Password");
|
||||||
|
dlg->resize(300, 200);
|
||||||
|
auto vBox = new VBox(dlg);
|
||||||
|
vBox->addStretch();
|
||||||
|
vBox->addLabel(translate("","The Device's Hotspot password is too weak, please change the password."));
|
||||||
|
vBox->addStretch();
|
||||||
|
vBox->addLabel(translate("","The password must have 8 characters at least and contain numbers, uppercase and lowercase letters"));
|
||||||
|
vBox->addStretch();
|
||||||
|
|
||||||
|
auto grid = new Grid(vBox);
|
||||||
|
grid->addLabel(translate("","Hotspot Name"),0,0);
|
||||||
|
grid->addLabel(apName, 0,1);
|
||||||
|
|
||||||
|
grid->addLabel(translate("","New password"),1,0);
|
||||||
|
auto ed = new QLineEdit;
|
||||||
|
grid->addWidget(ed,1,1);
|
||||||
|
grid->addLabel(translate("","Confirm password"),2,0);
|
||||||
|
auto ed2 = new QLineEdit;
|
||||||
|
grid->addWidget(ed2,2,1);
|
||||||
|
vBox->addStretch();
|
||||||
|
|
||||||
|
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
|
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
||||||
|
auto pswd = ed->text();
|
||||||
|
if(pswd.size()<8 || !isStrongPswd(pswd)) {
|
||||||
|
QMessageBox::warning(this, translate("","Tip"), translate("","The password must have 8 characters at least and contain numbers, uppercase and lowercase letters"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(pswd!=ed2->text()) {
|
||||||
|
QMessageBox::warning(this, translate("","Tip"), translate("","Two passwords are not same"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObj json;
|
||||||
|
json.insert("_id", "ConfigurationHotSpot");
|
||||||
|
json.insert("_type", "ConfigurationHotSpot");
|
||||||
|
json.insert("apName", apName);
|
||||||
|
//json.insert("apBand", edIs5G->isChecked() ? 1 : 0);
|
||||||
|
json.insert("password", pswd);
|
||||||
|
auto waitingDlg = new WaitingDlg(this, tr("Config Hotspot")+" ...");
|
||||||
|
waitingDlg->show();
|
||||||
|
auto reply = NetReq("http://192.168.43.1:2016/settings").post(json);
|
||||||
|
ConnReply(reply, waitingDlg) [=] {
|
||||||
|
waitingDlg->close();
|
||||||
|
auto err = errStrWithJson(reply);
|
||||||
|
if(! err.isEmpty()) {
|
||||||
|
QMessageBox::critical(this, translate("","Error"), err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QMessageBox::information(this, translate("","Tip"), translate("","Password changed successfully"));
|
||||||
|
dlg->accept();
|
||||||
|
timer->start(60000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
vBox->addWidget(btnBox);
|
||||||
|
dlg->show();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
timer->start(20000);
|
||||||
|
|
||||||
|
// DWORD clientVersion = 2;
|
||||||
|
// PDWORD version = 0;
|
||||||
|
// HANDLE clientHandle = 0;
|
||||||
|
// auto ret = WlanOpenHandle(clientVersion, 0, version, &clientHandle);
|
||||||
|
// if(ret != ERROR_SUCCESS) {
|
||||||
|
// qDebug() << "Failed to open a client handle."<<ret;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// PWLAN_INTERFACE_INFO_LIST interfaceList;
|
||||||
|
// ret = WlanEnumInterfaces(clientHandle, 0, &interfaceList);
|
||||||
|
// if(ret == ERROR_SUCCESS) {
|
||||||
|
// for(DWORD i=0; i<interfaceList->dwNumberOfItems; i++) {
|
||||||
|
// auto interfaceInfo = &interfaceList->InterfaceInfo[i];
|
||||||
|
// if(interfaceInfo->isState==wlan_interface_state_connected) {
|
||||||
|
// //WCHAR* ssidName = interfaceInfo->CurrentConnection.wlanAssociationAttributes.dot11Ssid;
|
||||||
|
// //QString wifiName = QString::fromWCharArray(ssidName);
|
||||||
|
// //qDebug() << "Current WiFi Name:" << wifiName;
|
||||||
|
// qDebug() << "Current WiFi Name:" << interfaceInfo->strInterfaceDescription;
|
||||||
|
// break; // Assuming you only want the first connected interface's SSID.
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// qDebug() << "Failed to get interface list.";
|
||||||
|
// }
|
||||||
|
// WlanCloseHandle(clientHandle, 0);
|
||||||
}
|
}
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
@ -711,7 +831,7 @@ void MainWindow::transUi() {
|
||||||
act_help->setText(tr("Help"));
|
act_help->setText(tr("Help"));
|
||||||
if(act_about) act_about->setText(tr("About"));
|
if(act_about) act_about->setText(tr("About"));
|
||||||
if(act_upd) act_upd->setText(tr("Check for updates"));
|
if(act_upd) act_upd->setText(tr("Check for updates"));
|
||||||
actFirmware->setText(tr("firmware manager"));
|
actFirmware->setText(tr("Firmware Manager"));
|
||||||
actPreferences->setText(tr("Preferences"));
|
actPreferences->setText(tr("Preferences"));
|
||||||
bn_Setting->setToolTip(tr("Setting"));
|
bn_Setting->setToolTip(tr("Setting"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ protected:
|
||||||
void transUi();
|
void transUi();
|
||||||
private:
|
private:
|
||||||
QJsonObject updates;
|
QJsonObject updates;
|
||||||
QTranslator translator;
|
QTranslator qtTranslator, appTranslator;
|
||||||
LoQTitleBar *m_wTitle;
|
LoQTitleBar *m_wTitle;
|
||||||
QActionGroup *langGrp;
|
QActionGroup *langGrp;
|
||||||
QAction *act_lang;
|
QAction *act_lang;
|
||||||
|
|
|
||||||
|
|
@ -3,78 +3,68 @@
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
EleScroll::EleScroll(QWidget *parent, QString dirPre, const JValue &json, int w, int h) : QWidget{parent}, w(w), h(h) {
|
EleScroll::EleScroll(QWidget *parent, QList<QPixmap> imgs, char direct, double speed) : QWidget{parent}, imgs(imgs), direct(direct) {
|
||||||
img.load(dirPre + json["id"].toString());
|
auto img0 = imgs[0];
|
||||||
auto effStr = json["effect"].toString();
|
qDebug().nospace()<<" SrcScroll img cnt "<<imgs.size()<<", "<<img0.width()<<"x"<<img0.height()<<" direct "<<direct<<" speed "<<speed;
|
||||||
if(effStr.isEmpty() || effStr=="no") return;
|
if(speed==0) return;
|
||||||
|
int width = 0, height = 0;
|
||||||
|
for(auto &img : imgs) {
|
||||||
|
width += img.width();
|
||||||
|
height += img.height();
|
||||||
|
}
|
||||||
|
if(direct=='l') end = -(width-step);
|
||||||
|
else if(direct=='r') end = width-step;
|
||||||
|
else if(direct=='t') end = -(height-step);
|
||||||
|
else if(direct=='b') end = height-step;
|
||||||
|
else direct = 0;
|
||||||
|
if(direct==0) return;
|
||||||
|
|
||||||
auto scrollSpeed = json["scrollSpeed"].toDouble();
|
|
||||||
if(scrollSpeed==0) {
|
|
||||||
auto scrollDur = json["effectSpeed"].toDouble();
|
|
||||||
if(scrollDur==0) return;
|
|
||||||
scrollSpeed = 1000 / scrollDur;
|
|
||||||
}
|
|
||||||
interval = step = 1;
|
interval = step = 1;
|
||||||
if(scrollSpeed > 60) step = (int) round(scrollSpeed/60);
|
if(speed > 60) step = (int) round(speed/60);
|
||||||
else if(scrollSpeed < 60) interval = (int) round(60/scrollSpeed);
|
else if(speed < 60) interval = (int) round(60/speed);
|
||||||
int idx = effStr.lastIndexOf(' ');
|
|
||||||
if(idx > -1) {
|
|
||||||
effect = effStr.at(idx+1).toLatin1();
|
|
||||||
if(effect=='l') end = -(img.width()-step);
|
|
||||||
else if(effect=='r') end = img.width()-step;
|
|
||||||
else if(effect=='t') end = -(img.height()-step);
|
|
||||||
else if(effect=='b') end = img.height()-step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EleScroll::EleScroll(QWidget *parent, QString imgPath, char effect, double scrollSpeed) : QWidget{parent}, effect(effect) {
|
|
||||||
img.load(imgPath);
|
|
||||||
if(effect==0) return;
|
|
||||||
if(scrollSpeed==0) return;
|
|
||||||
interval = step = 1;
|
|
||||||
if(scrollSpeed > 60) step = (int) round(scrollSpeed/60);
|
|
||||||
else if(scrollSpeed < 60) interval = (int) round(60/scrollSpeed);
|
|
||||||
if(effect=='l') end = -(img.width()-step);
|
|
||||||
else if(effect=='r') end = img.width()-step;
|
|
||||||
else if(effect=='t') end = -(img.height()-step);
|
|
||||||
else if(effect=='b') end = img.height()-step;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EleScroll::paintEvent(QPaintEvent *e) {
|
void EleScroll::paintEvent(QPaintEvent *e) {
|
||||||
if(img.isNull()) return;
|
if(imgs.isEmpty()) return;
|
||||||
auto rect = e->rect();
|
auto rect = e->rect();
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||||
if(effect=='l') {
|
if(direct=='l') {
|
||||||
int x = cur;
|
int ii = 0, x = cur;
|
||||||
do {
|
do {
|
||||||
if(x > rect.left()-img.width() && x < rect.right()+1) painter.drawPixmap(x, 0, img);
|
if(x > rect.left()-imgs[ii].width() && x < rect.right()+1) painter.drawPixmap(x, 0, imgs[ii]);
|
||||||
x += img.width();
|
x += imgs[ii].width();
|
||||||
|
if(++ii >= imgs.size()) ii = 0;
|
||||||
} while(x < rect.right()+1);
|
} while(x < rect.right()+1);
|
||||||
} else if(effect=='r') {
|
} else if(direct=='r') {
|
||||||
int x = cur + w;
|
int ii = imgs.size()-1, x = cur + width();
|
||||||
bool con1;
|
bool con1;
|
||||||
do {
|
do {
|
||||||
x -= img.width();
|
x -= imgs[ii].width();
|
||||||
con1 = x > rect.left()-img.width();
|
con1 = x > rect.left()-imgs[ii].width();
|
||||||
if(con1 && x < rect.right()+1) painter.drawPixmap(x, 0, img);
|
if(con1 && x < rect.right()+1) painter.drawPixmap(x, 0, imgs[ii]);
|
||||||
|
if(--ii < 0) ii = imgs.size()-1;
|
||||||
} while(con1);
|
} while(con1);
|
||||||
} else if(effect=='t') {
|
} else if(direct=='t') {
|
||||||
int y = cur;
|
int ii = 0, y = cur;
|
||||||
do {
|
do {
|
||||||
if(y > rect.top()-img.height() && y < rect.bottom()+1) painter.drawPixmap(0, y, img);
|
if(y > rect.top()-imgs[ii].height() && y < rect.bottom()+1) painter.drawPixmap(0, y, imgs[ii]);
|
||||||
y += img.height();
|
y += imgs[ii].height();
|
||||||
|
if(++ii >= imgs.size()) ii = 0;
|
||||||
} while(y < rect.bottom()+1);
|
} while(y < rect.bottom()+1);
|
||||||
} else if(effect=='b') {
|
} else if(direct=='b') {
|
||||||
int y = cur + h;
|
int ii = imgs.size()-1, y = cur + height();
|
||||||
bool con1;
|
bool con1;
|
||||||
do {
|
do {
|
||||||
y -= img.height();
|
y -= imgs[ii].height();
|
||||||
con1 = y > rect.top()-img.height();
|
con1 = y > rect.top()-imgs[ii].height();
|
||||||
if(con1 && y < rect.bottom()+1) painter.drawPixmap(0, y, img);
|
if(con1 && y < rect.bottom()+1) painter.drawPixmap(0, y, imgs[ii]);
|
||||||
|
if(--ii < 0) ii = imgs.size()-1;
|
||||||
} while(con1);
|
} while(con1);
|
||||||
} else painter.drawPixmap(0, 0, img);
|
} else painter.drawPixmap(0, 0, imgs[0]);
|
||||||
if(freshCnt==0 && effect!=0 && interval!=0) connect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, &EleScroll::doFrame, Qt::UniqueConnection);
|
if(freshCnt==0 && direct!=0 && interval!=0) connect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, &EleScroll::doFrame, Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EleScroll::doFrame() {
|
void EleScroll::doFrame() {
|
||||||
|
|
@ -86,10 +76,10 @@ void EleScroll::doFrame() {
|
||||||
if(freshCnt < interval) freshCnt++;
|
if(freshCnt < interval) freshCnt++;
|
||||||
else {
|
else {
|
||||||
freshCnt = 1;
|
freshCnt = 1;
|
||||||
if(effect=='t' || effect=='l') {
|
if(direct=='t' || direct=='l') {
|
||||||
if(cur <= end) cur -= end;
|
if(cur <= end) cur -= end;
|
||||||
else cur -= step;
|
else cur -= step;
|
||||||
} else if(effect=='b' || effect=='r') {
|
} else if(direct=='b' || direct=='r') {
|
||||||
if(cur >= end) cur -= end;
|
if(cur >= end) cur -= end;
|
||||||
else cur += step;
|
else cur += step;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,10 @@ class EleScroll : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EleScroll(QWidget *, QString, const JValue &, int, int);
|
explicit EleScroll(QWidget *, QString, const JValue &, int, int);
|
||||||
explicit EleScroll(QWidget *, QString, char effect = 0, double effDur = 0.0);
|
explicit EleScroll(QWidget *parent, QList<QPixmap> imgs, char direct = 0, double speed = 0.0);
|
||||||
int w = 0, h = 0;
|
QList<QPixmap> imgs;
|
||||||
QPixmap img;
|
char direct = 0;
|
||||||
char effect = 0;
|
|
||||||
int interval = 0, freshCnt = 0, cur = 0, end = 0, step = 1;
|
int interval = 0, freshCnt = 0, cur = 0, end = 0, step = 1;
|
||||||
bool noUpdate = false;
|
|
||||||
void doFrame();
|
void doFrame();
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
|
||||||
|
|
@ -120,15 +120,36 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const JValue
|
||||||
lb->setScaledContents(true);
|
lb->setScaledContents(true);
|
||||||
src.view = lb;
|
src.view = lb;
|
||||||
}
|
}
|
||||||
|
} else if(src.type=="Scroll") {
|
||||||
|
auto imgs = source["imgs"];
|
||||||
|
if(imgs.empty()) continue;
|
||||||
|
QList<QPixmap> images;
|
||||||
|
for(auto &img : imgs) images.push_back(QPixmap(dir+"/"+img.toStr()));
|
||||||
|
auto directStr = source["direct"].toStr();
|
||||||
|
src.view = new EleScroll(box, images, directStr.isEmpty() ? 0 : directStr[0].toLatin1(), source["speed"].toInt());
|
||||||
|
} else if(src.type=="MultiPng") {
|
||||||
|
auto imgs = source["arrayPics"];
|
||||||
|
if(imgs.empty()) continue;
|
||||||
|
QList<QPixmap> images;
|
||||||
|
for(auto &img : imgs) images.push_back(QPixmap(dir+"/"+img["id"].toStr()));
|
||||||
|
auto speed = imgs[0]["scrollSpeed"].toDouble();
|
||||||
|
if(speed==0) {
|
||||||
|
auto scrollDur = imgs[0]["effectSpeed"].toDouble();
|
||||||
|
if(scrollDur!=0) speed = 1000 / scrollDur;
|
||||||
|
}
|
||||||
|
char direct = 0;
|
||||||
|
auto directStr = imgs[0]["effect"].toStr();
|
||||||
|
if(! directStr.isEmpty() && directStr!="no") {
|
||||||
|
int idx = directStr.lastIndexOf(' ');
|
||||||
|
if(idx > -1) direct = directStr[idx+1].toLatin1();
|
||||||
|
}
|
||||||
|
src.view = new EleScroll(box, images, direct, speed);
|
||||||
} else if(src.type.startsWith("Environ")) {
|
} else if(src.type.startsWith("Environ")) {
|
||||||
auto previewImg = source["previewImg"].toStr();
|
auto previewImg = source["previewImg"].toStr();
|
||||||
if(! previewImg.isEmpty()) {
|
if(! previewImg.isEmpty()) {
|
||||||
if(source["bSingleScroll"].toBool()) src.view = new EleScroll(box, dir+"/"+previewImg, 'l', source["iScrollSpeed"].toDouble());
|
if(source["bSingleScroll"].toBool()) src.view = new EleScroll(box, {QPixmap(dir+"/"+previewImg)}, 'l', source["iScrollSpeed"].toDouble());
|
||||||
else src.view = new EleScroll(box, dir+"/"+previewImg);
|
else src.view = new EleScroll(box, {QPixmap(dir+"/"+previewImg)});
|
||||||
}
|
}
|
||||||
} else if(src.type=="MultiPng" || src.type=="SplitText") {
|
|
||||||
auto imgs = source["arrayPics"];
|
|
||||||
if(! imgs.empty()) src.view = new EleScroll(box, dir+"/", imgs[0], w, h);
|
|
||||||
} else if(src.type=="DigitalClockNew") src.view = new EleDigiClock(dir+"/", source, box);
|
} else if(src.type=="DigitalClockNew") src.view = new EleDigiClock(dir+"/", source, box);
|
||||||
else if(src.type=="AnalogClock") src.view = new EleAnaClock(w, h, dir+"/"+id, source, box);
|
else if(src.type=="AnalogClock") src.view = new EleAnaClock(w, h, dir+"/"+id, source, box);
|
||||||
else if(src.type=="Video" || src.type=="Audio") {
|
else if(src.type=="Video" || src.type=="Audio") {
|
||||||
|
|
|
||||||
|
|
@ -569,7 +569,7 @@ bool EAClock::save(const QString &pRoot){
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
JObj EAClock::attrJson() const {
|
JObj EAClock::attrJson() {
|
||||||
JObj json;
|
JObj json;
|
||||||
json["elementType"] = "AClock";
|
json["elementType"] = "AClock";
|
||||||
json["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
|
json["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public:
|
||||||
int type() const override { return EBase::AClock; }
|
int type() const override { return EBase::AClock; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &pRoot) override;
|
bool save(const QString &pRoot) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent *) override;
|
void timerEvent(QTimerEvent *) override;
|
||||||
|
|
|
||||||
|
|
@ -721,7 +721,7 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
auto borderFd = new QComboBox;
|
auto borderFd = new QComboBox;
|
||||||
borderFd->addItem(tr("None"));
|
borderFd->addItem(tr("None"));
|
||||||
for(int i=0; i<borderImgs.size(); i++) borderFd->addItem(QIcon(borderImgs[i].img), QString::number(borderImgs[i].img.height()), borderImgs[i].name);
|
for(auto borderImg : borderImgs) borderFd->addItem(QIcon(borderImg.img), QString::number(borderImg.img.height()), borderImg.name);
|
||||||
borderFd->setIconSize(QSize(borderImgMaxWidth, borderImgMaxHeight));
|
borderFd->setIconSize(QSize(borderImgMaxWidth, borderImgMaxHeight));
|
||||||
if(bdImgIdx>-1) borderFd->setCurrentIndex(bdImgIdx+1);
|
if(bdImgIdx>-1) borderFd->setCurrentIndex(bdImgIdx+1);
|
||||||
connect(borderFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int idx){
|
connect(borderFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int idx){
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||||
|
|
||||||
virtual JObj attrJson() const = 0;
|
virtual JObj attrJson() = 0;
|
||||||
virtual bool save(const QString &) {return true;}
|
virtual bool save(const QString &) {return true;}
|
||||||
virtual QWidget* attrWgt() = 0;
|
virtual QWidget* attrWgt() = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ QWidget* EDClock::attrWgt() {
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EDClock::attrJson() const {
|
JObj EDClock::attrJson() {
|
||||||
JObj json;
|
JObj json;
|
||||||
addBaseAttr(json);
|
addBaseAttr(json);
|
||||||
json["elementType"] = "DClock";
|
json["elementType"] = "DClock";
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
int type() const override { return EBase::DClock; }
|
int type() const override { return EBase::DClock; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
QTimeZone timeZone;
|
QTimeZone timeZone;
|
||||||
QFont font = qfont("Arial", 12);
|
QFont font = qfont("Arial", 12);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ JObj EEnviron::genProg(const JValue &json, const QString &dstDir, const QString
|
||||||
Tools::saveImg(dstDir, metric, font, color, values, tr("W"), "W");
|
Tools::saveImg(dstDir, metric, font, color, values, tr("W"), "W");
|
||||||
Tools::saveImg(dstDir, metric, font, color, values, tr("NW"), "NW");
|
Tools::saveImg(dstDir, metric, font, color, values, tr("NW"), "NW");
|
||||||
res["values"] = values;
|
res["values"] = values;
|
||||||
|
auto hideUnits = json["hideUnits"].toBool();
|
||||||
JArray oitems;
|
JArray oitems;
|
||||||
std::unordered_map<QString, QString> unitMap;
|
std::unordered_map<QString, QString> unitMap;
|
||||||
auto itemMap = genItemMap();
|
auto itemMap = genItemMap();
|
||||||
|
|
@ -61,6 +61,7 @@ JObj EEnviron::genProg(const JValue &json, const QString &dstDir, const QString
|
||||||
oitems->push_back(JObj{{"name", pair.first}});
|
oitems->push_back(JObj{{"name", pair.first}});
|
||||||
auto oitem = oitems->back().toObj();
|
auto oitem = oitems->back().toObj();
|
||||||
Tools::saveImg(dstDir, metric, font, color, oitem, pair.second["label"].toString(), "label");
|
Tools::saveImg(dstDir, metric, font, color, oitem, pair.second["label"].toString(), "label");
|
||||||
|
if(hideUnits) continue;
|
||||||
auto unit = itemMap[pair.first].unit;
|
auto unit = itemMap[pair.first].unit;
|
||||||
if(unit.isEmpty()) continue;
|
if(unit.isEmpty()) continue;
|
||||||
auto &url = unitMap[unit];
|
auto &url = unitMap[unit];
|
||||||
|
|
@ -101,6 +102,7 @@ EEnviron::EEnviron(const JObj &json, EBase *multiWin): EBase(multiWin){
|
||||||
textColor = json["textColor"].toStr("#ff000000");
|
textColor = json["textColor"].toStr("#ff000000");
|
||||||
tempCompen = json["tempCompen"].toInt();
|
tempCompen = json["tempCompen"].toInt();
|
||||||
useFahrenheit = json["useFahrenheit"].toInt();
|
useFahrenheit = json["useFahrenheit"].toInt();
|
||||||
|
hideUnits = json["hideUnits"].toBool();
|
||||||
title = json["title"].toStr();
|
title = json["title"].toStr();
|
||||||
isSingleLine = json["isSingleLine"].toBool();
|
isSingleLine = json["isSingleLine"].toBool();
|
||||||
scrollSpeed = json["scrollSpeed"].toInt();
|
scrollSpeed = json["scrollSpeed"].toInt();
|
||||||
|
|
@ -161,7 +163,8 @@ void EEnviron::calAttr() {
|
||||||
if(item.first=="temp") scroll_txt += QString::number(tempCompen);
|
if(item.first=="temp") scroll_txt += QString::number(tempCompen);
|
||||||
else if(item.first=="windDirection") scroll_txt += "--";
|
else if(item.first=="windDirection") scroll_txt += "--";
|
||||||
else scroll_txt += "0";
|
else scroll_txt += "0";
|
||||||
scroll_txt += item.second.unit + " ";
|
if(! hideUnits) scroll_txt += item.second.unit;
|
||||||
|
scroll_txt += " ";
|
||||||
}
|
}
|
||||||
scroll_width = QFontMetrics(font).horizontalAdvance(scroll_txt);
|
scroll_width = QFontMetrics(font).horizontalAdvance(scroll_txt);
|
||||||
}
|
}
|
||||||
|
|
@ -187,7 +190,7 @@ void EEnviron::drawText(QPainter *painter, QRectF& rect) {
|
||||||
if(itemPair.first=="temp") text += QString::number(tempCompen);
|
if(itemPair.first=="temp") text += QString::number(tempCompen);
|
||||||
else if(itemPair.first=="windDirection") text += "--";
|
else if(itemPair.first=="windDirection") text += "--";
|
||||||
else text += "0";
|
else text += "0";
|
||||||
text += itemPair.second.unit;
|
if(! hideUnits) text += itemPair.second.unit;
|
||||||
painter->drawText(rect, text, opt);
|
painter->drawText(rect, text, opt);
|
||||||
rect.translate(0, rect.height());
|
rect.translate(0, rect.height());
|
||||||
}
|
}
|
||||||
|
|
@ -280,7 +283,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
hBox->addWidget(fdIsCelsius);
|
hBox->addWidget(fdIsCelsius);
|
||||||
|
|
||||||
auto fdIsFahrenheit = new QRadioButton("℉");
|
auto fdIsFahrenheit = new QRadioButton("℉");
|
||||||
connect(fdIsFahrenheit, &QRadioButton::toggled, this, [this](bool checked) {
|
connect(fdIsFahrenheit, &QRadioButton::toggled, this, [=](bool checked) {
|
||||||
useFahrenheit = checked;
|
useFahrenheit = checked;
|
||||||
calAttr();
|
calAttr();
|
||||||
update();
|
update();
|
||||||
|
|
@ -307,7 +310,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
hBox->addWidget(new QLabel(tr("Compensation")));
|
hBox->addLabel(tr("Compensation"));
|
||||||
|
|
||||||
auto fdCompen = new QSpinBox;
|
auto fdCompen = new QSpinBox;
|
||||||
fdCompen->setRange(-99, 999);
|
fdCompen->setRange(-99, 999);
|
||||||
|
|
@ -321,6 +324,17 @@ QWidget* EEnviron::attrWgt() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
auto edHideUnits = new QCheckBox("Hide Units");
|
||||||
|
if(hideUnits) edHideUnits->setChecked(true);
|
||||||
|
connect(edHideUnits, &QRadioButton::toggled, this, [=](bool checked) {
|
||||||
|
hideUnits = checked;
|
||||||
|
calAttr();
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
hBox->addWidget(edHideUnits);
|
||||||
|
|
||||||
auto wgtAlign = new QWidget;
|
auto wgtAlign = new QWidget;
|
||||||
vBox->addWidget(wgtAlign);
|
vBox->addWidget(wgtAlign);
|
||||||
hBox = new HBox(wgtAlign);
|
hBox = new HBox(wgtAlign);
|
||||||
|
|
@ -329,7 +343,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
|
|
||||||
auto fdLeft = new QRadioButton(tr("Left"));
|
auto fdLeft = new QRadioButton(tr("Left"));
|
||||||
fdLeft->setChecked(true);
|
fdLeft->setChecked(true);
|
||||||
connect(fdLeft, &QRadioButton::toggled, this, [this](bool checked) {
|
connect(fdLeft, &QRadioButton::toggled, this, [=](bool checked) {
|
||||||
if(! checked) return;
|
if(! checked) return;
|
||||||
align = 0;
|
align = 0;
|
||||||
calAttr();
|
calAttr();
|
||||||
|
|
@ -338,7 +352,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
hBox->addWidget(fdLeft);
|
hBox->addWidget(fdLeft);
|
||||||
|
|
||||||
auto fdCenter = new QRadioButton(tr("Center"));
|
auto fdCenter = new QRadioButton(tr("Center"));
|
||||||
connect(fdCenter, &QRadioButton::toggled, this, [this](bool checked) {
|
connect(fdCenter, &QRadioButton::toggled, this, [=](bool checked) {
|
||||||
if(! checked) return;
|
if(! checked) return;
|
||||||
align = 1;
|
align = 1;
|
||||||
calAttr();
|
calAttr();
|
||||||
|
|
@ -347,7 +361,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
hBox->addWidget(fdCenter);
|
hBox->addWidget(fdCenter);
|
||||||
|
|
||||||
auto fdRight = new QRadioButton(tr("Right"));
|
auto fdRight = new QRadioButton(tr("Right"));
|
||||||
connect(fdRight, &QRadioButton::toggled, this, [this](bool checked) {
|
connect(fdRight, &QRadioButton::toggled, this, [=](bool checked) {
|
||||||
if(! checked) return;
|
if(! checked) return;
|
||||||
align = 2;
|
align = 2;
|
||||||
calAttr();
|
calAttr();
|
||||||
|
|
@ -490,7 +504,7 @@ QWidget* EEnviron::attrWgt() {
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EEnviron::attrJson() const{
|
JObj EEnviron::attrJson() {
|
||||||
JObj json;
|
JObj json;
|
||||||
addBaseAttr(json);
|
addBaseAttr(json);
|
||||||
json["elementType"] = "Temp";
|
json["elementType"] = "Temp";
|
||||||
|
|
@ -503,6 +517,7 @@ JObj EEnviron::attrJson() const{
|
||||||
json["items"] = items;
|
json["items"] = items;
|
||||||
json["tempCompen"] = tempCompen;
|
json["tempCompen"] = tempCompen;
|
||||||
json["useFahrenheit"] = useFahrenheit;
|
json["useFahrenheit"] = useFahrenheit;
|
||||||
|
json["hideUnits"] = hideUnits;
|
||||||
json["isSingleLine"] = isSingleLine;
|
json["isSingleLine"] = isSingleLine;
|
||||||
json["scrollSpeed"] = scrollSpeed;
|
json["scrollSpeed"] = scrollSpeed;
|
||||||
json["align"] = align;
|
json["align"] = align;
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ public:
|
||||||
int tempCompen = 0;
|
int tempCompen = 0;
|
||||||
int align = 0;
|
int align = 0;
|
||||||
int scrollSpeed = 30;
|
int scrollSpeed = 30;
|
||||||
bool useFahrenheit = false;
|
bool useFahrenheit = false, isSingleLine = false, hideUnits = false;
|
||||||
bool isSingleLine = false;
|
|
||||||
|
|
||||||
static JObj genProg(const JValue &, const QString &, const QString &);
|
static JObj genProg(const JValue &, const QString &, const QString &);
|
||||||
|
|
||||||
|
|
@ -54,7 +53,7 @@ public:
|
||||||
int type() const override { return EBase::Environ; }
|
int type() const override { return EBase::Environ; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &pRoot) override;
|
bool save(const QString &pRoot) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "etimer.h"
|
#include "etimer.h"
|
||||||
#include "eenviron.h"
|
#include "eenviron.h"
|
||||||
#include "eweb.h"
|
#include "eweb.h"
|
||||||
|
#include "etable.h"
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
|
@ -28,13 +29,14 @@ EMultiWin::EMultiWin(const JObj &json, PageListItem *pageItem) : mPageItem(pageI
|
||||||
QString type = element["elementType"].toString();
|
QString type = element["elementType"].toString();
|
||||||
EBase *inner = 0;
|
EBase *inner = 0;
|
||||||
if(type=="Text") inner = new EText(element.toObj(), this);
|
if(type=="Text") inner = new EText(element.toObj(), this);
|
||||||
else if(type=="Image" || type=="Photo" || type=="Gif") inner = EPhoto::create(element.toObj(), pageItem, this);
|
else if(type=="Image" || type=="Photo" || type=="Gif") inner = EPhoto::create(element.toObj(), pageItem->mPageDir, this);
|
||||||
else if(type=="Video"||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);
|
||||||
else if(type=="Web") inner = new EWeb(element.toObj(), this);
|
else if(type=="Web") inner = new EWeb(element.toObj(), this);
|
||||||
else if(type=="Timer") inner = new ETimer(element.toObj(), this);
|
else if(type=="Timer") inner = new ETimer(element.toObj(), this);
|
||||||
|
else if(type=="Table") inner = new ETable(element.toObj(), pageItem->mPageDir, this);
|
||||||
if(inner==0) continue;
|
if(inner==0) continue;
|
||||||
inner->setPos(0, 0);
|
inner->setPos(0, 0);
|
||||||
inner->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
inner->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||||
|
|
@ -66,7 +68,7 @@ bool EMultiWin::save(const QString &pageDir) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EMultiWin::attrJson() const{
|
JObj EMultiWin::attrJson() {
|
||||||
JArray eles;
|
JArray eles;
|
||||||
for(auto inner : inners) eles.append(inner->attrJson());
|
for(auto inner : inners) eles.append(inner->attrJson());
|
||||||
JObj oRoot;
|
JObj oRoot;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public:
|
||||||
int type() const override { return EBase::Window; }
|
int type() const override { return EBase::Window; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &) override;
|
bool save(const QString &) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
void setCur(EBase *);
|
void setCur(EBase *);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,15 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
EPhoto *EPhoto::create(const JObj &json, PageListItem *pageItem, EBase *multiWin) {
|
EPhoto *EPhoto::create(const JObj &json, const QString &dir, EBase *multiWin) {
|
||||||
auto widget = json["widget"];
|
auto widget = json["widget"];
|
||||||
auto name = (widget.isNull() ? json["name"] : widget["file"]).toString();
|
auto name = (widget.isNull() ? json["name"] : widget["file"]).toString();
|
||||||
auto file = pageItem->mPageDir + "/" + name;
|
auto file = dir + "/" + name;
|
||||||
QImageReader reader(file);
|
QImageReader reader(file);
|
||||||
reader.setAutoTransform(true);
|
reader.setAutoTransform(true);
|
||||||
auto img = reader.read();
|
auto img = reader.read();
|
||||||
if(img.isNull()) return 0;
|
if(img.isNull()) return 0;
|
||||||
auto ins = new EPhoto(reader, img, pageItem->mPageDir, name, json, multiWin);
|
auto ins = new EPhoto(reader, img, dir, name, json, multiWin);
|
||||||
ins->setBaseAttr(json);
|
ins->setBaseAttr(json);
|
||||||
return ins;
|
return ins;
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ EPhoto::EPhoto(QImageReader &reader, const QImage &img, const QString &dir, cons
|
||||||
speed = json["speed"].toInt();
|
speed = json["speed"].toInt();
|
||||||
tailSpacing = json["tailSpacing"].toInt();
|
tailSpacing = json["tailSpacing"].toInt();
|
||||||
}
|
}
|
||||||
JObj EPhoto::attrJson() const {
|
JObj EPhoto::attrJson() {
|
||||||
JObj json;
|
JObj json;
|
||||||
addBaseAttr(json);
|
addBaseAttr(json);
|
||||||
json["elementType"] = frames.empty() ? "Image" : "Gif";
|
json["elementType"] = frames.empty() ? "Image" : "Gif";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
#define EPHOTO_H
|
#define EPHOTO_H
|
||||||
|
|
||||||
#include "ebase.h"
|
#include "ebase.h"
|
||||||
#include "pagelistitem.h"
|
|
||||||
#include "synctimer.h"
|
#include "synctimer.h"
|
||||||
|
|
||||||
struct Frame {
|
struct Frame {
|
||||||
|
|
@ -13,14 +12,14 @@ struct Frame {
|
||||||
class EPhoto : public EBase {
|
class EPhoto : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static QString filters() { return tr("Images (*.png *.jpg *.jpeg *.bmp *.gif)"); }
|
static QString filters() { return tr("Images")+" (*.png *.jpg *.jpeg *.bmp *.gif)"; }
|
||||||
static EPhoto *create(const JObj &, PageListItem *pageItem, EBase *multiWin = 0);
|
static EPhoto *create(const JObj &, const QString &dir, EBase *multiWin = 0);
|
||||||
|
|
||||||
explicit EPhoto(QImageReader &reader, const QImage &, const QString &dir, const QString &name, const JObj &json, EBase *multiWin = 0);
|
explicit EPhoto(QImageReader &reader, const QImage &, const QString &dir, const QString &name, const JObj &json, EBase *multiWin = 0);
|
||||||
|
|
||||||
int type() const override { return EBase::Image; }
|
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() override;
|
||||||
bool save(const QString &pageDir) override;
|
bool save(const QString &pageDir) override;
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,50 +4,383 @@
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "xlsxcellrange.h"
|
#include <QFontComboBox>
|
||||||
#include "xlsxchart.h"
|
#include <QButtonGroup>
|
||||||
#include "xlsxchartsheet.h"
|
#include <QBuffer>
|
||||||
#include "xlsxdocument.h"
|
#include "xlsxdocument.h"
|
||||||
#include "xlsxrichstring.h"
|
#include "xlsxformat.h"
|
||||||
#include "xlsxworkbook.h"
|
#include "xlsxworkbook.h"
|
||||||
#include "xlsxworksheet.h"
|
|
||||||
|
|
||||||
ETable::ETable(EBase *multiWin) : EBase(multiWin) {
|
ETable::ETable(int row, int col, EBase *multiWin) : EBase(multiWin) {
|
||||||
|
init(row, col);
|
||||||
|
}
|
||||||
|
ETable::ETable(const JObj &json, const QString &dir, EBase *multiWin) : EBase(multiWin) {
|
||||||
mType = EBase::Table;
|
mType = EBase::Table;
|
||||||
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
setBaseAttr(json);
|
||||||
dlg.resize(600, 600);
|
name = json["name"].toStr();
|
||||||
|
direction = json["direction"].toStr();
|
||||||
|
speed = json["speed"].toInt();
|
||||||
|
img = QPixmap(dir+"/"+name+".png");
|
||||||
|
init();
|
||||||
|
edGridColor->setColor(json["gridColor"].toString());
|
||||||
|
|
||||||
|
QXlsx::Document doc(dir+"/"+name+".xlsx");
|
||||||
|
auto sheet = doc.currentWorksheet();
|
||||||
|
if(doc.isLoadPackage() && sheet) read(sheet);
|
||||||
|
else {
|
||||||
|
table->setRowCount(8);
|
||||||
|
table->setColumnCount(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ETable::init(int row, int col) {
|
||||||
|
mType = EBase::Table;
|
||||||
|
dlg.setWindowModality(Qt::ApplicationModal);
|
||||||
|
dlg.resize(1024, 800);
|
||||||
dlg.setWindowTitle(tr("Table Editor"));
|
dlg.setWindowTitle(tr("Table Editor"));
|
||||||
auto vBox = new VBox(&dlg);
|
auto vBox = new VBox(&dlg);
|
||||||
vBox->setContentsMargins(6, 0, 6, 0);
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
|
vBox->setSpacing(4);
|
||||||
|
|
||||||
|
table = row==0 ? new PaintTableWidget : new PaintTableWidget(row, col);
|
||||||
|
table->ebase = this;
|
||||||
|
|
||||||
auto hBox = new HBox(vBox);
|
auto hBox = new HBox(vBox);
|
||||||
hBox = new HBox(vBox);
|
auto vv = new VBox(hBox);
|
||||||
table = new TableWidget(8, 3);
|
auto hh = new HBox(vv);
|
||||||
|
auto edFontFamily = new QFontComboBox;
|
||||||
|
edFontFamily->setEditable(false);
|
||||||
|
edFontFamily->setCurrentFont(QFont("Calibri"));
|
||||||
|
connect(edFontFamily, &QFontComboBox::currentFontChanged, table, [=](const QFont &f) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto ft = item->font();
|
||||||
|
ft.setFamily(f.family());
|
||||||
|
item->setFont(ft);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edFontFamily);
|
||||||
|
|
||||||
|
hh = new HBox(vv);
|
||||||
|
|
||||||
|
auto edFontSize = new QSpinBox;
|
||||||
|
edFontSize->setRange(4, 9999);
|
||||||
|
edFontSize->setValue(11);
|
||||||
|
connect(edFontSize, &QSpinBox::valueChanged, table, [=](int value) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
if(value <= 0) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto ft = item->font();
|
||||||
|
ft.setPointSize(value);
|
||||||
|
item->setFont(ft);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edFontSize);
|
||||||
|
|
||||||
|
auto edFontBold = new QPushButton("B");
|
||||||
|
edFontBold->setToolTip(tr("Bold"));
|
||||||
|
edFontBold->setStyleSheet("QPushButton{background: #ddd; color: #444; font-size: 16px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
|
edFontBold->setFixedSize(26, 26);
|
||||||
|
edFontBold->setCheckable(true);
|
||||||
|
connect(edFontBold, &QPushButton::toggled, this, [=](bool checked) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto ft = item->font();
|
||||||
|
ft.setBold(checked);
|
||||||
|
item->setFont(ft);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edFontBold);
|
||||||
|
|
||||||
|
auto edFontItalic = new QPushButton("I");
|
||||||
|
edFontItalic->setToolTip(tr("Italic"));
|
||||||
|
edFontItalic->setStyleSheet("QPushButton{background: #ddd; color: #444; font-size: 16px; font-weight: bold; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
|
edFontItalic->setFixedSize(26, 26);
|
||||||
|
edFontItalic->setCheckable(true);
|
||||||
|
connect(edFontItalic, &QPushButton::toggled, this, [=](bool checked) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto ft = item->font();
|
||||||
|
ft.setItalic(checked);
|
||||||
|
item->setFont(ft);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edFontItalic);
|
||||||
|
|
||||||
|
auto edFontUnderline = new QPushButton("U");
|
||||||
|
edFontUnderline->setToolTip(tr("Underline"));
|
||||||
|
edFontUnderline->setStyleSheet("QPushButton{background: #ddd; color: #444; font-size: 16px; font-weight: bold; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
|
edFontUnderline->setFixedSize(26, 26);
|
||||||
|
edFontUnderline->setCheckable(true);
|
||||||
|
connect(edFontUnderline, &QPushButton::toggled, this, [=](bool checked) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto ft = item->font();
|
||||||
|
ft.setUnderline(checked);
|
||||||
|
item->setFont(ft);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edFontUnderline);
|
||||||
|
|
||||||
|
auto edTextColor = new LoColorSelector("T", Qt::white);
|
||||||
|
edTextColor->setToolTip(tr("Text Color"));
|
||||||
|
edTextColor->setFixedSize(26, 26);
|
||||||
|
connect(edTextColor, &LoColorSelector::sColorChanged, this, [=](const QColor &color) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
if(! color.isValid()) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
item->setForeground(color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edTextColor);
|
||||||
|
|
||||||
|
auto edBackColor = new LoColorSelector("B", Qt::transparent);
|
||||||
|
edBackColor->setToolTip(tr("Back Color"));
|
||||||
|
edBackColor->setFixedSize(26, 26);
|
||||||
|
connect(edBackColor, &LoColorSelector::sColorChanged, this, [=](const QColor &color) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
if(! color.isValid()) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
item->setBackground(color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hh->addWidget(edBackColor);
|
||||||
|
|
||||||
|
edGridColor = new LoColorSelector("G", Qt::white);
|
||||||
|
edGridColor->setToolTip(tr("Grid Color"));
|
||||||
|
edGridColor->setFixedSize(26, 26);
|
||||||
|
connect(edGridColor, &LoColorSelector::sColorChanged, this, [=](const QColor &color) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
if(! color.isValid()) return;
|
||||||
|
table->setStyleSheet("QTableWidget { gridline-color: "+color.name()+";}");
|
||||||
|
});
|
||||||
|
hh->addWidget(edGridColor);
|
||||||
|
|
||||||
|
auto line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
vv = new VBox(hBox);
|
||||||
|
hh = new HBox(vv);
|
||||||
|
|
||||||
|
auto edAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
||||||
|
edAlignHL->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
edAlignHL->setFixedSize(26, 26);
|
||||||
|
edAlignHL->setIconSize(QSize(26, 26));
|
||||||
|
edAlignHL->setCheckable(true);
|
||||||
|
hh->addWidget(edAlignHL);
|
||||||
|
|
||||||
|
auto edAlignHC = new QPushButton(QIcon(":/res/program/TextAlignHC.png"), "");
|
||||||
|
edAlignHC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
edAlignHC->setFixedSize(26, 26);
|
||||||
|
edAlignHC->setIconSize(QSize(26, 26));
|
||||||
|
edAlignHC->setCheckable(true);
|
||||||
|
hh->addWidget(edAlignHC);
|
||||||
|
|
||||||
|
auto edAlignHR = new QPushButton(QIcon(":/res/program/TextAlignHR.png"), "");
|
||||||
|
edAlignHR->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
edAlignHR->setFixedSize(26, 26);
|
||||||
|
edAlignHR->setIconSize(QSize(26, 26));
|
||||||
|
edAlignHR->setCheckable(true);
|
||||||
|
hh->addWidget(edAlignHR);
|
||||||
|
|
||||||
|
hh = new HBox(vv);
|
||||||
|
|
||||||
|
auto edAlignVT = new QPushButton(QIcon(":/res/program/TextAlignVT.png"), "");
|
||||||
|
edAlignVT->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
edAlignVT->setFixedSize(26, 26);
|
||||||
|
edAlignVT->setIconSize(QSize(26, 26));
|
||||||
|
edAlignVT->setCheckable(true);
|
||||||
|
hh->addWidget(edAlignVT);
|
||||||
|
|
||||||
|
auto edAlignVC = new QPushButton(QIcon(":/res/program/TextAlignVC.png"), "");
|
||||||
|
edAlignVC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
edAlignVC->setFixedSize(26, 26);
|
||||||
|
edAlignVC->setIconSize(QSize(26, 26));
|
||||||
|
edAlignVC->setCheckable(true);
|
||||||
|
hh->addWidget(edAlignVC);
|
||||||
|
|
||||||
|
auto edAlignVB = new QPushButton(QIcon(":/res/program/TextAlignVB.png"), "");
|
||||||
|
edAlignVB->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
|
edAlignVB->setFixedSize(26, 26);
|
||||||
|
edAlignVB->setIconSize(QSize(26, 26));
|
||||||
|
edAlignVB->setCheckable(true);
|
||||||
|
hh->addWidget(edAlignVB);
|
||||||
|
|
||||||
|
auto edAlignH = new QButtonGroup(this);
|
||||||
|
edAlignH->addButton(edAlignHL, Qt::AlignLeft);
|
||||||
|
edAlignH->addButton(edAlignHC, Qt::AlignHCenter);
|
||||||
|
edAlignH->addButton(edAlignHR, Qt::AlignRight);
|
||||||
|
connect(edAlignH, &QButtonGroup::idClicked, this, [=](int value) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto align = item->textAlignment();
|
||||||
|
align = (align & Qt::AlignVertical_Mask) | value;
|
||||||
|
item->setTextAlignment(align);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
auto edAlignV = new QButtonGroup(this);
|
||||||
|
edAlignV->addButton(edAlignVT, Qt::AlignTop);
|
||||||
|
edAlignV->addButton(edAlignVC, Qt::AlignVCenter);
|
||||||
|
edAlignV->addButton(edAlignVB, Qt::AlignBottom);
|
||||||
|
connect(edAlignV, &QButtonGroup::idClicked, this, [=](int value) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
auto item = table->itemValid(r, c);
|
||||||
|
auto align = item->textAlignment();
|
||||||
|
align = (align & Qt::AlignHorizontal_Mask) | value;
|
||||||
|
item->setTextAlignment(align);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
auto grid = new Grid(hBox);
|
||||||
|
grid->addLabel(tr("Col Width"), 0, 0, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
grid->addLabel(tr("Row Height"), 1, 0, Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto edColWidth = new QSpinBox;
|
||||||
|
edColWidth->setRange(4, 9999);
|
||||||
|
edColWidth->setValue(64);
|
||||||
|
connect(edColWidth, &QSpinBox::valueChanged, table, [=](int value) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
if(value <= 0) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int c=range.leftColumn(); c<=range.rightColumn(); c++) {
|
||||||
|
table->setColumnWidth(c, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
grid->addWidget(edColWidth, 0, 1);
|
||||||
|
|
||||||
|
auto edRowHeight = new QSpinBox;
|
||||||
|
edRowHeight->setRange(4, 9999);
|
||||||
|
edRowHeight->setValue(18);
|
||||||
|
connect(edRowHeight, &QSpinBox::valueChanged, table, [=](int value) {
|
||||||
|
if(isAutoSetting) return;
|
||||||
|
if(value <= 0) return;
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) for(int r=range.topRow(); r<=range.bottomRow(); r++) {
|
||||||
|
table->setRowHeight(r, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
grid->addWidget(edRowHeight, 1, 1);
|
||||||
|
|
||||||
|
line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
grid = new Grid(hBox);
|
||||||
|
auto edInsRow = new QPushButton(tr("Insert Row"));
|
||||||
|
connect(edInsRow, &QPushButton::clicked, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
table->insertRow(ranges.isEmpty() ? table->rowCount() : ranges[0].topRow());
|
||||||
|
});
|
||||||
|
grid->addWidget(edInsRow, 0, 0);
|
||||||
|
|
||||||
|
auto edInsCol = new QPushButton(tr("Insert Col"));
|
||||||
|
connect(edInsCol, &QPushButton::clicked, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
table->insertColumn(ranges.isEmpty() ? table->columnCount() : ranges[0].leftColumn());
|
||||||
|
});
|
||||||
|
grid->addWidget(edInsCol, 0, 1);
|
||||||
|
|
||||||
|
auto edDelRow = new QPushButton(tr("Delete Row"));
|
||||||
|
connect(edDelRow, &QPushButton::clicked, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range = ranges.end()-1; range>=ranges.begin(); range--) for(auto row = range->bottomRow(); row>=range->topRow(); row--) table->removeRow(row);
|
||||||
|
});
|
||||||
|
grid->addWidget(edDelRow, 1, 0);
|
||||||
|
|
||||||
|
auto edDelCol = new QPushButton(tr("Delete Col"));
|
||||||
|
connect(edDelCol, &QPushButton::clicked, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range = ranges.end()-1; range>=ranges.begin(); range--) for(auto col = range->rightColumn(); col>=range->leftColumn(); col--) table->removeColumn(col);
|
||||||
|
});
|
||||||
|
grid->addWidget(edDelCol, 1, 1);
|
||||||
|
|
||||||
|
auto edMerge = new QPushButton(tr("Merge"));
|
||||||
|
connect(edMerge, &QPushButton::clicked, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
table->clearSelection();
|
||||||
|
qDebug()<<ranges.size();
|
||||||
|
for(auto range : ranges) table->setSpan(range.topRow(), range.leftColumn(), range.rowCount(), range.columnCount());
|
||||||
|
});
|
||||||
|
grid->addWidget(edMerge, 0, 2);
|
||||||
|
|
||||||
|
auto edUnmerge = new QPushButton(tr("Unmerge"));
|
||||||
|
connect(edUnmerge, &QPushButton::clicked, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
for(auto range : ranges) table->setSpan(range.topRow(), range.leftColumn(), 1, 1);
|
||||||
|
});
|
||||||
|
grid->addWidget(edUnmerge, 1, 2);
|
||||||
|
|
||||||
|
line = new QFrame;
|
||||||
|
line->setFrameShape(QFrame::VLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
auto edClear = new QPushButton(QIcon(":/res/program/Clean.png"), tr("Clear Data"));
|
||||||
|
hBox->addWidget(edClear);
|
||||||
|
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
connect(table, &QTableWidget::itemSelectionChanged, table, [=] {
|
||||||
|
auto ranges = table->selectedRanges();
|
||||||
|
if(ranges.isEmpty()) return;
|
||||||
|
auto item = table->item(ranges[0].topRow(), ranges[0].leftColumn());
|
||||||
|
isAutoSetting = true;
|
||||||
|
auto ft = item ? item->font() : table->font();
|
||||||
|
edFontFamily->setCurrentFont(QFont(ft.family()));
|
||||||
|
edFontSize->setValue(ft.pointSize());
|
||||||
|
edFontBold->setChecked(ft.bold());
|
||||||
|
edFontItalic->setChecked(ft.italic());
|
||||||
|
edFontUnderline->setChecked(ft.underline());
|
||||||
|
edTextColor->setColor(item ? BrushToColor(item->foreground(), Qt::white) : Qt::white);
|
||||||
|
edBackColor->setColor(item ? BrushToColor(item->background(), Qt::transparent) : Qt::transparent);
|
||||||
|
if(item) {
|
||||||
|
if(item->textAlignment() & Qt::AlignHCenter) edAlignHC->setChecked(true);
|
||||||
|
else if(item->textAlignment() & Qt::AlignRight) edAlignHR->setChecked(true);
|
||||||
|
else edAlignHL->setChecked(true);
|
||||||
|
if(item->textAlignment() & Qt::AlignTop) edAlignVT->setChecked(true);
|
||||||
|
else if(item->textAlignment() & Qt::AlignBottom) edAlignVB->setChecked(true);
|
||||||
|
else edAlignVC->setChecked(true);
|
||||||
|
} else {
|
||||||
|
edAlignHL->setChecked(true);
|
||||||
|
edAlignVC->setChecked(true);
|
||||||
|
}
|
||||||
|
edColWidth->setValue(table->columnWidth(ranges[0].leftColumn()));
|
||||||
|
edRowHeight->setValue(table->rowHeight(ranges[0].topRow()));
|
||||||
|
isAutoSetting = false;
|
||||||
|
});
|
||||||
|
|
||||||
auto pal = table->palette();
|
auto pal = table->palette();
|
||||||
pal.setBrush(QPalette::Active, QPalette::WindowText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Active, QPalette::WindowText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::WindowText, QBrush({157,157,157,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Disabled, QPalette::WindowText, QBrush({157,157,157,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::WindowText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Inactive, QPalette::WindowText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Active, QPalette::Button, QBrush({60,60,60,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::Button, QBrush({60,60,60,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Button, QBrush({60,60,60,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Active, QPalette::Light, QBrush({120,120,120,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::Light, QBrush({120,120,120,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Light, QBrush({120,120,120,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Active, QPalette::Midlight, QBrush({90,90,90,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::Midlight, QBrush({90,90,90,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Midlight, QBrush({90,90,90,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Active, QPalette::Dark, QBrush({30,30,30,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::Dark, QBrush({30,30,30,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Dark, QBrush({30,30,30,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Active, QPalette::Mid, QBrush({40,40,40,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::Mid, QBrush({40,40,40,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Mid, QBrush({40,40,40,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Active, QPalette::Text, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Active, QPalette::Text, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::Text, QBrush({157,157,157,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Disabled, QPalette::Text, QBrush({157,157,157,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Text, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Inactive, QPalette::Text, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Active, QPalette::BrightText, QBrush({95,255,165,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::BrightText, QBrush({95,255,165,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::BrightText, QBrush({95,255,165,255}, Qt::SolidPattern));
|
|
||||||
pal.setBrush(QPalette::Active, QPalette::ButtonText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Active, QPalette::ButtonText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, QBrush({157,157,157,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, QBrush({157,157,157,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::ButtonText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Inactive, QPalette::ButtonText, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
|
|
@ -89,59 +422,155 @@ ETable::ETable(EBase *multiWin) : EBase(multiWin) {
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::PlaceholderText, QBrush({255,255,255,128}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Inactive, QPalette::PlaceholderText, QBrush({255,255,255,128}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Active, QPalette::NColorRoles, QBrush({157,157,157,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Active, QPalette::NColorRoles, QBrush({157,157,157,255}, Qt::SolidPattern));
|
||||||
pal.setBrush(QPalette::Disabled, QPalette::NColorRoles, QBrush({255,255,255,255}, Qt::SolidPattern));
|
pal.setBrush(QPalette::Disabled, QPalette::NColorRoles, QBrush({255,255,255,255}, Qt::SolidPattern));
|
||||||
|
|
||||||
pal.setBrush(QPalette::Inactive, QPalette::Highlight, pal.brush(QPalette::Active, QPalette::Highlight));
|
pal.setBrush(QPalette::Inactive, QPalette::Highlight, pal.brush(QPalette::Active, QPalette::Highlight));
|
||||||
table->setPalette(pal);
|
table->setPalette(pal);
|
||||||
|
|
||||||
auto ft = table->font();
|
auto ft = table->font();
|
||||||
|
ft.setFamily("Calibri");
|
||||||
|
ft.setPointSize(11);
|
||||||
ft.setStyleStrategy(QFont::NoAntialias);
|
ft.setStyleStrategy(QFont::NoAntialias);
|
||||||
table->setFont(ft);
|
table->setFont(ft);
|
||||||
table->setShowGrid(false);
|
table->viewport()->setFont(ft);
|
||||||
table->setStyleSheet("QTableView::item { border: 1px solid red;}");
|
auto item = new QTableWidgetItem;
|
||||||
|
item->setFont(ft);
|
||||||
|
table->setItemPrototype(item);
|
||||||
|
table->setStyleSheet("QTableWidget { gridline-color: #fff;}");
|
||||||
|
//table->setStyleSheet("QTableWidget::item { border: 0.5px solid #fff;}");
|
||||||
|
table->setRowHeight(20);
|
||||||
|
table->setColWidth(64);
|
||||||
vBox->addWidget(table);
|
vBox->addWidget(table);
|
||||||
|
|
||||||
read();
|
connect(&dlg, &EmitCloseWidget::onClose, this, &ETable::grabImg);
|
||||||
}
|
}
|
||||||
ETable::ETable(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
void PaintTableWidget::paintEvent(QPaintEvent *event) {
|
||||||
mType = EBase::Table;
|
TableWidget::paintEvent(event);
|
||||||
setBaseAttr(json);
|
if(ebase) {
|
||||||
url = json["url"].toString();
|
QPainter painter(viewport());
|
||||||
read();
|
painter.setPen(QPen(Qt::green));
|
||||||
|
auto rect = ebase->innerRect();
|
||||||
|
painter.drawRect(columnViewportPosition(0)-1, rowViewportPosition(0)-1, rect.width(), rect.height());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int ETable::read() {
|
JObj ETable::attrJson() {
|
||||||
QXlsx::Document xlsxDoc("d:/aaa.xlsx");
|
if(png.isEmpty()) {
|
||||||
if(! xlsxDoc.isLoadPackage()) {
|
QBuffer buf(&png);
|
||||||
qCritical() << "Failed to load xlsx";
|
img.save(&buf, "PNG");
|
||||||
return -1;
|
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||||
}
|
cryptoHash.addData(png);
|
||||||
auto currentSheet = xlsxDoc.currentWorksheet();
|
name = QString::fromLatin1(cryptoHash.result().toHex());
|
||||||
if(currentSheet == 0) {
|
|
||||||
qCritical() << "Failed to load Worksheet";
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int maxRow = -1, maxCol = -1;
|
|
||||||
auto cells = currentSheet->getFullCells(&maxRow, &maxCol);
|
|
||||||
for(auto &cell : cells) {
|
|
||||||
auto value = cell.cell->value();
|
|
||||||
auto fmt = cell.cell->format();
|
|
||||||
fmt.font();
|
|
||||||
qDebug()<<cell.row<<cell.col<<cell.cell->cellType()<<fmt.font()<<fmt.fontColor()<<fmt.patternBackgroundColor()<<value;
|
|
||||||
}
|
}
|
||||||
|
JObj obj;
|
||||||
|
addBaseAttr(obj);
|
||||||
|
obj["elementType"] = "Table";
|
||||||
|
obj["name"] = name;
|
||||||
|
obj["direction"] = direction;
|
||||||
|
obj["speed"] = speed;
|
||||||
|
obj["gridColor"] = edGridColor->color.name(QColor::HexArgb);
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ETable::save(const QString &pageDir) {
|
||||||
|
if(png.isEmpty()) {
|
||||||
|
QBuffer buf(&png);
|
||||||
|
img.save(&buf, "PNG");
|
||||||
|
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||||
|
cryptoHash.addData(png);
|
||||||
|
name = QString::fromLatin1(cryptoHash.result().toHex());
|
||||||
|
}
|
||||||
|
QFile file(pageDir+"/"+name+".png");
|
||||||
|
if(! file.open(QFile::WriteOnly)) return false;
|
||||||
|
file.write(png);
|
||||||
|
file.close();
|
||||||
|
QXlsx::Document doc;
|
||||||
|
for(int r=0; r<table->rowCount(); r++) doc.setRowHeight(r+1, table->rowHeight(r) * 3.0 / 4);
|
||||||
|
for(int c=0; c<table->columnCount(); c++) doc.setColumnWidth(c+1, table->columnWidth(c) / 7.2);
|
||||||
|
for(int r=0; r<table->rowCount(); r++) for(int c=0; c<table->columnCount(); c++) {
|
||||||
|
auto item = table->item(r, c);
|
||||||
|
if(item==0) continue;
|
||||||
|
QXlsx::Format format;
|
||||||
|
format.setFont(item->font());
|
||||||
|
format.setFontColor(BrushToColor(item->foreground()));
|
||||||
|
format.setPatternBackgroundColor(BrushToColor(item->background()));
|
||||||
|
if(item->textAlignment() & Qt::AlignLeft) format.setHorizontalAlignment(QXlsx::Format::AlignLeft);
|
||||||
|
else if(item->textAlignment() & Qt::AlignHCenter) format.setHorizontalAlignment(QXlsx::Format::AlignHCenter);
|
||||||
|
else if(item->textAlignment() & Qt::AlignRight) format.setHorizontalAlignment(QXlsx::Format::AlignRight);
|
||||||
|
if(item->textAlignment() & Qt::AlignTop) format.setVerticalAlignment(QXlsx::Format::AlignTop);
|
||||||
|
else if(item->textAlignment() & Qt::AlignBottom) format.setVerticalAlignment(QXlsx::Format::AlignBottom);
|
||||||
|
else format.setVerticalAlignment(QXlsx::Format::AlignVCenter);
|
||||||
|
doc.write(r+1, c+1, item->text(), format);
|
||||||
|
auto rs = table->rowSpan(r, c);
|
||||||
|
auto cs = table->columnSpan(r, c);
|
||||||
|
if(rs>1 || cs>1) doc.mergeCells(QXlsx::CellRange(r+1, c+1, r+rs, c+cs));
|
||||||
|
}
|
||||||
|
doc.saveAs(pageDir+"/"+name+".xlsx");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
int ETable::read(QXlsx::Worksheet *sheet) {
|
||||||
|
int rowCnt, colCnt;
|
||||||
|
auto cells = sheet->getFullCells(&rowCnt, &colCnt);
|
||||||
|
auto dimension = sheet->dimension();
|
||||||
|
if(dimension.rowCount() > rowCnt) rowCnt = dimension.rowCount();
|
||||||
|
if(dimension.columnCount() > colCnt) colCnt = dimension.columnCount();
|
||||||
|
table->setRowCount(rowCnt);
|
||||||
|
table->setColumnCount(colCnt);
|
||||||
|
for(int r=0; r<rowCnt; r++) table->setRowHeight(r, sheet->rowHeight(r+1) * 4 / 3);
|
||||||
|
for(int c=0; c<colCnt; c++) table->setColumnWidth(c, sheet->columnWidth(c+1) * 7.2);
|
||||||
|
for(auto &cell : cells) {
|
||||||
|
auto fmt = cell.cell->format();
|
||||||
|
auto item = new QTableWidgetItem(cell.cell->value().toString());
|
||||||
|
auto ft = fmt.font();
|
||||||
|
ft.setStyleStrategy(QFont::NoAntialias);
|
||||||
|
item->setFont(ft);
|
||||||
|
auto color = fmt.fontColor();
|
||||||
|
if(color.isValid()) item->setForeground(color);
|
||||||
|
color = fmt.patternBackgroundColor();
|
||||||
|
if(color.isValid()) item->setBackground(color);
|
||||||
|
auto ha = fmt.horizontalAlignment();
|
||||||
|
auto va = fmt.verticalAlignment();
|
||||||
|
auto hAlign = Qt::AlignLeft;
|
||||||
|
auto vAlign = Qt::AlignVCenter;
|
||||||
|
if(ha==QXlsx::Format::AlignHCenter) hAlign = Qt::AlignHCenter;
|
||||||
|
else if(ha==QXlsx::Format::AlignRight) hAlign = Qt::AlignRight;
|
||||||
|
if(va==QXlsx::Format::AlignTop) vAlign = Qt::AlignTop;
|
||||||
|
else if(va==QXlsx::Format::AlignBottom) vAlign = Qt::AlignBottom;
|
||||||
|
item->setTextAlignment(hAlign | vAlign);
|
||||||
|
table->setItem(cell.row-1, cell.col-1, item);
|
||||||
|
qDebug()<<cell.row<<cell.col<<cell.cell->cellType()<<fmt.font()<<fmt.fontSize()<<fmt.fontColor()<<fmt.patternBackgroundColor()<<"va"<<va;
|
||||||
|
//cell.cell->cellType();
|
||||||
|
}
|
||||||
|
auto mergeds = sheet->mergedCells();
|
||||||
|
for(auto &merged : mergeds) table->setSpan(merged.firstRow()-1, merged.firstColumn()-1, merged.rowCount(), merged.columnCount());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void ETable::grabImg() {
|
||||||
|
table->ebase = 0;
|
||||||
|
table->clearSelection();
|
||||||
|
int width = 0, height = 0;
|
||||||
|
for(int r=0; r<table->rowCount(); r++) height += table->rowHeight(r);
|
||||||
|
for(int c=0; c<table->columnCount(); c++) width += table->columnWidth(c);
|
||||||
|
auto size = dlg.size();
|
||||||
|
dlg.resize(width+80, height+200);
|
||||||
|
img = QPixmap(width+20, height+20);
|
||||||
|
QPainter painter(&img);
|
||||||
|
painter.translate(1, 1);
|
||||||
|
table->viewport()->render(&painter);
|
||||||
|
painter.translate(-1, -1);
|
||||||
|
painter.setPen(QPen(edGridColor->color));
|
||||||
|
painter.drawLine(0,0, width, 0);
|
||||||
|
painter.drawLine(0,0, 0, height);
|
||||||
|
table->ebase = this;
|
||||||
|
dlg.resize(size);
|
||||||
|
png.clear();
|
||||||
|
update();
|
||||||
|
}
|
||||||
void ETable::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
|
void ETable::paint(QPainter *painter, const QStyleOptionGraphicsItem *a, QWidget *b) {
|
||||||
auto inner = innerRect();
|
auto inner = innerRect();
|
||||||
painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||||
painter->drawPixmap(inner.left(), inner.top(), img);
|
painter->drawPixmap(inner.left(), inner.top(), inner.width(), inner.height(), img, 0, 0, inner.width(), inner.height());
|
||||||
EBase::paint(painter, a, b);
|
EBase::paint(painter, a, b);
|
||||||
}
|
}
|
||||||
void ETable::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
void ETable::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
|
||||||
dlg.exec();
|
dlg.show();
|
||||||
img = table->grab();
|
|
||||||
auto twidth = table->width();
|
|
||||||
if(twidth != img.width()) {
|
|
||||||
img = img.scaledToWidth(twidth, Qt::SmoothTransformation);
|
|
||||||
qDebug()<<"scaledToWidth"<<twidth;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QWidget* ETable::attrWgt() {
|
QWidget* ETable::attrWgt() {
|
||||||
auto wgtAttr = new QWidget;
|
auto wgtAttr = new QWidget;
|
||||||
|
|
@ -160,45 +589,57 @@ QWidget* ETable::attrWgt() {
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addSpacing(6);
|
|
||||||
hBox->addLabel("URL:");
|
|
||||||
|
|
||||||
auto url_fd = new QLineEdit(url);
|
|
||||||
hBox->addWidget(url_fd);
|
auto label = hBox->addLabel(tr("Direction"));
|
||||||
connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &text) {
|
label->setMinimumWidth(80);
|
||||||
url = text;
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
auto edDirection = new QComboBox;
|
||||||
|
edDirection->addItem(tr("Static"), "");
|
||||||
|
edDirection->addItem(tr("Bottom -> Top"), "top");
|
||||||
|
edDirection->addItem(tr("Right -> Left"), "left");
|
||||||
|
edDirection->addItem(tr("Top -> Bottom"), "bottom");
|
||||||
|
edDirection->addItem(tr("Left -> Right"), "right");
|
||||||
|
SetCurData(edDirection, direction);
|
||||||
|
connect(edDirection, &QComboBox::currentIndexChanged, this, [=] {
|
||||||
|
direction = edDirection->currentData().toString();
|
||||||
});
|
});
|
||||||
|
hBox->addWidget(edDirection);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
label = hBox->addLabel(tr("Speed"));
|
||||||
auto lb = hBox->addLabel(tr("Refresh every")+":");
|
label->setMinimumWidth(80);
|
||||||
lb->setMinimumWidth(70);
|
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
lb->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
|
|
||||||
|
|
||||||
auto edRefresh = new QSpinBox;
|
auto edSpeed = new QComboBox;
|
||||||
edRefresh->setRange(0, 99999);
|
edSpeed->setEditable(true);
|
||||||
edRefresh->setValue(refresh);
|
edSpeed->setMinimumWidth(50);
|
||||||
connect(edRefresh, &QSpinBox::valueChanged, this, [=](int value) {
|
edSpeed->addItem("600");
|
||||||
refresh = value;
|
edSpeed->addItem("540");
|
||||||
|
edSpeed->addItem("480");
|
||||||
|
edSpeed->addItem("420");
|
||||||
|
edSpeed->addItem("360");
|
||||||
|
edSpeed->addItem("300");
|
||||||
|
edSpeed->addItem("240");
|
||||||
|
edSpeed->addItem("180");
|
||||||
|
edSpeed->addItem("120");
|
||||||
|
edSpeed->addItem("60");
|
||||||
|
edSpeed->addItem("30");
|
||||||
|
edSpeed->setMaxVisibleItems(edSpeed->count());
|
||||||
|
auto text = QString::number(speed);
|
||||||
|
if(SetCurText(edSpeed, text)==-1) {
|
||||||
|
SetCurText(edSpeed, "60");
|
||||||
|
edSpeed->setCurrentText(text);
|
||||||
|
}
|
||||||
|
connect(edSpeed, &QComboBox::editTextChanged, this, [=](const QString &text) {
|
||||||
|
bool ok;
|
||||||
|
auto speed = text.toInt(&ok);
|
||||||
|
if(ok) this->speed = speed;
|
||||||
});
|
});
|
||||||
hBox->addWidget(edRefresh);
|
hBox->addWidget(edSpeed);
|
||||||
hBox->addSpacing(-3);
|
hBox->addLabel("px/s");
|
||||||
hBox->addLabel("s");
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
vBox->addStretch();
|
vBox->addStretch();
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj ETable::attrJson() const {
|
|
||||||
JObj obj;
|
|
||||||
addBaseAttr(obj);
|
|
||||||
obj["elementType"] = "Table";
|
|
||||||
obj["url"] = url;
|
|
||||||
obj["zoom"] = zoom;
|
|
||||||
obj["refreshSec"] = refresh;
|
|
||||||
obj["offX"] = _x;
|
|
||||||
obj["offY"] = _y;
|
|
||||||
obj["scaleX"] = scaleX;
|
|
||||||
obj["scaleY"] = scaleY;
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,27 +3,42 @@
|
||||||
|
|
||||||
#include "ebase.h"
|
#include "ebase.h"
|
||||||
#include "gutil/qgui.h"
|
#include "gutil/qgui.h"
|
||||||
#include <QDialog>
|
#include "base/locolorselector.h"
|
||||||
|
#include "xlsxworksheet.h"
|
||||||
|
|
||||||
|
class PaintTableWidget : public TableWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using TableWidget::TableWidget;
|
||||||
|
EBase *ebase = 0;
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
};
|
||||||
|
|
||||||
class ETable : public EBase {
|
class ETable : public EBase {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ETable(EBase *multiWin = 0);
|
explicit ETable(int, int, EBase *multiWin = 0);
|
||||||
explicit ETable(const JObj &json, EBase *multiWin = 0);
|
explicit ETable(const JObj &json, const QString &dir, EBase *multiWin = 0);
|
||||||
|
void init(int=0, int=0);
|
||||||
int read();
|
int read(QXlsx::Worksheet *);
|
||||||
|
void grabImg();
|
||||||
int type() const override {return EBase::Table;}
|
int type() const override {return EBase::Table;}
|
||||||
|
JObj attrJson() override;
|
||||||
|
bool save(const QString &) override;
|
||||||
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &) override {return true;};
|
|
||||||
JObj attrJson() const override;
|
|
||||||
|
|
||||||
QDialog dlg;
|
EmitCloseWidget dlg;
|
||||||
TableWidget *table;
|
PaintTableWidget *table = 0;
|
||||||
QPixmap img;
|
QPixmap img;
|
||||||
QString url;
|
QByteArray png;
|
||||||
int zoom = 100, refresh = 0, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
|
LoColorSelector *edGridColor;
|
||||||
|
QString name;
|
||||||
|
QString direction;
|
||||||
|
int speed = 60;
|
||||||
|
bool isAutoSetting = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ETABLE_H
|
#endif // ETABLE_H
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||||
align = (Qt::Alignment) widget["align"].toInt();
|
align = (Qt::Alignment) widget["align"].toInt();
|
||||||
backColor = widget["backColor"].toString("#00000000");
|
backColor = widget["backColor"].toString("#00000000");
|
||||||
lastFont = widget["lastFont"].toString("黑体");
|
lastFont = widget["lastFont"].toString("黑体");
|
||||||
|
letterSpacin = widget["letterSpacin"].toInt(100);
|
||||||
auto play = json["play"];
|
auto play = json["play"];
|
||||||
if(play.isNull()) {
|
if(play.isNull()) {
|
||||||
playMode = json["playMode"].toString();
|
playMode = json["playMode"].toString();
|
||||||
|
|
@ -93,25 +94,25 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
auto fdText = new TTextEdit("");
|
auto fdText = new TTextEdit("");
|
||||||
|
|
||||||
auto fdFontFamily = new QFontComboBox;
|
auto edFontFamily = new QFontComboBox;
|
||||||
fdFontFamily->setEditable(false);
|
edFontFamily->setEditable(false);
|
||||||
fdFontFamily->setCurrentFont(QFont(lastFont));
|
edFontFamily->setCurrentFont(QFont(lastFont));
|
||||||
connect(fdFontFamily, &QFontComboBox::currentFontChanged, fdText, [=](const QFont &f) {
|
connect(edFontFamily, &QFontComboBox::currentFontChanged, fdText, [=](const QFont &f) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontFamilies({f.family()});
|
fmt.setFontFamilies({f.family()});
|
||||||
QTextCursor cursor = fdText->textCursor();
|
auto cursor = fdText->textCursor();
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
cursor.mergeCharFormat(fmt);
|
cursor.mergeCharFormat(fmt);
|
||||||
lastFont = f.family();
|
lastFont = f.family();
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontFamily);
|
hBox->addWidget(edFontFamily);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdFontSize = new QSpinBox;
|
auto edFontSize = new QSpinBox;
|
||||||
fdFontSize->setRange(4, 9999);
|
edFontSize->setRange(4, 9999);
|
||||||
fdFontSize->setValue(16);
|
edFontSize->setValue(16);
|
||||||
connect(fdFontSize, &QSpinBox::valueChanged, fdText, [=](int value) {
|
connect(edFontSize, &QSpinBox::valueChanged, fdText, [=](int value) {
|
||||||
if(value <= 0) return;
|
if(value <= 0) return;
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setProperty(QTextFormat::FontPixelSize, value);
|
fmt.setProperty(QTextFormat::FontPixelSize, value);
|
||||||
|
|
@ -119,74 +120,77 @@ QWidget* EText::attrWgt() {
|
||||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||||
cursor.mergeCharFormat(fmt);
|
cursor.mergeCharFormat(fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontSize);
|
hBox->addWidget(edFontSize);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->setSpacing(3);
|
hBox->setSpacing(3);
|
||||||
|
|
||||||
auto wTextAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
auto edAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
||||||
wTextAlignHL->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
edAlignHL->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
wTextAlignHL->setFixedSize(30, 30);
|
edAlignHL->setFixedSize(26, 26);
|
||||||
wTextAlignHL->setIconSize(QSize(30, 30));
|
edAlignHL->setIconSize(QSize(26, 26));
|
||||||
wTextAlignHL->setCheckable(true);
|
edAlignHL->setCheckable(true);
|
||||||
wTextAlignHL->setChecked(true);
|
edAlignHL->setChecked(true);
|
||||||
hBox->addWidget(wTextAlignHL);
|
hBox->addWidget(edAlignHL);
|
||||||
|
|
||||||
auto wTextAlignHC = new QPushButton(QIcon(":/res/program/TextAlignHC.png"), "");
|
auto edAlignHC = new QPushButton(QIcon(":/res/program/TextAlignHC.png"), "");
|
||||||
wTextAlignHC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
edAlignHC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
wTextAlignHC->setFixedSize(30, 30);
|
edAlignHC->setFixedSize(26, 26);
|
||||||
wTextAlignHC->setIconSize(QSize(30, 30));
|
edAlignHC->setIconSize(QSize(26, 26));
|
||||||
wTextAlignHC->setCheckable(true);
|
edAlignHC->setCheckable(true);
|
||||||
hBox->addWidget(wTextAlignHC);
|
hBox->addWidget(edAlignHC);
|
||||||
|
|
||||||
auto wTextAlignHR = new QPushButton(QIcon(":/res/program/TextAlignHR.png"), "");
|
auto edAlignHR = new QPushButton(QIcon(":/res/program/TextAlignHR.png"), "");
|
||||||
wTextAlignHR->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
edAlignHR->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
wTextAlignHR->setFixedSize(30, 30);
|
edAlignHR->setFixedSize(26, 26);
|
||||||
wTextAlignHR->setIconSize(QSize(30, 30));
|
edAlignHR->setIconSize(QSize(26, 26));
|
||||||
wTextAlignHR->setCheckable(true);
|
edAlignHR->setCheckable(true);
|
||||||
hBox->addWidget(wTextAlignHR);
|
hBox->addWidget(edAlignHR);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdFontBold = new QPushButton("B");
|
auto edFontBold = new QPushButton("B");
|
||||||
fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
edFontBold->setToolTip(tr("Bold"));
|
||||||
fdFontBold->setFixedSize(30, 30);
|
edFontBold->setStyleSheet("QPushButton{background: #ddd; color: #444; font-size: 16px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontBold->setCheckable(true);
|
edFontBold->setFixedSize(26, 26);
|
||||||
connect(fdFontBold, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
edFontBold->setCheckable(true);
|
||||||
|
connect(edFontBold, &QToolButton::toggled, fdText, [=](bool checked) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
|
fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
|
||||||
MergeFmt(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontBold);
|
hBox->addWidget(edFontBold);
|
||||||
|
|
||||||
auto fdFontItalic = new QPushButton("I");
|
auto edFontItalic = new QPushButton("I");
|
||||||
fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
edFontItalic->setToolTip(tr("Italic"));
|
||||||
fdFontItalic->setFixedSize(30, 30);
|
edFontItalic->setStyleSheet("QPushButton{background: #ddd; color: #444; font-size: 16px; font-weight: bold; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontItalic->setCheckable(true);
|
edFontItalic->setFixedSize(26, 26);
|
||||||
connect(fdFontItalic, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
edFontItalic->setCheckable(true);
|
||||||
|
connect(edFontItalic, &QToolButton::toggled, fdText, [=](bool checked) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontItalic(checked);
|
fmt.setFontItalic(checked);
|
||||||
MergeFmt(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontItalic);
|
hBox->addWidget(edFontItalic);
|
||||||
|
|
||||||
auto fdFontUnderline = new QPushButton("U");
|
auto edFontUnderline = new QPushButton("U");
|
||||||
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
edFontUnderline->setToolTip(tr("Underline"));
|
||||||
fdFontUnderline->setFixedSize(30, 30);
|
edFontUnderline->setStyleSheet("QPushButton{background: #ddd; color: #444; font-size: 16px; font-weight: bold; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||||
fdFontUnderline->setCheckable(true);
|
edFontUnderline->setFixedSize(26, 26);
|
||||||
connect(fdFontUnderline, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
edFontUnderline->setCheckable(true);
|
||||||
|
connect(edFontUnderline, &QToolButton::toggled, fdText, [=](bool checked) {
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setFontUnderline(checked);
|
fmt.setFontUnderline(checked);
|
||||||
MergeFmt(fdText, fmt);
|
MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(fdFontUnderline);
|
hBox->addWidget(edFontUnderline);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto fdTextColor = new LoColorSelector("T", Qt::white);
|
auto fdTextColor = new LoColorSelector("T", Qt::white);
|
||||||
fdTextColor->setToolTip(tr("Text Color"));
|
fdTextColor->setToolTip(tr("Text Color"));
|
||||||
fdTextColor->setFixedSize(30, 30);
|
fdTextColor->setFixedSize(26, 26);
|
||||||
connect(fdTextColor, &LoColorSelector::sColorChanged, fdText, [fdText](const QColor &color) {
|
connect(fdTextColor, &LoColorSelector::sColorChanged, fdText, [=](const QColor &color) {
|
||||||
if(! color.isValid()) return;
|
if(! color.isValid()) return;
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
fmt.setForeground(color);
|
fmt.setForeground(color);
|
||||||
|
|
@ -196,8 +200,8 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
auto fdBackColor = new LoColorSelector("B", backColor);
|
auto fdBackColor = new LoColorSelector("B", backColor);
|
||||||
fdBackColor->setToolTip(tr("Back Color"));
|
fdBackColor->setToolTip(tr("Back Color"));
|
||||||
fdBackColor->setFixedSize(30, 30);
|
fdBackColor->setFixedSize(26, 26);
|
||||||
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [=](const QColor &color) {
|
||||||
if(! color.isValid()) return;
|
if(! color.isValid()) return;
|
||||||
backColor = color;
|
backColor = color;
|
||||||
updImg();
|
updImg();
|
||||||
|
|
@ -227,26 +231,26 @@ QWidget* EText::attrWgt() {
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->setSpacing(3);
|
hBox->setSpacing(3);
|
||||||
|
|
||||||
auto wTextAlignVT = new QPushButton(QIcon(":/res/program/TextAlignVT.png"), "");
|
auto edAlignVT = new QPushButton(QIcon(":/res/program/TextAlignVT.png"), "");
|
||||||
wTextAlignVT->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
edAlignVT->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
wTextAlignVT->setFixedSize(30, 30);
|
edAlignVT->setFixedSize(26, 26);
|
||||||
wTextAlignVT->setIconSize(QSize(30, 30));
|
edAlignVT->setIconSize(QSize(26, 26));
|
||||||
wTextAlignVT->setCheckable(true);
|
edAlignVT->setCheckable(true);
|
||||||
hBox->addWidget(wTextAlignVT);
|
hBox->addWidget(edAlignVT);
|
||||||
|
|
||||||
auto wTextAlignVC = new QPushButton(QIcon(":/res/program/TextAlignVC.png"), "");
|
auto edAlignVC = new QPushButton(QIcon(":/res/program/TextAlignVC.png"), "");
|
||||||
wTextAlignVC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
edAlignVC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
wTextAlignVC->setFixedSize(30, 30);
|
edAlignVC->setFixedSize(26, 26);
|
||||||
wTextAlignVC->setIconSize(QSize(30, 30));
|
edAlignVC->setIconSize(QSize(26, 26));
|
||||||
wTextAlignVC->setCheckable(true);
|
edAlignVC->setCheckable(true);
|
||||||
hBox->addWidget(wTextAlignVC);
|
hBox->addWidget(edAlignVC);
|
||||||
|
|
||||||
auto wTextAlignVB = new QPushButton(QIcon(":/res/program/TextAlignVB.png"), "");
|
auto edAlignVB = new QPushButton(QIcon(":/res/program/TextAlignVB.png"), "");
|
||||||
wTextAlignVB->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
edAlignVB->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||||
wTextAlignVB->setFixedSize(30, 30);
|
edAlignVB->setFixedSize(26, 26);
|
||||||
wTextAlignVB->setIconSize(QSize(30, 30));
|
edAlignVB->setIconSize(QSize(26, 26));
|
||||||
wTextAlignVB->setCheckable(true);
|
edAlignVB->setCheckable(true);
|
||||||
hBox->addWidget(wTextAlignVB);
|
hBox->addWidget(edAlignVB);
|
||||||
|
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
|
|
@ -255,11 +259,13 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
auto edLetterSpacing = new QSpinBox;
|
auto edLetterSpacing = new QSpinBox;
|
||||||
edLetterSpacing->setMaximum(9999);
|
edLetterSpacing->setMaximum(9999);
|
||||||
edLetterSpacing->setValue(100);
|
edLetterSpacing->setValue(letterSpacin);
|
||||||
connect(edLetterSpacing, &QSpinBox::valueChanged, this, [=](int value) {
|
connect(edLetterSpacing, &QSpinBox::valueChanged, this, [=](int value) {
|
||||||
QTextCharFormat fmt;
|
letterSpacin = value;
|
||||||
fmt.setFontLetterSpacing(value);
|
updImg();
|
||||||
MergeFmt(fdText, fmt);
|
// QTextCharFormat fmt;
|
||||||
|
// fmt.setFontLetterSpacing(value);
|
||||||
|
// MergeFmt(fdText, fmt);
|
||||||
});
|
});
|
||||||
hBox->addWidget(edLetterSpacing);
|
hBox->addWidget(edLetterSpacing);
|
||||||
|
|
||||||
|
|
@ -284,9 +290,9 @@ QWidget* EText::attrWgt() {
|
||||||
|
|
||||||
|
|
||||||
auto fdAlignH = new QButtonGroup(wgtAttr);
|
auto fdAlignH = new QButtonGroup(wgtAttr);
|
||||||
fdAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
fdAlignH->addButton(edAlignHL, Qt::AlignLeft);
|
||||||
fdAlignH->addButton(wTextAlignHC, Qt::AlignHCenter);
|
fdAlignH->addButton(edAlignHC, Qt::AlignHCenter);
|
||||||
fdAlignH->addButton(wTextAlignHR, Qt::AlignRight);
|
fdAlignH->addButton(edAlignHR, Qt::AlignRight);
|
||||||
connect(fdAlignH, &QButtonGroup::idClicked, this, [=](int value) {
|
connect(fdAlignH, &QButtonGroup::idClicked, this, [=](int value) {
|
||||||
QTextBlockFormat fmt;
|
QTextBlockFormat fmt;
|
||||||
fmt.setAlignment((Qt::Alignment) value);
|
fmt.setAlignment((Qt::Alignment) value);
|
||||||
|
|
@ -296,18 +302,18 @@ QWidget* EText::attrWgt() {
|
||||||
});
|
});
|
||||||
|
|
||||||
auto fdAlignV = new QButtonGroup(wgtAttr);
|
auto fdAlignV = new QButtonGroup(wgtAttr);
|
||||||
fdAlignV->addButton(wTextAlignVT, Qt::AlignTop);
|
fdAlignV->addButton(edAlignVT, Qt::AlignTop);
|
||||||
fdAlignV->addButton(wTextAlignVC, Qt::AlignVCenter);
|
fdAlignV->addButton(edAlignVC, Qt::AlignVCenter);
|
||||||
fdAlignV->addButton(wTextAlignVB, Qt::AlignBottom);
|
fdAlignV->addButton(edAlignVB, Qt::AlignBottom);
|
||||||
connect(fdAlignV, &QButtonGroup::idClicked, this, [this](int value) {
|
connect(fdAlignV, &QButtonGroup::idClicked, this, [=](int value) {
|
||||||
align = (Qt::Alignment) value;
|
align = (Qt::Alignment) value;
|
||||||
updImg();
|
updImg();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto v_align = align & Qt::AlignVertical_Mask;
|
auto v_align = align & Qt::AlignVertical_Mask;
|
||||||
if(v_align==Qt::AlignTop) wTextAlignVT->setChecked(true);
|
if(v_align==Qt::AlignTop) edAlignVT->setChecked(true);
|
||||||
if(v_align==Qt::AlignVCenter) wTextAlignVC->setChecked(true);
|
if(v_align==Qt::AlignVCenter) edAlignVC->setChecked(true);
|
||||||
if(v_align==Qt::AlignBottom) wTextAlignVB->setChecked(true);
|
if(v_align==Qt::AlignBottom) edAlignVB->setChecked(true);
|
||||||
|
|
||||||
fdText->setMinimumHeight(160);
|
fdText->setMinimumHeight(160);
|
||||||
auto doc = fdText->document();
|
auto doc = fdText->document();
|
||||||
|
|
@ -332,14 +338,14 @@ QWidget* EText::attrWgt() {
|
||||||
auto ft = format.font();
|
auto ft = format.font();
|
||||||
auto families = ft.families();
|
auto families = ft.families();
|
||||||
if(! families.isEmpty()) {
|
if(! families.isEmpty()) {
|
||||||
fdFontFamily->blockSignals(true);
|
edFontFamily->blockSignals(true);
|
||||||
fdFontFamily->setCurrentFont(families[0]);
|
edFontFamily->setCurrentFont(families[0]);
|
||||||
fdFontFamily->blockSignals(false);
|
edFontFamily->blockSignals(false);
|
||||||
lastFont = families[0];
|
lastFont = families[0];
|
||||||
}
|
}
|
||||||
fdFontSize->blockSignals(true);
|
edFontSize->blockSignals(true);
|
||||||
fdFontSize->setValue(ft.pixelSize());
|
edFontSize->setValue(ft.pixelSize());
|
||||||
fdFontSize->blockSignals(false);
|
edFontSize->blockSignals(false);
|
||||||
auto foreground = format.foreground();
|
auto foreground = format.foreground();
|
||||||
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());
|
||||||
|
|
@ -365,20 +371,20 @@ QWidget* EText::attrWgt() {
|
||||||
hBox->addStretch();
|
hBox->addStretch();
|
||||||
|
|
||||||
auto pageInfoWgt = new QWidget;
|
auto pageInfoWgt = new QWidget;
|
||||||
auto hhh = new QHBoxLayout(pageInfoWgt);
|
auto hhh = new HBox(pageInfoWgt);
|
||||||
hhh->setContentsMargins(0,0,0,0);
|
hhh->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
hhh->addWidget(new QLabel(tr("PageCount:")));
|
hhh->addLabel(tr("PageCount:"));
|
||||||
|
|
||||||
auto fdPageCnt = new QLabel(QString::number(mImgs.size()));
|
auto fdPageCnt = new QLabel(QString::number(mImgs.size()));
|
||||||
hhh->addWidget(fdPageCnt);
|
hhh->addWidget(fdPageCnt);
|
||||||
|
|
||||||
hhh->addSpacing(20);
|
hhh->addSpacing(20);
|
||||||
hhh->addWidget(new QLabel(tr("page")));
|
hhh->addLabel(tr("page"));
|
||||||
|
|
||||||
auto fdPageIdx = new QSpinBox();
|
auto fdPageIdx = new QSpinBox;
|
||||||
fdPageIdx->setRange(1, mImgs.size());
|
fdPageIdx->setRange(1, mImgs.size());
|
||||||
connect(fdPageIdx, &QSpinBox::valueChanged, this, [this](int idx) {
|
connect(fdPageIdx, &QSpinBox::valueChanged, this, [=](int idx) {
|
||||||
curIdx = idx - 1;
|
curIdx = idx - 1;
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
|
|
@ -414,9 +420,9 @@ QWidget* EText::attrWgt() {
|
||||||
hBox->addWidget(btnImport);
|
hBox->addWidget(btnImport);
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addWidget(new QLabel(tr("Play Properties")));
|
hBox->addLabel(tr("Play Properties"));
|
||||||
|
|
||||||
line = new QFrame();
|
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);
|
||||||
|
|
@ -557,7 +563,7 @@ bool EText::save(const QString &pageDir) {
|
||||||
for(int i=0; i<mImgs.count(); i++) mImgs[i].save(idDir + QString("/text%1.png").arg(i));
|
for(int i=0; i<mImgs.count(); i++) mImgs[i].save(idDir + QString("/text%1.png").arg(i));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
JObj EText::attrJson() const {
|
JObj EText::attrJson() {
|
||||||
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{
|
||||||
|
|
@ -567,6 +573,7 @@ JObj EText::attrJson() const {
|
||||||
{"align", (int) align},
|
{"align", (int) align},
|
||||||
{"backColor", backColor.name(QColor::HexArgb)},
|
{"backColor", backColor.name(QColor::HexArgb)},
|
||||||
{"lastFont", lastFont},
|
{"lastFont", lastFont},
|
||||||
|
{"letterSpacin", letterSpacin},
|
||||||
{"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)}
|
||||||
};
|
};
|
||||||
|
|
@ -602,6 +609,7 @@ void EText::updImg() {
|
||||||
QFont font;
|
QFont font;
|
||||||
font.setFamilies({"Arial","黑体"});
|
font.setFamilies({"Arial","黑体"});
|
||||||
font.setPixelSize(16);
|
font.setPixelSize(16);
|
||||||
|
font.setLetterSpacing(QFont::PercentageSpacing, letterSpacin);
|
||||||
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;}");
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public:
|
||||||
int type() const override { return EBase::Text; }
|
int type() const override { return EBase::Text; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &pRoot) override;
|
bool save(const QString &pRoot) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
Qt::Alignment align;
|
Qt::Alignment align;
|
||||||
|
|
@ -23,6 +23,7 @@ public:
|
||||||
QString direction = "left";
|
QString direction = "left";
|
||||||
int speed = 60;
|
int speed = 60;
|
||||||
int tailSpacing = 10;
|
int tailSpacing = 10;
|
||||||
|
int letterSpacin = 100;
|
||||||
bool useNewFmt = false;
|
bool useNewFmt = false;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
@ -35,7 +36,7 @@ private:
|
||||||
QImage copy(QImage &img, int x, int y, int w, int h);
|
QImage copy(QImage &img, int x, int y, int w, int h);
|
||||||
|
|
||||||
QList<QImage> mImgs;
|
QList<QImage> mImgs;
|
||||||
int curIdx{0};
|
int curIdx = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ETEXT_H
|
#endif // ETEXT_H
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ QWidget* ETimer::attrWgt() {
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj ETimer::attrJson() const {
|
JObj ETimer::attrJson() {
|
||||||
JObj obj;
|
JObj obj;
|
||||||
addBaseAttr(obj);
|
addBaseAttr(obj);
|
||||||
obj["elementType"] = "Timer";
|
obj["elementType"] = "Timer";
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
int type() const override { return EBase::Timer; }
|
int type() const override { return EBase::Timer; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
int secs = 0;
|
int secs = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ void repLineHeight(QString &html) {
|
||||||
end:
|
end:
|
||||||
if(! pre.isEmpty()) html = pre + html.mid(last);
|
if(! pre.isEmpty()) html = pre + html.mid(last);
|
||||||
}
|
}
|
||||||
JObj ETimer2::attrJson() const {
|
JObj ETimer2::attrJson() {
|
||||||
JObj ele{{"elementType", "Timer2"}};
|
JObj ele{{"elementType", "Timer2"}};
|
||||||
addBaseAttr(ele);
|
addBaseAttr(ele);
|
||||||
ele["isUp"] = isUp;
|
ele["isUp"] = isUp;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
int type() const override { return EBase::TimerHtml; }
|
int type() const override { return EBase::TimerHtml; }
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
QDateTime targetTime;
|
QDateTime targetTime;
|
||||||
QString html;
|
QString html;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ EVideo *EVideo::create(const JObj &ele, PageListItem *pageItem, EBase *multiWin)
|
||||||
auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, pageItem, multiWin);
|
auto ins = new EVideo(dir, name, widget["pathRaw"].toString(), widget["fileRaw"].toString(), img, pageItem, multiWin);
|
||||||
ins->setBaseAttr(ele);
|
ins->setBaseAttr(ele);
|
||||||
if(ins->_duration < 4) ins->_duration = dur;
|
if(ins->_duration < 4) ins->_duration = dur;
|
||||||
|
ins->vol = ele["vol"].toInt(100);
|
||||||
ins->useSW = ele["useSW"].toBool();
|
ins->useSW = ele["useSW"].toBool();
|
||||||
ins->isPreSplit = ele["isPreSplit"].toBool();
|
ins->isPreSplit = ele["isPreSplit"].toBool();
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
|
|
@ -139,7 +140,7 @@ QWidget* EVideo::attrWgt() {
|
||||||
// wAspectRatioMode->addItem(tr("KeepAspectRatio"));
|
// wAspectRatioMode->addItem(tr("KeepAspectRatio"));
|
||||||
// wAspectRatioMode->addItem(tr("KeepAspectRatioByExpanding"));
|
// wAspectRatioMode->addItem(tr("KeepAspectRatioByExpanding"));
|
||||||
// wAspectRatioMode->setCurrentIndex(aspectRatioMode);
|
// wAspectRatioMode->setCurrentIndex(aspectRatioMode);
|
||||||
// connect(wAspectRatioMode, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int value) {
|
// connect(wAspectRatioMode, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [=](int value) {
|
||||||
// aspectRatioMode = value;
|
// aspectRatioMode = value;
|
||||||
// });
|
// });
|
||||||
// hBox->addWidget(wAspectRatioMode);
|
// hBox->addWidget(wAspectRatioMode);
|
||||||
|
|
@ -153,6 +154,21 @@ QWidget* EVideo::attrWgt() {
|
||||||
line->setFrameShadow(QFrame::Sunken);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
hBox->addWidget(line, 1);
|
hBox->addWidget(line, 1);
|
||||||
|
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addSpacing(6);
|
||||||
|
hBox->addLabel("Vol");
|
||||||
|
|
||||||
|
auto edVol = new QSlider(Qt::Horizontal);
|
||||||
|
edVol->setRange(0, 100);
|
||||||
|
edVol->setValue(vol);
|
||||||
|
hBox->addWidget(edVol);
|
||||||
|
auto lbVol = hBox->addLabel(QString::number(vol));
|
||||||
|
lbVol->setMinimumWidth(30);
|
||||||
|
connect(edVol, &QSlider::valueChanged, this, [=](int value) {
|
||||||
|
vol = value;
|
||||||
|
lbVol->setText(QString::number(vol));
|
||||||
|
});
|
||||||
|
|
||||||
hBox = new HBox(vBox);
|
hBox = new HBox(vBox);
|
||||||
hBox->addSpacing(6);
|
hBox->addSpacing(6);
|
||||||
hBox->addLabel(tr("Play Times"));
|
hBox->addLabel(tr("Play Times"));
|
||||||
|
|
@ -160,7 +176,7 @@ QWidget* EVideo::attrWgt() {
|
||||||
auto edPlayTimes = new QSpinBox;
|
auto edPlayTimes = new QSpinBox;
|
||||||
edPlayTimes->setRange(1, 99999);
|
edPlayTimes->setRange(1, 99999);
|
||||||
edPlayTimes->setValue(playTimes);
|
edPlayTimes->setValue(playTimes);
|
||||||
connect(edPlayTimes, &QSpinBox::valueChanged, this, [this](int value) {
|
connect(edPlayTimes, &QSpinBox::valueChanged, this, [=](int value) {
|
||||||
playTimes = value;
|
playTimes = value;
|
||||||
});
|
});
|
||||||
hBox->addWidget(edPlayTimes);
|
hBox->addWidget(edPlayTimes);
|
||||||
|
|
@ -171,7 +187,7 @@ QWidget* EVideo::attrWgt() {
|
||||||
|
|
||||||
auto edUseSW = new QCheckBox(tr("Use SW"));
|
auto edUseSW = new QCheckBox(tr("Use SW"));
|
||||||
edUseSW->setChecked(useSW);
|
edUseSW->setChecked(useSW);
|
||||||
connect(edUseSW, &QCheckBox::stateChanged, this, [this](int value) {
|
connect(edUseSW, &QCheckBox::stateChanged, this, [=](int value) {
|
||||||
useSW = value==Qt::Checked;
|
useSW = value==Qt::Checked;
|
||||||
});
|
});
|
||||||
hBox->addWidget(edUseSW);
|
hBox->addWidget(edUseSW);
|
||||||
|
|
@ -214,13 +230,14 @@ bool EVideo::save(const QString &pageDir) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EVideo::attrJson() const {
|
JObj EVideo::attrJson() {
|
||||||
JObj obj{
|
JObj obj{
|
||||||
{"elementType", "Video"},
|
{"elementType", "Video"},
|
||||||
{"path", mDir},
|
{"path", mDir},
|
||||||
{"file", mName},
|
{"file", mName},
|
||||||
{"pathRaw", mRawDir},
|
{"pathRaw", mRawDir},
|
||||||
{"fileRaw", mRawName},
|
{"fileRaw", mRawName},
|
||||||
|
{"vol", vol},
|
||||||
{"useSW", useSW},
|
{"useSW", useSW},
|
||||||
{"isPreSplit", isPreSplit},
|
{"isPreSplit", isPreSplit},
|
||||||
{"playTimes", playTimes}
|
{"playTimes", playTimes}
|
||||||
|
|
@ -294,7 +311,7 @@ QString EVideo::transcoding(QWidget *parent, QString rawFile, QString rawName, Q
|
||||||
} else err.append(txt);
|
} else err.append(txt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
process.start("ffmpeg", {"-y", "-i", rawFile, "-vcodec", "h264", "-s", QString::number(w)+"x"+QString::number(h), "-profile:v", "main", "-b:v", QString::number(w*h/150)+"k", outFile});
|
process.start("ffmpeg", {"-y", "-i", rawFile, "-vcodec", "h264", "-s", QString::number((w>>1)<<1)+"x"+QString::number((h>>1)<<1), "-profile:v", "main", "-b:v", QString::number(w*h/150)+"k", outFile});
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
if(err.right(32).contains("Conversion failed!")) {
|
if(err.right(32).contains("Conversion failed!")) {
|
||||||
QMessageBox::critical(parent, translate("","Error"), err);
|
QMessageBox::critical(parent, translate("","Error"), err);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &pRoot) override;
|
bool save(const QString &pRoot) override;
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
QString mDir;
|
QString mDir;
|
||||||
QString mName;
|
QString mName;
|
||||||
|
|
@ -37,7 +37,7 @@ public:
|
||||||
QImage mCoverImg;
|
QImage mCoverImg;
|
||||||
protected:
|
protected:
|
||||||
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
||||||
int playTimes = 1;
|
int vol = 100, playTimes = 1;
|
||||||
bool useSW = false, isPreSplit = false;
|
bool useSW = false, isPreSplit = false;
|
||||||
PageListItem *mPageItem;
|
PageListItem *mPageItem;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ QWidget* EWeb::attrWgt() {
|
||||||
return wgtAttr;
|
return wgtAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
JObj EWeb::attrJson() const {
|
JObj EWeb::attrJson() {
|
||||||
JObj obj;
|
JObj obj;
|
||||||
addBaseAttr(obj);
|
addBaseAttr(obj);
|
||||||
obj["elementType"] = "Web";
|
obj["elementType"] = "Web";
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public:
|
||||||
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||||
QWidget* attrWgt() override;
|
QWidget* attrWgt() override;
|
||||||
bool save(const QString &) override {return true;};
|
bool save(const QString &) override {return true;};
|
||||||
JObj attrJson() const override;
|
JObj attrJson() override;
|
||||||
|
|
||||||
QString url;
|
QString url;
|
||||||
int zoom = 100, refresh = 0, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
|
int zoom = 100, refresh = 0, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,7 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
source["id"] = id;
|
source["id"] = id;
|
||||||
source["md5"] = id;
|
source["md5"] = id;
|
||||||
source["name"] = name;
|
source["name"] = name;
|
||||||
|
source["vol"] = ele["vol"];
|
||||||
source["useSW"] = ele["useSW"];
|
source["useSW"] = ele["useSW"];
|
||||||
source["isPreSplit"] = ele["isPreSplit"];
|
source["isPreSplit"] = ele["isPreSplit"];
|
||||||
auto play = ele["play"];
|
auto play = ele["play"];
|
||||||
|
|
@ -265,6 +266,21 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
||||||
source["isUp"] = ele["isUp"];
|
source["isUp"] = ele["isUp"];
|
||||||
source["html"] = ele["html"];
|
source["html"] = ele["html"];
|
||||||
source["backColor"] = ele["backColor"];
|
source["backColor"] = ele["backColor"];
|
||||||
|
} else if(type=="Table") {
|
||||||
|
auto name = ele["name"].toString();
|
||||||
|
auto srcFile = srcPageDir + "/" + name+".png";
|
||||||
|
QFileInfo srcInfo(srcFile);
|
||||||
|
if(! srcInfo.isFile()) continue;
|
||||||
|
auto geometry = ele["geometry"];
|
||||||
|
auto direction = ele["direction"].toStr().toLower();
|
||||||
|
auto speed = ele["speed"].toInt();
|
||||||
|
auto isScroll = ! direction.isEmpty() && speed > 0;
|
||||||
|
QFile::copy(srcFile, dstDir+"/"+name);
|
||||||
|
source["_type"] = "Scroll";
|
||||||
|
source["imgs"] = JArray{name};
|
||||||
|
source["direct"] = direction;
|
||||||
|
source["speed"] = isScroll ? speed : 0;
|
||||||
|
source["timeSpan"] = ele["duration"];
|
||||||
}
|
}
|
||||||
if(! source.empty()) {
|
if(! source.empty()) {
|
||||||
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
if(source["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
||||||
|
|
@ -422,7 +438,7 @@ JObj GenTmpThread::genImage(const JValue &ele) {
|
||||||
} else */
|
} else */
|
||||||
auto isScroll = ! direct.isEmpty() && speed > 0;
|
auto isScroll = ! direct.isEmpty() && speed > 0;
|
||||||
QString md5;
|
QString md5;
|
||||||
if((isScroll && (img.width() != width || img.height() != height)) || (img.width() > width*2 && img.height() > height*2)) {
|
if((isScroll && (img.width() != width || img.height() != height)) || (img.width() > width*1.2 && img.height() > height*1.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);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include "program/etimer2.h"
|
#include "program/etimer2.h"
|
||||||
#include "program/evideo.h"
|
#include "program/evideo.h"
|
||||||
#include "program/eweb.h"
|
#include "program/eweb.h"
|
||||||
|
#include "program/etable.h"
|
||||||
#include <QDateEdit>
|
#include <QDateEdit>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
@ -42,7 +43,7 @@ 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=="Image"||type=="Photo"||type=="Gif") element = EPhoto::create(ele.toObj(), this);
|
else if(type=="Image"||type=="Photo"||type=="Gif") element = EPhoto::create(ele.toObj(), mPageDir);
|
||||||
else if(type=="Video"||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());
|
||||||
|
|
@ -50,6 +51,7 @@ PageListItem::PageListItem(const JObj &attr, const QString &pageDir) : mAttr(att
|
||||||
else if(type=="Web") element = new EWeb(ele.toObj());
|
else if(type=="Web") element = new EWeb(ele.toObj());
|
||||||
else if(type=="Timer") element = new ETimer(ele.toObj());
|
else if(type=="Timer") element = new ETimer(ele.toObj());
|
||||||
else if(type=="Timer2") element = new ETimer2(ele.toObj());
|
else if(type=="Timer2") element = new ETimer2(ele.toObj());
|
||||||
|
else if(type=="Table") element = new ETable(ele.toObj(), mPageDir);
|
||||||
else if(type=="Window") element = new EMultiWin(ele.toObj(), this);
|
else if(type=="Window") element = new EMultiWin(ele.toObj(), this);
|
||||||
if(element) mScene->addItem(element);
|
if(element) mScene->addItem(element);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,16 @@
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QToolButton>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
#include "xlsxdocument.h"
|
||||||
|
#include "xlsxworkbook.h"
|
||||||
|
|
||||||
ProgItem *gProgItem = 0;
|
ProgItem *gProgItem = 0;
|
||||||
|
|
||||||
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
||||||
|
|
@ -48,7 +52,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
vBox->setContentsMargins(0, 0, 0, 0);
|
vBox->setContentsMargins(0, 0, 0, 0);
|
||||||
vBox->setSpacing(0);
|
vBox->setSpacing(0);
|
||||||
|
|
||||||
auto toolBar = new QToolBar();
|
auto toolBar = new QToolBar;
|
||||||
toolBar->setFloatable(false);
|
toolBar->setFloatable(false);
|
||||||
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
toolBar->setIconSize(QSize(46, 40));
|
toolBar->setIconSize(QSize(46, 40));
|
||||||
|
|
@ -193,13 +197,60 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer")+" (HTML)");
|
action = new QAction(QIcon(":/res/program/Timer.png"), tr("Timer")+" (HTML)");
|
||||||
action->setData(EBase::TimerHtml);
|
action->setData(EBase::TimerHtml);
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
|
|
||||||
action = new QAction(QIcon(":/res/program/Table.png"), tr("Table"));
|
action = new QAction(QIcon(":/res/program/Table.png"), tr("Table"));
|
||||||
action->setData(EBase::Table);
|
action->setData(EBase::Table);
|
||||||
menu = new QMenu;
|
menu = new QMenu;
|
||||||
action->setMenu(menu);
|
action->setMenu(menu);
|
||||||
toolBar->addAction(action);
|
toolBar->addAction(action);
|
||||||
|
connect(action, &QAction::triggered, this, [=] {
|
||||||
|
menu->popup(QWidget::mapToGlobal(action->associatedWidgets()[1]->geometry().bottomLeft()), action);
|
||||||
|
});
|
||||||
|
action = new QAction(QIcon(":/res/program/Table.png"), tr("New"));
|
||||||
|
connect(action, &QAction::triggered, this, [=] {
|
||||||
|
auto scene = mPageEditor->graphicsView->scene();
|
||||||
|
if(scene==0) return;
|
||||||
|
auto table = new ETable(8, 4);
|
||||||
|
table->setPos({0,0});
|
||||||
|
table->setSize(mProgItem->mWidth, mProgItem->mHeight);
|
||||||
|
table->setZValue(mPageEditor->sortedEles().count());
|
||||||
|
scene->addItem(table);
|
||||||
|
auto sels = scene->selectedItems();
|
||||||
|
if(sels.count() == 1) sels.at(0)->setSelected(false);
|
||||||
|
table->setSelected(true);
|
||||||
|
table->grabImg();
|
||||||
|
});
|
||||||
|
menu->addAction(action);
|
||||||
|
|
||||||
action = new QAction(QIcon(":/res/program/Table.png"), tr("Import"));
|
action = new QAction(QIcon(":/res/program/Table.png"), tr("Import"));
|
||||||
action->setData(EBase::Table);
|
connect(action, &QAction::triggered, this, [=] {
|
||||||
|
auto file = QFileDialog::getOpenFileName(this, tr("Table"), gFileHome, "Tables (*.xlsx *.xls)");
|
||||||
|
if(file.isEmpty()) return;
|
||||||
|
auto scene = mPageEditor->graphicsView->scene();
|
||||||
|
if(scene==0) return;
|
||||||
|
|
||||||
|
QXlsx::Document doc(file);
|
||||||
|
if(! doc.isLoadPackage()) {
|
||||||
|
QMessageBox::critical(this, "Table Error", "Failed to load Package\n"+file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto sheet = doc.currentWorksheet();
|
||||||
|
if(sheet == 0) {
|
||||||
|
QMessageBox::critical(this, "Table Error", "Failed to load Worksheet\n"+file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto table = new ETable(0, 0);
|
||||||
|
table->read(sheet);
|
||||||
|
table->setPos({0,0});
|
||||||
|
table->setSize(mProgItem->mWidth, mProgItem->mHeight);
|
||||||
|
table->setZValue(mPageEditor->sortedEles().count());
|
||||||
|
scene->addItem(table);
|
||||||
|
auto sels = scene->selectedItems();
|
||||||
|
if(sels.count() == 1) sels.at(0)->setSelected(false);
|
||||||
|
table->setSelected(true);
|
||||||
|
table->grabImg();
|
||||||
|
gFileHome = QFileInfo(file).absolutePath();
|
||||||
|
});
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
|
|
||||||
#ifndef leyide
|
#ifndef leyide
|
||||||
|
|
@ -360,7 +411,6 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
||||||
} else if(type==EBase::Timer) element = new ETimer;
|
} else if(type==EBase::Timer) element = new ETimer;
|
||||||
else if(type==EBase::TimerHtml) element = new ETimer2;
|
else if(type==EBase::TimerHtml) element = new ETimer2;
|
||||||
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
||||||
else if(type==EBase::Table) element = new ETable;
|
|
||||||
if(element) {
|
if(element) {
|
||||||
if(element->mWidth==0) {
|
if(element->mWidth==0) {
|
||||||
element->setPos(mNewEleX, mNewEleY);
|
element->setPos(mNewEleX, mNewEleY);
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 887 B After Width: | Height: | Size: 395 B |
|
Before Width: | Height: | Size: 384 B After Width: | Height: | Size: 424 B |
|
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 421 B |
|
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 419 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 419 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 420 B |