forked from yydcaib/TCPClient
修改了linux下的bug,并一定程度优化了逻辑
This commit is contained in:
parent
b05254e259
commit
546b53a5e8
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 6.0.2, 2023-01-08T22:52:47. -->
|
<!-- Written by QtCreator 6.0.2, 2023-01-09T15:53:28. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|
|
@ -8,6 +8,7 @@ DataManager::DataManager(QObject *parent)
|
||||||
connect(tcpclient, &TCPClient::TCPClientConnected, this, &DataManager::TCPClientConnected);
|
connect(tcpclient, &TCPClient::TCPClientConnected, this, &DataManager::TCPClientConnected);
|
||||||
connect(tcpclient, &TCPClient::TCPClientDisconnected, this, &DataManager::TCPClientDisconnected);
|
connect(tcpclient, &TCPClient::TCPClientDisconnected, this, &DataManager::TCPClientDisconnected);
|
||||||
connect(tcpclient, &TCPClient::recv_data, this, &DataManager::recv_from_server);
|
connect(tcpclient, &TCPClient::recv_data, this, &DataManager::recv_from_server);
|
||||||
|
tcpclient->setServer("192.168.126.129",7890);
|
||||||
tcpclient->configAndrun();
|
tcpclient->configAndrun();
|
||||||
// tcpclient->setCallBack(recv_from_server);
|
// tcpclient->setCallBack(recv_from_server);
|
||||||
protocol = Protocol::getInstance();
|
protocol = Protocol::getInstance();
|
||||||
|
@ -126,7 +127,7 @@ void DataManager::Register(QString username, QString password)
|
||||||
data = protocol->data_maker(Protocol::REQUEST, QString("register"), QList<QString>{"user", username, "password", password});
|
data = protocol->data_maker(Protocol::REQUEST, QString("register"), QList<QString>{"user", username, "password", password});
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "发送注册信息" << username << password;
|
qDebug() << "发送注册信息" << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::signin_request(QString username, QString password)
|
void DataManager::signin_request(QString username, QString password)
|
||||||
|
@ -135,7 +136,7 @@ void DataManager::signin_request(QString username, QString password)
|
||||||
data = protocol->data_maker(Protocol::REQUEST, QString("signin"), QList<QString>{"user", username, "password", password});
|
data = protocol->data_maker(Protocol::REQUEST, QString("signin"), QList<QString>{"user", username, "password", password});
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "发送登录信息" << username << password;
|
qDebug() << "发送登录信息" << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_text(QString sendname, QString text)
|
void DataManager::send_text(QString sendname, QString text)
|
||||||
|
@ -144,7 +145,7 @@ void DataManager::send_text(QString sendname, QString text)
|
||||||
data = protocol->data_maker(Protocol::MESSAGE, sendname, text);
|
data = protocol->data_maker(Protocol::MESSAGE, sendname, text);
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "群发文本信息" << sendname;
|
qDebug() << "群发文本信息" << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_to_user(QString sendname, QString to_user, QString text)
|
void DataManager::send_to_user(QString sendname, QString to_user, QString text)
|
||||||
|
@ -153,7 +154,7 @@ void DataManager::send_to_user(QString sendname, QString to_user, QString text)
|
||||||
data = protocol->data_maker(Protocol::MESSAGE, sendname, to_user, text);
|
data = protocol->data_maker(Protocol::MESSAGE, sendname, to_user, text);
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "私发文本信息" << sendname << to_user;
|
qDebug() << "私发文本信息" << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_file_to_all(QString sendname, QString filename, QByteArray file)
|
void DataManager::send_file_to_all(QString sendname, QString filename, QByteArray file)
|
||||||
|
@ -162,7 +163,7 @@ void DataManager::send_file_to_all(QString sendname, QString filename, QByteArra
|
||||||
data = protocol->data_maker(Protocol::FILE, sendname, filename, QString(file));
|
data = protocol->data_maker(Protocol::FILE, sendname, filename, QString(file));
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "群发文件" << sendname;
|
qDebug() << "群发文件" << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::send_file_private(QString sendname, QString filename, QByteArray file, QString name)
|
void DataManager::send_file_private(QString sendname, QString filename, QByteArray file, QString name)
|
||||||
|
@ -171,7 +172,7 @@ void DataManager::send_file_private(QString sendname, QString filename, QByteArr
|
||||||
data = protocol->data_maker(Protocol::FILE, name, sendname, filename, QString(file));
|
data = protocol->data_maker(Protocol::FILE, name, sendname, filename, QString(file));
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "私发文件" << sendname << name;
|
qDebug() << "私发文件" << data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataManager::account_cancellation(QString username)
|
void DataManager::account_cancellation(QString username)
|
||||||
|
@ -189,5 +190,5 @@ void DataManager::update_namelist(QString username)
|
||||||
data = protocol->data_maker(Protocol::REQUEST, QString("update_namelist"),QList<QString>{"name",username});
|
data = protocol->data_maker(Protocol::REQUEST, QString("update_namelist"),QList<QString>{"name",username});
|
||||||
data_encrypt = protocol->data_encrypt(data);
|
data_encrypt = protocol->data_encrypt(data);
|
||||||
tcpclient->sendToserver(data_encrypt);
|
tcpclient->sendToserver(data_encrypt);
|
||||||
qDebug() << "发送更新在线用户列表信息";
|
qDebug() << "发送更新在线用户列表信息" << data;
|
||||||
}
|
}
|
||||||
|
|
55
login.cpp
55
login.cpp
|
@ -28,6 +28,7 @@ Login::~Login()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************QEvent*************************************/
|
||||||
void Login::paintEvent(QPaintEvent *event)
|
void Login::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
//创建画家,指定绘图设备
|
//创建画家,指定绘图设备
|
||||||
|
@ -78,17 +79,6 @@ void Login::paintEvent(QPaintEvent *event)
|
||||||
ui->btn_signup->setGraphicsEffect(shadow);
|
ui->btn_signup->setGraphicsEffect(shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Login::new_closebutton(QPushButton* btn, QString position,QSize size)
|
|
||||||
{
|
|
||||||
QPixmap pixmap;
|
|
||||||
pixmap.load(position);
|
|
||||||
btn->setIconSize(size);
|
|
||||||
btn->setStyleSheet("QPushButton{border-width: 1px;border-style: solid;border-radius:15px;background-color: rgb(64, 145, 252);}"
|
|
||||||
"QPushButton:hover{background-color:#999999;}");
|
|
||||||
//设置图标
|
|
||||||
btn->setIcon(pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Login::mousePressEvent(QMouseEvent *event)
|
void Login::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() == Qt::LeftButton)
|
if (event->buttons() == Qt::LeftButton)
|
||||||
|
@ -122,8 +112,12 @@ void Login::mouseMoveEvent(QMouseEvent *event)
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************SLOTS************************************/
|
||||||
void Login::on_btn_signin_clicked()
|
void Login::on_btn_signin_clicked()
|
||||||
{
|
{
|
||||||
|
this->zoom_down(ui->btn_signin);
|
||||||
|
this->zoom_up(ui->btn_signin);
|
||||||
if(connect_flag == true)
|
if(connect_flag == true)
|
||||||
{
|
{
|
||||||
user = ui->lineEdit_username->text();
|
user = ui->lineEdit_username->text();
|
||||||
|
@ -143,6 +137,8 @@ void Login::on_btn_signin_clicked()
|
||||||
|
|
||||||
void Login::on_btn_signup_clicked()
|
void Login::on_btn_signup_clicked()
|
||||||
{
|
{
|
||||||
|
this->zoom_down(ui->btn_signup);
|
||||||
|
this->zoom_up(ui->btn_signup);
|
||||||
signup = new Signup();
|
signup = new Signup();
|
||||||
connect(signup,&Signup::show_login_ui,this,&Login::show_login_ui);
|
connect(signup,&Signup::show_login_ui,this,&Login::show_login_ui);
|
||||||
connect(signup,&Signup::Register,this,&Login::slot_Register);
|
connect(signup,&Signup::Register,this,&Login::slot_Register);
|
||||||
|
@ -232,3 +228,40 @@ void Login::exit_client()
|
||||||
{
|
{
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************private functions************************************/
|
||||||
|
void Login::zoom_down(QPushButton* btn)
|
||||||
|
{
|
||||||
|
QPropertyAnimation *animalton = new QPropertyAnimation(btn,"geometry");
|
||||||
|
//设置间隔时间
|
||||||
|
animalton->setDuration(200);
|
||||||
|
//设置起始位置
|
||||||
|
animalton->setStartValue(QRect(btn->x(),btn->y(),btn->width(),btn->height()));
|
||||||
|
//设置结束位置
|
||||||
|
animalton->setEndValue(QRect(btn->x(),btn->y()+5,btn->width(),btn->height()));
|
||||||
|
//设置动画曲线
|
||||||
|
animalton->setEasingCurve(QEasingCurve::OutBounce);
|
||||||
|
animalton->start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Login::zoom_up(QPushButton* btn)
|
||||||
|
{
|
||||||
|
QPropertyAnimation *animalton = new QPropertyAnimation(btn,"geometry");
|
||||||
|
animalton->setDuration(200);
|
||||||
|
animalton->setStartValue(QRect(btn->x(),btn->y()+5,btn->width(),btn->height()));
|
||||||
|
animalton->setEndValue(QRect(btn->x(),btn->y(),btn->width(),btn->height()));
|
||||||
|
animalton->setEasingCurve(QEasingCurve::OutBounce);
|
||||||
|
animalton->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Login::new_closebutton(QPushButton* btn, QString position,QSize size)
|
||||||
|
{
|
||||||
|
QPixmap pixmap;
|
||||||
|
pixmap.load(position);
|
||||||
|
btn->setIconSize(size);
|
||||||
|
btn->setStyleSheet("QPushButton{border-width: 1px;border-style: solid;border-radius:15px;background-color: rgb(64, 145, 252);}"
|
||||||
|
"QPushButton:hover{background-color:#999999;}");
|
||||||
|
//设置图标
|
||||||
|
btn->setIcon(pixmap);
|
||||||
|
}
|
||||||
|
|
6
login.h
6
login.h
|
@ -6,6 +6,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
@ -30,7 +31,6 @@ public:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void new_closebutton(QPushButton* btn, QString position,QSize size);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signin_request(QString username,QString password);
|
void signin_request(QString username,QString password);
|
||||||
|
@ -60,6 +60,10 @@ private:
|
||||||
DataManager *datamanager;
|
DataManager *datamanager;
|
||||||
bool connect_flag = false;
|
bool connect_flag = false;
|
||||||
|
|
||||||
|
void new_closebutton(QPushButton* btn, QString position,QSize size);
|
||||||
|
void zoom_up(QPushButton* btn);
|
||||||
|
void zoom_down(QPushButton* btn);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOGIN_H
|
#endif // LOGIN_H
|
||||||
|
|
4
login.ui
4
login.ui
|
@ -40,7 +40,7 @@ border-radius:7px;
|
||||||
padding:2px 4px;
|
padding:2px 4px;
|
||||||
font: 14pt "Candara";}
|
font: 14pt "Candara";}
|
||||||
|
|
||||||
QPushButton:hover
|
QPushButton:pressed
|
||||||
{background-color:#999999;}</string>
|
{background-color:#999999;}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -98,7 +98,7 @@ border-radius:7px;
|
||||||
padding:2px 4px;
|
padding:2px 4px;
|
||||||
font: 14pt "Candara";}
|
font: 14pt "Candara";}
|
||||||
|
|
||||||
QPushButton:hover
|
QPushButton:pressed
|
||||||
{background-color:#999999;}</string>
|
{background-color:#999999;}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -6,6 +6,7 @@ MainWidget::MainWidget(QString username,QWidget *parent) :
|
||||||
ui(new Ui::MainWidget)
|
ui(new Ui::MainWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setFixedSize(this->width(), this->height());
|
||||||
this->setWindowIcon(QIcon(":/icon.png"));
|
this->setWindowIcon(QIcon(":/icon.png"));
|
||||||
this->setWindowTitle(QString("TCP聊天室:%1").arg(username));
|
this->setWindowTitle(QString("TCP聊天室:%1").arg(username));
|
||||||
ui->name_list->setEditTriggers(QAbstractItemView::NoEditTriggers); //不允许编辑
|
ui->name_list->setEditTriggers(QAbstractItemView::NoEditTriggers); //不允许编辑
|
||||||
|
@ -166,8 +167,8 @@ void MainWidget::on_exit_btn_clicked()
|
||||||
|
|
||||||
if(response == QMessageBox::Yes)
|
if(response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
emit exit_client();
|
//emit exit_client();
|
||||||
emit update_namelist(username);
|
//emit update_namelist(username);
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -184,7 +185,7 @@ void MainWidget::on_stop_clicked()
|
||||||
if(response == QMessageBox::Yes)
|
if(response == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
qDebug() << "点击注销账户按钮";
|
qDebug() << "点击注销账户按钮";
|
||||||
emit exit_client();
|
//emit exit_client();
|
||||||
emit account_cancellation(username);
|
emit account_cancellation(username);
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
|
@ -6,19 +6,25 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>798</width>
|
<width>722</width>
|
||||||
<height>587</height>
|
<height>587</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>722</width>
|
||||||
|
<height>587</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>50</x>
|
<x>60</x>
|
||||||
<y>510</y>
|
<y>500</y>
|
||||||
<width>401</width>
|
<width>361</width>
|
||||||
<height>31</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -42,8 +48,8 @@
|
||||||
<widget class="QWidget" name="layoutWidget_2">
|
<widget class="QWidget" name="layoutWidget_2">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>520</x>
|
<x>470</x>
|
||||||
<y>510</y>
|
<y>500</y>
|
||||||
<width>211</width>
|
<width>211</width>
|
||||||
<height>31</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
|
@ -68,27 +74,30 @@
|
||||||
<widget class="QTextEdit" name="textEdit">
|
<widget class="QTextEdit" name="textEdit">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>50</x>
|
<x>60</x>
|
||||||
<y>30</y>
|
<y>50</y>
|
||||||
<width>401</width>
|
<width>361</width>
|
||||||
<height>421</height>
|
<height>401</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border-radius:20px;</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget_3">
|
<widget class="QWidget" name="layoutWidget_3">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>520</x>
|
<x>490</x>
|
||||||
<y>30</y>
|
<y>50</y>
|
||||||
<width>211</width>
|
<width>171</width>
|
||||||
<height>441</height>
|
<height>401</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font: 12pt "Arial Black";</string>
|
<string notr="true">font: 10pt "Arial Black";</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>在线用户列表</string>
|
<string>在线用户列表</string>
|
||||||
|
@ -98,11 +107,11 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="name_list">
|
<widget class="QListWidget" name="name_list">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"> QListWidget { outline: none; border:1px solid white; color: #696969;}
|
<string notr="true"> QListWidget { outline: none; border:1px solid white; color: #696969;border-radius:\n7px;}
|
||||||
QListWidget::Item { width: 60px; height: 40px; }
|
QListWidget::Item { width: 60px; height: 35px; }
|
||||||
QListWidget::Item:hover { background: #FFA500; color: white; }
|
QListWidget::Item:hover { background: #FFA500; color: white; }
|
||||||
QListWidget::item:selected { background: #FFC0CB; color: #DC143C; }
|
QListWidget::item:selected { background: #FFC0CB; color: #DC143C; }
|
||||||
QListWidget::item:selected:!active { background: blue; }
|
/*QListWidget::item:selected:!active { background: blue; }*/
|
||||||
|
|
||||||
QScrollBar:vertical
|
QScrollBar:vertical
|
||||||
{
|
{
|
||||||
|
@ -206,18 +215,26 @@ QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical
|
||||||
<widget class="QWidget" name="layoutWidget_4">
|
<widget class="QWidget" name="layoutWidget_4">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>50</x>
|
<x>60</x>
|
||||||
<y>460</y>
|
<y>460</y>
|
||||||
<width>401</width>
|
<width>361</width>
|
||||||
<height>31</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="msg_edit"/>
|
<widget class="QLineEdit" name="msg_edit">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">border-radius:
|
||||||
|
7px;padding:2px 4px;</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="send_btn">
|
<widget class="QPushButton" name="send_btn">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>发送</string>
|
<string>发送</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -117,11 +117,11 @@ QPair<Protocol::data_types,QJsonObject> Protocol::data_parser(QByteArray data)
|
||||||
return qMakePair(RESPONSE,json_data.object());
|
return qMakePair(RESPONSE,json_data.object());
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Protocol::XOR_En_Decrypt(QString src)
|
QByteArray Protocol::XOR_En_Decrypt(QByteArray src)
|
||||||
{
|
{
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
for(auto &i:src)
|
for(auto &i:src)
|
||||||
result.append(i.toLatin1() ^ cipher_word);
|
result.append(i ^ cipher_word);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +155,11 @@ QByteArray Protocol::data_encrypt(QByteArray src)
|
||||||
|
|
||||||
QByteArray Protocol::data_decrypt(QByteArray src)
|
QByteArray Protocol::data_decrypt(QByteArray src)
|
||||||
{
|
{
|
||||||
|
qDebug() << QString(src);
|
||||||
QByteArray result = XOR_En_Decrypt(src);
|
QByteArray result = XOR_En_Decrypt(src);
|
||||||
|
//qDebug() << result;
|
||||||
result = Upper_Lower_En_Decrypt(result);
|
result = Upper_Lower_En_Decrypt(result);
|
||||||
|
//qDebug() << result;
|
||||||
return QByteArray::fromBase64(result);
|
return QByteArray::fromBase64(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ private:
|
||||||
explicit Protocol(QObject *parent = nullptr);
|
explicit Protocol(QObject *parent = nullptr);
|
||||||
~Protocol();
|
~Protocol();
|
||||||
QByteArray data_builder(QList<any_types> &args);
|
QByteArray data_builder(QList<any_types> &args);
|
||||||
QByteArray XOR_En_Decrypt(QString src);
|
QByteArray XOR_En_Decrypt(QByteArray src);
|
||||||
QByteArray Upper_Lower_En_Decrypt(QString src);
|
QByteArray Upper_Lower_En_Decrypt(QString src);
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ Signup::Signup(QWidget *parent) : QWidget(parent),
|
||||||
|
|
||||||
Signup::~Signup()
|
Signup::~Signup()
|
||||||
{
|
{
|
||||||
|
emit
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ void TCPClient::configAndrun()
|
||||||
|
|
||||||
void TCPClient::sendToserver(QByteArray &data)
|
void TCPClient::sendToserver(QByteArray &data)
|
||||||
{
|
{
|
||||||
|
qDebug() << data;
|
||||||
if (socket.isOpen())
|
if (socket.isOpen())
|
||||||
{
|
{
|
||||||
socket.write(data);
|
socket.write(data);
|
||||||
|
|
Loading…
Reference in New Issue