63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
//
|
|
// Created by Krad on 2021/11/11.
|
|
//
|
|
|
|
#include "GetIPDialog.h"
|
|
|
|
#include <QFormLayout>
|
|
#include <QLabel>
|
|
#include "components/ULineEdit.h"
|
|
|
|
#include "device/networkmanager.h"
|
|
|
|
GetIPDialog::GetIPDialog(QWidget* parent, Qt::WindowFlags f)
|
|
: GUIFormBaseDialog(parent, f)
|
|
, mIp(new ULineEdit(this))
|
|
, mMask(new ULineEdit(this))
|
|
, mLabelError(new QLabel(this))
|
|
{
|
|
setWindowModality(Qt::WindowModal);
|
|
QFormLayout* formLayout = new QFormLayout(mFormWidget);
|
|
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;
|
|
}
|