This commit is contained in:
gangphon 2023-04-19 14:42:06 +08:00
parent d812977c14
commit 8bd2a98dd7
25 changed files with 92 additions and 431 deletions

View File

@ -2,9 +2,12 @@ QT += core gui widgets
QT += multimedia QT += multimedia
QT += network QT += network
QT += concurrent QT += concurrent
QT += serialport
QT += opengl QT += opengl
QT += webenginewidgets QT += webenginewidgets
greaterThan(QT_MAJOR_VERSION, 5) {
QT += openglwidgets
}
CONFIG += c++20 CONFIG += c++20
CONFIG += lrelease CONFIG += lrelease
CONFIG += embed_translations CONFIG += embed_translations
@ -19,8 +22,14 @@ TARGET = $$quote(LedOK Express)
VERSION = 1.3.5 VERSION = 1.3.5
DEFINES += APP_VERSION=\\\"$$VERSION\\\" DEFINES += APP_VERSION=\\\"$$VERSION\\\"
msvc { msvc {
contains(QT_ARCH, i386) {
QMAKE_LFLAGS += /LARGEADDRESSAWARE
#QMAKE_LFLAGS += -Wl,--large-address-aware
}
lessThan(QT_MAJOR_VERSION, 6) {
QMAKE_CXXFLAGS += -execution-charset:utf-8 QMAKE_CXXFLAGS += -execution-charset:utf-8
QMAKE_CXXFLAGS += -source-charset:utf-8 QMAKE_CXXFLAGS += -source-charset:utf-8
}
CONFIG += force_debug_info CONFIG += force_debug_info
CONFIG += separate_debug_info CONFIG += separate_debug_info
@ -31,17 +40,11 @@ msvc {
# QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO # QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
# QMAKE_LFLAGS_RELEASE += $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO # QMAKE_LFLAGS_RELEASE += $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
LIBS += -lDbgHelp
} }
win* { win* {
LIBS += -lwinmm LIBS += -lwinmm
LIBS += -lDbghelp LIBS += -lDbghelp
} }
win32 {
QMAKE_LFLAGS += /LARGEADDRESSAWARE
#QMAKE_LFLAGS += -Wl,--large-address-aware
}
SOURCES += \ SOURCES += \
base/aboutdlg.cpp \ base/aboutdlg.cpp \
@ -49,7 +52,6 @@ SOURCES += \
base/customprogressindicator.cpp \ base/customprogressindicator.cpp \
base/loemptydialog.cpp \ base/loemptydialog.cpp \
base/pixbmpshowdialog.cpp \ base/pixbmpshowdialog.cpp \
base/qiplineedit.cpp \
base/softconfigdialog.cpp \ base/softconfigdialog.cpp \
base/switchcontrol.cpp \ base/switchcontrol.cpp \
base/taesclass.cpp \ base/taesclass.cpp \
@ -144,7 +146,6 @@ HEADERS += \
base/customprogressindicator.h \ base/customprogressindicator.h \
base/loemptydialog.h \ base/loemptydialog.h \
base/pixbmpshowdialog.h \ base/pixbmpshowdialog.h \
base/qiplineedit.h \
base/softconfigdialog.h \ base/softconfigdialog.h \
base/switchcontrol.h \ base/switchcontrol.h \
base/taesclass.h \ base/taesclass.h \

View File

@ -1,285 +0,0 @@
/*
* http://blog.csdn.net/u011417605,并在此基础上进行修改
* 1.
* 2.
* 3.
* 4.
* 5.255.IP值时IP格式
* 使QLineEdit嵌套四个小的QLineEdit使paintEvent画出来的使eventFilter来进行分发实现的
*
* QWidget替换原先的__super
*
*
* QLineEdit之间的空隙
*
* 192QLineEdit出
* text()使1921680127192.168.0.127
**/
#include "qiplineedit.h"
#include <QRegExpValidator>
#include <QPainter>
#include <QKeyEvent>
#include <QMessageBox>
#define SPACE 5
QIPLineEdit::QIPLineEdit(QWidget *parent) : QLineEdit(parent) {
QRegExp rx("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");
pHBox = new QHBoxLayout(this);
pHBox->setSpacing(SPACE);
pHBox->setContentsMargins(0, 0, 0, 0);
for(int i = 0; i < 4; i++) {
m_lineEidt[i] = new QLineEdit(this);
m_lineEidt[i]->setFrame(false);
m_lineEidt[i]->setMaxLength(3);
m_lineEidt[i]->setAlignment(Qt::AlignCenter);
m_lineEidt[i]->installEventFilter(this);
m_lineEidt[i]->setValidator(new QRegExpValidator(rx, this));
m_lineEidt[i]->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
switch (i)
{
case 0:
m_lineEidt[i]->setStyleSheet(QLatin1String( "border:1px solid #536874;\n" "border-left-color: rgb(0, 0, 0);\n"
"border-top-color: rgb(0, 0, 0);\n" "border-bottom-color: rgb(0, 0, 0);\n" "border-right: 0px;\n"
"border-right-color: rgbl(255, 255, 255,0);" "border-radius:0px"));
break;
case 1:
m_lineEidt[i]->setStyleSheet(QLatin1String( "border:1px solid #536874;\n" "border-left-color: rgb(255, 255, 255);\n"
"border-top-color: rgb(0, 0, 0);\n" "border-bottom-color: rgb(0, 0, 0);\n" "border-right: 0px;\n" "border-left: 0px;\n"
"border-right-color: rgb(255, 255, 255);" "border-radius:0px"));
break;
case 2:
m_lineEidt[i]->setStyleSheet(QLatin1String( "border:1px solid #536874;\n" "border-left-color: rgb(255, 255, 255);\n"
"border-top-color: rgb(0, 0, 0);\n" "border-bottom-color: rgb(0, 0, 0);\n" "border-right: 0px;\n" "border-left: 0px;\n"
"border-right-color: rgb(255, 255, 255);" "border-radius:0px"));
break;
case 3:
m_lineEidt[i]->setStyleSheet(QLatin1String( "border:1px solid #536874;\n" "border-left-color: rgb(255, 255, 255);\n"
"border-top-color: rgb(0, 0, 0);\n" "border-bottom-color: rgb(0, 0, 0);\n" "border-left: 0px;\n"
"border-right-color: rgb(0, 0, 0);" "border-radius:0px"));
break;
default:
break;
}
pHBox->addWidget(m_lineEidt[i]);
}
this->setReadOnly(true);
m_Color=Qt::white;
connect(m_lineEidt[0],SIGNAL(textChanged(const QString &)),this,SLOT(OnLineEdit1TextChanged(const QString &)));
connect(m_lineEidt[1],SIGNAL(textChanged(const QString &)),this,SLOT(OnLineEdit2TextChanged(const QString &)));
connect(m_lineEidt[2],SIGNAL(textChanged(const QString &)),this,SLOT(OnLineEdit3TextChanged(const QString &)));
connect(m_lineEidt[3],SIGNAL(textChanged(const QString &)),this,SLOT(OnLineEdit4TextChanged(const QString &)));
}
QIPLineEdit::~QIPLineEdit() {
m_lineEidt[0]->deleteLater();
m_lineEidt[1]->deleteLater();
m_lineEidt[2]->deleteLater();
m_lineEidt[3]->deleteLater();
pHBox->deleteLater();
}
void QIPLineEdit::MySetColor(QColor cr)
{
m_Color=cr;
}
void QIPLineEdit::OnLineEdit1TextChanged(const QString & strtemp)
{
if(strtemp.right(1)=="."||strtemp.right(1)=="")
{
m_lineEidt[0]->setText(strtemp.left(strtemp.length()-1));
m_lineEidt[0 + 1]->setFocus();
m_lineEidt[0 + 1]->setCursorPosition(0);
}
}
void QIPLineEdit::OnLineEdit2TextChanged(const QString & strtemp)
{
if(strtemp.right(1)=="."||strtemp.right(1)=="")
{
m_lineEidt[1]->setText(strtemp.left(strtemp.length()-1));
m_lineEidt[1 + 1]->setFocus();
m_lineEidt[1 + 1]->setCursorPosition(0);
}
}
void QIPLineEdit::OnLineEdit3TextChanged(const QString & strtemp)
{
if(strtemp.right(1)=="."||strtemp.right(1)=="")
{
m_lineEidt[2]->setText(strtemp.left(strtemp.length()-1));
m_lineEidt[2 + 1]->setFocus();
m_lineEidt[2 + 1]->setCursorPosition(0);
}
}
void QIPLineEdit::OnLineEdit4TextChanged(const QString & strtemp)
{
if(strtemp.right(1)=="."||strtemp.right(1)=="")
{
m_lineEidt[3]->setText(strtemp.left(strtemp.length()-1));
}
}
void QIPLineEdit::paintEvent(QPaintEvent *event) {
QWidget::paintEvent(event);
QPainter painter(this);
QBrush brush;
int width = 0;
for(int i = 0; i < 3; i++) {
brush.setStyle(Qt::BrushStyle::SolidPattern);
//将两个lineEdit之间的空隙绘制成白色
brush.setColor(m_Color);
painter.setPen(m_Color);
painter.setBrush(brush);
painter.drawRect(m_lineEidt[i]->x() + m_lineEidt[i]->width(), m_lineEidt[i]->y(), SPACE, height());
//绘制空隙的边框
painter.setPen(Qt::black);
painter.drawLine(0, 0, this->width(), 0);
painter.drawLine(0, this->height() - 1, this->width(), this->height() - 1);
//绘制小黑点
brush.setColor(Qt::black);
painter.setPen(QPen());
painter.setBrush(brush);
width += m_lineEidt[i]->width() + (i == 0 ? 2 : SPACE);//布局的间隔
painter.drawEllipse(width, height() / 2 + 4, 1, 1);
}
}
int QIPLineEdit::getIndex(QLineEdit *pEdit){
int index = -1;
for(int i = 0; i < 4; i++) if(pEdit == m_lineEidt[i]) index = i;
return index;
}
bool QIPLineEdit::eventFilter(QObject *obj, QEvent *ev) {
if(children().contains(obj) && QEvent::KeyPress == ev->type()) {
QKeyEvent *keyEvent = dynamic_cast<QKeyEvent *>(ev);
QLineEdit *pEdit = qobject_cast<QLineEdit *>(obj);
switch (keyEvent->key()) {
case Qt::Key_0:
case Qt::Key_1:
case Qt::Key_2:
case Qt::Key_3:
case Qt::Key_4:
case Qt::Key_5:
case Qt::Key_6:
case Qt::Key_7:
case Qt::Key_8:
case Qt::Key_9:
{
QString strText = pEdit->text();
if (pEdit->selectedText().length())
{
pEdit->text().replace(pEdit->selectedText(), QChar(keyEvent->key()));
}
else if (strText.length() == 2 || (strText.length() < 2 && strText.toInt() * 10 > 255))
{
int index = getIndex(pEdit);
if (index != -1 && index != 3)
{
m_lineEidt[index + 1]->setFocus();
m_lineEidt[index + 1]->selectAll();
}
}
else if (strText.length() == 2 && strText.toInt() * 10 < 255)
{
if (Qt::Key_0 == keyEvent->key() && strText.toInt())
{
pEdit->setText(strText.insert(pEdit->cursorPosition(), QChar(Qt::Key_0)));
}
}
return QWidget::eventFilter(obj, ev);
}
break;
case Qt::Key_Backspace:
{
QString strText = pEdit->text();
if (!strText.length() || (strText.length() && !pEdit->cursorPosition()))
{
int index = getIndex(pEdit);
if (index != -1 && index != 0)
{
m_lineEidt[index - 1]->setFocus();
int length = m_lineEidt[index - 1]->text().length();
m_lineEidt[index - 1]->setCursorPosition(length ? length : 0);
}
}
return QWidget::eventFilter(obj, ev);
}
break;
case Qt::Key_Left:
{
if (!pEdit->cursorPosition())
{
int index = getIndex(pEdit);
if (index != -1 && index != 0)
{
m_lineEidt[index - 1]->setFocus();
int length = m_lineEidt[index - 1]->text().length();
m_lineEidt[index - 1]->setCursorPosition(length ? length : 0);
}
}
return QWidget::eventFilter(obj, ev);
}
break;
case Qt::Key_Right:
{
if (pEdit->cursorPosition() == pEdit->text().length())
{
int index = getIndex(pEdit);
if (index != -1 && index != 3)
{
m_lineEidt[index + 1]->setFocus();
m_lineEidt[index + 1]->setCursorPosition(0);
}
}
return QWidget::eventFilter(obj, ev);
}
break;
default:
break;
}
}
return false;
}
void QIPLineEdit::setText(const QString &strIP)
{
if (!isTextValid(strIP))
{
QMessageBox::warning(this, "Attention", "Your IP Address is Invalid!["+strIP+"]", QMessageBox::StandardButton::Ok);
return;
}
else
{
int i = 0;
QStringList ipList = strIP.split(".");
foreach (QString ip, ipList)
{
m_lineEidt[i]->setText(ip);
i++;
}
}
}
bool QIPLineEdit::isTextValid(const QString &strIP) {
QRegExp rx2("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
return rx2.exactMatch(strIP);
}
QString QIPLineEdit::text() const
{
QString strIP;
for (int i = 0; i < 4; i++)
{
strIP.append(m_lineEidt[i]->text());
if (i < 3)
{
strIP.append(".");
}
}
return strIP;
}
void QIPLineEdit::MyClear()
{
m_lineEidt[0]->clear();
m_lineEidt[1]->clear();
m_lineEidt[2]->clear();
m_lineEidt[3]->clear();
}

View File

@ -1,37 +0,0 @@
#ifndef QIPLINEEDIT_H
#define QIPLINEEDIT_H
#include <QLineEdit>
#include <QEvent>
#include <QHBoxLayout>
class QIPLineEdit : public QLineEdit {
Q_OBJECT
public:
QIPLineEdit(QWidget *parent = nullptr);
~QIPLineEdit();
void setText(const QString &strIP);
QString text() const;
void MyClear();
void MySetColor(QColor cr);
protected:
void paintEvent(QPaintEvent *event);
bool eventFilter(QObject *obj, QEvent *ev);
int getIndex(QLineEdit *pEdit);
bool isTextValid(const QString &strIP);
protected slots:
void OnLineEdit1TextChanged(const QString & strtemp);
void OnLineEdit2TextChanged(const QString & strtemp);
void OnLineEdit3TextChanged(const QString & strtemp);
void OnLineEdit4TextChanged(const QString & strtemp);
private:
QLineEdit *m_lineEidt[4];
QHBoxLayout *pHBox;
QColor m_Color;
};
#endif // QIPLINEEDIT_H

View File

@ -43,7 +43,11 @@ void BaseDlg::mouseMoveEvent(QMouseEvent *e) {
} }
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
#include <windows.h> #include <windows.h>
bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *){ #if(QT_VERSION_MAJOR > 5)
bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, qintptr *) {
#else
bool BaseDlg::nativeEvent(const QByteArray &eventType, void *message, long *) {
#endif
if(eventType=="windows_generic_MSG"){ if(eventType=="windows_generic_MSG"){
MSG *msg = (MSG*)message; MSG *msg = (MSG*)message;
if(msg->message==WM_NCACTIVATE){ if(msg->message==WM_NCACTIVATE){

View File

@ -19,7 +19,11 @@ protected:
void mouseReleaseEvent(QMouseEvent *) override; void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override; void mouseMoveEvent(QMouseEvent *) override;
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
#if(QT_VERSION_MAJOR > 5)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#else
bool nativeEvent(const QByteArray &, void *, long *) override; bool nativeEvent(const QByteArray &, void *, long *) override;
#endif
#endif #endif
QPoint pressRel; QPoint pressRel;
bool isActive = false; bool isActive = false;

View File

@ -117,7 +117,13 @@ void BaseWin::mouseDoubleClickEvent(QMouseEvent *e) {
else setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | Qt::WindowMaximized); else setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | Qt::WindowMaximized);
} }
bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *){ #ifdef Q_OS_WINDOWS
#include <windows.h>
#if(QT_VERSION_MAJOR > 5)
bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, qintptr *) {
#else
bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *) {
#endif
if(eventType=="windows_generic_MSG"){ if(eventType=="windows_generic_MSG"){
MSG *msg = (MSG*)message; MSG *msg = (MSG*)message;
if(msg->message==WM_NCACTIVATE){ if(msg->message==WM_NCACTIVATE){
@ -127,3 +133,4 @@ bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *){
} }
return false; return false;
} }
#endif

View File

@ -24,7 +24,13 @@ protected:
bool eventFilter(QObject *, QEvent *) override; bool eventFilter(QObject *, QEvent *) override;
void changeEvent(QEvent *) override; void changeEvent(QEvent *) override;
void mouseDoubleClickEvent(QMouseEvent *) override; void mouseDoubleClickEvent(QMouseEvent *) override;
#ifdef Q_OS_WINDOWS
#if(QT_VERSION_MAJOR > 5)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#else
bool nativeEvent(const QByteArray &, void *, long *) override; bool nativeEvent(const QByteArray &, void *, long *) override;
#endif
#endif
void setFrmSec(const QPoint &pos); void setFrmSec(const QPoint &pos);
void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor); void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor);

View File

@ -166,11 +166,6 @@ void HpptClient::httpGet(const QString &url) {
mProcessingRq.insert(url, true); mProcessingRq.insert(url, true);
QNetworkRequest request{url}; QNetworkRequest request{url};
QSslConfiguration config = request.sslConfiguration();
config.setPeerVerifyMode(QSslSocket::VerifyNone);
config.setProtocol(QSsl::TlsV1SslV3);
request.setSslConfiguration(config);
QNetworkReply* rp = mNetAccessManager.get(request); QNetworkReply* rp = mNetAccessManager.get(request);
connect(rp, &QNetworkReply::downloadProgress, this, &HpptClient::onHttpGetRspProgress); connect(rp, &QNetworkReply::downloadProgress, this, &HpptClient::onHttpGetRspProgress);
} }

