1 Star 0 Fork 16

黄新宇/qipmsg

forked from caowai/qipmsg 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dialogsetting.cpp 3.68 KB
一键复制 编辑 原始数据 按行查看 历史
caowai 提交于 2019-01-09 13:36 . init version
#include "dialogsetting.h"
#include "ui_dialogsetting.h"
#include <QHostAddress>
#include <QDialogButtonBox>
#include <QCloseEvent>
#include <QEvent>
#include <unistd.h>
DialogSetting::DialogSetting(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogSetting)
{
ui->setupUi(this);
}
DialogSetting::~DialogSetting()
{
delete ui;
}
bool DialogSetting::event(QEvent *event)
{
//Language changed.
if(event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
//Must call QWidget:event(event) or the process to be broken
return QWidget::event(event);
}
void DialogSetting::closeEvent(QCloseEvent *event)
{
emit setDialogClose();
}
void DialogSetting::setUserName(QByteArray userId)
{
ui->lineEditUserName->setText(userId);
}
void DialogSetting::setUserNickName(QByteArray userNickName)
{
ui->lineEditNickName->setText(userNickName);
}
void DialogSetting::setGroupName(QByteArray groupName)
{
ui->lineEditGroupName->setText(groupName);
}
void DialogSetting::setStartIp(unsigned int ip)
{
QHostAddress add;
add.setAddress(ip);
ui->lineEditStartIp->setText(add.toString());
}
void DialogSetting::setEndIp(unsigned int ip)
{
QHostAddress add;
add.setAddress(ip);
ui->lineEditEndIp->setText(add.toString());
}
QString DialogSetting::getUserName()
{
return ui->lineEditUserName->text();
}
QString DialogSetting::getUserNickName()
{
return ui->lineEditNickName->text();
}
QString DialogSetting::getGroupName()
{
return ui->lineEditGroupName->text();
}
QString DialogSetting::getStartIp()
{
return ui->lineEditStartIp->text();
}
QString DialogSetting::getEndIp()
{
return ui->lineEditEndIp->text();
}
void DialogSetting::on_lineEditUserName_textEdited(const QString &arg1)
{
if(arg1.length()>32 || arg1.length() == 0)
{
ui->labelWarning->setText(tr("User name length is from 1-32"));
return;
}
else
{
ui->labelWarning->setText("Valid user name");
}
return;
}
void DialogSetting::on_lineEditNickName_textEdited(const QString &arg1)
{
if(arg1.length()>32 || arg1.length() == 0)
{
ui->labelWarning->setText(tr("Nick name length is from 1-32"));
return;
}
else
{
ui->labelWarning->setText("Valid nick name");
}
return;
}
void DialogSetting::on_lineEditGroupName_textEdited(const QString &arg1)
{
if(arg1.length()>32 || arg1.length() == 0)
{
ui->labelWarning->setText(tr("Group name length is from 1-32"));
return;
}
else
{
ui->labelWarning->setText("Valid group name");
}
return;
}
void DialogSetting::on_lineEditStartIp_textEdited(const QString &arg1)
{
QHostAddress tmp;
if(false == tmp.setAddress(arg1))
{
ui->labelWarning->setText(tr("Invalid Start IP Address"));
}
else
{
ui->labelWarning->setText(tr("Valid Start IP Address"));
}
return;
}
void DialogSetting::on_lineEditEndIp_textEdited(const QString &arg1)
{
QHostAddress tmp;
if(false == tmp.setAddress(arg1))
{
ui->labelWarning->setText(tr("Invalid End IP Address"));
}
else
{
ui->labelWarning->setText(tr("Valid End IP Address"));
}
return;
}
void DialogSetting::on_pushButtonAccept_clicked()
{
QHostAddress start;
QHostAddress end;
start.setAddress(ui->lineEditStartIp->text());
end.setAddress(ui->lineEditEndIp->text());
if(start.toIPv4Address() > end.toIPv4Address())
{
ui->labelWarning->setText(tr("End IP should >= Start IP"));
return;
}
else
{
emit setDialogAccepted();
}
}
void DialogSetting::on_pushButtonCancel_clicked()
{
emit setDialogRejected();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/flydilong/qipmsg.git
[email protected]:flydilong/qipmsg.git
flydilong
qipmsg
qipmsg
master

搜索帮助