forked from yydcaib/TCPClient
105 lines
2.6 KiB
C++
105 lines
2.6 KiB
C++
#include "signup.h"
|
|
#include "ui_signup.h"
|
|
#include <QPointer>
|
|
|
|
Signup::Signup(QWidget *parent) : QWidget(parent),
|
|
ui(new Ui::Signup)
|
|
{
|
|
ui->setupUi(this);
|
|
QScopedPointer<QPixmap> pix (new QPixmap(":/blue.png"));
|
|
QSize sz = ui->label_image->size();
|
|
ui->label_image->setPixmap(pix->scaled(sz));
|
|
|
|
this->setWindowIcon(QIcon(":/icon.png"));
|
|
this->setWindowFlags(Qt::FramelessWindowHint); //无边框
|
|
|
|
//设置阴影
|
|
QPointer<QGraphicsDropShadowEffect> shadow (new QGraphicsDropShadowEffect(this));
|
|
shadow->setOffset(-3, 0);
|
|
shadow->setColor(QColor("#888888"));
|
|
shadow->setBlurRadius(30);
|
|
ui->label_image->setGraphicsEffect(shadow);
|
|
}
|
|
|
|
Signup::~Signup()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
//返回登录按钮
|
|
void Signup::on_btn_return_clicked()
|
|
{
|
|
this->close();
|
|
emit show_login_ui();
|
|
}
|
|
|
|
//注册按钮
|
|
void Signup::on_btn_sure_clicked()
|
|
{
|
|
QString username = ui->lineEdit_username->text();
|
|
QString password = ui->lineEdit_passwd->text();
|
|
QString surepass = ui->lineEdit_surepasswd->text();
|
|
if (username.isEmpty() || password.isEmpty() || surepass.isEmpty())
|
|
{
|
|
QMessageBox::warning(this, "注册失败", "输入不能为空!");
|
|
}
|
|
|
|
else
|
|
{
|
|
if (password == surepass)
|
|
{
|
|
emit Register(username,password);
|
|
}
|
|
else
|
|
{
|
|
QMessageBox::information(this, "用户注册", "两次密码输入不一致!");
|
|
}
|
|
}
|
|
}
|
|
|
|
void Signup::paintEvent(QPaintEvent *event)
|
|
{
|
|
QPainter painter(this);
|
|
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
|
|
|
painter.setPen(Qt::transparent);
|
|
QRect rect = this->rect(); // rect为绘制大小
|
|
rect.setWidth(rect.width() - 1);
|
|
rect.setHeight(rect.height() - 1);
|
|
painter.drawRoundedRect(rect, 10, 10); // 10为圆角角度
|
|
}
|
|
|
|
void Signup::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
if (event->buttons() == Qt::LeftButton)
|
|
{
|
|
point = event->pos();
|
|
}
|
|
}
|
|
|
|
void Signup::mouseMoveEvent(QMouseEvent *event)
|
|
{
|
|
if (event->buttons() == Qt::LeftButton)
|
|
{
|
|
//当窗口最大化或最小化时也不进行触发
|
|
if (Signup::isMaximized() || Signup::isMinimized())
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//当在按钮之类需要鼠标操作的地方不进行触发(防误触)
|
|
if (ui->btn_sure->underMouse() || ui->btn_return->underMouse())
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Signup::move(Signup::mapToGlobal(event->pos() - point)); //移动
|
|
}
|
|
}
|
|
}
|
|
event->accept();
|
|
}
|
|
|