Skip to content

Commit

Permalink
feat: Network Model Connection UI Optimisation and Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
XMuli committed Dec 14, 2023
1 parent ef852b4 commit 87de5d9
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 145 deletions.
4 changes: 2 additions & 2 deletions AboutAuthor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <QPalette>

AboutAuthor::AboutAuthor(QWidget *parent) :
QDialog(parent),
ui(new Ui::AboutAuthor)
ui(new Ui::AboutAuthor),
QDialog(parent)
{
this->setWindowIcon(QIcon(":/images/chess.svg"));
ui->setupUi(this);
Expand Down
12 changes: 6 additions & 6 deletions AboutAuthor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
#include <QDialog>
#include <QFont>

namespace Ui {
class AboutAuthor;
namespace Ui
{
class AboutAuthor;
}

class AboutAuthor : public QDialog
{
Q_OBJECT

public:
explicit AboutAuthor(QWidget *parent = 0);
explicit AboutAuthor(QWidget* parent = 0);
~AboutAuthor();

protected:
virtual void paintEvent(QPaintEvent *event) override;
virtual void paintEvent(QPaintEvent* event) override;

private:
Ui::AboutAuthor *ui;
QWidget * QDialog;
Ui::AboutAuthor* ui;
};

#endif // ABOUTAUTHOR_H
23 changes: 14 additions & 9 deletions AboutAuthor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="chooseresource.qrc">:/images/Alipay.png</pixmap>
<pixmap resource="resources/res.qrc">:/images/Alipay.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down Expand Up @@ -106,7 +106,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="chooseresource.qrc">:/images/WeChat.png</pixmap>
<pixmap resource="resources/res.qrc">:/images/WeChat.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
Expand Down Expand Up @@ -145,19 +145,25 @@
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt;作者:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli&quot;&gt;&lt;span style=&quot; font-family:'华文楷体'; text-decoration: underline; color:#007af4;&quot;&gt;偕臧&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; Copyri © 2019-2022&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli&quot;&gt;&lt;span style=&quot; font-family:'华文楷体'; text-decoration: underline; color:#007af4;&quot;&gt;偕臧&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'华文楷体';&quot;&gt; Copyri © 2019-2024&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'华文楷体'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;贡献者: &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/Bruce-Ch&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;Bruce-Ch&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/BlueArvin&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;BlueArvin&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/Ubuntuser2012&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;Ubuntuser2012&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/kira-yamatoo&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;kira-yamatoo&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/hmsjy2017&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;hmsjy2017&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/zjuyk&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;zjuyk&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; - &lt;/span&gt;&lt;a href=&quot;https://github.com/ryanfortner&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;ryanfortner&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;项目:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; 关于 &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli/chineseChess&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;ChinessChess&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; 此开源项目,兴趣之做;说明都在这里 [&lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli/chineseChess/blob/master/README.zh_CN.md&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;中文&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; | &lt;/span&gt;&lt;a href=&quot;https://github.com/XMuli/chineseChess/blob/master/README.md&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;English&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;]&lt;/span&gt;&lt;/p&gt;
Expand All @@ -169,7 +175,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt; 所有参与贡献的,亦都会留名在此。​热爱开源,热爱生命,热爱生活。&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong';&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;Bolg: &lt;/span&gt;&lt;a href=&quot;https://ifmet.cn&quot;&gt;&lt;span style=&quot; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;ifmet.cn&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;Bolg: &lt;/span&gt;&lt;a href=&quot;https://xmuli.tech&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;xmuli.tech&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'FangSong';&quot;&gt;Gmail: [email protected]&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'FangSong'; text-decoration: underline; color:#007af4;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
Expand All @@ -187,8 +193,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<resources>
<include location="chooseresource.qrc"/>
<include location="chooseresource.qrc"/>
<include location="resources/res.qrc"/>
</resources>
<connections>
<connection>
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(project_version_path 0)
set(project_version ${project_version_major}.${project_version_minor}.${project_version_path})
project(${project_name} VERSION ${project_version} LANGUAGES CXX)

add_definitions(-DXBUILD_TIME="2023.12.13")
add_definitions(-DXBUILD_TIME="2023.12.14")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
Expand Down
61 changes: 20 additions & 41 deletions ChessBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
*/
#include "ChessBoard.h"

#include <mutex>
#include "ui_ChessBoard.h"

ChessBoard::ChessBoard(QWidget *parent) :
Expand Down Expand Up @@ -409,31 +411,11 @@ bool ChessBoard:: isGeneral()
return false;
}

void ChessBoard::setNetworkGroupShow(const bool &show)
void ChessBoard::showNetworkGui(const bool &show)
{
ui->networkGroup->setVisible(show);
}

/*!
* \brief ChessBoard::setNetworkGroupText
* \param group group的名称
* \param input 输入栏 IP+prot
* \param btn 按钮的名称,监听或者连接
* \param statue 连接结果的名称
*/
void ChessBoard::setNetworkGroupText(const QString &group, const QString &input, const QString &btn, const QString &statue)
{
ui->networkGroup->setTitle(group);
ui->lineEdit->setText(input);
ui->btnTcpConnect->setText(btn);
ui->labConnectStatus->setText(statue);
}

void ChessBoard::setstatusText(const QString &statue)
{
ui->labConnectStatus->setText(statue);
}

//鼠标按下事件
//void ChessBoard::mousePressEvent(QMouseEvent *ev)
//{
Expand Down Expand Up @@ -810,6 +792,13 @@ void ChessBoard::clickPieces(int id, int &row, int &col)
else {
tryMoveStone(id, row, col);
}

// 初次按下时,自启动计时器
std::once_flag flag;
std::call_once(flag, [&]() {
m_bIsStart = false;
on_pushButton_start_clicked();
});
}

