From af838bb79fb1cc7dd5c7de24a97d23570d5d8a36 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Fri, 11 Aug 2023 16:09:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=94=9F=E5=83=BB=E5=AD=97):=E4=BD=BF?= =?UTF-8?q?=E7=94=A8validator=E9=99=90=E5=88=B6=E5=AD=97=E7=AC=A6=E9=95=BF?= =?UTF-8?q?=E5=BA=A6(#185510)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/netdetails/creatnetpage.cpp | 5 ++++- src/frontend/netdetails/detailpage.cpp | 5 ++++- src/frontend/netdetails/joinhiddenwifipage.cpp | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/frontend/netdetails/creatnetpage.cpp b/src/frontend/netdetails/creatnetpage.cpp index bd50cc20..beeaa366 100644 --- a/src/frontend/netdetails/creatnetpage.cpp +++ b/src/frontend/netdetails/creatnetpage.cpp @@ -33,7 +33,6 @@ CreatNetPage::CreatNetPage(QWidget *parent):QFrame(parent) void CreatNetPage::initUI() { connNameEdit = new LineEdit(this); - connNameEdit->setMaxLength(MAX_NAME_LENGTH); ipv4ConfigCombox = new QComboBox(this); ipv4addressEdit = new LineEdit(this); netMaskEdit = new LineEdit(this); @@ -109,6 +108,10 @@ void CreatNetPage::initUI() ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)" ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动" + QRegExp nameRx("^.{0,32}$"); + QValidator *validator = new QRegExpValidator(nameRx, this); + + connNameEdit->setValidator(validator); ipv4addressEdit->setValidator(new QRegExpValidator(rx, this)); gateWayEdit->setValidator(new QRegExpValidator(rx, this)); netMaskEdit->setValidator(new QRegExpValidator(rx, this)); diff --git a/src/frontend/netdetails/detailpage.cpp b/src/frontend/netdetails/detailpage.cpp index fb95803a..46a1c85c 100644 --- a/src/frontend/netdetails/detailpage.cpp +++ b/src/frontend/netdetails/detailpage.cpp @@ -245,7 +245,10 @@ void DetailPage::initUI() { m_SSIDEdit->setAlignment(Qt::AlignRight); m_SSIDEdit->setStyleSheet("border-top:0px solid;border-bottom:1px solid;border-left:0px solid;border-right: 0px solid;background:transparent"); m_SSIDEdit->setPlaceholderText(tr("Please input SSID:")); - m_SSIDEdit->setMaxLength(MAX_NAME_LENGTH); + QRegExp nameRx("^.{0,32}$"); + QValidator *validator = new QRegExpValidator(nameRx, this); + + m_SSIDEdit->setValidator(validator); m_ssidWidget = new DetailWidget(qobject_cast(m_SSIDEdit), m_listWidget); } diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp index d5792bc6..16cc963d 100644 --- a/src/frontend/netdetails/joinhiddenwifipage.cpp +++ b/src/frontend/netdetails/joinhiddenwifipage.cpp @@ -147,7 +147,9 @@ void JoinHiddenWiFiPage::initUI() m_cancelBtn->setText(tr("Cancel")); m_joinBtn->setText(tr("Join")); - m_nameEdit->setMaxLength(MAX_NAME_LENGTH); + QRegExp nameRx("^.{0,32}$"); + QValidator *validator = new QRegExpValidator(nameRx, this); + m_nameEdit->setValidator(validator); m_nameEdit->setPlaceholderText(tr("Required")); //必填 this->setWindowTitle(tr("Find and Join WLAN"));