View File

@ -21,7 +21,6 @@
#include <QMetaEnum> #include <QMetaEnum>
#include <QProcess> #include <QProcess>
#include <QSettings> #include <QSettings>
#include <QTextCodec>
#include <QUuid> #include <QUuid>
#include <QHeaderView> #include <QHeaderView>
#include <QColorDialog> #include <QColorDialog>
@ -2053,8 +2052,8 @@ void CtrlAdvancedPanel::init() {
hide(); hide();
PasswordInChDlg dlg(gMainWin); PasswordInChDlg dlg(gMainWin);
connect(dlg.btnBox, &QDialogButtonBox::accepted, &dlg, [&dlg]() { connect(dlg.btnBox, &QDialogButtonBox::accepted, &dlg, [&dlg]() {
QString passRaw = QSettings().value("advUiPs").toString(); QString pwdRaw = QSettings().value("advUiPs").toString();
QString password = passRaw.isEmpty() ? "888" : QTextCodec::codecForName("GBK")->toUnicode(QByteArray::fromBase64(passRaw.toLocal8Bit())); QString password = pwdRaw.isEmpty() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toLatin1()));
if(dlg.fdPassword->text() == password) dlg.accept(); if(dlg.fdPassword->text() == password) dlg.accept();
else QMessageBox::critical(&dlg, tr("Tip"),tr("Password is error")); else QMessageBox::critical(&dlg, tr("Tip"),tr("Password is error"));
}); });

