From 8bd2a98dd76923a6e322b6eea3fe25718737b655 Mon Sep 17 00:00:00 2001 From: gangphon Date: Wed, 19 Apr 2023 14:42:06 +0800 Subject: [PATCH] ledok --- LedOK/LedOK.pro | 23 +-- LedOK/base/qiplineedit.cpp | 285 ----------------------------- LedOK/base/qiplineedit.h | 37 ---- LedOK/basedlg.cpp | 6 +- LedOK/basedlg.h | 4 + LedOK/basewin.cpp | 9 +- LedOK/basewin.h | 6 + LedOK/communication/hpptclient.cpp | 5 - LedOK/device/ctrladvancedpanel.cpp | 5 +- LedOK/device/ctrlbrightpanel.cpp | 2 +- LedOK/device/ctrlhdmipanel.cpp | 2 +- LedOK/device/ctrlnetworkpanel.cpp | 76 +++----- LedOK/device/ctrlnetworkpanel.h | 17 +- LedOK/device/upgradeapkdialog.cpp | 2 +- LedOK/device/wupgradeapkitem.cpp | 1 - LedOK/globaldefine.cpp | 10 +- LedOK/globaldefine.h | 1 - LedOK/mainwindow.cpp | 5 + LedOK/player/digiclock.cpp | 5 +- LedOK/player/elemultipng.cpp | 2 +- LedOK/player/elemultipng.h | 2 +- LedOK/player/playwin.cpp | 8 +- LedOK/program/emultiwin.cpp | 4 +- LedOK/program/gentmpthread.cpp | 2 +- LedOK/program/sendprogthread.cpp | 4 +- 25 files changed, 92 insertions(+), 431 deletions(-) delete mode 100644 LedOK/base/qiplineedit.cpp delete mode 100644 LedOK/base/qiplineedit.h diff --git a/LedOK/LedOK.pro b/LedOK/LedOK.pro index 69dfbf7..72f0298 100644 --- a/LedOK/LedOK.pro +++ b/LedOK/LedOK.pro @@ -2,9 +2,12 @@ QT += core gui widgets QT += multimedia QT += network QT += concurrent +QT += serialport QT += opengl QT += webenginewidgets - +greaterThan(QT_MAJOR_VERSION, 5) { + QT += openglwidgets +} CONFIG += c++20 CONFIG += lrelease CONFIG += embed_translations @@ -19,8 +22,14 @@ TARGET = $$quote(LedOK Express) VERSION = 1.3.5 DEFINES += APP_VERSION=\\\"$$VERSION\\\" msvc { - QMAKE_CXXFLAGS += -execution-charset:utf-8 - QMAKE_CXXFLAGS += -source-charset:utf-8 + 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 += -source-charset:utf-8 + } CONFIG += force_debug_info CONFIG += separate_debug_info @@ -31,17 +40,11 @@ msvc { # QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO # QMAKE_LFLAGS_RELEASE += $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO - - LIBS += -lDbgHelp } win* { LIBS += -lwinmm LIBS += -lDbghelp } -win32 { -QMAKE_LFLAGS += /LARGEADDRESSAWARE -#QMAKE_LFLAGS += -Wl,--large-address-aware -} SOURCES += \ base/aboutdlg.cpp \ @@ -49,7 +52,6 @@ SOURCES += \ base/customprogressindicator.cpp \ base/loemptydialog.cpp \ base/pixbmpshowdialog.cpp \ - base/qiplineedit.cpp \ base/softconfigdialog.cpp \ base/switchcontrol.cpp \ base/taesclass.cpp \ @@ -144,7 +146,6 @@ HEADERS += \ base/customprogressindicator.h \ base/loemptydialog.h \ base/pixbmpshowdialog.h \ - base/qiplineedit.h \ base/softconfigdialog.h \ base/switchcontrol.h \ base/taesclass.h \ diff --git a/LedOK/base/qiplineedit.cpp b/LedOK/base/qiplineedit.cpp deleted file mode 100644 index ad0c89c..0000000 --- a/LedOK/base/qiplineedit.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - * 此类的封装参考了:博客网址:http://blog.csdn.net/u011417605,并在此基础上进行修改 - * 1.连续输入 - * 2.连续删除 - * 3.任意位置插入 - * 4.自适应大小变化 - * 5.正则匹配,每个值不大于255.设置IP值时,有正则验证是否是IP格式 - * 实现方法:使用一个大的QLineEdit嵌套四个小的QLineEdit,中间的点是使用paintEvent画出来的。操作是使用eventFilter来进行分发实现的 - * 修改: - * 用QWidget替换原先的__super - * 修改构造函数中的正则匹配 - * 修改小圆点位置和大小 - * 两个QLineEdit之间的空隙,在绘制小圆点之前,把空气用白色背景填充 - * 修改样式表加边框 - * 当输入类似192时,焦点自动跳转到下一个QLineEdit出 - * 修改text()的输出,使输出由原来的1921680127变为192.168.0.127 - **/ - -#include "qiplineedit.h" -#include -#include -#include -#include -#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(ev); - QLineEdit *pEdit = qobject_cast(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(); -} diff --git a/LedOK/base/qiplineedit.h b/LedOK/base/qiplineedit.h deleted file mode 100644 index 083eeb5..0000000 --- a/LedOK/base/qiplineedit.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef QIPLINEEDIT_H -#define QIPLINEEDIT_H - -#include -#include -#include - -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 diff --git a/LedOK/basedlg.cpp b/LedOK/basedlg.cpp index 5af071e..574b256 100644 --- a/LedOK/basedlg.cpp +++ b/LedOK/basedlg.cpp @@ -43,7 +43,11 @@ void BaseDlg::mouseMoveEvent(QMouseEvent *e) { } #ifdef Q_OS_WINDOWS #include -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"){ MSG *msg = (MSG*)message; if(msg->message==WM_NCACTIVATE){ diff --git a/LedOK/basedlg.h b/LedOK/basedlg.h index 8f4090b..e046101 100644 --- a/LedOK/basedlg.h +++ b/LedOK/basedlg.h @@ -19,7 +19,11 @@ protected: void mouseReleaseEvent(QMouseEvent *) override; void mouseMoveEvent(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; +#endif #endif QPoint pressRel; bool isActive = false; diff --git a/LedOK/basewin.cpp b/LedOK/basewin.cpp index b64c42e..7ce16c3 100644 --- a/LedOK/basewin.cpp +++ b/LedOK/basewin.cpp @@ -117,7 +117,13 @@ void BaseWin::mouseDoubleClickEvent(QMouseEvent *e) { else setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen)) | Qt::WindowMaximized); } -bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *){ +#ifdef Q_OS_WINDOWS +#include +#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"){ MSG *msg = (MSG*)message; if(msg->message==WM_NCACTIVATE){ @@ -127,3 +133,4 @@ bool BaseWin::nativeEvent(const QByteArray &eventType, void *message, long *){ } return false; } +#endif diff --git a/LedOK/basewin.h b/LedOK/basewin.h index b4c9b91..361b192 100644 --- a/LedOK/basewin.h +++ b/LedOK/basewin.h @@ -24,7 +24,13 @@ protected: bool eventFilter(QObject *, QEvent *) override; void changeEvent(QEvent *) 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; +#endif +#endif void setFrmSec(const QPoint &pos); void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor); diff --git a/LedOK/communication/hpptclient.cpp b/LedOK/communication/hpptclient.cpp index 5c9b787..7f93884 100644 --- a/LedOK/communication/hpptclient.cpp +++ b/LedOK/communication/hpptclient.cpp @@ -166,11 +166,6 @@ void HpptClient::httpGet(const QString &url) { mProcessingRq.insert(url, true); QNetworkRequest request{url}; - QSslConfiguration config = request.sslConfiguration(); - config.setPeerVerifyMode(QSslSocket::VerifyNone); - config.setProtocol(QSsl::TlsV1SslV3); - request.setSslConfiguration(config); - QNetworkReply* rp = mNetAccessManager.get(request); connect(rp, &QNetworkReply::downloadProgress, this, &HpptClient::onHttpGetRspProgress); } diff --git a/LedOK/device/ctrladvancedpanel.cpp b/LedOK/device/ctrladvancedpanel.cpp index 3d68ac5..675437c 100644 --- a/LedOK/device/ctrladvancedpanel.cpp +++ b/LedOK/device/ctrladvancedpanel.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -2053,8 +2052,8 @@ void CtrlAdvancedPanel::init() { hide(); PasswordInChDlg dlg(gMainWin); connect(dlg.btnBox, &QDialogButtonBox::accepted, &dlg, [&dlg]() { - QString passRaw = QSettings().value("advUiPs").toString(); - QString password = passRaw.isEmpty() ? "888" : QTextCodec::codecForName("GBK")->toUnicode(QByteArray::fromBase64(passRaw.toLocal8Bit())); + QString pwdRaw = QSettings().value("advUiPs").toString(); + QString password = pwdRaw.isEmpty() ? "888" : QString::fromUtf8(QByteArray::fromBase64(pwdRaw.toLatin1())); if(dlg.fdPassword->text() == password) dlg.accept(); else QMessageBox::critical(&dlg, tr("Tip"),tr("Password is error")); }); diff --git a/LedOK/device/ctrlbrightpanel.cpp b/LedOK/device/ctrlbrightpanel.cpp index 224cedf..e687f1c 100644 --- a/LedOK/device/ctrlbrightpanel.cpp +++ b/LedOK/device/ctrlbrightpanel.cpp @@ -649,7 +649,7 @@ CtrlBrightPanel::CtrlBrightPanel(QWidget *parent) : QWidget(parent) { tableSche->setRowCount(0); fdDefBright->setValue(json["defaultBrightness"].toInt()); auto jsitems = json["items"].toArray(); - foreach(auto jsitem, jsitems) { + foreach(QJsonValue jsitem, jsitems) { auto schedule = jsitem["schedules"][0]; int row = tableSche->rowCount(); tableSche->insertRow(row); diff --git a/LedOK/device/ctrlhdmipanel.cpp b/LedOK/device/ctrlhdmipanel.cpp index cc46580..1d05750 100644 --- a/LedOK/device/ctrlhdmipanel.cpp +++ b/LedOK/device/ctrlhdmipanel.cpp @@ -370,7 +370,7 @@ void CtrlHdmiPanel::transUi() { void CtrlHdmiPanel::restoreScheduleJson(QJsonObject oTaskSync) { tableSche->setRowCount(0); auto oSchedules = oTaskSync["schedules"].toArray(); - foreach(auto oSchedule, oSchedules) { + foreach(QJsonValue oSchedule, oSchedules) { int row = tableSche->rowCount(); tableSche->insertRow(row); diff --git a/LedOK/device/ctrlnetworkpanel.cpp b/LedOK/device/ctrlnetworkpanel.cpp index 5602eda..19e0185 100644 --- a/LedOK/device/ctrlnetworkpanel.cpp +++ b/LedOK/device/ctrlnetworkpanel.cpp @@ -45,37 +45,37 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) { auto vvv = new VBox(gBoxSpecifyIp); auto hhh = new HBox(vvv); - labelIpAddress = new QLabel; - hhh->addWidget(labelIpAddress); + hhh->addWidget(labelIpAddress = new QLabel); - fdIP = new QIPLineEdit; + fdIP = new QLineEdit; + fdIP->setInputMask("000.000.000.000"); fdIP->setFixedWidth(160); hhh->addWidget(fdIP); hhh = new HBox(vvv); - labelMaskAddress = new QLabel; - hhh->addWidget(labelMaskAddress); + hhh->addWidget(labelMaskAddress = new QLabel); - fdMask = new QIPLineEdit; + fdMask = new QLineEdit; + fdMask->setInputMask("000.000.000.000"); fdMask->setFixedWidth(160); hhh->addWidget(fdMask); hhh = new HBox(vvv); - labelGateway = new QLabel; - hhh->addWidget(labelGateway); + hhh->addWidget(labelGateway = new QLabel); - fdGateWay = new QIPLineEdit; + fdGateWay = new QLineEdit; + fdGateWay->setInputMask("000.000.000.000"); fdGateWay->setFixedWidth(160); hhh->addWidget(fdGateWay); hhh = new HBox(vvv); - labelDnsAddress = new QLabel; - hhh->addWidget(labelDnsAddress); + hhh->addWidget(labelDnsAddress = new QLabel); - fdDns = new QIPLineEdit; + fdDns = new QLineEdit; + fdDns->setInputMask("000.000.000.000"); fdDns->setFixedWidth(160); hhh->addWidget(fdDns); } @@ -94,56 +94,36 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) { QMessageBox::information(gMainWin, tr("Tip"), tr("NoSelectedController")); return; } - QString ip = fdIP->text(); - QString mask = fdMask->text(); - QString gateWay = fdGateWay->text(); - QString dns = fdDns->text(); + QString ip = fdIP->text().trimmed(); + QString mask = fdMask->text().trimmed(); + QString gateWay = fdGateWay->text().trimmed(); + QString dns = fdDns->text().trimmed(); if(fdDhcp->isChecked()) { - if(ip=="...") ip="0.255.255.255"; - if(mask=="...") mask="0.255.255.255"; - if(gateWay=="...") gateWay="0.255.255.255"; - if(dns=="...") dns="0.255.255.255"; + if(ip.isEmpty()) ip = "0.255.255.255"; + if(mask.isEmpty()) mask = "0.255.255.255"; + if(gateWay.isEmpty()) gateWay = "0.255.255.255"; + if(dns.isEmpty()) dns = "0.255.255.255"; } else { - if(ip=="...") { + if(ip.isEmpty()) { QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input IP address!")); fdIP->setFocus(); return; } - if(!isTextValid(ip)) { - QMessageBox::warning(gMainWin, tr("Attention"), tr("Your IP Address is Invalid!")+"["+ip+"]"); - fdIP->setFocus(); - return; - } - if(mask=="...") { + if(mask.isEmpty()) { QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input Mask address!")); fdMask->setFocus(); return; } - if(!isTextValid(mask)) { - QMessageBox::warning(gMainWin, tr("Attention"), tr("Your Mask Address is Invalid!")); - fdMask->setFocus(); - return; - } - if(gateWay=="...") { + if(gateWay.isEmpty()) { QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input Gateway address!")); fdGateWay->setFocus(); return; } - if(!isTextValid(gateWay)) { - QMessageBox::warning(gMainWin, tr("Attention"), tr("Your Gateway Address is Invalid!")); - fdGateWay->setFocus(); - return; - } - if(dns=="...") { + if(dns.isEmpty()) { QMessageBox::warning(gMainWin, tr("Attention"), tr("Please input DNS address!")); fdDns->setFocus(); return; } - if (!isTextValid(dns)) { - QMessageBox::warning(gMainWin, tr("Attention"), tr("Your DNS Address is Invalid!")); - fdDns->setFocus(); - return; - } } QJsonObject json; json.insert("_id", "SetEthernet"); @@ -279,7 +259,7 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) { auto wifis = json["wifiList"].toArray(); auto cur = fdWifiName->currentText(); 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); }); } @@ -567,7 +547,7 @@ CtrlNetworkPanel::CtrlNetworkPanel(QWidget *parent) : QWidget(parent) { fdCarrierName->clear(); fdCarrierName->addItem(""); 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); @@ -871,7 +851,7 @@ void CtrlNetworkPanel::init() { if(! err.isEmpty()) return; auto wifis = json["wifiList"].toArray(); 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; json.insert("_id", "IsPortableHotSpot"); @@ -916,7 +896,7 @@ void CtrlNetworkPanel::init() { fdMcc->clear(); fdMcc->addItem(""); auto apns = json["apns"].toArray(); - foreach(auto apn, apns) { + foreach(QJsonValue apn, apns) { QString mcc = apn["mcc"].toString(); for(int i=0; icount(); i++) if(mcc==fdMcc->itemText(i)) { auto var = fdMcc->itemData(i); diff --git a/LedOK/device/ctrlnetworkpanel.h b/LedOK/device/ctrlnetworkpanel.h index 315e31b..a569c12 100644 --- a/LedOK/device/ctrlnetworkpanel.h +++ b/LedOK/device/ctrlnetworkpanel.h @@ -4,11 +4,11 @@ #include #include #include -#include "base/qiplineedit.h" #include "base/switchcontrol.h" +#include #include #include -#include +#include #include #include @@ -42,16 +42,9 @@ private: QLabel *lbLanCfg; QRadioButton *fdDhcp, *fdSpecifyIp; QGroupBox *gBoxSpecifyIp; - QLabel *labelIpAddress; - QIPLineEdit *fdIP; - QLabel *labelMaskAddress; - QIPLineEdit *fdGateWay; - QLabel *labelGateway; - QIPLineEdit *fdMask; - QLabel *labelDnsAddress; - QIPLineEdit *fdDns; - QPushButton *btnLanSet; - QPushButton *btnLanGet; + QLabel *labelIpAddress, *labelMaskAddress, *labelGateway, *labelDnsAddress; + QLineEdit *fdIP, *fdMask, *fdGateWay, *fdDns; + QPushButton *btnLanSet, *btnLanGet; QLabel *label_5; QLabel *lbWifiName; QLabel *lbWifiPassword; diff --git a/LedOK/device/upgradeapkdialog.cpp b/LedOK/device/upgradeapkdialog.cpp index 6b85be9..390c0c0 100644 --- a/LedOK/device/upgradeapkdialog.cpp +++ b/LedOK/device/upgradeapkdialog.cpp @@ -90,7 +90,7 @@ UpgradeApkDialog::UpgradeApkDialog(QWidget *parent) : QDialog(parent) { }; table->setDefs(); table->setSelectionMode(QAbstractItemView::SingleSelection); - foreach(auto file, files) { + foreach(QJsonValue file, files) { auto rr = table->appendRow(); table->setText(rr, "name", file["fileName"].toString()+"."+file["suffix"].toString()); table->setText(rr, "size", byteSizeStr(file["fileSize"].toInt()))->setTextAlignment(AlignRight); diff --git a/LedOK/device/wupgradeapkitem.cpp b/LedOK/device/wupgradeapkitem.cpp index 4291ab0..21141bd 100644 --- a/LedOK/device/wupgradeapkitem.cpp +++ b/LedOK/device/wupgradeapkitem.cpp @@ -15,7 +15,6 @@ #include #include #include -#include wUpgradeApkItem::wUpgradeApkItem(LedCard *pLedCard, LoQTreeWidget *parent, QWidget *pWnd) : QObject(parent), QTreeWidgetItem(UserType), m_parent(parent) { m_pWnd=pWnd; diff --git a/LedOK/globaldefine.cpp b/LedOK/globaldefine.cpp index b919666..e1b35ce 100644 --- a/LedOK/globaldefine.cpp +++ b/LedOK/globaldefine.cpp @@ -1,5 +1,4 @@ -#include -#include +#include #include #include #include @@ -67,13 +66,6 @@ QString checkReplyForJson(QNetworkReply *reply, QJsonDocument *outJson, QByteArr 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) { static const char table[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; static const int tableSize = sizeof(table) - 1; diff --git a/LedOK/globaldefine.h b/LedOK/globaldefine.h index bb87762..03cd520 100644 --- a/LedOK/globaldefine.h +++ b/LedOK/globaldefine.h @@ -151,7 +151,6 @@ extern bool gTextAntialiasing; extern bool gShowLoraScreen; extern bool gWidthSplit; -extern bool isTextValid(const QString &strIP); extern quint64 dirFileSize(const QString &path); extern bool isFileExist(QString fullFileName); extern QString getRandomString(int length); diff --git a/LedOK/mainwindow.cpp b/LedOK/mainwindow.cpp index f72e7c4..ae40d11 100644 --- a/LedOK/mainwindow.cpp +++ b/LedOK/mainwindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "QSimpleUpdater.h" QWidget *gMainWin; @@ -35,7 +36,11 @@ public: icons[1] = checked; } protected: +#if(QT_VERSION_MAJOR > 5) + void enterEvent(QEnterEvent *) override { +#else void enterEvent(QEvent *) override { +#endif if(this->isChecked()) return; setIcon(icons[1]); } diff --git a/LedOK/player/digiclock.cpp b/LedOK/player/digiclock.cpp index eb31a53..f26be86 100644 --- a/LedOK/player/digiclock.cpp +++ b/LedOK/player/digiclock.cpp @@ -2,13 +2,12 @@ #include "gutil/qgui.h" #include #include -#include DigiClock::DigiClock(QString prefix, const QJsonObject &layer, QWidget *parent) : QWidget{parent} { timeZone = QTimeZone(layer["timezone"].toString().toUtf8()); auto spaceWidth = layer["spaceWidth"].toDouble(); - QJsonArray pics = layer["arrayPics"].toArray(); - foreach(auto pic, pics) imgs.insert(pic["name"].toString(), QPixmap(prefix+pic["id"].toString())); + auto pics = layer["arrayPics"].toArray(); + foreach(QJsonValue pic, pics) imgs.insert(pic["name"].toString(), QPixmap(prefix+pic["id"].toString())); int dateStyle = layer["dateStyle"].toInt(); isSingleMonth = dateStyle==1||dateStyle==2||dateStyle==4||dateStyle==6||dateStyle==8||dateStyle==10||dateStyle==12; QPixmap& timeSep = imgs["maohao"]; diff --git a/LedOK/player/elemultipng.cpp b/LedOK/player/elemultipng.cpp index 6ceb671..2ca2bf6 100644 --- a/LedOK/player/elemultipng.cpp +++ b/LedOK/player/elemultipng.cpp @@ -10,7 +10,7 @@ EleMultiPng::EleMultiPng(QString dirPre, QJsonArray maps, QWidget *parent) : QWi picDur = map["picDuration"].toInt()*1000; if(picDur==0) return; 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(); if(effStr.isEmpty() || effStr=="no") EffDur = 0; else if(effStr.endsWith("left")) effType = 'l'; diff --git a/LedOK/player/elemultipng.h b/LedOK/player/elemultipng.h index 2191b3e..7c49466 100644 --- a/LedOK/player/elemultipng.h +++ b/LedOK/player/elemultipng.h @@ -13,7 +13,7 @@ public: QVector imgs; int timerId = 0, moveTimerId = 0; int picDur = 0, EffDur = 0, moveInter = 0, movePx = 0, imgc = 0, imgx = 0, imgy = 0; - QChar effType = 0; + QChar effType{0}; QRandomGenerator rand; bool needRand = false; QList splits; diff --git a/LedOK/player/playwin.cpp b/LedOK/player/playwin.cpp index dfea6eb..beb0bbf 100644 --- a/LedOK/player/playwin.cpp +++ b/LedOK/player/playwin.cpp @@ -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->setVisible(false); for(int ll=layers.size()-1; ll>=0; ll--) { - QJsonObject layer = layers[ll].toObject(); + auto layer = layers[ll].toObject(); auto repeat = layer["repeat"].toBool(); - QJsonArray srcMaps = layer["sources"].toArray(); + auto srcMaps = layer["sources"].toArray(); QJsonValue border = layer["border"]; - EleBorder *bdEle = nullptr; + EleBorder *bdEle = 0; int bdWidth = 0, bdStart = 0xffff, bdEnd = 0; if(! border.isNull()) { bdEle = new EleBorder(dir+"/"+border["img"].toString(), border["eff"].toString(), border["speed"].toInt(), page); bdWidth = bdEle->img.height(); } - foreach(auto srcMap, srcMaps) { + foreach(QJsonValue srcMap, srcMaps) { ele.type = srcMap["_type"].toString(); if(ele.type.isEmpty()) continue; auto timeSpan = srcMap["timeSpan"].toInt()*1000; diff --git a/LedOK/program/emultiwin.cpp b/LedOK/program/emultiwin.cpp index 64a6f08..e1e3620 100644 --- a/LedOK/program/emultiwin.cpp +++ b/LedOK/program/emultiwin.cpp @@ -25,9 +25,9 @@ EMultiWin::EMultiWin(PageListItem *pageItem) : mPageItem(pageItem) { EMultiWin::EMultiWin(const QJsonObject &json, PageListItem *pageItem) : mPageItem(pageItem) { mType = EBase::Window; setBaseAttr(json); - QJsonArray elements = json["elements"].toArray(); + auto elements = json["elements"].toArray(); index = json["index"].toInt(); - foreach(auto element, elements) { + foreach(QJsonValue element, elements) { QString type = element["elementType"].toString(); EBase *inner = nullptr; if(type=="Text") inner = new EText(element.toObject(), this); diff --git a/LedOK/program/gentmpthread.cpp b/LedOK/program/gentmpthread.cpp index b6835db..49bdf6e 100644 --- a/LedOK/program/gentmpthread.cpp +++ b/LedOK/program/gentmpthread.cpp @@ -110,7 +110,7 @@ QJsonObject GenTmpThread::cvtPage(const QJsonDocument &pageJson, const QJsonDocu auto sourceRepeat = pageJson["loop"].toBool(); QJsonArray sources; int start = 0; - foreach(auto audio, audios) { + foreach(QJsonValue audio, audios) { auto dur = audio["dur"].toInt(); if(dur==0) continue; auto name = audio["name"].toString(); diff --git a/LedOK/program/sendprogthread.cpp b/LedOK/program/sendprogthread.cpp index c6eda2d..8f85987 100644 --- a/LedOK/program/sendprogthread.cpp +++ b/LedOK/program/sendprogthread.cpp @@ -88,9 +88,9 @@ void SendProgThread::run() { } if(res["_type"].toString()=="consult") { fileInfos.clear(); - fileInfos.append(QString(prog_dir+"/program")); + fileInfos.append(QFileInfo(prog_dir+"/program")); 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) {