//
// Created by Krad on 2021/11/11.
//

#include <QFormLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "getadminpsw.h"
#include "device/networkmanager.h"
#include "device/networkmanager.h"

GetAdminPsw::GetAdminPsw(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {

	setWindowModality(Qt::WindowModal);
	QFormLayout* form = new QFormLayout(formWidget);
	QString value1 = QString(tr("Admin Password"));
	_psw = new QLineEdit(this);
	_psw->setEchoMode(QLineEdit::Password);
	form->addRow(value1, _psw);

	lbl_error = new QLabel(this);
	lbl_error->setObjectName(QString::fromUtf8("warn"));
	form->addRow("", lbl_error);

}

GetAdminPsw::~GetAdminPsw() {

}

QString GetAdminPsw::getPsw()const
{
	return _psw->text();
}

bool GetAdminPsw::updateReferenceData() {
#ifndef WIN32
    //verify the password
    QString err;
    if (!NetworkManager::checkPassWord(_psw->text(),err))
    {
        lbl_error->setText(err);
        return false;
    }
#endif
	return true;
}