View File

@ -649,7 +649,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) {
tableSche->setRowCount(0); tableSche->setRowCount(0);
fdDefBright->setValue(json["defaultBrightness"].toInt()); fdDefBright->setValue(json["defaultBrightness"].toInt());
auto jsitems = json["items"].toArray(); auto jsitems = json["items"].toArray();
foreach(auto jsitem, jsitems) { foreach(QJsonValue jsitem, jsitems) {
auto schedule = jsitem["schedules"][0]; auto schedule = jsitem["schedules"][0];
int row = tableSche->rowCount(); int row = tableSche->rowCount();
tableSche->insertRow(row); tableSche->insertRow(row);

View File

@ -370,7 +370,7 @@ void CtrlHdmiPanel::transUi() {
void CtrlHdmiPanel::restoreScheduleJson(QJsonObject oTaskSync) { void CtrlHdmiPanel::restoreScheduleJson(QJsonObject oTaskSync) {
tableSche->setRowCount(0); tableSche->setRowCount(0);
auto oSchedules = oTaskSync["schedules"].toArray(); auto oSchedules = oTaskSync["schedules"].toArray();
foreach(auto oSchedule, oSchedules) { foreach(QJsonValue oSchedule, oSchedules) {
int row = tableSche->rowCount(); int row = tableSche->rowCount();
tableSche->insertRow(row); tableSche->insertRow(row);

View File

@ -45,37 +45,37 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
auto vvv = new VBox(gBoxSpecifyIp); auto vvv = new VBox(gBoxSpecifyIp);
auto hhh = new HBox(vvv); auto hhh = new HBox(vvv);
labelIpAddress = new QLabel; hhh->addWidget(labelIpAddress = new QLabel);
hhh->addWidget(labelIpAddress);
fdIP = new QIPLineEdit; fdIP = new QLineEdit;
fdIP->setInputMask("000.000.000.000");
fdIP->setFixedWidth(160); fdIP->setFixedWidth(160);
hhh->addWidget(fdIP); hhh->addWidget(fdIP);
hhh = new HBox(vvv); hhh = new HBox(vvv);
labelMaskAddress = new QLabel; hhh->addWidget(labelMaskAddress = new QLabel);
hhh->addWidget(labelMaskAddress);
fdMask = new QIPLineEdit; fdMask = new QLineEdit;
fdMask->setInputMask("000.000.000.000");
fdMask->setFixedWidth(160); fdMask->setFixedWidth(160);
hhh->addWidget(fdMask); hhh->addWidget(fdMask);
hhh = new HBox(vvv); hhh = new HBox(vvv);
labelGateway = new QLabel; hhh->addWidget(labelGateway = new QLabel);
hhh->addWidget(labelGateway);
fdGateWay = new QIPLineEdit; fdGateWay = new QLineEdit;
fdGateWay->setInputMask("000.000.000.000");
fdGateWay->setFixedWidth(160); fdGateWay->setFixedWidth(160);
hhh->addWidget(fdGateWay); hhh->addWidget(fdGateWay);
hhh = new HBox(vvv); hhh = new HBox(vvv);
labelDnsAddress = new QLabel; hhh->addWidget(labelDnsAddress = new QLabel);
hhh->addWidget(labelDnsAddress);
fdDns = new QIPLineEdit; fdDns = new QLineEdit;
fdDns->setInputMask("000.000.000.000");
fdDns->setFixedWidth(160); fdDns->setFixedWidth(160);
hhh->addWidget(fdDns); hhh->addWidget(fdDns);
} }
@ -94,56 +94,36 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController")); QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController"));
return; return;
} }
QString ip = fdIP->text(); QString ip = fdIP->text().trimmed();
QString mask = fdMask->text(); QString mask = fdMask->text().trimmed();
QString gateWay = fdGateWay->text(); QString gateWay = fdGateWay->text().trimmed();
QString dns = fdDns->text(); QString dns = fdDns->text().trimmed();
if(fdDhcp->isChecked()) { if(fdDhcp->isChecked()) {
if(ip=="...") ip="0.255.255.255"; if(ip.isEmpty()) ip = "0.255.255.255";
if(mask=="...") mask="0.255.255.255"; if(mask.isEmpty()) mask = "0.255.255.255";
if(gateWay=="...") gateWay="0.255.255.255"; if(gateWay.isEmpty()) gateWay = "0.255.255.255";
if(dns=="...") dns="0.255.255.255"; if(dns.isEmpty()) dns = "0.255.255.255";
} else { } else {
if(ip=="...") { if(ip.isEmpty()) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!")); QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!"));
fdIP->setFocus(); fdIP->setFocus();
return; return;
} }
if(!isTextValid(ip)) { if(mask.isEmpty()) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Your IP Address is Invalid!")+"["+ip+"]");
fdIP->setFocus();
return;
}
if(mask=="...") {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input Mask address!")); QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input Mask address!"));
fdMask->setFocus(); fdMask->setFocus();
return; return;
} }
if(!isTextValid(mask)) { if(gateWay.isEmpty()) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Your Mask Address is Invalid!"));
fdMask->setFocus();
return;
}
if(gateWay=="...") {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input Gateway address!")); QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input Gateway address!"));
fdGateWay->setFocus(); fdGateWay->setFocus();
return; return;
} }
if(!isTextValid(gateWay)) { if(dns.isEmpty()) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Your Gateway Address is Invalid!"));
fdGateWay->setFocus();
return;
}
if(dns=="...") {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input DNS address!")); QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input DNS address!"));
fdDns->setFocus(); fdDns->setFocus();
return; return;
} }
if (!isTextValid(dns)) {
QMessageBox::warning(gMainWin, tr("Attention"), tr("Your DNS Address is Invalid!"));
fdDns->setFocus();
return;
}
} }
QJsonObject json; QJsonObject json;
json.insert("_id", "SetEthernet"); json.insert("_id", "SetEthernet");
@ -279,7 +259,7 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
auto wifis = json["wifiList"].toArray(); auto wifis = json["wifiList"].toArray();
auto cur = fdWifiName->currentText(); auto cur = fdWifiName->currentText();
fdWifiName->clear(); fdWifiName->clear();
foreach(auto wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString()); foreach(QJsonValue wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
if(! cur.isEmpty()) fdWifiName->setCurrentText(cur); if(! cur.isEmpty()) fdWifiName->setCurrentText(cur);
}); });
} }
@ -567,7 +547,7 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) {
fdCarrierName->clear(); fdCarrierName->clear();
fdCarrierName->addItem(""); fdCarrierName->addItem("");
auto apnInfos = fdMcc->itemData(index).toJsonArray(); auto apnInfos = fdMcc->itemData(index).toJsonArray();
foreach(auto apnInfo, apnInfos) fdCarrierName->addItem(apnInfo["carrier"].toString(), apnInfo); foreach(QJsonValue apnInfo, apnInfos) fdCarrierName->addItem(apnInfo["carrier"].toString(), apnInfo);
}); });
hBox->addWidget(fdMcc); hBox->addWidget(fdMcc);
@ -871,7 +851,7 @@ void CtrlNetworkPanel::init() {
if(! err.isEmpty()) return; if(! err.isEmpty()) return;
auto wifis = json["wifiList"].toArray(); auto wifis = json["wifiList"].toArray();
fdWifiName->clear(); fdWifiName->clear();
foreach(auto wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString()); foreach(QJsonValue wifi, wifis) fdWifiName->addItem(QIcon(":/res/signal-"+QString::number((wifi["signal"].toInt()+19)/20)+".png"), wifi["ssid"].toString());
{ {
QJsonObject json; QJsonObject json;
json.insert("_id", "IsPortableHotSpot"); json.insert("_id", "IsPortableHotSpot");
@ -916,7 +896,7 @@ void CtrlNetworkPanel::init() {
fdMcc->clear(); fdMcc->clear();
fdMcc->addItem(""); fdMcc->addItem("");
auto apns = json["apns"].toArray(); auto apns = json["apns"].toArray();
foreach(auto apn, apns) { foreach(QJsonValue apn, apns) {
QString mcc = apn["mcc"].toString(); QString mcc = apn["mcc"].toString();
for(int i=0; i<fdMcc->count(); i++) if(mcc==fdMcc->itemText(i)) { for(int i=0; i<fdMcc->count(); i++) if(mcc==fdMcc->itemText(i)) {
auto var = fdMcc->itemData(i); auto var = fdMcc->itemData(i);

View File

@ -4,11 +4,11 @@
#include <device/ledcard.h> #include <device/ledcard.h>
#include <communication/hpptclient.h> #include <communication/hpptclient.h>
#include <base/loemptydialog.h> #include <base/loemptydialog.h>
#include "base/qiplineedit.h"
#include "base/switchcontrol.h" #include "base/switchcontrol.h"
#include <QRadioButton>
#include <QButtonGroup> #include <QButtonGroup>
#include <QJsonObject> #include <QJsonObject>
#include <QRadioButton> #include <QLineEdit>
#include <QGroupBox> #include <QGroupBox>
#include <QCheckBox> #include <QCheckBox>
@ -42,16 +42,9 @@ private:
QLabel *lbLanCfg; QLabel *lbLanCfg;
QRadioButton *fdDhcp, *fdSpecifyIp; QRadioButton *fdDhcp, *fdSpecifyIp;
QGroupBox *gBoxSpecifyIp; QGroupBox *gBoxSpecifyIp;
QLabel *labelIpAddress; QLabel *labelIpAddress, *labelMaskAddress, *labelGateway, *labelDnsAddress;
QIPLineEdit *fdIP; QLineEdit *fdIP, *fdMask, *fdGateWay, *fdDns;
QLabel *labelMaskAddress; QPushButton *btnLanSet, *btnLanGet;
QIPLineEdit *fdGateWay;
QLabel *labelGateway;
QIPLineEdit *fdMask;
QLabel *labelDnsAddress;
QIPLineEdit *fdDns;
QPushButton *btnLanSet;
QPushButton *btnLanGet;
QLabel *label_5; QLabel *label_5;
QLabel *lbWifiName; QLabel *lbWifiName;
QLabel *lbWifiPassword; QLabel *lbWifiPassword;

View File

@ -90,7 +90,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) {
}; };
table->setDefs(); table->setDefs();
table->setSelectionMode(QAbstractItemView::SingleSelection); table->setSelectionMode(QAbstractItemView::SingleSelection);
foreach(auto file, files) { foreach(QJsonValue file, files) {
auto rr = table->appendRow(); auto rr = table->appendRow();
table->setText(rr, "name", file["fileName"].toString()+"."+file["suffix"].toString()); table->setText(rr, "name", file["fileName"].toString()+"."+file["suffix"].toString());
table->setText(rr, "size", byteSizeStr(file["fileSize"].toInt()))->setTextAlignment(AlignRight); table->setText(rr, "size", byteSizeStr(file["fileSize"].toInt()))->setTextAlignment(AlignRight);

View File

@ -15,7 +15,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QHostAddress> #include <QHostAddress>
#include <QInputDialog> #include <QInputDialog>
#include <QTextCodec>
wUpgradeApkItem::wUpgradeApkItem(LedCard *pLedCard, LoQTreeWidget *parent, QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent) { wUpgradeApkItem::wUpgradeApkItem(LedCard *pLedCard, LoQTreeWidget *parent, QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent) {
m_pWnd=pWnd; m_pWnd=pWnd;

View File

@ -1,5 +1,4 @@
#include <QRegExp> #include <globaldefine.h>
#include <globaldefine.h>
#include <QDir> #include <QDir>
#include <QDateTime> #include <QDateTime>
#include <QCoreApplication> #include <QCoreApplication>
@ -67,13 +66,6 @@ QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArr
return ""; return "";
} }
bool isTextValid(const QString &strIP){
if(! strIP.isEmpty()) {
QRegExp rx2("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
if (!rx2.exactMatch(strIP)) return false;
}
return true;
}
QString getRandomString(int len) { QString getRandomString(int len) {
static const char table[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const char table[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const int tableSize = sizeof(table) - 1; static const int tableSize = sizeof(table) - 1;

View File

@ -151,7 +151,6 @@ extern bool gTextAntialiasing;
extern bool gShowLoraScreen; extern bool gShowLoraScreen;
extern bool gWidthSplit; extern bool gWidthSplit;
extern bool isTextValid(const QString &strIP);
extern quint64 dirFileSize(const QString &path); extern quint64 dirFileSize(const QString &path);
extern bool isFileExist(QString fullFileName); extern bool isFileExist(QString fullFileName);
extern QString getRandomString(int length); extern QString getRandomString(int length);

View File

@ -14,6 +14,7 @@
#include <QSettings> #include <QSettings>
#include <QButtonGroup> #include <QButtonGroup>
#include <QHeaderView> #include <QHeaderView>
#include <QStandardPaths>
#include "QSimpleUpdater.h" #include "QSimpleUpdater.h"
QWidget *gMainWin; QWidget *gMainWin;
@ -35,7 +36,11 @@ public:
icons[1] = checked; icons[1] = checked;
} }
protected: protected:
#if(QT_VERSION_MAJOR > 5)
void enterEvent(QEnterEvent *) override {
#else
void enterEvent(QEvent *) override { void enterEvent(QEvent *) override {
#endif
if(this->isChecked()) return; if(this->isChecked()) return;
setIcon(icons[1]); setIcon(icons[1]);
} }

View File

@ -2,13 +2,12 @@
#include "gutil/qgui.h" #include "gutil/qgui.h"
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include <QVBoxLayout>
DigiClock::DigiClock(QString prefix, const QJsonObject &layer, QWidget *parent) : QWidget{parent} { DigiClock::DigiClock(QString prefix, const QJsonObject &layer, QWidget *parent) : QWidget{parent} {
timeZone = QTimeZone(layer["timezone"].toString().toUtf8()); timeZone = QTimeZone(layer["timezone"].toString().toUtf8());
auto spaceWidth = layer["spaceWidth"].toDouble(); auto spaceWidth = layer["spaceWidth"].toDouble();
QJsonArray pics = layer["arrayPics"].toArray(); auto pics = layer["arrayPics"].toArray();
foreach(auto pic, pics) imgs.insert(pic["name"].toString(), QPixmap(prefix+pic["id"].toString())); foreach(QJsonValue pic, pics) imgs.insert(pic["name"].toString(), QPixmap(prefix+pic["id"].toString()));
int dateStyle = layer["dateStyle"].toInt(); int dateStyle = layer["dateStyle"].toInt();
isSingleMonth = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12; isSingleMonth = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12;
QPixmap& timeSep = imgs["maohao"]; QPixmap& timeSep = imgs["maohao"];

View File

@ -10,7 +10,7 @@ EleMultiPng::EleMultiPng(QString dirPre, QJsonArray maps, QWidget *parent) : QWi
picDur = map["picDuration"].toInt()*1000; picDur = map["picDuration"].toInt()*1000;
if(picDur==0) return; if(picDur==0) return;
EffDur = map["effectSpeed"].toInt()*1000; EffDur = map["effectSpeed"].toInt()*1000;
foreach(auto map, maps) imgs.append(QPixmap(dirPre+map["id"].toString())); foreach(QJsonValue map, maps) imgs.append(QPixmap(dirPre+map["id"].toString()));
QString effStr = map["effect"].toString(); QString effStr = map["effect"].toString();
if(effStr.isEmpty() || effStr=="no") EffDur = 0; if(effStr.isEmpty() || effStr=="no") EffDur = 0;
else if(effStr.endsWith("left")) effType = 'l'; else if(effStr.endsWith("left")) effType = 'l';

View File

@ -13,7 +13,7 @@ public:
QVector<QPixmap> imgs; QVector<QPixmap> imgs;
int timerId = 0, moveTimerId = 0; int timerId = 0, moveTimerId = 0;
int picDur = 0, EffDur = 0, moveInter = 0, movePx = 0, imgc = 0, imgx = 0, imgy = 0; int picDur = 0, EffDur = 0, moveInter = 0, movePx = 0, imgc = 0, imgx = 0, imgy = 0;
QChar effType = 0; QChar effType{0};
QRandomGenerator rand; QRandomGenerator rand;
bool needRand = false; bool needRand = false;
QList<EleSplitPng*> splits; QList<EleSplitPng*> splits;

View File

@ -55,17 +55,17 @@ PlayWin::PlayWin(int x, int y, int width, int height, QString dir, const QJsonOb
page->setGeometry(0, 0, width, height); page->setGeometry(0, 0, width, height);
page->setVisible(false); page->setVisible(false);
for(int ll=layers.size()-1; ll>=0; ll--) { for(int ll=layers.size()-1; ll>=0; ll--) {
QJsonObject layer = layers[ll].toObject(); auto layer = layers[ll].toObject();
auto repeat = layer["repeat"].toBool(); auto repeat = layer["repeat"].toBool();
QJsonArray srcMaps = layer["sources"].toArray(); auto srcMaps = layer["sources"].toArray();
QJsonValue border = layer["border"]; QJsonValue border = layer["border"];
EleBorder *bdEle = nullptr; EleBorder *bdEle = 0;
int bdWidth = 0, bdStart = 0xffff, bdEnd = 0; int bdWidth = 0, bdStart = 0xffff, bdEnd = 0;
if(! border.isNull()) { if(! border.isNull()) {
bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page); bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page);
bdWidth = bdEle->img.height(); bdWidth = bdEle->img.height();
} }
foreach(auto srcMap, srcMaps) { foreach(QJsonValue srcMap, srcMaps) {
ele.type = srcMap["_type"].toString(); ele.type = srcMap["_type"].toString();
if(ele.type.isEmpty()) continue; if(ele.type.isEmpty()) continue;
auto timeSpan = srcMap["timeSpan"].toInt()*1000; auto timeSpan = srcMap["timeSpan"].toInt()*1000;

View File

@ -25,9 +25,9 @@ EMultiWin::EMultiWin(PageListItem *pageItem) : mPageItem(pageItem) {
EMultiWin::EMultiWin(const QJsonObject &json, PageListItem *pageItem) : mPageItem(pageItem) { EMultiWin::EMultiWin(const QJsonObject &json, PageListItem *pageItem) : mPageItem(pageItem) {
mType = EBase::Window; mType = EBase::Window;
setBaseAttr(json); setBaseAttr(json);
QJsonArray elements = json["elements"].toArray(); auto elements = json["elements"].toArray();
index = json["index"].toInt(); index = json["index"].toInt();
foreach(auto element, elements) { foreach(QJsonValue element, elements) {
QString type = element["elementType"].toString(); QString type = element["elementType"].toString();
EBase *inner = nullptr; EBase *inner = nullptr;
if(type=="Text") inner = new EText(element.toObject(), this); if(type=="Text") inner = new EText(element.toObject(), this);

View File

@ -110,7 +110,7 @@ QJsonObject GenTmpThread::cvtPage(const QJsonDocument &pageJson, const QJsonDocu
auto sourceRepeat = pageJson["loop"].toBool(); auto sourceRepeat = pageJson["loop"].toBool();
QJsonArray sources; QJsonArray sources;
int start = 0; int start = 0;
foreach(auto audio, audios) { foreach(QJsonValue audio, audios) {
auto dur = audio["dur"].toInt(); auto dur = audio["dur"].toInt();
if(dur==0) continue; if(dur==0) continue;
auto name = audio["name"].toString(); auto name = audio["name"].toString();

View File

@ -88,9 +88,9 @@ void SendProgThread::run() {
} }
if(res["_type"].toString()=="consult") { if(res["_type"].toString()=="consult") {
fileInfos.clear(); fileInfos.clear();
fileInfos.append(QString(prog_dir+"/program")); fileInfos.append(QFileInfo(prog_dir+"/program"));
QJsonArray ids = res["idList"].toArray(); QJsonArray ids = res["idList"].toArray();
foreach(auto id, ids) fileInfos.append(QString(prog_dir+"/"+id.toString())); foreach(auto id, ids) fileInfos.append(QFileInfo(prog_dir+"/"+id.toString()));
} }
} }
if(stoped) { if(stoped) {