diff --git a/TcpClient.pro b/TcpClient.pro index a04066e..a4a2238 100644 --- a/TcpClient.pro +++ b/TcpClient.pro @@ -37,3 +37,6 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin RESOURCES += \ imgs/imgs.qrc + +RC_ICON = imgs/exeicon.ico +RC_FILE += imgs/exeicon.rc diff --git a/TcpClient.pro.user b/TcpClient.pro.user index 117888e..7b546b6 100644 --- a/TcpClient.pro.user +++ b/TcpClient.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -91,16 +91,96 @@ ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 6.2.3 MinGW 64-bit - Desktop Qt 6.2.3 MinGW 64-bit - qt.qt6.623.win64_mingw_kit - 2 + Desktop Qt 6.2.3 MSVC2019 64bit + Desktop Qt 6.2.3 MSVC2019 64bit + qt.qt6.623.win64_msvc2019_64_kit + 0 0 0 0 - C:\Users\25761\Desktop\Error-in-"-Util.asciify("build-C:\Users\25761\Desktop\tcpclient\TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Profile")":-SyntaxError:-Expected-token-`)' - C:/Users/25761/Desktop/Error-in-"-Util.asciify("build-C:/Users/25761/Desktop/tcpclient/TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-Profile")":-SyntaxError:-Expected-token-`)' + C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug + C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Release + C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Profile + C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Profile true @@ -139,47 +219,50 @@ 0 0 - - 0 - C:\Users\25761\Desktop\build-TCPClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 - C:/Users/25761/Desktop/build-TCPClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 + 3 + - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - 111 - Qt4ProjectManager.Qt4BuildConfiguration - 2 + 1 + + false + ProjectExplorer.DefaultDeployConfiguration - + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/25761/Desktop/tcpclient/TcpClient.pro + C:/Users/25761/Desktop/tcpclient/TcpClient.pro + false + true + true + false + true + C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MSVC2019_64bit-Debug + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Desktop Qt 6.2.3 MinGW 64-bit + Desktop Qt 6.2.3 MinGW 64-bit + qt.qt6.623.win64_mingw_kit + 1 + 0 + 0 + C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 @@ -219,7 +302,47 @@ 0 0 - 3 + + 0 + C:\Users\25761\Desktop\build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 + C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + 111 + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + 2 0 @@ -247,14 +370,13 @@ true false true - C:/Users/25761/Desktop/build-TcpClient-Desktop_Qt_6_2_3_MinGW_64_bit-111 1 ProjectExplorer.Project.TargetCount - 1 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/imgs/cancel.png b/imgs/cancel.png new file mode 100644 index 0000000..a838902 Binary files /dev/null and b/imgs/cancel.png differ diff --git a/imgs/imgs.qrc b/imgs/imgs.qrc index ff709f0..f872d2d 100644 --- a/imgs/imgs.qrc +++ b/imgs/imgs.qrc @@ -4,5 +4,12 @@ blue.png close.png icon.png + user_label.png + namelist.png + cancel.png + quit.png + save.png + send.png + text.png diff --git a/imgs/namelist.png b/imgs/namelist.png new file mode 100644 index 0000000..697f57b Binary files /dev/null and b/imgs/namelist.png differ diff --git a/imgs/quit.png b/imgs/quit.png new file mode 100644 index 0000000..f270eac Binary files /dev/null and b/imgs/quit.png differ diff --git a/imgs/save.png b/imgs/save.png new file mode 100644 index 0000000..78a5e1d Binary files /dev/null and b/imgs/save.png differ diff --git a/imgs/send.png b/imgs/send.png new file mode 100644 index 0000000..9308afc Binary files /dev/null and b/imgs/send.png differ diff --git a/imgs/text.png b/imgs/text.png new file mode 100644 index 0000000..956ba14 Binary files /dev/null and b/imgs/text.png differ diff --git a/imgs/user_label.png b/imgs/user_label.png new file mode 100644 index 0000000..ba85abc Binary files /dev/null and b/imgs/user_label.png differ diff --git a/mainwidget.cpp b/mainwidget.cpp index d0d7a5e..e308d59 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -9,9 +9,12 @@ MainWidget::MainWidget(QString username,QWidget *parent) : this->setFixedSize(this->width(), this->height()); this->setWindowIcon(QIcon(":/icon.png")); this->setWindowTitle(QString("TCP聊天室:%1").arg(username)); + this->setAttribute(Qt::WA_StyledBackground); + ui->name_list->setEditTriggers(QAbstractItemView::NoEditTriggers); //不允许编辑 - ui->name_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + //ui->name_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); ui->name_list->verticalScrollBar()->setStyleSheet("QScrollBar{width:16px;}"); + ui->textEdit->setReadOnly(true); ui->textEdit->setFocusPolicy(Qt::NoFocus); //防止QTextBrowser中的内容被重定向 @@ -20,7 +23,6 @@ MainWidget::MainWidget(QString username,QWidget *parent) : connect(ui->textEdit, &QTextBrowser::anchorClicked, this, [=](const QUrl &link) { auto path = link.path(); - qDebug() << path; path.remove(0, 1); qDebug() << path; QFileInfo info(path); @@ -29,8 +31,19 @@ MainWidget::MainWidget(QString username,QWidget *parent) : else if(info.isFile()) QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }); + ui->send_btn->setFocus(); ui->send_btn->setDefault(true); + + ui->send_text->setMouseTracking(true); + ui->send_text->setToolTip(QStringLiteral("发送文件")); + ui->stop->setMouseTracking(true); + ui->stop->setToolTip(QStringLiteral("注销用户")); + ui->exit_btn->setMouseTracking(true); + ui->exit_btn->setToolTip(QStringLiteral("退出登录")); + ui->save_btn->setMouseTracking(true); + ui->save_btn->setToolTip(QStringLiteral("保存聊天记录")); + ui->msg_edit->installEventFilter(this);//设置完后自动调用其eventFilter函数 this->username = username; } @@ -42,6 +55,8 @@ MainWidget::~MainWidget() void MainWidget::on_send_text_clicked() { + zoom_down(ui->send_text); + zoom_up(ui->send_text); QString homePath = QDir::homePath(); QString filePath = QFileDialog::getOpenFileName(this, tr("Open a file"), homePath, tr("All files (*.*)"), NULL, QFileDialog::DontResolveSymlinks); @@ -102,6 +117,8 @@ void MainWidget::on_send_text_clicked() void MainWidget::on_save_btn_clicked() { + zoom_down(ui->save_btn); + zoom_up(ui->save_btn); QFile file("./ChatRecord/memory.txt"); if (file.exists()) //文件存在 { @@ -151,6 +168,8 @@ void MainWidget::on_save_btn_clicked() void MainWidget::on_send_btn_clicked() { + zoom_down(ui->send_btn); + zoom_up(ui->send_btn); QString text; text = ui->msg_edit->text(); if(text.isEmpty()) @@ -213,6 +232,8 @@ void MainWidget::on_name_list_itemDoubleClicked(QListWidgetItem *item) void MainWidget::on_exit_btn_clicked() { + zoom_down(ui->exit_btn); + zoom_up(ui->exit_btn); QMessageBox::StandardButton response; response = QMessageBox::question(this, "退出", tr("是否退出软件?")); @@ -230,6 +251,8 @@ void MainWidget::on_exit_btn_clicked() void MainWidget::on_stop_clicked() { + zoom_down(ui->stop); + zoom_up(ui->stop); QMessageBox::StandardButton response; response = QMessageBox::question(this, "注销", tr("是否退出软件并注销账户?")); @@ -314,6 +337,10 @@ void MainWidget::update_users(int count,QListonline_users) { ui->name_list->addItem(*it); } + for(int i=0;iname_list->count();i++) + { + ui->name_list->item(i)->setIcon(QIcon(":/user_label.png")); + } } @@ -414,3 +441,23 @@ bool MainWidget::eventFilter(QObject *target, QEvent *event) return QWidget::eventFilter(target,event); } +void MainWidget::zoom_down(QPushButton* btn) +{ + QPropertyAnimation *animalton = new QPropertyAnimation(btn,"geometry"); + animalton->setDuration(150); + 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 MainWidget::zoom_up(QPushButton* btn) +{ + QPropertyAnimation *animalton = new QPropertyAnimation(btn,"geometry"); + animalton->setDuration(150); + 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(); +} diff --git a/mainwidget.h b/mainwidget.h index 33caa0f..e76fbc5 100644 --- a/mainwidget.h +++ b/mainwidget.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace Ui { class MainWidget; @@ -56,6 +57,8 @@ public slots: private: Ui::MainWidget *ui; QString username; + void zoom_up(QPushButton* btn); + void zoom_down(QPushButton* btn); }; #endif // MAINWIDGET_H diff --git a/mainwidget.ui b/mainwidget.ui index 372029b..33b16e0 100644 --- a/mainwidget.ui +++ b/mainwidget.ui @@ -19,82 +19,197 @@ Form - + + #MainWidget +{background-color:rgba(131, 212, 255,175);} + + - 60 - 500 - 361 + 50 + 30 + 401 + 471 + + + + font: 11pt; + border-radius:7px + + + + + + 50 + 520 + 301 31 - - - - - 发送文件 - - - - - - - 保存聊天记录 - - - - + + border-radius: +7px;padding:2px 4px; + - + - 470 - 500 - 211 + 360 + 520 + 91 31 - - - - - 退出聊天 - - - - - - - 注销用户 - - - - + + QPushButton +{ +border :1px solid rgb(66,20,255); +border-radius: 5px; +/*border-image: url(:/icon.png);*/ +qproperty-icon: url(:/send.png); +icon-size: 40px 40px; +padding-right:15px; +background-color: rgb(); +} + + + 发送 + - + + + + 500 + 480 + 60 + 35 + + + + #send_text +{ +border-image: url(:/text.png); +padding-right:15px; +} + + + + + + + + + 570 + 480 + 60 + 35 + + + + #save_btn +{ +border-image: url(:/save.png); +padding-right:15px; +} + + + + + + + + + 570 + 520 + 61 + 35 + + + + #stop +{ + +border-image: url(:/cancel.png); +padding-right:15px; +} + + + + + + + + + 500 + 520 + 60 + 35 + + + + #exit_btn +{ +border-image: url(:/quit.png); +padding-right:15px; +} + + + + + + + + + 520 + 30 + 126 + 32 + + + + font: 10pt "Arial Black"; + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial Black'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:700;">在线用户列表</span></p></body></html> + + + 490 - 50 - 171 - 401 + 30 + 31 + 29 - - - - - font: 10pt "Arial Black"; - - - 在线用户列表 - - - - - - - QListWidget { outline: none; border:1px solid white; color: #696969;border-radius:\n7px;} + + QLabel +{ +border-image: url(:/namelist.png); +} + + + + + + 0 + + + + + + 490 + 70 + 171 + 391 + + + + QListWidget { outline: none;/* border:1px solid ; color: #696969;border :1px solid ;*/} QListWidget::Item { width: 60px; height: 35px; } QListWidget::Item:hover { background: #FFA500; color: white; } QListWidget::item:selected { background: #FFC0CB; color: #DC143C; } @@ -149,101 +264,60 @@ QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical background:rgba(0,0,0,10%); border-radius:4px; }*/ - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - - - - - - 60 - 460 - 361 - 31 - - - - - - - border-radius: -7px;padding:2px 4px; - - - - - - - - - - 发送 - - - - - - - - - 55 - 51 - 371 - 401 - - - - border-radius: -7px;padding:2px 4px; + + + 新建项目 + + + + :/user_label.png:/user_label.png + + + + + 新建项目 + + + + + 新建项目 + + + + + 新建项目 + + + + + 新建项目 + + + + + 新建项目 + + + + + 新建项目 + + + + + 新建项目 + + + + + 新建项目 + + - + + +