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.
|
||||
#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\\\"
|
||||
msvc {
|
||||
contains(QT_ARCH, i386) {
|
||||
|
|
@ -77,6 +77,9 @@ win32 {
|
|||
copy.files += $$files(ffmpeg$$DIR_SUFFIX/bin/*.dll)
|
||||
copy.files += 7z/7z.dll
|
||||
copy.files += 7z/7z.exe
|
||||
copy.files += adb.exe
|
||||
copy.files += AdbWinApi.dll
|
||||
copy.files += AdbWinUsbApi.dll
|
||||
|
||||
copy.path = $$OUT_PWD
|
||||
copydir.path = $$OUT_PWD
|
||||
|
|
@ -120,6 +123,7 @@ SOURCES += \
|
|||
base/locolorselector.cpp \
|
||||
base/loqtitlebar.cpp \
|
||||
base/loqtreewidget.cpp \
|
||||
device/badpointdetectdialog.cpp \
|
||||
device/progressesdlg.cpp \
|
||||
gutil/qcore.cpp \
|
||||
gutil/qwaitingdlg.cpp \
|
||||
|
|
@ -188,6 +192,7 @@ HEADERS += \
|
|||
base/locolorselector.h \
|
||||
base/loqtitlebar.h \
|
||||
base/loqtreewidget.h \
|
||||
device/badpointdetectdialog.h \
|
||||
device/progressesdlg.h \
|
||||
gutil/qcore.h \
|
||||
gutil/qwaitingdlg.h \
|
||||
|
|
|
|||
|
|
@ -466,8 +466,9 @@ QFont Format::font() const
|
|||
{
|
||||
QFont font;
|
||||
font.setFamily(fontName());
|
||||
if (fontSize() > 0)
|
||||
font.setPointSize(fontSize());
|
||||
auto size = fontSize();
|
||||
if(size==0) size = 11;
|
||||
font.setPointSize(size);
|
||||
font.setBold(fontBold());
|
||||
font.setItalic(fontItalic());
|
||||
font.setUnderline(fontUnderline() != FontUnderlineNone);
|
||||
|
|
|
|||
BIN
LedOK/adb.exe
Normal file
|
|
@ -15,7 +15,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
|||
#endif
|
||||
auto vBox = new QVBoxLayout(this);
|
||||
auto hBox = new QHBoxLayout();
|
||||
auto label = new QLabel(tr("Old password"));
|
||||
auto label = new QLabel(translate("","Old password"));
|
||||
hBox->addWidget(label);
|
||||
|
||||
fdOld = new QLineEdit();
|
||||
|
|
@ -25,7 +25,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
|||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
auto label_2 = new QLabel(tr("New password"));
|
||||
auto label_2 = new QLabel(translate("","New password"));
|
||||
hBox->addWidget(label_2);
|
||||
|
||||
fdNew = new QLineEdit();
|
||||
|
|
@ -47,7 +47,7 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
|||
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(btnBox, &QDialogButtonBox::accepted, this, [=] {
|
||||
QString pwdOld = fdOld->text();
|
||||
auto pwdOld = fdOld->text();
|
||||
if(pwdOld.isEmpty()) {
|
||||
QMessageBox::warning(this, translate("","Tip"), tr("Please input old password"));
|
||||
fdOld->setFocus();
|
||||
|
|
@ -55,21 +55,21 @@ ChangePasswordForm::ChangePasswordForm(QWidget *parent) : QDialog(parent) {
|
|||
}
|
||||
QSettings settings;
|
||||
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) {
|
||||
QMessageBox::critical(this, translate("","Tip"), tr("Old password is wrong"));
|
||||
fdOld->setFocus();
|
||||
return;
|
||||
}
|
||||
QString pwdNew = fdNew->text();
|
||||
auto pwdNew = fdNew->text();
|
||||
if(pwdNew.length() < 3 && ! pwdNew.isEmpty()) {
|
||||
QMessageBox::warning(this, translate("","Tip"), tr("Please enter a password with more than 3 characters"));
|
||||
fdNew->setFocus();
|
||||
return;
|
||||
}
|
||||
QString pwdAgn = fdAgn->text();
|
||||
auto pwdAgn = fdAgn->text();
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LoColorSelector::LoColorSelector(const QString &text, const QColor &color, QWidg
|
|||
init();
|
||||
}
|
||||
void LoColorSelector::init() {
|
||||
connect(this, &QPushButton::clicked, this, [this]{
|
||||
connect(this, &QPushButton::clicked, this, [=]{
|
||||
QColorDialog colorDlg(this);
|
||||
colorDlg.setOption(QColorDialog::ShowAlphaChannel);
|
||||
colorDlg.setOption(QColorDialog::DontUseNativeDialog);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
class LoColorSelector : public QPushButton {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoColorSelector(QWidget *parent = nullptr);
|
||||
explicit LoColorSelector(const QString &text, const QColor &color = Qt::transparent, QWidget *parent = nullptr);
|
||||
explicit LoColorSelector(QWidget *parent = 0);
|
||||
explicit LoColorSelector(const QString &text, const QColor &color = Qt::transparent, QWidget *parent = 0);
|
||||
void init();
|
||||
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-radius: 4px;
|
||||
background-color: transparent;
|
||||
padding: 3px 6px;
|
||||
max-height: 30px;
|
||||
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 <QStandardPaths>
|
||||
#include <QUuid>
|
||||
#include <QDateEdit>
|
||||
|
||||
CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
|
@ -1299,6 +1300,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
grpG12 = new QGroupBox;
|
||||
{
|
||||
auto hBox = new HBox(grpG12);
|
||||
hBox->setSpacing(2);
|
||||
|
||||
auto edG12Reso = new QComboBox;
|
||||
edG12Reso->setMinimumWidth(160);
|
||||
|
|
@ -1316,27 +1318,72 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
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("720x480P60", "720x480@59.94-736-798-858-489-495-525-a-27000");
|
||||
edG12Reso->addItem("Custom", "Custom");
|
||||
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);
|
||||
connect(btn, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
JObj json;
|
||||
json.insert("_id", "SetScreenSizeTo3568");
|
||||
json.insert("_type", "SetScreenSizeTo3568");
|
||||
json.insert("screenSize", edG12Reso->currentData().toString());
|
||||
if(gSelCards.count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, translate("","Setting ")+translate("","Screen Size")+" 3568 ...");
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
Def_CtrlSetReqAfter
|
||||
});
|
||||
auto screenSize = edG12Reso->currentData().toString();
|
||||
if(screenSize=="Custom") {
|
||||
JObj json;
|
||||
json.insert("_id", "CustomHdmiResolution");
|
||||
json.insert("_type", "CustomHdmiResolution");
|
||||
json.insert("width", cosWidth->text().toInt());
|
||||
json.insert("height", cosHeight->text().toInt());
|
||||
json.insert("frame", cosFPS->text().toDouble());
|
||||
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")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(auto &card : gSelCards) {
|
||||
Def_CtrlSetMulti(translate("","Set ")+translate("","Screen Size")+" 3568")
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -2461,6 +2508,150 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
line->setFrameStyle(QFrame::HLine | QFrame::Sunken);
|
||||
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;
|
||||
{
|
||||
|
|
@ -2490,7 +2681,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "SetSpecialResolution");
|
||||
json.insert("_type", "SetSpecialResolution");
|
||||
json.insert("displayResolution", fdM80Resolu->currentText()); //显示分辨率
|
||||
|
|
@ -2516,7 +2707,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "GetSpecialResolution");
|
||||
json.insert("_type", "GetSpecialResolution");
|
||||
if(gSelCards.count() == 1) {
|
||||
|
|
@ -2532,8 +2723,8 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||
auto cardId = card.id;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
QJsonDocument json;
|
||||
QString err = checkReplyForJson(reply, &json);
|
||||
JValue json;
|
||||
auto err = errStrWithJson(reply, &json);
|
||||
if(err.isEmpty()) err = tr("totalResolution")+"["+json["totalResolution"].toString()+"], "+tr("strCurDisplayResolution")+"["+json["displayResolution"].toString()+"]";
|
||||
gFdResInfo->append(cardId+" "+tr("GetSpecialResolution")+" "+err);
|
||||
});
|
||||
|
|
@ -2549,7 +2740,7 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "CleanDisplayScreenSize");
|
||||
json.insert("_type", "CleanDisplayScreenSize");
|
||||
if(gSelCards.count() == 1) {
|
||||
|
|
@ -2885,30 +3076,75 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
|
||||
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(fdIsOpenADB, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
connect(bnADBOpen, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "OpenAdb");
|
||||
json.insert("_type", "OpenAdb");
|
||||
json.insert("open", checked);
|
||||
json.insert("open", true);
|
||||
if(gSelCards.count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("OpenAdb")+" ...");
|
||||
auto waitingDlg = new WaitingDlg(this, "Opening ADB ...");
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
Def_CtrlSetReqAfter
|
||||
});
|
||||
} else {
|
||||
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);
|
||||
|
||||
|
|
@ -3193,9 +3429,12 @@ CtrlAdvancedPanel::CtrlAdvancedPanel() {
|
|||
|
||||
for(auto btn : btnSets) 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;
|
||||
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [this] {
|
||||
#endif
|
||||
connect(gDevicePanel, &DevicePanel::sigSelectedDeviceList, this, [=] {
|
||||
if(isVisible()) init();
|
||||
});
|
||||
transUi();
|
||||
|
|
@ -3364,7 +3603,6 @@ void CtrlAdvancedPanel::transUi() {
|
|||
lbBaudModel->setText(tr("Model"));
|
||||
lbUart->setText(tr("Uart"));
|
||||
lbBaud->setText(tr("Baud"));
|
||||
fdIsOpenADB->setText(tr("Open ADB"));
|
||||
btnSendCustomJson->setText(translate("","Send"));
|
||||
btnCustomJsonGet->setText(translate("","Get"));
|
||||
|
||||
|
|
@ -3381,7 +3619,7 @@ void CtrlAdvancedPanel::transUi() {
|
|||
lbScreenWidth->setText(tr("Screen Width(pixel)"));
|
||||
fdCompanyId->setPlaceholderText(tr("Compant ID"));
|
||||
|
||||
btnWareUpdate->setText(tr("Firmware Management"));
|
||||
btnWareUpdate->setText(tr("Firmware Manager"));
|
||||
lbWareTip->setText("(APK / FPGA "+tr("update or uninstall")+")");
|
||||
btnApkCheck->setText(tr("Check Apk"));
|
||||
btnGetLog->setText(tr("Check Log"));
|
||||
|
|
|
|||
|
|
@ -78,7 +78,6 @@ private:
|
|||
QGroupBox *grpBoxHiddenSettings;
|
||||
QPushButton *btnSysUpd, *btnMcuUpd, *btnMcuGet;
|
||||
QLabel *lbRotate, *lbChargingStation, *lbBaudCfg, *lbBaudModel, *lbUart, *lbBaud;
|
||||
QCheckBox *fdIsOpenADB;
|
||||
QLabel *lbCustomJson;
|
||||
QTextEdit *fdCustomJson;
|
||||
QPushButton *btnSendCustomJson, *btnCustomJsonGet;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
fdBrightTip->setWordWrap(true);
|
||||
vBox->addWidget(fdBrightTip);
|
||||
|
||||
auto hBox = new QHBoxLayout;
|
||||
auto hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
lbSensi = new QLabel;
|
||||
|
|
@ -82,15 +82,15 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
});
|
||||
hBox->addWidget(lbSensiValue);
|
||||
|
||||
btnSensiSet = new QPushButton;
|
||||
btnSensiSet->setMinimumSize(60, 30);
|
||||
btnSensiSet->setProperty("ssType", "progManageTool");
|
||||
connect(btnSensiSet, &QPushButton::clicked, this, [this] {
|
||||
auto bn = new QPushButton;
|
||||
btnSets.push_back(bn);
|
||||
bn->setMinimumSize(60, 30);
|
||||
connect(bn, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "SetBrightnessSensitivity");
|
||||
json.insert("_type", "SetBrightnessSensitivity");
|
||||
json.insert("sensitivity", fdSensi->value());
|
||||
|
|
@ -106,17 +106,16 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
}
|
||||
}
|
||||
});
|
||||
hBox->addWidget(btnSensiSet);
|
||||
hBox->addWidget(bn);
|
||||
|
||||
btnSensiGet = new QPushButton;
|
||||
btnSensiGet->setMinimumSize(60, 30);
|
||||
btnSensiGet->setProperty("ssType", "progManageTool");
|
||||
connect(btnSensiGet, &QPushButton::clicked, this, [this] {
|
||||
btnGets.push_back(bn = new QPushButton);
|
||||
bn->setMinimumSize(60, 30);
|
||||
connect(bn, &QPushButton::clicked, this, [this] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "GetBrightnessSensitivity");
|
||||
json.insert("_type", "GetBrightnessSensitivity");
|
||||
if(gSelCards.count() == 1) {
|
||||
|
|
@ -129,9 +128,9 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
});
|
||||
} else {
|
||||
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;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
JValue json;
|
||||
auto err = errStrWithJson(reply, &json);
|
||||
if(err.isEmpty()) err = QString::number(json["sensitivity"].toInt());
|
||||
|
|
@ -140,44 +139,40 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
}
|
||||
}
|
||||
});
|
||||
hBox->addWidget(btnSensiGet);
|
||||
hBox->addWidget(bn);
|
||||
|
||||
hBox->addStretch();
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout;
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
lbMinBright = new QLabel;
|
||||
lbMinBright = hBox->addLabel();
|
||||
lbMinBright->setMinimumWidth(120);
|
||||
lbMinBright->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
hBox->addWidget(lbMinBright);
|
||||
|
||||
fdMinBright = new QSlider(Qt::Horizontal);
|
||||
fdMinBright->setRange(1, 100);
|
||||
hBox->addWidget(fdMinBright);
|
||||
edMinBright = new QSlider(Qt::Horizontal);
|
||||
edMinBright->setRange(1, 100);
|
||||
hBox->addWidget(edMinBright);
|
||||
|
||||
auto lbMinBrightValue = new QLabel(QString::number(fdMinBright->value())+"%");
|
||||
auto lbMinBrightValue = hBox->addLabel(QString::number(edMinBright->value())+"%");
|
||||
lbMinBrightValue->setMinimumWidth(40);
|
||||
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)+"%");
|
||||
});
|
||||
hBox->addWidget(lbMinBrightValue);
|
||||
|
||||
btnMinBrightSet = new QPushButton;
|
||||
btnMinBrightSet->setMinimumSize(60, 30);
|
||||
btnMinBrightSet->setProperty("ssType", "progManageTool");
|
||||
connect(btnMinBrightSet, &QPushButton::clicked, this, [this] {
|
||||
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();
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "SetMinBrightness");
|
||||
json.insert("_type", "SetMinBrightness");
|
||||
auto brightPercent = fdMinBright->value();
|
||||
auto brightPercent = edMinBright->value();
|
||||
if(! isAdaptToOld) json.insert("minBrightnessPercentage", brightPercent);
|
||||
if(gSelCards.count() == 1) {
|
||||
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;
|
||||
btnMinBrightGet->setMinimumSize(60, 30);
|
||||
btnMinBrightGet->setProperty("ssType", "progManageTool");
|
||||
connect(btnMinBrightGet, &QPushButton::clicked, this, [this] {
|
||||
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;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "GetMinBrightness");
|
||||
json.insert("_type", "GetMinBrightness");
|
||||
if(gSelCards.count() == 1) {
|
||||
|
|
@ -215,11 +209,11 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
waitingDlg->success();
|
||||
auto value = json["minBrightnessPercentage"].toInt(-1);
|
||||
if(value==-1) value = qRound(json["brightness"].toInt() * 100.0 / brightLevel);
|
||||
fdMinBright->setValue(value);
|
||||
edMinBright->setValue(value);
|
||||
});
|
||||
} else {
|
||||
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 brightLevel = card.BrightnessLevel;
|
||||
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();
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
|
||||
line = new QFrame;
|
||||
|
|
@ -251,7 +334,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
fdSensiTypeTip->setWordWrap(true);
|
||||
vBox->addWidget(fdSensiTypeTip);
|
||||
|
||||
hBox = new QHBoxLayout;
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
fdR68 = new QRadioButton("R68/RL3");
|
||||
|
|
@ -303,9 +386,10 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
return;
|
||||
}
|
||||
}
|
||||
auto rr = fdRL2->isChecked() ? 2 : 3;
|
||||
QJsonArray values;
|
||||
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()) {
|
||||
QMessageBox::information(this, translate("","Tip"), "Cell is empty at 3, "+QString::number(j+3));
|
||||
return;
|
||||
|
|
@ -379,10 +463,9 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
hBox->addWidget(btnTableGet);
|
||||
|
||||
hBox->addStretch();
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
|
||||
hBox = new QHBoxLayout;
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
lbCurBright = new QLabel;
|
||||
|
|
@ -421,7 +504,7 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
});
|
||||
} else {
|
||||
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] {
|
||||
JValue json;
|
||||
auto err = errStrWithJson(reply, &json);
|
||||
|
|
@ -434,7 +517,6 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
hBox->addWidget(btnCurBrightGet);
|
||||
|
||||
hBox->addStretch();
|
||||
vBox->addLayout(hBox);
|
||||
vBox->addStretch();
|
||||
}
|
||||
{
|
||||
|
|
@ -797,6 +879,9 @@ CtrlBrightPanel::CtrlBrightPanel() {
|
|||
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] {
|
||||
if(isVisible()) init();
|
||||
});
|
||||
|
|
@ -835,8 +920,8 @@ void CtrlBrightPanel::init() {
|
|||
json = JObj();
|
||||
json.insert("_id", "GetBrightnessSensitivity");
|
||||
json.insert("_type", "GetBrightnessSensitivity");
|
||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||
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;
|
||||
|
|
@ -850,14 +935,26 @@ void CtrlBrightPanel::init() {
|
|||
json = JObj();
|
||||
json.insert("_id", "GetMinBrightness");
|
||||
json.insert("_type", "GetMinBrightness");
|
||||
reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply, card] {
|
||||
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["minBrightnessPercentage"].toInt(-1);
|
||||
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();
|
||||
}
|
||||
void CtrlBrightPanel::transUi() {
|
||||
for(auto btn : btnSets) btn->setText(translate("","Set"));
|
||||
for(auto btn : btnGets) btn->setText(translate("","Get"));
|
||||
|
||||
lbTitle->setText(tr("Brightness Config"));
|
||||
radioAuto->setText(tr("Auto"));
|
||||
radioManual->setText(tr("Manual"));
|
||||
|
|
@ -875,15 +975,12 @@ void CtrlBrightPanel::transUi() {
|
|||
fdBrightTip->setText(tr("BrightTip1"));
|
||||
fdSensiTypeTip->setText(tr("BrightTip2"));
|
||||
lbSensi->setText(tr("Sensitivity"));
|
||||
lbMinBright->setText(tr("Minbrightness"));
|
||||
btnMinBrightSet->setText(translate("","Set"));
|
||||
btnSensiSet->setText(translate("","Set"));
|
||||
lbMinBright->setText(tr("Min Brightness"));
|
||||
lbMaxBright->setText(tr("Max Brightness"));
|
||||
btnUpload->setText(tr("Upload File"));
|
||||
btnMinBrightGet->setText(translate("","Readback"));
|
||||
btnSensiGet->setText(translate("","Readback"));
|
||||
btnTableGet->setText(translate("","Readback"));
|
||||
btnCurBrightGet->setText(translate("","Refresh"));
|
||||
lbCurBright->setText(tr("Cur Brigntness")+": ");
|
||||
lbCurBright->setText(tr("Ambient Brigntness")+": ");
|
||||
|
||||
lbFixedBright->setText(tr("Brightness value"));
|
||||
btnFixedSet->setText(translate("","Set"));
|
||||
|
|
|
|||
|
|
@ -23,21 +23,16 @@ private:
|
|||
bool restoreScheduleJson(JValue &, int);
|
||||
void getScheduleJson(QJsonObject &, int);
|
||||
QLabel *lbTitle;
|
||||
QRadioButton *radioAuto;
|
||||
QRadioButton *radioManual;
|
||||
QRadioButton *radioSchedule;
|
||||
QRadioButton *radioAuto, *radioManual, *radioSchedule;
|
||||
QCheckBox *fdAdaptToOld;
|
||||
char mSensi{-1};
|
||||
char mTask{-1};
|
||||
char mSensi = -1;
|
||||
char mTask = -1;
|
||||
|
||||
std::vector<QPushButton *> btnSets, btnGets;
|
||||
QLabel *lbSensi;
|
||||
QSlider *fdSensi;
|
||||
QLabel *lbMinBright;
|
||||
QSlider *fdMinBright;
|
||||
QPushButton *btnSensiSet;
|
||||
QPushButton *btnSensiGet;
|
||||
QPushButton *btnMinBrightSet;
|
||||
QPushButton *btnMinBrightGet;
|
||||
QLabel *lbMinBright, *lbMaxBright;
|
||||
QSlider *edMinBright, *edMaxBright;
|
||||
QRadioButton *fdR68;
|
||||
QRadioButton *fdRL2;
|
||||
QPushButton *btnUpload;
|
||||
|
|
|
|||
|
|
@ -59,16 +59,6 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
|||
|
||||
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->setMinimumSize(60, 30);
|
||||
btnSyncSet->setProperty("ssType", "progManageTool");
|
||||
|
|
@ -98,36 +88,78 @@ CtrlHdmiPanel::CtrlHdmiPanel() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(id) {
|
||||
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"))
|
||||
}
|
||||
// if(id) {
|
||||
// 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("_type", "AutoSyncSwitch");
|
||||
json.insert("isAuto", edAutoSwitch->isChecked());
|
||||
if(gSelCards.count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("SyncSwitch"));
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
Def_CtrlSetReqAfter
|
||||
});
|
||||
} else {
|
||||
for(auto &card : gSelCards) {
|
||||
Def_CtrlSetMulti(tr("SyncSwitch"))
|
||||
}
|
||||
}
|
||||
});
|
||||
hBox->addWidget(btnSyncSet);
|
||||
hBox->addSpacing(20);
|
||||
hBox->addWidget(btnAutoSet);
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addSpacing(20);
|
||||
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
btnSyncGet = new QPushButton;
|
||||
btnSyncGet->setMinimumSize(60, 30);
|
||||
|
|
@ -390,6 +422,7 @@ void CtrlHdmiPanel::transUi() {
|
|||
|
||||
fdAsync->setText(tr("Async"));
|
||||
btnSyncSet->setText(translate("","Set"));
|
||||
btnAutoSet->setText(translate("","Set"));
|
||||
btnSyncGet->setText(translate("","Readback"));
|
||||
|
||||
tableSche->setHeaderText("start", tr("Start Time"));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ private:
|
|||
QLabel *lbHdmiCfg;
|
||||
QRadioButton *fdManual, *fdSchedule, *fdAsync, *fdHdmi, *fdHdmi2;
|
||||
QCheckBox *edAutoSwitch;
|
||||
QPushButton *btnSyncSet, *btnSyncGet;
|
||||
QPushButton *btnSyncSet, *btnAutoSet, *btnSyncGet;
|
||||
|
||||
TableWidget *tableSche;
|
||||
QPushButton *btnScheAdd;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "ctrlnetworkpanel.h"
|
||||
#include "gutil/qwaitingdlg.h"
|
||||
#include "main.h"
|
||||
#include "tools.h"
|
||||
#include "devicepanel.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "gutil/qnetwork.h"
|
||||
|
|
@ -101,7 +100,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
btnLanSet = new QPushButton;
|
||||
btnLanSet->setMinimumSize(QSize(60, 30));
|
||||
btnLanSet->setProperty("ssType", "progManageTool");
|
||||
connect(btnLanSet, &QPushButton::clicked, this, [this] {
|
||||
connect(btnLanSet, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
|
|
@ -164,7 +163,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
btnLanGet = new QPushButton;
|
||||
btnLanGet->setMinimumSize(QSize(60, 30));
|
||||
btnLanGet->setProperty("ssType", "progManageTool");
|
||||
connect(btnLanGet, &QPushButton::clicked, this, [this] {
|
||||
connect(btnLanGet, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
|
|
@ -175,7 +174,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
if(gSelCards.count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("GetEthernet"));
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
Def_CtrlSingleGetReply
|
||||
waitingDlg->success();
|
||||
if(json["dhcp"].toBool()) {
|
||||
|
|
@ -192,9 +191,9 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
});
|
||||
} else {
|
||||
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;
|
||||
connect(reply, &QNetworkReply::finished, this, [reply, cardId] {
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
JValue json;
|
||||
auto err = errStrWithJson(reply, &json);
|
||||
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 hBox = new HBox(vvv);
|
||||
hBox->addStretch();
|
||||
hBox->addWidget(fdIsWifi = new QCheckBox);
|
||||
hBox->addWidget(edIsWifi = new QCheckBox);
|
||||
hBox->addStretch();
|
||||
|
||||
hBox = new HBox(vvv);
|
||||
|
|
@ -251,13 +250,13 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
QJsonObject json;
|
||||
JObj json;
|
||||
json.insert("_id", "GetWifiList");
|
||||
json.insert("_type", "GetWifiList");
|
||||
if(gSelCards.count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("GetWifiList")+" ...");
|
||||
Def_CtrlReqPre
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply, waitingDlg] {
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
Def_CtrlSingleGetReply
|
||||
waitingDlg->success();
|
||||
auto wifis = json["wifiList"].toArray();
|
||||
|
|
@ -294,7 +293,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
auto isWifi = fdIsWifi->isChecked();
|
||||
auto isWifi = edIsWifi->isChecked();
|
||||
JObj json;
|
||||
json.insert("_id", "SetSwitchWiFi");
|
||||
json.insert("_type", "SetSwitchWiFi");
|
||||
|
|
@ -313,7 +312,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
auto waitingDlg = new WaitingDlg(this, tr("ConfigurationWiFi")+" ...");
|
||||
waitingDlg->show();
|
||||
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) {
|
||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||
ConnReply(reply, waitingDlg) [=] {
|
||||
|
|
@ -337,7 +336,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
else waitingDlg->success();
|
||||
} else {
|
||||
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) {
|
||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(isG ? jsonG : json);
|
||||
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||
|
|
@ -371,7 +370,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
auto vvv = new VBox(hBox);
|
||||
auto hBox = new HBox(vvv);
|
||||
hBox->addStretch();
|
||||
hBox->addWidget(fdIsAP = new QCheckBox);
|
||||
hBox->addWidget(edIsHotspot = new QCheckBox);
|
||||
hBox->addStretch();
|
||||
|
||||
hBox = new HBox(vvv);
|
||||
|
|
@ -400,10 +399,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
hBox->addStretch();
|
||||
|
||||
hBox = new HBox(vvv);
|
||||
|
||||
auto lll = new QLabel;
|
||||
lll->setMinimumWidth(80);
|
||||
hBox->addWidget(lll);
|
||||
hBox->addSpacing(86);
|
||||
|
||||
auto edIs2_4G = new QRadioButton("2.4G");
|
||||
edIs2_4G->setChecked(true);
|
||||
|
|
@ -424,7 +420,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
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;
|
||||
jsonG.insert("_id", "ControllerWifiSwitch");
|
||||
jsonG.insert("_type", "ControllerWifiSwitch");
|
||||
|
|
@ -435,12 +436,12 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
json.insert("_type", "ConfigurationHotSpot");
|
||||
json.insert("apName", edHotspotName->text());
|
||||
json.insert("apBand", edIs5G->isChecked() ? 1 : 0);
|
||||
json.insert("password", edHotspotPswd->text());
|
||||
json.insert("password", hotspotPswd);
|
||||
if(gSelCards.count() == 1) {
|
||||
auto waitingDlg = new WaitingDlg(this, tr("Config Hotspot")+" ...");
|
||||
waitingDlg->show();
|
||||
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) {
|
||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||
|
|
@ -466,7 +467,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
} else waitingDlg->success();
|
||||
} else {
|
||||
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) {
|
||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(jsonG);
|
||||
connect(reply, &QNetworkReply::finished, gFdResInfo, [=] {
|
||||
|
|
@ -491,7 +492,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
vvv->addStretch();
|
||||
}
|
||||
hBox->addStretch();
|
||||
fdIsWifi->setChecked(true);
|
||||
edIsWifi->setChecked(true);
|
||||
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
|
@ -511,18 +512,18 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
jsonG.insert("_id", "GetWifiSwitchState");
|
||||
jsonG.insert("_type", "GetWifiSwitchState");
|
||||
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();
|
||||
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);
|
||||
connect(waitingDlg, &WaitingDlg::rejected, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [=] {
|
||||
Def_CtrlSingleGetReply
|
||||
waitingDlg->success();
|
||||
if(isG) {
|
||||
fdIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||
fdIsAP->setChecked(json["apEnable"].toBool());
|
||||
edIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||
edIsHotspot->setChecked(json["apEnable"].toBool());
|
||||
edWifiName->setCurrentText(json["wifiName"].toString());
|
||||
edHotspotName->setText(json["hotSpotName"].toString());
|
||||
edIs5G->setChecked(json["apBand"].toBool());
|
||||
|
|
@ -530,15 +531,15 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
edWifiName->setCurrentText(json["wifi"].toString());
|
||||
auto hotSpots = json["hotSpots"].toString();
|
||||
edHotspotName->setText(hotSpots);
|
||||
fdIsWifi->setChecked(hotSpots.isEmpty());
|
||||
fdIsAP->setChecked(! hotSpots.isEmpty());
|
||||
edIsWifi->setChecked(hotSpots.isEmpty());
|
||||
edIsHotspot->setChecked(! hotSpots.isEmpty());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for(auto &card : gSelCards) {
|
||||
auto reply = NetReq("http://"+card.ip+":2016/settings").post(json);
|
||||
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, [=] {
|
||||
JValue json;
|
||||
auto err = errStrWithJson(reply, &json);
|
||||
|
|
@ -555,7 +556,7 @@ CtrlNetworkPanel::CtrlNetworkPanel() {
|
|||
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;
|
||||
json.insert("_id", "GetEthernet");
|
||||
json.insert("_type", "GetEthernet");
|
||||
auto reply = NetReq("http://"+card.ip+":2016/settings").timeout(120000).post(json);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply] {
|
||||
auto 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;
|
||||
|
|
@ -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());
|
||||
{
|
||||
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) {
|
||||
json.insert("_id", "GetWifiSwitchState");
|
||||
json.insert("_type", "GetWifiSwitchState");
|
||||
|
|
@ -1027,8 +1028,8 @@ void CtrlNetworkPanel::init() {
|
|||
auto err = errStrWithJson(reply, &json);
|
||||
if(! err.isEmpty()) return;
|
||||
if(isG) {
|
||||
fdIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||
fdIsAP->setChecked(json["apEnable"].toBool());
|
||||
edIsWifi->setChecked(json["wifiEnable"].toBool());
|
||||
edIsHotspot->setChecked(json["apEnable"].toBool());
|
||||
edWifiName->setCurrentText(json["wifiName"].toString());
|
||||
edHotspotName->setText(json["hotSpotName"].toString());
|
||||
edIs5G->setChecked(json["apBand"].toBool());
|
||||
|
|
@ -1036,8 +1037,8 @@ void CtrlNetworkPanel::init() {
|
|||
edWifiName->setCurrentText(json["wifi"].toString());
|
||||
auto hotspots = json["hotSpots"].toString();
|
||||
edHotspotName->setText(hotspots);
|
||||
fdIsWifi->setChecked(hotspots.isEmpty());
|
||||
fdIsAP->setChecked(! hotspots.isEmpty());
|
||||
edIsWifi->setChecked(hotspots.isEmpty());
|
||||
edIsHotspot->setChecked(! hotspots.isEmpty());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1046,7 +1047,7 @@ void CtrlNetworkPanel::init() {
|
|||
json = JObj();
|
||||
json.insert("_id", "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, [=] {
|
||||
JValue json;
|
||||
auto err = errStrWithJson(reply, &json);
|
||||
|
|
@ -1060,7 +1061,7 @@ void CtrlNetworkPanel::init() {
|
|||
json = JObj();
|
||||
json.insert("_id", "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, [=] {
|
||||
QJsonDocument json;
|
||||
auto err = checkReplyForJson(reply, &json);
|
||||
|
|
@ -1104,9 +1105,9 @@ void CtrlNetworkPanel::changeEvent(QEvent *event) {
|
|||
void CtrlNetworkPanel::transUi() {
|
||||
lbLanCfg->setText(tr("Wire Enther(RJ45) Configuration"));
|
||||
fdSpecifyIp->setText(tr("Specify IP"));
|
||||
lbHotspotName->setText(tr("AP name"));
|
||||
lbHotspotName->setText(tr("Hotspot Name"));
|
||||
labelGateway->setText(tr("Gateway"));
|
||||
lbWifiName->setText(tr("WiFi name"));
|
||||
lbWifiName->setText(tr("WiFi Name"));
|
||||
labelIpAddress->setText(tr("IP Address"));
|
||||
lbHotspotPswd->setText(tr("Password"));
|
||||
labelDnsAddress->setText(tr("DNS Address"));
|
||||
|
|
@ -1118,12 +1119,12 @@ void CtrlNetworkPanel::transUi() {
|
|||
btnLanSet->setText(translate("","Set"));
|
||||
btnWiFiGet->setText(translate("","Readback"));
|
||||
btnLanGet->setText(translate("","Readback"));
|
||||
fdIsWifi->setText(tr("Enable WiFi"));
|
||||
fdIsAP->setText(tr("Enable AP"));
|
||||
edIsWifi->setText(tr("Enable WiFi"));
|
||||
edIsHotspot->setText(tr("Enable Hotspot"));
|
||||
lbWifiCfg->setText(tr("WiFi Config"));
|
||||
edHotspotPswd->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"));
|
||||
lbCheckStatusTip->setText(tr("Through the check status button"));
|
||||
fdEnableCellular->setText(tr("Enable Cellular Data"));
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ private:
|
|||
QRadioButton *edIs5G;
|
||||
QLabel *lbWifiPswd;
|
||||
|
||||
QCheckBox *fdIsWifi, *fdIsAP;
|
||||
QCheckBox *edIsWifi, *edIsHotspot;
|
||||
QLineEdit *edWifiPswd;
|
||||
QPushButton *btnScan;
|
||||
QPushButton *btnWiFiSet, *btnHotspotSet, *btnWiFiGet;
|
||||
|
|
|
|||
|
|
@ -249,10 +249,10 @@ void CtrlPwdPanel::changeEvent(QEvent *event) {
|
|||
void CtrlPwdPanel::transUi() {
|
||||
lbPwdConfig->setText(tr("Set Password"));
|
||||
lbOldPwd->setText(tr("Original password"));
|
||||
lbNewPwd->setText(tr("New password"));
|
||||
lbNewPwd->setText(translate("","New password"));
|
||||
lbPwdAgain->setText(tr("Enter again"));
|
||||
fdOldPwd->setPlaceholderText(tr("original password"));
|
||||
fdNewPwd->setPlaceholderText(tr("New password"));
|
||||
fdNewPwd->setPlaceholderText(translate("","New password"));
|
||||
fdPwdAgain->setPlaceholderText(tr("Repeat new password"));
|
||||
btnPwdSet->setText(tr("Set encryption"));
|
||||
btnPwdClear->setText(tr("Cancel encryption"));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "ctrltestpanel.h"
|
||||
#include "tools.h"
|
||||
#include "badpointdetectdialog.h"
|
||||
#include "main.h"
|
||||
#include "gutil/qgui.h"
|
||||
#include "gutil/qnetwork.h"
|
||||
#include "gutil/qwaitingdlg.h"
|
||||
|
|
@ -15,14 +16,27 @@
|
|||
CtrlTestPanel::CtrlTestPanel() {
|
||||
auto vBox = new VBox(this);
|
||||
|
||||
labelTestScreen = new QLabel;
|
||||
labelTestScreen->setAlignment(Qt::AlignCenter);
|
||||
vBox->addWidget(labelTestScreen);
|
||||
lbTestScreen = vBox->addLabel();
|
||||
lbTestScreen->setAlignment(Qt::AlignCenter);
|
||||
|
||||
auto hBox = new HBox(vBox);
|
||||
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;
|
||||
vv->addWidget(groupBox);
|
||||
|
||||
auto vvv = new VBox(groupBox);
|
||||
auto hhh = new HBox(vvv);
|
||||
hhh->addStretch();
|
||||
|
|
@ -85,9 +99,10 @@ CtrlTestPanel::CtrlTestPanel() {
|
|||
pushButtonStartLine->setMaximumSize(QSize(80, 16777215));
|
||||
vvv->addWidget(pushButtonStartLine, 0, Qt::AlignHCenter);
|
||||
|
||||
vv->addWidget(groupBox);
|
||||
|
||||
groupBox_2 = new QGroupBox;
|
||||
vv->addWidget(groupBox_2);
|
||||
|
||||
vvv = new VBox(groupBox_2);
|
||||
checkBoxShowInfo = new QCheckBox;
|
||||
|
||||
|
|
@ -142,9 +157,10 @@ CtrlTestPanel::CtrlTestPanel() {
|
|||
pushButtonStartGray->setMaximumSize(QSize(80, 16777215));
|
||||
vvv->addWidget(pushButtonStartGray, 0, Qt::AlignHCenter);
|
||||
|
||||
vv->addWidget(groupBox_2);
|
||||
|
||||
groupBox_3 = new QGroupBox;
|
||||
vv->addWidget(groupBox_3);
|
||||
|
||||
vvv = new VBox(groupBox_3);
|
||||
|
||||
checkBoxGradient = new QCheckBox;
|
||||
|
|
@ -172,7 +188,6 @@ CtrlTestPanel::CtrlTestPanel() {
|
|||
|
||||
vvv->addWidget(pushButtonStartColor, 0, Qt::AlignHCenter);
|
||||
|
||||
vv->addWidget(groupBox_3);
|
||||
|
||||
hhh = new HBox(vv);
|
||||
hhh->addStretch();
|
||||
|
|
@ -237,13 +252,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
|||
btnAnycastReset->setFixedSize(60, 30);
|
||||
btnAnycastReset->setProperty("ssType", "progManageTool");
|
||||
connect(btnAnycastReset, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
SendAnycastCmd(0);
|
||||
fdAnycast->setText("- "+tr("Loop Mode")+" -");
|
||||
btnAnycast->setEnabled(false);
|
||||
});
|
||||
gridLayout->addWidget(btnAnycastReset, 3, 2, 1, 1);
|
||||
|
||||
|
|
@ -252,13 +261,7 @@ CtrlTestPanel::CtrlTestPanel() {
|
|||
btnAnycast->setMinimumHeight(36);
|
||||
btnAnycast->setProperty("ssType", "progManageTool");
|
||||
connect(btnAnycast, &QPushButton::clicked, this, [=] {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
SendAnycastCmd(fdAnycast->text().toInt());
|
||||
fdAnycast->setText(tr("Anycast")+" - "+fdAnycast->text());
|
||||
btnAnycast->setEnabled(false);
|
||||
});
|
||||
vv->addWidget(btnAnycast);
|
||||
vv->addStretch();
|
||||
|
|
@ -423,7 +426,8 @@ void CtrlTestPanel::changeEvent(QEvent *event) {
|
|||
if(event->type() == QEvent::LanguageChange) 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"));
|
||||
radioButtonRed->setText(tr("Red"));
|
||||
radioButtonGreen->setText(tr("Green"));
|
||||
|
|
@ -464,6 +468,10 @@ void CtrlTestPanel::transUi() {
|
|||
}
|
||||
|
||||
void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
||||
if(gSelCards.isEmpty()) {
|
||||
QMessageBox::information(this, translate("","Tip"), translate("","Please select screen first"));
|
||||
return;
|
||||
}
|
||||
ST_ANSY_PROGRAM_PACKET tempStreadPakcet;
|
||||
tempStreadPakcet.ucCommType = 0x97;
|
||||
tempStreadPakcet.iBaoLiu = 0;
|
||||
|
|
@ -476,9 +484,13 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
|||
auto data = QByteArray(reinterpret_cast<char*>(&tempStreadPakcet), iLenPacket);
|
||||
auto action = progIdx==0 ? tr("Reset loop mode") : tr("Anycast");
|
||||
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+" ...");
|
||||
waitingDlg->show();
|
||||
auto card = gSelCards[0];
|
||||
auto tcp = new TcpSocket;
|
||||
connect(waitingDlg, &WaitingDlg::rejected, tcp, [=] {
|
||||
tcp->abort();
|
||||
|
|
@ -505,8 +517,12 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
|||
tcp->startTimer(10000);
|
||||
} else {
|
||||
for(auto &card : gSelCards) {
|
||||
auto tcp = new TcpSocket;
|
||||
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, [=] {
|
||||
tcp->stopTimer();
|
||||
tcp->write(data);
|
||||
|
|
@ -527,4 +543,6 @@ void CtrlTestPanel::SendAnycastCmd(int progIdx) {
|
|||
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
|
||||
public:
|
||||
explicit CtrlTestPanel();
|
||||
signals:
|
||||
void sigSend(QJsonObject &,QString);
|
||||
protected:
|
||||
void changeEvent(QEvent *) override;
|
||||
void transUi();
|
||||
signals:
|
||||
void sigSend(QJsonObject &,QString);
|
||||
private:
|
||||
void SendAnycastCmd(int);
|
||||
|
||||
QLabel *labelTestScreen;
|
||||
QLabel *lbTestScreen;
|
||||
QPushButton *btnBadPoint;
|
||||
QGroupBox *groupBox;
|
||||
QRadioButton *radioButtonRed;
|
||||
QRadioButton *radioButtonGreen;
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
|||
auto btnSelectFpga = new QPushButton(tr("Select Fpga"));
|
||||
hBox->addWidget(btnSelectFpga);
|
||||
|
||||
auto fdFileName = new QLineEdit;
|
||||
fdFileName->setReadOnly(true);
|
||||
fdFileName->setMinimumWidth(200);
|
||||
hBox->addWidget(fdFileName);
|
||||
auto edFileName = new QLineEdit;
|
||||
edFileName->setReadOnly(true);
|
||||
edFileName->setMinimumWidth(200);
|
||||
hBox->addWidget(edFileName);
|
||||
|
||||
connect(btnSelectApk, &QPushButton::clicked, this, [=] {
|
||||
auto aaa = QFileDialog::getOpenFileName(this, "Open file", gApkHome, "apk package (*.apk *.zip)");
|
||||
if(aaa.isEmpty()) return;
|
||||
QFileInfo info(filePath = aaa);
|
||||
gApkHome = info.absolutePath();
|
||||
fdFileName->setText(info.fileName());
|
||||
edFileName->setText(info.fileName());
|
||||
fileId = "";
|
||||
});
|
||||
connect(btnSelectFpga, &QPushButton::clicked, this, [=] {
|
||||
|
|
@ -54,7 +54,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
|||
if(aaa.isEmpty()) return;
|
||||
QFileInfo info(filePath = aaa);
|
||||
gApkHome = info.absolutePath();
|
||||
fdFileName->setText(info.fileName());
|
||||
edFileName->setText(info.fileName());
|
||||
fileId = "";
|
||||
});
|
||||
connect(btnSelectOnlineApk, &QPushButton::clicked, this, [=] {
|
||||
|
|
@ -103,7 +103,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
|||
}
|
||||
connect(table, &TreeWidget::itemDoubleClicked, &dlg, [=, &dlg](QTreeWidgetItem *itm) {
|
||||
auto item = (TreeWidgetItem*) itm;
|
||||
fdFileName->setText(item->text("name"));
|
||||
edFileName->setText(item->text("name"));
|
||||
fileId = item->data(0).toString();
|
||||
filePath = "";
|
||||
dlg.accept();
|
||||
|
|
@ -119,7 +119,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
|||
QMessageBox::warning(&dlg, "Warning", tr("Please select a file"));
|
||||
return;
|
||||
}
|
||||
fdFileName->setText(item->text("name"));
|
||||
edFileName->setText(item->text("name"));
|
||||
fileId = item->data(0).toString();
|
||||
filePath = "";
|
||||
dlg.accept();
|
||||
|
|
@ -132,7 +132,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
|
|||
|
||||
auto btnUpdate = new QPushButton(tr("Upgrade"));
|
||||
connect(btnUpdate, &QPushButton::clicked, this, [=] {
|
||||
auto fileName = fdFileName->text();
|
||||
auto fileName = edFileName->text();
|
||||
if(fileName.length() < 3) return;
|
||||
int cnt = table->topLevelItemCount();
|
||||
QList<UpdateApkItem *> items;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class UpdateApkItem;
|
|||
class UpgradeApkDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UpgradeApkDialog(QWidget *parent = nullptr);
|
||||
explicit UpgradeApkDialog(QWidget *parent = 0);
|
||||
void sendProgress(UpdateApkItem *item);
|
||||
|
||||
QString filePath, fileId;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef QCORE_H
|
||||
#define QCORE_H
|
||||
#include <QThread>
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QProcess>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#define ToStr QString::number
|
||||
|
|
@ -42,6 +44,17 @@ inline int wait(int msec, QObject *context = 0, QEventLoop::ProcessEventsFlags f
|
|||
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>
|
||||
inline QThread *ThreadStart(Func &&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);
|
||||
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) {
|
||||
auto c0 = wgt->textColor();
|
||||
wgt->setTextColor(color);
|
||||
wgt->append(text);
|
||||
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 {
|
||||
public:
|
||||
VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {}
|
||||
|
|
@ -442,6 +455,7 @@ public:
|
|||
horizontalHeader()->setSectionResizeMode(mode);
|
||||
return this;
|
||||
}
|
||||
using QTableWidget::setRowHeight;
|
||||
auto setRowHeight(int value) {
|
||||
if(verticalHeader()->minimumSectionSize() > value) verticalHeader()->setMinimumSectionSize(value);
|
||||
verticalHeader()->setDefaultSectionSize(value);
|
||||
|
|
|
|||
|
|
@ -57,11 +57,12 @@ int main(int argc, char *argv[]) {
|
|||
QApplication::setStyle("Fusion");
|
||||
QApplication app(argc, argv);
|
||||
|
||||
#ifndef leyide
|
||||
QSplashScreen splash(QPixmap(":/res/splash.png"));
|
||||
splash.show();
|
||||
splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white);
|
||||
app.processEvents();
|
||||
|
||||
#endif
|
||||
QFile file(":/css.css");
|
||||
if(file.exists() && file.open(QFile::ReadOnly)) {
|
||||
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));
|
||||
app.setPalette(plt);
|
||||
|
||||
QTranslator qtTrans;
|
||||
if(qtTrans.load(QLocale(), "qt", "_", "translations")) QCoreApplication::installTranslator(&qtTrans);
|
||||
//QTranslator qtTrans;
|
||||
//if(qtTrans.load(QLocale(), "qt", "_", "translations")) QCoreApplication::installTranslator(&qtTrans);
|
||||
|
||||
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||
|
||||
|
|
@ -86,7 +87,9 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
MainWindow win;
|
||||
win.show();
|
||||
#ifndef leyide
|
||||
splash.finish(&win);
|
||||
#endif
|
||||
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);
|
||||
}
|
||||
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 errStrWithJson(QNetworkReply *, JValue * = 0, QByteArray * = 0);
|
||||
QString errStrWithJson(QNetworkReply *, QString errField);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "devicepanel.h"
|
||||
#include "gutil/qnetwork.h"
|
||||
#include "device/upgradeapkdialog.h"
|
||||
#include "gutil/qwaitingdlg.h"
|
||||
#include <QColorDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QMenu>
|
||||
|
|
@ -19,6 +20,11 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include <QNetworkConfigurationManager>
|
||||
#include <Windows.h>
|
||||
#include <WLANAPI.h>
|
||||
#include <QDebug>
|
||||
|
||||
extern QPoint gPlayPos;
|
||||
|
||||
QString gApkHome;
|
||||
|
|
@ -75,7 +81,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
langGrp = new QActionGroup(menuLang);
|
||||
connect(menuLang, &QMenu::triggered, this, [this](QAction* action) {
|
||||
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;
|
||||
|
|
@ -181,7 +188,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
#endif
|
||||
actLan->setChecked(true);
|
||||
emit menuLang->triggered(actLan);
|
||||
QCoreApplication::installTranslator(&translator);
|
||||
QCoreApplication::installTranslator(&qtTranslator);
|
||||
QCoreApplication::installTranslator(&appTranslator);
|
||||
|
||||
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);
|
||||
|
|
@ -227,12 +235,13 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
|
||||
auto menu_setting = new QMenu;
|
||||
|
||||
actFirmware = new QAction(tr("firmware manager"));
|
||||
actFirmware = new QAction(tr("Firmware Manager"));
|
||||
connect(actFirmware, &QAction::triggered, this, [this] {
|
||||
new UpgradeApkDialog(this);
|
||||
});
|
||||
#ifndef leyide
|
||||
menu_setting->addAction(actFirmware);
|
||||
|
||||
#endif
|
||||
actPreferences = new QAction(tr("Preferences"));
|
||||
connect(actPreferences, &QAction::triggered, this, [this] {
|
||||
QDialog dlg(this);
|
||||
|
|
@ -674,6 +683,117 @@ MainWindow::MainWindow(QWidget *parent) : BaseWin(parent) {
|
|||
}
|
||||
|
||||
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() {
|
||||
QSettings settings;
|
||||
|
|
@ -711,7 +831,7 @@ void MainWindow::transUi() {
|
|||
act_help->setText(tr("Help"));
|
||||
if(act_about) act_about->setText(tr("About"));
|
||||
if(act_upd) act_upd->setText(tr("Check for updates"));
|
||||
actFirmware->setText(tr("firmware manager"));
|
||||
actFirmware->setText(tr("Firmware Manager"));
|
||||
actPreferences->setText(tr("Preferences"));
|
||||
bn_Setting->setToolTip(tr("Setting"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ protected:
|
|||
void transUi();
|
||||
private:
|
||||
QJsonObject updates;
|
||||
QTranslator translator;
|
||||
QTranslator qtTranslator, appTranslator;
|
||||
LoQTitleBar *m_wTitle;
|
||||
QActionGroup *langGrp;
|
||||
QAction *act_lang;
|
||||
|
|
|
|||
|
|
@ -3,78 +3,68 @@
|
|||
#include <QOpenGLWidget>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QDebug>
|
||||
|
||||
EleScroll::EleScroll(QWidget *parent, QString dirPre, const JValue &json, int w, int h) : QWidget{parent}, w(w), h(h) {
|
||||
img.load(dirPre + json["id"].toString());
|
||||
auto effStr = json["effect"].toString();
|
||||
if(effStr.isEmpty() || effStr=="no") return;
|
||||
EleScroll::EleScroll(QWidget *parent, QList<QPixmap> imgs, char direct, double speed) : QWidget{parent}, imgs(imgs), direct(direct) {
|
||||
auto img0 = imgs[0];
|
||||
qDebug().nospace()<<" SrcScroll img cnt "<<imgs.size()<<", "<<img0.width()<<"x"<<img0.height()<<" direct "<<direct<<" speed "<<speed;
|
||||
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;
|
||||
if(scrollSpeed > 60) step = (int) round(scrollSpeed/60);
|
||||
else if(scrollSpeed < 60) interval = (int) round(60/scrollSpeed);
|
||||
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;
|
||||
if(speed > 60) step = (int) round(speed/60);
|
||||
else if(speed < 60) interval = (int) round(60/speed);
|
||||
}
|
||||
|
||||
void EleScroll::paintEvent(QPaintEvent *e) {
|
||||
if(img.isNull()) return;
|
||||
if(imgs.isEmpty()) return;
|
||||
auto rect = e->rect();
|
||||
QPainter painter(this);
|
||||
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
|
||||
if(effect=='l') {
|
||||
int x = cur;
|
||||
if(direct=='l') {
|
||||
int ii = 0, x = cur;
|
||||
do {
|
||||
if(x > rect.left()-img.width() && x < rect.right()+1) painter.drawPixmap(x, 0, img);
|
||||
x += img.width();
|
||||
if(x > rect.left()-imgs[ii].width() && x < rect.right()+1) painter.drawPixmap(x, 0, imgs[ii]);
|
||||
x += imgs[ii].width();
|
||||
if(++ii >= imgs.size()) ii = 0;
|
||||
} while(x < rect.right()+1);
|
||||
} else if(effect=='r') {
|
||||
int x = cur + w;
|
||||
} else if(direct=='r') {
|
||||
int ii = imgs.size()-1, x = cur + width();
|
||||
bool con1;
|
||||
do {
|
||||
x -= img.width();
|
||||
con1 = x > rect.left()-img.width();
|
||||
if(con1 && x < rect.right()+1) painter.drawPixmap(x, 0, img);
|
||||
x -= imgs[ii].width();
|
||||
con1 = x > rect.left()-imgs[ii].width();
|
||||
if(con1 && x < rect.right()+1) painter.drawPixmap(x, 0, imgs[ii]);
|
||||
if(--ii < 0) ii = imgs.size()-1;
|
||||
} while(con1);
|
||||
} else if(effect=='t') {
|
||||
int y = cur;
|
||||
} else if(direct=='t') {
|
||||
int ii = 0, y = cur;
|
||||
do {
|
||||
if(y > rect.top()-img.height() && y < rect.bottom()+1) painter.drawPixmap(0, y, img);
|
||||
y += img.height();
|
||||
if(y > rect.top()-imgs[ii].height() && y < rect.bottom()+1) painter.drawPixmap(0, y, imgs[ii]);
|
||||
y += imgs[ii].height();
|
||||
if(++ii >= imgs.size()) ii = 0;
|
||||
} while(y < rect.bottom()+1);
|
||||
} else if(effect=='b') {
|
||||
int y = cur + h;
|
||||
} else if(direct=='b') {
|
||||
int ii = imgs.size()-1, y = cur + height();
|
||||
bool con1;
|
||||
do {
|
||||
y -= img.height();
|
||||
con1 = y > rect.top()-img.height();
|
||||
if(con1 && y < rect.bottom()+1) painter.drawPixmap(0, y, img);
|
||||
y -= imgs[ii].height();
|
||||
con1 = y > rect.top()-imgs[ii].height();
|
||||
if(con1 && y < rect.bottom()+1) painter.drawPixmap(0, y, imgs[ii]);
|
||||
if(--ii < 0) ii = imgs.size()-1;
|
||||
} while(con1);
|
||||
} else painter.drawPixmap(0, 0, img);
|
||||
if(freshCnt==0 && effect!=0 && interval!=0) connect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, &EleScroll::doFrame, Qt::UniqueConnection);
|
||||
} else painter.drawPixmap(0, 0, imgs[0]);
|
||||
if(freshCnt==0 && direct!=0 && interval!=0) connect(PlayWin::self->gl, &QOpenGLWidget::frameSwapped, this, &EleScroll::doFrame, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void EleScroll::doFrame() {
|
||||
|
|
@ -86,10 +76,10 @@ void EleScroll::doFrame() {
|
|||
if(freshCnt < interval) freshCnt++;
|
||||
else {
|
||||
freshCnt = 1;
|
||||
if(effect=='t' || effect=='l') {
|
||||
if(direct=='t' || direct=='l') {
|
||||
if(cur <= end) cur -= end;
|
||||
else cur -= step;
|
||||
} else if(effect=='b' || effect=='r') {
|
||||
} else if(direct=='b' || direct=='r') {
|
||||
if(cur >= end) cur -= end;
|
||||
else cur += step;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,10 @@ class EleScroll : public QWidget {
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit EleScroll(QWidget *, QString, const JValue &, int, int);
|
||||
explicit EleScroll(QWidget *, QString, char effect = 0, double effDur = 0.0);
|
||||
int w = 0, h = 0;
|
||||
QPixmap img;
|
||||
char effect = 0;
|
||||
explicit EleScroll(QWidget *parent, QList<QPixmap> imgs, char direct = 0, double speed = 0.0);
|
||||
QList<QPixmap> imgs;
|
||||
char direct = 0;
|
||||
int interval = 0, freshCnt = 0, cur = 0, end = 0, step = 1;
|
||||
bool noUpdate = false;
|
||||
void doFrame();
|
||||
protected:
|
||||
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);
|
||||
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")) {
|
||||
auto previewImg = source["previewImg"].toStr();
|
||||
if(! previewImg.isEmpty()) {
|
||||
if(source["bSingleScroll"].toBool()) src.view = new EleScroll(box, dir+"/"+previewImg, 'l', source["iScrollSpeed"].toDouble());
|
||||
else src.view = new EleScroll(box, dir+"/"+previewImg);
|
||||
if(source["bSingleScroll"].toBool()) src.view = new EleScroll(box, {QPixmap(dir+"/"+previewImg)}, 'l', source["iScrollSpeed"].toDouble());
|
||||
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=="AnalogClock") src.view = new EleAnaClock(w, h, dir+"/"+id, source, box);
|
||||
else if(src.type=="Video" || src.type=="Audio") {
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ bool EAClock::save(const QString &pRoot){
|
|||
}
|
||||
return true;
|
||||
}
|
||||
JObj EAClock::attrJson() const {
|
||||
JObj EAClock::attrJson() {
|
||||
JObj json;
|
||||
json["elementType"] = "AClock";
|
||||
json["timeZone"] = QString::fromUtf8(m_attr.timeZone.id());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public:
|
|||
int type() const override { return EBase::AClock; }
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &pRoot) override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
|
|
|
|||
|
|
@ -721,7 +721,7 @@ void EBase::addBaseAttrWgt(QBoxLayout *vBox) {
|
|||
hBox->addStretch();
|
||||
auto borderFd = new QComboBox;
|
||||
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));
|
||||
if(bdImgIdx>-1) borderFd->setCurrentIndex(bdImgIdx+1);
|
||||
connect(borderFd, (void(QComboBox::*)(int))&QComboBox::currentIndexChanged, this, [this](int idx){
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public:
|
|||
QRectF boundingRect() const 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 QWidget* attrWgt() = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ QWidget* EDClock::attrWgt() {
|
|||
return wgtAttr;
|
||||
}
|
||||
|
||||
JObj EDClock::attrJson() const {
|
||||
JObj EDClock::attrJson() {
|
||||
JObj json;
|
||||
addBaseAttr(json);
|
||||
json["elementType"] = "DClock";
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
int type() const override { return EBase::DClock; }
|
||||
QWidget* attrWgt() override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
QTimeZone timeZone;
|
||||
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("NW"), "NW");
|
||||
res["values"] = values;
|
||||
|
||||
auto hideUnits = json["hideUnits"].toBool();
|
||||
JArray oitems;
|
||||
std::unordered_map<QString, QString> unitMap;
|
||||
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}});
|
||||
auto oitem = oitems->back().toObj();
|
||||
Tools::saveImg(dstDir, metric, font, color, oitem, pair.second["label"].toString(), "label");
|
||||
if(hideUnits) continue;
|
||||
auto unit = itemMap[pair.first].unit;
|
||||
if(unit.isEmpty()) continue;
|
||||
auto &url = unitMap[unit];
|
||||
|
|
@ -101,6 +102,7 @@ EEnviron::EEnviron(const JObj &json, EBase *multiWin): EBase(multiWin){
|
|||
textColor = json["textColor"].toStr("#ff000000");
|
||||
tempCompen = json["tempCompen"].toInt();
|
||||
useFahrenheit = json["useFahrenheit"].toInt();
|
||||
hideUnits = json["hideUnits"].toBool();
|
||||
title = json["title"].toStr();
|
||||
isSingleLine = json["isSingleLine"].toBool();
|
||||
scrollSpeed = json["scrollSpeed"].toInt();
|
||||
|
|
@ -161,7 +163,8 @@ void EEnviron::calAttr() {
|
|||
if(item.first=="temp") scroll_txt += QString::number(tempCompen);
|
||||
else if(item.first=="windDirection") scroll_txt += "--";
|
||||
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);
|
||||
}
|
||||
|
|
@ -187,7 +190,7 @@ void EEnviron::drawText(QPainter *painter, QRectF& rect) {
|
|||
if(itemPair.first=="temp") text += QString::number(tempCompen);
|
||||
else if(itemPair.first=="windDirection") text += "--";
|
||||
else text += "0";
|
||||
text += itemPair.second.unit;
|
||||
if(! hideUnits) text += itemPair.second.unit;
|
||||
painter->drawText(rect, text, opt);
|
||||
rect.translate(0, rect.height());
|
||||
}
|
||||
|
|
@ -280,7 +283,7 @@ QWidget* EEnviron::attrWgt() {
|
|||
hBox->addWidget(fdIsCelsius);
|
||||
|
||||
auto fdIsFahrenheit = new QRadioButton("℉");
|
||||
connect(fdIsFahrenheit, &QRadioButton::toggled, this, [this](bool checked) {
|
||||
connect(fdIsFahrenheit, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
useFahrenheit = checked;
|
||||
calAttr();
|
||||
update();
|
||||
|
|
@ -307,7 +310,7 @@ QWidget* EEnviron::attrWgt() {
|
|||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
|
||||
hBox->addWidget(new QLabel(tr("Compensation")));
|
||||
hBox->addLabel(tr("Compensation"));
|
||||
|
||||
auto fdCompen = new QSpinBox;
|
||||
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;
|
||||
vBox->addWidget(wgtAlign);
|
||||
hBox = new HBox(wgtAlign);
|
||||
|
|
@ -329,7 +343,7 @@ QWidget* EEnviron::attrWgt() {
|
|||
|
||||
auto fdLeft = new QRadioButton(tr("Left"));
|
||||
fdLeft->setChecked(true);
|
||||
connect(fdLeft, &QRadioButton::toggled, this, [this](bool checked) {
|
||||
connect(fdLeft, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
if(! checked) return;
|
||||
align = 0;
|
||||
calAttr();
|
||||
|
|
@ -338,7 +352,7 @@ QWidget* EEnviron::attrWgt() {
|
|||
hBox->addWidget(fdLeft);
|
||||
|
||||
auto fdCenter = new QRadioButton(tr("Center"));
|
||||
connect(fdCenter, &QRadioButton::toggled, this, [this](bool checked) {
|
||||
connect(fdCenter, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
if(! checked) return;
|
||||
align = 1;
|
||||
calAttr();
|
||||
|
|
@ -347,7 +361,7 @@ QWidget* EEnviron::attrWgt() {
|
|||
hBox->addWidget(fdCenter);
|
||||
|
||||
auto fdRight = new QRadioButton(tr("Right"));
|
||||
connect(fdRight, &QRadioButton::toggled, this, [this](bool checked) {
|
||||
connect(fdRight, &QRadioButton::toggled, this, [=](bool checked) {
|
||||
if(! checked) return;
|
||||
align = 2;
|
||||
calAttr();
|
||||
|
|
@ -490,7 +504,7 @@ QWidget* EEnviron::attrWgt() {
|
|||
return wgtAttr;
|
||||
}
|
||||
|
||||
JObj EEnviron::attrJson() const{
|
||||
JObj EEnviron::attrJson() {
|
||||
JObj json;
|
||||
addBaseAttr(json);
|
||||
json["elementType"] = "Temp";
|
||||
|
|
@ -503,6 +517,7 @@ JObj EEnviron::attrJson() const{
|
|||
json["items"] = items;
|
||||
json["tempCompen"] = tempCompen;
|
||||
json["useFahrenheit"] = useFahrenheit;
|
||||
json["hideUnits"] = hideUnits;
|
||||
json["isSingleLine"] = isSingleLine;
|
||||
json["scrollSpeed"] = scrollSpeed;
|
||||
json["align"] = align;
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ public:
|
|||
int tempCompen = 0;
|
||||
int align = 0;
|
||||
int scrollSpeed = 30;
|
||||
bool useFahrenheit = false;
|
||||
bool isSingleLine = false;
|
||||
bool useFahrenheit = false, isSingleLine = false, hideUnits = false;
|
||||
|
||||
static JObj genProg(const JValue &, const QString &, const QString &);
|
||||
|
||||
|
|
@ -54,7 +53,7 @@ public:
|
|||
int type() const override { return EBase::Environ; }
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &pRoot) override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "etimer.h"
|
||||
#include "eenviron.h"
|
||||
#include "eweb.h"
|
||||
#include "etable.h"
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QGraphicsScene>
|
||||
|
|
@ -28,13 +29,14 @@ EMultiWin::EMultiWin(const JObj &json, PageListItem *pageItem) : mPageItem(pageI
|
|||
QString type = element["elementType"].toString();
|
||||
EBase *inner = 0;
|
||||
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=="DClock") inner = new EDClock(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=="Web") inner = new EWeb(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;
|
||||
inner->setPos(0, 0);
|
||||
inner->setFlag(QGraphicsItem::ItemStacksBehindParent);
|
||||
|
|
@ -66,7 +68,7 @@ bool EMultiWin::save(const QString &pageDir) {
|
|||
return true;
|
||||
}
|
||||
|
||||
JObj EMultiWin::attrJson() const{
|
||||
JObj EMultiWin::attrJson() {
|
||||
JArray eles;
|
||||
for(auto inner : inners) eles.append(inner->attrJson());
|
||||
JObj oRoot;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public:
|
|||
int type() const override { return EBase::Window; }
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &) override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
void setCur(EBase *);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@
|
|||
#include <QPainter>
|
||||
#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 name = (widget.isNull() ? json["name"] : widget["file"]).toString();
|
||||
auto file = pageItem->mPageDir + "/" + name;
|
||||
auto file = dir + "/" + name;
|
||||
QImageReader reader(file);
|
||||
reader.setAutoTransform(true);
|
||||
auto img = reader.read();
|
||||
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);
|
||||
return ins;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ EPhoto::EPhoto(QImageReader &reader, const QImage &img, const QString &dir, cons
|
|||
speed = json["speed"].toInt();
|
||||
tailSpacing = json["tailSpacing"].toInt();
|
||||
}
|
||||
JObj EPhoto::attrJson() const {
|
||||
JObj EPhoto::attrJson() {
|
||||
JObj json;
|
||||
addBaseAttr(json);
|
||||
json["elementType"] = frames.empty() ? "Image" : "Gif";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#define EPHOTO_H
|
||||
|
||||
#include "ebase.h"
|
||||
#include "pagelistitem.h"
|
||||
#include "synctimer.h"
|
||||
|
||||
struct Frame {
|
||||
|
|
@ -13,14 +12,14 @@ struct Frame {
|
|||
class EPhoto : public EBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QString filters() { return tr("Images (*.png *.jpg *.jpeg *.bmp *.gif)"); }
|
||||
static EPhoto *create(const JObj &, PageListItem *pageItem, EBase *multiWin = 0);
|
||||
static QString filters() { return tr("Images")+" (*.png *.jpg *.jpeg *.bmp *.gif)"; }
|
||||
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);
|
||||
|
||||
int type() const override { return EBase::Image; }
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
bool save(const QString &pageDir) override;
|
||||
QWidget* attrWgt() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,50 +4,383 @@
|
|||
#include <QSpinBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPainter>
|
||||
#include "xlsxcellrange.h"
|
||||
#include "xlsxchart.h"
|
||||
#include "xlsxchartsheet.h"
|
||||
#include <QFontComboBox>
|
||||
#include <QButtonGroup>
|
||||
#include <QBuffer>
|
||||
#include "xlsxdocument.h"
|
||||
#include "xlsxrichstring.h"
|
||||
#include "xlsxformat.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;
|
||||
dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
||||
dlg.resize(600, 600);
|
||||
setBaseAttr(json);
|
||||
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"));
|
||||
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);
|
||||
hBox = new HBox(vBox);
|
||||
table = new TableWidget(8, 3);
|
||||
auto vv = new VBox(hBox);
|
||||
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();
|
||||
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::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::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::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::Disabled, QPalette::ButtonText, QBrush({157,157,157,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::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::Inactive, QPalette::Highlight, pal.brush(QPalette::Active, QPalette::Highlight));
|
||||
table->setPalette(pal);
|
||||
|
||||
auto ft = table->font();
|
||||
ft.setFamily("Calibri");
|
||||
ft.setPointSize(11);
|
||||
ft.setStyleStrategy(QFont::NoAntialias);
|
||||
table->setFont(ft);
|
||||
table->setShowGrid(false);
|
||||
table->setStyleSheet("QTableView::item { border: 1px solid red;}");
|
||||
table->viewport()->setFont(ft);
|
||||
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);
|
||||
|
||||
read();
|
||||
connect(&dlg, &EmitCloseWidget::onClose, this, &ETable::grabImg);
|
||||
}
|
||||
ETable::ETable(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
||||
mType = EBase::Table;
|
||||
setBaseAttr(json);
|
||||
url = json["url"].toString();
|
||||
read();
|
||||
void PaintTableWidget::paintEvent(QPaintEvent *event) {
|
||||
TableWidget::paintEvent(event);
|
||||
if(ebase) {
|
||||
QPainter painter(viewport());
|
||||
painter.setPen(QPen(Qt::green));
|
||||
auto rect = ebase->innerRect();
|
||||
painter.drawRect(columnViewportPosition(0)-1, rowViewportPosition(0)-1, rect.width(), rect.height());
|
||||
}
|
||||
}
|
||||
int ETable::read() {
|
||||
QXlsx::Document xlsxDoc("d:/aaa.xlsx");
|
||||
if(! xlsxDoc.isLoadPackage()) {
|
||||
qCritical() << "Failed to load xlsx";
|
||||
return -1;
|
||||
}
|
||||
auto currentSheet = xlsxDoc.currentWorksheet();
|
||||
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 ETable::attrJson() {
|
||||
if(png.isEmpty()) {
|
||||
QBuffer buf(&png);
|
||||
img.save(&buf, "PNG");
|
||||
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||
cryptoHash.addData(png);
|
||||
name = QString::fromLatin1(cryptoHash.result().toHex());
|
||||
}
|
||||
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) {
|
||||
auto inner = innerRect();
|
||||
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);
|
||||
}
|
||||
void ETable::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||
dlg.exec();
|
||||
img = table->grab();
|
||||
auto twidth = table->width();
|
||||
if(twidth != img.width()) {
|
||||
img = img.scaledToWidth(twidth, Qt::SmoothTransformation);
|
||||
qDebug()<<"scaledToWidth"<<twidth;
|
||||
}
|
||||
void ETable::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
|
||||
dlg.show();
|
||||
}
|
||||
QWidget* ETable::attrWgt() {
|
||||
auto wgtAttr = new QWidget;
|
||||
|
|
@ -160,45 +589,57 @@ QWidget* ETable::attrWgt() {
|
|||
hBox->addWidget(line, 1);
|
||||
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addSpacing(6);
|
||||
hBox->addLabel("URL:");
|
||||
|
||||
auto url_fd = new QLineEdit(url);
|
||||
hBox->addWidget(url_fd);
|
||||
connect(url_fd, &QLineEdit::textChanged, this, [this](const QString &text) {
|
||||
url = text;
|
||||
|
||||
auto label = hBox->addLabel(tr("Direction"));
|
||||
label->setMinimumWidth(80);
|
||||
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);
|
||||
auto lb = hBox->addLabel(tr("Refresh every")+":");
|
||||
lb->setMinimumWidth(70);
|
||||
lb->setAlignment(Qt::AlignVCenter|Qt::AlignRight);
|
||||
label = hBox->addLabel(tr("Speed"));
|
||||
label->setMinimumWidth(80);
|
||||
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
|
||||
auto edRefresh = new QSpinBox;
|
||||
edRefresh->setRange(0, 99999);
|
||||
edRefresh->setValue(refresh);
|
||||
connect(edRefresh, &QSpinBox::valueChanged, this, [=](int value) {
|
||||
refresh = value;
|
||||
auto edSpeed = new QComboBox;
|
||||
edSpeed->setEditable(true);
|
||||
edSpeed->setMinimumWidth(50);
|
||||
edSpeed->addItem("600");
|
||||
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->addSpacing(-3);
|
||||
hBox->addLabel("s");
|
||||
hBox->addWidget(edSpeed);
|
||||
hBox->addLabel("px/s");
|
||||
hBox->addStretch();
|
||||
|
||||
vBox->addStretch();
|
||||
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 "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 {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ETable(EBase *multiWin = 0);
|
||||
explicit ETable(const JObj &json, EBase *multiWin = 0);
|
||||
|
||||
int read();
|
||||
explicit ETable(int, int, EBase *multiWin = 0);
|
||||
explicit ETable(const JObj &json, const QString &dir, EBase *multiWin = 0);
|
||||
void init(int=0, int=0);
|
||||
int read(QXlsx::Worksheet *);
|
||||
void grabImg();
|
||||
int type() const override {return EBase::Table;}
|
||||
JObj attrJson() override;
|
||||
bool save(const QString &) override;
|
||||
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &) override {return true;};
|
||||
JObj attrJson() const override;
|
||||
|
||||
QDialog dlg;
|
||||
TableWidget *table;
|
||||
EmitCloseWidget dlg;
|
||||
PaintTableWidget *table = 0;
|
||||
QPixmap img;
|
||||
QString url;
|
||||
int zoom = 100, refresh = 0, _x = 0, _y = 0, scaleX = 100, scaleY = 100;
|
||||
QByteArray png;
|
||||
LoColorSelector *edGridColor;
|
||||
QString name;
|
||||
QString direction;
|
||||
int speed = 60;
|
||||
bool isAutoSetting = false;
|
||||
};
|
||||
|
||||
#endif // ETABLE_H
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ EText::EText(const JObj &json, EBase *multiWin) : EBase(multiWin) {
|
|||
align = (Qt::Alignment) widget["align"].toInt();
|
||||
backColor = widget["backColor"].toString("#00000000");
|
||||
lastFont = widget["lastFont"].toString("黑体");
|
||||
letterSpacin = widget["letterSpacin"].toInt(100);
|
||||
auto play = json["play"];
|
||||
if(play.isNull()) {
|
||||
playMode = json["playMode"].toString();
|
||||
|
|
@ -93,25 +94,25 @@ QWidget* EText::attrWgt() {
|
|||
|
||||
auto fdText = new TTextEdit("");
|
||||
|
||||
auto fdFontFamily = new QFontComboBox;
|
||||
fdFontFamily->setEditable(false);
|
||||
fdFontFamily->setCurrentFont(QFont(lastFont));
|
||||
connect(fdFontFamily, &QFontComboBox::currentFontChanged, fdText, [=](const QFont &f) {
|
||||
auto edFontFamily = new QFontComboBox;
|
||||
edFontFamily->setEditable(false);
|
||||
edFontFamily->setCurrentFont(QFont(lastFont));
|
||||
connect(edFontFamily, &QFontComboBox::currentFontChanged, fdText, [=](const QFont &f) {
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontFamilies({f.family()});
|
||||
QTextCursor cursor = fdText->textCursor();
|
||||
auto cursor = fdText->textCursor();
|
||||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||
cursor.mergeCharFormat(fmt);
|
||||
lastFont = f.family();
|
||||
});
|
||||
hBox->addWidget(fdFontFamily);
|
||||
hBox->addWidget(edFontFamily);
|
||||
|
||||
hBox->addStretch();
|
||||
|
||||
auto fdFontSize = new QSpinBox;
|
||||
fdFontSize->setRange(4, 9999);
|
||||
fdFontSize->setValue(16);
|
||||
connect(fdFontSize, &QSpinBox::valueChanged, fdText, [=](int value) {
|
||||
auto edFontSize = new QSpinBox;
|
||||
edFontSize->setRange(4, 9999);
|
||||
edFontSize->setValue(16);
|
||||
connect(edFontSize, &QSpinBox::valueChanged, fdText, [=](int value) {
|
||||
if(value <= 0) return;
|
||||
QTextCharFormat fmt;
|
||||
fmt.setProperty(QTextFormat::FontPixelSize, value);
|
||||
|
|
@ -119,74 +120,77 @@ QWidget* EText::attrWgt() {
|
|||
if(! cursor.hasSelection()) cursor.select(QTextCursor::WordUnderCursor);
|
||||
cursor.mergeCharFormat(fmt);
|
||||
});
|
||||
hBox->addWidget(fdFontSize);
|
||||
hBox->addWidget(edFontSize);
|
||||
|
||||
hBox = new HBox(vBox);
|
||||
hBox->setSpacing(3);
|
||||
|
||||
auto wTextAlignHL = new QPushButton(QIcon(":/res/program/TextAlignHL.png"), "");
|
||||
wTextAlignHL->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||
wTextAlignHL->setFixedSize(30, 30);
|
||||
wTextAlignHL->setIconSize(QSize(30, 30));
|
||||
wTextAlignHL->setCheckable(true);
|
||||
wTextAlignHL->setChecked(true);
|
||||
hBox->addWidget(wTextAlignHL);
|
||||
auto 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);
|
||||
edAlignHL->setChecked(true);
|
||||
hBox->addWidget(edAlignHL);
|
||||
|
||||
auto wTextAlignHC = new QPushButton(QIcon(":/res/program/TextAlignHC.png"), "");
|
||||
wTextAlignHC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||
wTextAlignHC->setFixedSize(30, 30);
|
||||
wTextAlignHC->setIconSize(QSize(30, 30));
|
||||
wTextAlignHC->setCheckable(true);
|
||||
hBox->addWidget(wTextAlignHC);
|
||||
auto 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);
|
||||
hBox->addWidget(edAlignHC);
|
||||
|
||||
auto wTextAlignHR = new QPushButton(QIcon(":/res/program/TextAlignHR.png"), "");
|
||||
wTextAlignHR->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||
wTextAlignHR->setFixedSize(30, 30);
|
||||
wTextAlignHR->setIconSize(QSize(30, 30));
|
||||
wTextAlignHR->setCheckable(true);
|
||||
hBox->addWidget(wTextAlignHR);
|
||||
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);
|
||||
hBox->addWidget(edAlignHR);
|
||||
|
||||
hBox->addStretch();
|
||||
|
||||
auto fdFontBold = new QPushButton("B");
|
||||
fdFontBold->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-weight: bold;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontBold->setFixedSize(30, 30);
|
||||
fdFontBold->setCheckable(true);
|
||||
connect(fdFontBold, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||
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, &QToolButton::toggled, fdText, [=](bool checked) {
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontWeight(checked ? QFont::Bold : QFont::Normal);
|
||||
MergeFmt(fdText, fmt);
|
||||
});
|
||||
hBox->addWidget(fdFontBold);
|
||||
hBox->addWidget(edFontBold);
|
||||
|
||||
auto fdFontItalic = new QPushButton("I");
|
||||
fdFontItalic->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; font-style: italic;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontItalic->setFixedSize(30, 30);
|
||||
fdFontItalic->setCheckable(true);
|
||||
connect(fdFontItalic, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||
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, &QToolButton::toggled, fdText, [=](bool checked) {
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontItalic(checked);
|
||||
MergeFmt(fdText, fmt);
|
||||
});
|
||||
hBox->addWidget(fdFontItalic);
|
||||
hBox->addWidget(edFontItalic);
|
||||
|
||||
auto fdFontUnderline = new QPushButton("U");
|
||||
fdFontUnderline->setStyleSheet("QPushButton{background: #bbb; color: #888; font-size: 20px; text-decoration: underline;} QPushButton:checked{background: #29c; color: #fff;}");
|
||||
fdFontUnderline->setFixedSize(30, 30);
|
||||
fdFontUnderline->setCheckable(true);
|
||||
connect(fdFontUnderline, &QToolButton::toggled, fdText, [fdText](bool checked) {
|
||||
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, &QToolButton::toggled, fdText, [=](bool checked) {
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontUnderline(checked);
|
||||
MergeFmt(fdText, fmt);
|
||||
});
|
||||
hBox->addWidget(fdFontUnderline);
|
||||
hBox->addWidget(edFontUnderline);
|
||||
|
||||
hBox->addStretch();
|
||||
|
||||
auto fdTextColor = new LoColorSelector("T", Qt::white);
|
||||
fdTextColor->setToolTip(tr("Text Color"));
|
||||
fdTextColor->setFixedSize(30, 30);
|
||||
connect(fdTextColor, &LoColorSelector::sColorChanged, fdText, [fdText](const QColor &color) {
|
||||
fdTextColor->setFixedSize(26, 26);
|
||||
connect(fdTextColor, &LoColorSelector::sColorChanged, fdText, [=](const QColor &color) {
|
||||
if(! color.isValid()) return;
|
||||
QTextCharFormat fmt;
|
||||
fmt.setForeground(color);
|
||||
|
|
@ -196,8 +200,8 @@ QWidget* EText::attrWgt() {
|
|||
|
||||
auto fdBackColor = new LoColorSelector("B", backColor);
|
||||
fdBackColor->setToolTip(tr("Back Color"));
|
||||
fdBackColor->setFixedSize(30, 30);
|
||||
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [this](const QColor &color) {
|
||||
fdBackColor->setFixedSize(26, 26);
|
||||
connect(fdBackColor, &LoColorSelector::sColorChanged, this, [=](const QColor &color) {
|
||||
if(! color.isValid()) return;
|
||||
backColor = color;
|
||||
updImg();
|
||||
|
|
@ -227,26 +231,26 @@ QWidget* EText::attrWgt() {
|
|||
hBox = new HBox(vBox);
|
||||
hBox->setSpacing(3);
|
||||
|
||||
auto wTextAlignVT = new QPushButton(QIcon(":/res/program/TextAlignVT.png"), "");
|
||||
wTextAlignVT->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||
wTextAlignVT->setFixedSize(30, 30);
|
||||
wTextAlignVT->setIconSize(QSize(30, 30));
|
||||
wTextAlignVT->setCheckable(true);
|
||||
hBox->addWidget(wTextAlignVT);
|
||||
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);
|
||||
hBox->addWidget(edAlignVT);
|
||||
|
||||
auto wTextAlignVC = new QPushButton(QIcon(":/res/program/TextAlignVC.png"), "");
|
||||
wTextAlignVC->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||
wTextAlignVC->setFixedSize(30, 30);
|
||||
wTextAlignVC->setIconSize(QSize(30, 30));
|
||||
wTextAlignVC->setCheckable(true);
|
||||
hBox->addWidget(wTextAlignVC);
|
||||
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);
|
||||
hBox->addWidget(edAlignVC);
|
||||
|
||||
auto wTextAlignVB = new QPushButton(QIcon(":/res/program/TextAlignVB.png"), "");
|
||||
wTextAlignVB->setStyleSheet("QPushButton{border: none; background: #bbb;} QPushButton:checked{background: #29c;}");
|
||||
wTextAlignVB->setFixedSize(30, 30);
|
||||
wTextAlignVB->setIconSize(QSize(30, 30));
|
||||
wTextAlignVB->setCheckable(true);
|
||||
hBox->addWidget(wTextAlignVB);
|
||||
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);
|
||||
hBox->addWidget(edAlignVB);
|
||||
|
||||
hBox->addStretch();
|
||||
|
||||
|
|
@ -255,11 +259,13 @@ QWidget* EText::attrWgt() {
|
|||
|
||||
auto edLetterSpacing = new QSpinBox;
|
||||
edLetterSpacing->setMaximum(9999);
|
||||
edLetterSpacing->setValue(100);
|
||||
edLetterSpacing->setValue(letterSpacin);
|
||||
connect(edLetterSpacing, &QSpinBox::valueChanged, this, [=](int value) {
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontLetterSpacing(value);
|
||||
MergeFmt(fdText, fmt);
|
||||
letterSpacin = value;
|
||||
updImg();
|
||||
// QTextCharFormat fmt;
|
||||
// fmt.setFontLetterSpacing(value);
|
||||
// MergeFmt(fdText, fmt);
|
||||
});
|
||||
hBox->addWidget(edLetterSpacing);
|
||||
|
||||
|
|
@ -284,9 +290,9 @@ QWidget* EText::attrWgt() {
|
|||
|
||||
|
||||
auto fdAlignH = new QButtonGroup(wgtAttr);
|
||||
fdAlignH->addButton(wTextAlignHL, Qt::AlignLeft);
|
||||
fdAlignH->addButton(wTextAlignHC, Qt::AlignHCenter);
|
||||
fdAlignH->addButton(wTextAlignHR, Qt::AlignRight);
|
||||
fdAlignH->addButton(edAlignHL, Qt::AlignLeft);
|
||||
fdAlignH->addButton(edAlignHC, Qt::AlignHCenter);
|
||||
fdAlignH->addButton(edAlignHR, Qt::AlignRight);
|
||||
connect(fdAlignH, &QButtonGroup::idClicked, this, [=](int value) {
|
||||
QTextBlockFormat fmt;
|
||||
fmt.setAlignment((Qt::Alignment) value);
|
||||
|
|
@ -296,18 +302,18 @@ QWidget* EText::attrWgt() {
|
|||
});
|
||||
|
||||
auto fdAlignV = new QButtonGroup(wgtAttr);
|
||||
fdAlignV->addButton(wTextAlignVT, Qt::AlignTop);
|
||||
fdAlignV->addButton(wTextAlignVC, Qt::AlignVCenter);
|
||||
fdAlignV->addButton(wTextAlignVB, Qt::AlignBottom);
|
||||
connect(fdAlignV, &QButtonGroup::idClicked, this, [this](int value) {
|
||||
fdAlignV->addButton(edAlignVT, Qt::AlignTop);
|
||||
fdAlignV->addButton(edAlignVC, Qt::AlignVCenter);
|
||||
fdAlignV->addButton(edAlignVB, Qt::AlignBottom);
|
||||
connect(fdAlignV, &QButtonGroup::idClicked, this, [=](int value) {
|
||||
align = (Qt::Alignment) value;
|
||||
updImg();
|
||||
});
|
||||
|
||||
auto v_align = align & Qt::AlignVertical_Mask;
|
||||
if(v_align==Qt::AlignTop) wTextAlignVT->setChecked(true);
|
||||
if(v_align==Qt::AlignVCenter) wTextAlignVC->setChecked(true);
|
||||
if(v_align==Qt::AlignBottom) wTextAlignVB->setChecked(true);
|
||||
if(v_align==Qt::AlignTop) edAlignVT->setChecked(true);
|
||||
if(v_align==Qt::AlignVCenter) edAlignVC->setChecked(true);
|
||||
if(v_align==Qt::AlignBottom) edAlignVB->setChecked(true);
|
||||
|
||||
fdText->setMinimumHeight(160);
|
||||
auto doc = fdText->document();
|
||||
|
|
@ -332,14 +338,14 @@ QWidget* EText::attrWgt() {
|
|||
auto ft = format.font();
|
||||
auto families = ft.families();
|
||||
if(! families.isEmpty()) {
|
||||
fdFontFamily->blockSignals(true);
|
||||
fdFontFamily->setCurrentFont(families[0]);
|
||||
fdFontFamily->blockSignals(false);
|
||||
edFontFamily->blockSignals(true);
|
||||
edFontFamily->setCurrentFont(families[0]);
|
||||
edFontFamily->blockSignals(false);
|
||||
lastFont = families[0];
|
||||
}
|
||||
fdFontSize->blockSignals(true);
|
||||
fdFontSize->setValue(ft.pixelSize());
|
||||
fdFontSize->blockSignals(false);
|
||||
edFontSize->blockSignals(true);
|
||||
edFontSize->setValue(ft.pixelSize());
|
||||
edFontSize->blockSignals(false);
|
||||
auto foreground = format.foreground();
|
||||
fdTextColor->blockSignals(true);
|
||||
fdTextColor->setColor(foreground.style()==Qt::NoBrush ? Qt::white : foreground.color());
|
||||
|
|
@ -365,20 +371,20 @@ QWidget* EText::attrWgt() {
|
|||
hBox->addStretch();
|
||||
|
||||
auto pageInfoWgt = new QWidget;
|
||||
auto hhh = new QHBoxLayout(pageInfoWgt);
|
||||
auto hhh = new HBox(pageInfoWgt);
|
||||
hhh->setContentsMargins(0,0,0,0);
|
||||
|
||||
hhh->addWidget(new QLabel(tr("PageCount:")));
|
||||
hhh->addLabel(tr("PageCount:"));
|
||||
|
||||
auto fdPageCnt = new QLabel(QString::number(mImgs.size()));
|
||||
hhh->addWidget(fdPageCnt);
|
||||
|
||||
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());
|
||||
connect(fdPageIdx, &QSpinBox::valueChanged, this, [this](int idx) {
|
||||
connect(fdPageIdx, &QSpinBox::valueChanged, this, [=](int idx) {
|
||||
curIdx = idx - 1;
|
||||
update();
|
||||
});
|
||||
|
|
@ -414,9 +420,9 @@ QWidget* EText::attrWgt() {
|
|||
hBox->addWidget(btnImport);
|
||||
|
||||
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->setFrameShadow(QFrame::Sunken);
|
||||
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));
|
||||
return true;
|
||||
}
|
||||
JObj EText::attrJson() const {
|
||||
JObj EText::attrJson() {
|
||||
JArray files;
|
||||
for(int i=0; i<mImgs.count(); i++) files.append(QString("text%1.png").arg(i)); //上下滚动,生成一张纵向长图
|
||||
JObj obj{
|
||||
|
|
@ -567,6 +573,7 @@ JObj EText::attrJson() const {
|
|||
{"align", (int) align},
|
||||
{"backColor", backColor.name(QColor::HexArgb)},
|
||||
{"lastFont", lastFont},
|
||||
{"letterSpacin", letterSpacin},
|
||||
{"files", files},
|
||||
{"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;
|
||||
font.setFamilies({"Arial","黑体"});
|
||||
font.setPixelSize(16);
|
||||
font.setLetterSpacing(QFont::PercentageSpacing, letterSpacin);
|
||||
if(! gTextAntialiasing) font.setStyleStrategy(QFont::NoAntialias);
|
||||
doc.setDefaultFont(font);
|
||||
doc.setDefaultStyleSheet("body {color: #fff;}");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
int type() const override { return EBase::Text; }
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &pRoot) override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
QString text;
|
||||
Qt::Alignment align;
|
||||
|
|
@ -23,6 +23,7 @@ public:
|
|||
QString direction = "left";
|
||||
int speed = 60;
|
||||
int tailSpacing = 10;
|
||||
int letterSpacin = 100;
|
||||
bool useNewFmt = false;
|
||||
|
||||
public slots:
|
||||
|
|
@ -35,7 +36,7 @@ private:
|
|||
QImage copy(QImage &img, int x, int y, int w, int h);
|
||||
|
||||
QList<QImage> mImgs;
|
||||
int curIdx{0};
|
||||
int curIdx = 0;
|
||||
};
|
||||
|
||||
#endif // ETEXT_H
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ QWidget* ETimer::attrWgt() {
|
|||
return wgtAttr;
|
||||
}
|
||||
|
||||
JObj ETimer::attrJson() const {
|
||||
JObj ETimer::attrJson() {
|
||||
JObj obj;
|
||||
addBaseAttr(obj);
|
||||
obj["elementType"] = "Timer";
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
int type() const override { return EBase::Timer; }
|
||||
QWidget* attrWgt() override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
int secs = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ void repLineHeight(QString &html) {
|
|||
end:
|
||||
if(! pre.isEmpty()) html = pre + html.mid(last);
|
||||
}
|
||||
JObj ETimer2::attrJson() const {
|
||||
JObj ETimer2::attrJson() {
|
||||
JObj ele{{"elementType", "Timer2"}};
|
||||
addBaseAttr(ele);
|
||||
ele["isUp"] = isUp;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
int type() const override { return EBase::TimerHtml; }
|
||||
QWidget* attrWgt() override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
QDateTime targetTime;
|
||||
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);
|
||||
ins->setBaseAttr(ele);
|
||||
if(ins->_duration < 4) ins->_duration = dur;
|
||||
ins->vol = ele["vol"].toInt(100);
|
||||
ins->useSW = ele["useSW"].toBool();
|
||||
ins->isPreSplit = ele["isPreSplit"].toBool();
|
||||
auto play = ele["play"];
|
||||
|
|
@ -139,7 +140,7 @@ QWidget* EVideo::attrWgt() {
|
|||
// wAspectRatioMode->addItem(tr("KeepAspectRatio"));
|
||||
// wAspectRatioMode->addItem(tr("KeepAspectRatioByExpanding"));
|
||||
// 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;
|
||||
// });
|
||||
// hBox->addWidget(wAspectRatioMode);
|
||||
|
|
@ -153,6 +154,21 @@ QWidget* EVideo::attrWgt() {
|
|||
line->setFrameShadow(QFrame::Sunken);
|
||||
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->addSpacing(6);
|
||||
hBox->addLabel(tr("Play Times"));
|
||||
|
|
@ -160,7 +176,7 @@ QWidget* EVideo::attrWgt() {
|
|||
auto edPlayTimes = new QSpinBox;
|
||||
edPlayTimes->setRange(1, 99999);
|
||||
edPlayTimes->setValue(playTimes);
|
||||
connect(edPlayTimes, &QSpinBox::valueChanged, this, [this](int value) {
|
||||
connect(edPlayTimes, &QSpinBox::valueChanged, this, [=](int value) {
|
||||
playTimes = value;
|
||||
});
|
||||
hBox->addWidget(edPlayTimes);
|
||||
|
|
@ -171,7 +187,7 @@ QWidget* EVideo::attrWgt() {
|
|||
|
||||
auto edUseSW = new QCheckBox(tr("Use SW"));
|
||||
edUseSW->setChecked(useSW);
|
||||
connect(edUseSW, &QCheckBox::stateChanged, this, [this](int value) {
|
||||
connect(edUseSW, &QCheckBox::stateChanged, this, [=](int value) {
|
||||
useSW = value==Qt::Checked;
|
||||
});
|
||||
hBox->addWidget(edUseSW);
|
||||
|
|
@ -214,13 +230,14 @@ bool EVideo::save(const QString &pageDir) {
|
|||
return true;
|
||||
}
|
||||
|
||||
JObj EVideo::attrJson() const {
|
||||
JObj EVideo::attrJson() {
|
||||
JObj obj{
|
||||
{"elementType", "Video"},
|
||||
{"path", mDir},
|
||||
{"file", mName},
|
||||
{"pathRaw", mRawDir},
|
||||
{"fileRaw", mRawName},
|
||||
{"vol", vol},
|
||||
{"useSW", useSW},
|
||||
{"isPreSplit", isPreSplit},
|
||||
{"playTimes", playTimes}
|
||||
|
|
@ -294,7 +311,7 @@ QString EVideo::transcoding(QWidget *parent, QString rawFile, QString rawName, Q
|
|||
} 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();
|
||||
if(err.right(32).contains("Conversion failed!")) {
|
||||
QMessageBox::critical(parent, translate("","Error"), err);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public:
|
|||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &pRoot) override;
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
QString mDir;
|
||||
QString mName;
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
QImage mCoverImg;
|
||||
protected:
|
||||
int aspectRatioMode = Qt::IgnoreAspectRatio;
|
||||
int playTimes = 1;
|
||||
int vol = 100, playTimes = 1;
|
||||
bool useSW = false, isPreSplit = false;
|
||||
PageListItem *mPageItem;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ QWidget* EWeb::attrWgt() {
|
|||
return wgtAttr;
|
||||
}
|
||||
|
||||
JObj EWeb::attrJson() const {
|
||||
JObj EWeb::attrJson() {
|
||||
JObj obj;
|
||||
addBaseAttr(obj);
|
||||
obj["elementType"] = "Web";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public:
|
|||
void paint(QPainter*, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
QWidget* attrWgt() override;
|
||||
bool save(const QString &) override {return true;};
|
||||
JObj attrJson() const override;
|
||||
JObj attrJson() override;
|
||||
|
||||
QString url;
|
||||
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["md5"] = id;
|
||||
source["name"] = name;
|
||||
source["vol"] = ele["vol"];
|
||||
source["useSW"] = ele["useSW"];
|
||||
source["isPreSplit"] = ele["isPreSplit"];
|
||||
auto play = ele["play"];
|
||||
|
|
@ -265,6 +266,21 @@ JArray GenTmpThread::genSources(QString type, const JArray &eles) {
|
|||
source["isUp"] = ele["isUp"];
|
||||
source["html"] = ele["html"];
|
||||
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["timeSpan"].isNull()) source["timeSpan"] = ele["duration"];
|
||||
|
|
@ -422,7 +438,7 @@ JObj GenTmpThread::genImage(const JValue &ele) {
|
|||
} else */
|
||||
auto isScroll = ! direct.isEmpty() && speed > 0;
|
||||
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;
|
||||
img.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).save(&buf, "PNG");
|
||||
QCryptographicHash cryptoHash(QCryptographicHash::Md5);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "program/etimer2.h"
|
||||
#include "program/evideo.h"
|
||||
#include "program/eweb.h"
|
||||
#include "program/etable.h"
|
||||
#include <QDateEdit>
|
||||
#include <QDir>
|
||||
#include <QGraphicsView>
|
||||
|
|
@ -42,7 +43,7 @@ PageListItem::PageListItem(const JObj &attr, const QString &pageDir) : mAttr(att
|
|||
auto type = ele["elementType"].toStr();
|
||||
EBase *element = 0;
|
||||
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=="DClock") element = new EDClock(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=="Timer") element = new ETimer(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);
|
||||
if(element) mScene->addItem(element);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,16 @@
|
|||
#include <QCloseEvent>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QInputDialog>
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <QToolBar>
|
||||
#include <QUdpSocket>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "xlsxdocument.h"
|
||||
#include "xlsxworkbook.h"
|
||||
|
||||
ProgItem *gProgItem = 0;
|
||||
|
||||
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->setSpacing(0);
|
||||
|
||||
auto toolBar = new QToolBar();
|
||||
auto toolBar = new QToolBar;
|
||||
toolBar->setFloatable(false);
|
||||
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
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->setData(EBase::TimerHtml);
|
||||
menu->addAction(action);
|
||||
|
||||
action = new QAction(QIcon(":/res/program/Table.png"), tr("Table"));
|
||||
action->setData(EBase::Table);
|
||||
menu = new QMenu;
|
||||
action->setMenu(menu);
|
||||
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->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);
|
||||
|
||||
#ifndef leyide
|
||||
|
|
@ -248,35 +299,35 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
|||
connect(action, &QAction::triggered, this, [this] {
|
||||
if(PlayWin::self) PlayWin::self->close();
|
||||
else {
|
||||
if(isProgChanged()) onSave();
|
||||
auto waitingDlg = new WaitingDlg(this, tr("Generate preview data")+" ...");
|
||||
auto gen = new GenTmpThread(mProgItem, mProgItem->mName, "", "");
|
||||
connect(gen, &GenTmpThread::onErr, this, [=](QString err) {
|
||||
QMessageBox::warning(this, "GenTmpThread Error", err);
|
||||
});
|
||||
connect(gen, &QThread::finished, waitingDlg, &WaitingDlg::close);
|
||||
gen->start();
|
||||
waitingDlg->exec();
|
||||
QFile file(mProgItem->mProgDir+"_tmp/program");
|
||||
if(! file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
|
||||
auto value = file.readAll();
|
||||
file.close();
|
||||
QString jsErr;
|
||||
auto prog = JFrom(value, &jsErr);
|
||||
if(! jsErr.isEmpty()) return;
|
||||
int www = mProgItem->mWidth, hhh = mProgItem->mHeight;
|
||||
if(mProgItem->maxLen) {
|
||||
if(mProgItem->isVer) {
|
||||
hhh = mProgItem->maxLen;
|
||||
www *= mProgItem->partLens.size();
|
||||
} else {
|
||||
www = mProgItem->maxLen;
|
||||
hhh *= mProgItem->partLens.size();
|
||||
}
|
||||
}
|
||||
PlayWin::self = PlayWin::newIns(www, hhh, mProgItem->mProgDir+"_tmp", prog);
|
||||
}
|
||||
});
|
||||
if(isProgChanged()) onSave();
|
||||
auto waitingDlg = new WaitingDlg(this, tr("Generate preview data")+" ...");
|
||||
auto gen = new GenTmpThread(mProgItem, mProgItem->mName, "", "");
|
||||
connect(gen, &GenTmpThread::onErr, this, [=](QString err) {
|
||||
QMessageBox::warning(this, "GenTmpThread Error", err);
|
||||
});
|
||||
connect(gen, &QThread::finished, waitingDlg, &WaitingDlg::close);
|
||||
gen->start();
|
||||
waitingDlg->exec();
|
||||
QFile file(mProgItem->mProgDir+"_tmp/program");
|
||||
if(! file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
|
||||
auto value = file.readAll();
|
||||
file.close();
|
||||
QString jsErr;
|
||||
auto prog = JFrom(value, &jsErr);
|
||||
if(! jsErr.isEmpty()) return;
|
||||
int www = mProgItem->mWidth, hhh = mProgItem->mHeight;
|
||||
if(mProgItem->maxLen) {
|
||||
if(mProgItem->isVer) {
|
||||
hhh = mProgItem->maxLen;
|
||||
www *= mProgItem->partLens.size();
|
||||
} else {
|
||||
www = mProgItem->maxLen;
|
||||
hhh *= mProgItem->partLens.size();
|
||||
}
|
||||
}
|
||||
PlayWin::self = PlayWin::newIns(www, hhh, mProgItem->mProgDir+"_tmp", prog);
|
||||
}
|
||||
});
|
||||
toolBar->addAction(action);
|
||||
action = new QAction(QIcon(":/res/program/Send.png"), tr("Publish"));
|
||||
connect(action, &QAction::triggered, this, [this]{
|
||||
|
|
@ -360,7 +411,6 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(pare
|
|||
} else if(type==EBase::Timer) element = new ETimer;
|
||||
else if(type==EBase::TimerHtml) element = new ETimer2;
|
||||
else if(type==EBase::Window) element = new EMultiWin(mPageItem);
|
||||
else if(type==EBase::Table) element = new ETable;
|
||||
if(element) {
|
||||
if(element->mWidth==0) {
|
||||
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 |