* Refactor network package.
This commit is contained in:
62
src/network/GetIPDialog.cpp
Normal file
62
src/network/GetIPDialog.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Created by Krad on 2021/11/11.
|
||||
//
|
||||
|
||||
#include "GetIPDialog.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
|
||||
#include "device/networkmanager.h"
|
||||
|
||||
GetIPDialog::GetIPDialog(QWidget* parent, Qt::WindowFlags f)
|
||||
: GUIFormBaseDialog(parent, f)
|
||||
, mIp(new QLineEdit(this))
|
||||
, mMask(new QLineEdit(this))
|
||||
, mLabelError(new QLabel(this))
|
||||
{
|
||||
setWindowModality(Qt::WindowModal);
|
||||
QFormLayout* formLayout = new QFormLayout(formWidget);
|
||||
QLabel* IpValue = new QLabel(tr("IP Address"));
|
||||
formLayout->addRow(IpValue, mIp);
|
||||
|
||||
QLabel* maskValue = new QLabel(tr("Netmask"));
|
||||
formLayout->addRow(maskValue, mMask);
|
||||
|
||||
mLabelError->setObjectName(QString::fromUtf8("warn"));
|
||||
formLayout->addRow("", mLabelError);
|
||||
}
|
||||
|
||||
GetIPDialog::~GetIPDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QStringList GetIPDialog::getList()const
|
||||
{
|
||||
return QStringList() << mIp->text() << mMask->text();
|
||||
}
|
||||
void GetIPDialog::setList(const QStringList& list)
|
||||
{
|
||||
if (!list.empty())
|
||||
{
|
||||
mIp->setText(list[0]);
|
||||
mMask->setText(list[1]);
|
||||
}
|
||||
}
|
||||
|
||||
bool GetIPDialog::updateReferenceData()
|
||||
{
|
||||
if (!NetworkManager::validate(mIp->text()))
|
||||
{
|
||||
mLabelError->setText(tr("Wrong IP!"));
|
||||
return false;
|
||||
}
|
||||
if (!NetworkManager::validate(mMask->text()))
|
||||
{
|
||||
mLabelError->setText(tr("Wrong Netmask!"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user