void ChessBoard::trySelectStone(int id)
Expand Down Expand Up @@ -948,17 +937,17 @@ void ChessBoard::updateTime()
void ChessBoard::on_pushButton_start_clicked()
{
if(!m_bIsStart) //尚未开始 开始计时
{
m_timer->start(1000);
ui->pushButton_start->setText("暂停");
}
else //已经开始,暂停
{
m_timer->stop();
ui->pushButton_start->setText("继续");
}
{
m_timer->start(1000);
ui->pushButton_start->setText("暂停");
}
else //已经开始,暂停
{
m_timer->stop();
ui->pushButton_start->setText("继续");
}

m_bIsStart = !m_bIsStart;
m_bIsStart = !m_bIsStart;
}

void ChessBoard::on_pushButton_reset_clicked()
Expand Down Expand Up @@ -1001,14 +990,4 @@ void ChessBoard::on_pushButton_toMenu_clicked()
emit this->toMenu();
}

void ChessBoard::on_lineEdit_textChanged(const QString &arg1)
{
emit sigLineEditTextChanged(arg1);
}


void ChessBoard::on_btnTcpConnect_released()
{
emit sigBtnTcpConnectReleased();
}

16 changes: 3 additions & 13 deletions ChessBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ class ChessBoard : public QMainWindow
int relation(int row1, int col1, int row2, int col2); //计算选中的棋子的位置和要移动的位置之间的位置关系
QPoint getRealPoint(QPoint pt); // 使mouseMoveEvent取得的坐标同Painter的坐标一致
bool isGeneral(); //校验将移动后位置是否将死
void setNetworkGroupShow(const bool& show = false);

protected:
// 仅网络对战才需要的接口
void setNetworkGroupText(const QString& group, const QString& input, const QString &btn, const QString& statue);
void setstatusText(const QString& statue);
void showNetworkGui(const bool& show = false);

private:
bool hongMenFeast(); // 鸿门宴:对将
Expand Down Expand Up @@ -152,9 +147,6 @@ class ChessBoard : public QMainWindow
bool m_bIsShowStep; //是否显示步数
QString textStepRecord; //文本棋谱字符串

signals:
void sigLineEditTextChanged(const QString &arg1);
void sigBtnTcpConnectReleased();

private slots:
void updateTime();
Expand All @@ -165,13 +157,11 @@ private slots:
void on_pushButton_back_clicked();
void on_pushButton_showStep_clicked();
void on_pushButton_toMenu_clicked();
void on_lineEdit_textChanged(const QString &arg1);
void on_btnTcpConnect_released();


private:
protected:
Ui::ChessBoard *ui;

private:
QTimer * m_timer; //定时器 每秒更新时间
QTime * m_timeRecord; //记录时间
bool m_bIsStart; //记录是否已经开始计时
Expand Down
Loading

0 comments on commit 87de5d9

Please sign in to comment.