Skip to content

Commit

Permalink
Merge branch 'release/v1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
alphagocc committed Feb 11, 2018
2 parents d71ad06 + 45ec6bd commit fb4189e
Show file tree
Hide file tree
Showing 20 changed files with 1,441 additions and 22 deletions.
402 changes: 401 additions & 1 deletion .gitignore

Large diffs are not rendered by default.

41 changes: 35 additions & 6 deletions FiveChess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
#include "ui_FiveChess.h"
#include "battlegui.h"
#include "waitdialog.h"
#include "stdafx.h"
#include <QDebug>
#include <QLocale>

FiveChess::FiveChess(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::FiveChess)
QMainWindow(parent),
ui(new Ui::FiveChess)
{
ui->setupUi(this);
QObject::connect(ui->pushButtonNew,ui->pushButtonNew->clicked,this,newFiveChessGame);
QObject::connect(ui->pushButtonLoad,ui->pushButtonLoad->clicked,this,loadFiveChessGame);
ui->setupUi(this);
QObject::connect(ui->pushButtonNew, &QPushButton::clicked, this, &FiveChess::newFiveChessGame);
QObject::connect(ui->pushButtonLoad, &QPushButton::clicked, this, &FiveChess::loadFiveChessGame);
connect(ui->actionEnglish, &QAction::triggered, this, [&] {
translateUi(QLocale::UnitedStates);
qDebug() << "!!#3" << endl;
});
connect(ui->actionChinese, &QAction::triggered, this, [&] {
translateUi(QLocale::China);
qDebug() << "!!#zh_cn" << endl;
});
}

FiveChess::~FiveChess()
{
delete ui;
Expand All @@ -23,6 +32,7 @@ void FiveChess::newFiveChessGame()
hide();
battleGui *gameGui = new battleGui();
gameGui->setData(chessBoardData);
gameGui->setTranslator(tsor);
gameGui->show();
}

Expand All @@ -44,3 +54,22 @@ void FiveChess::setData(chessBoardData_Process *data)
this->chessBoardData=data;
qDebug()<<"SetData0!"<<data<<endl;
}

void FiveChess::translateUi(int value)
{
switch (value)
{
case QLocale::China: {
tsor->load(":/lang/zh_CN.qm");
break;
}
case QLocale::UnitedStates: {
tsor->load(":/lang/en_US.qm");
break;
}
default: {
break;
}
}
ui->retranslateUi(this);
}
5 changes: 4 additions & 1 deletion FiveChess.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QMainWindow>
#include "chessboarddata_process.h"
#include <QTranslator>

namespace Ui {
class FiveChess;
Expand All @@ -18,13 +19,15 @@ class FiveChess : public QMainWindow

private:
Ui::FiveChess *ui;

QTranslator *tsor;
public slots:
void newFiveChessGame();
void loadFiveChessGame();
public :
chessBoardData_Process *chessBoardData;
void setData(chessBoardData_Process*data);
void translateUi(int value);
void setTranslator(QTranslator *tsor) { this->tsor = tsor; }
};

#endif // FIVECHESS_H
4 changes: 4 additions & 0 deletions FiveChess.pro
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ RESOURCES += \
fivechessresources.qrc

ICON += Resources/ICO.ico

TRANSLATIONS += zh_CN.ts \
en_US.ts

2 changes: 1 addition & 1 deletion FiveChess.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.4.1, 2018-01-23T19:36:28. -->
<!-- Written by QtCreator 4.4.1, 2018-01-26T14:55:05. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
38 changes: 32 additions & 6 deletions FiveChess.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>FiveChess</string>
</property>
<property name="windowIcon">
<iconset>
<iconset resource="fivechessresources.qrc">
<normaloff>:/ico/Resources/ICO.ico</normaloff>
<normalon>:/ico/Resources/ICO.ico</normalon>
<disabledoff>:/ico/Resources/ICO.ico</disabledoff>
Expand All @@ -35,7 +35,7 @@
</sizepolicy>
</property>
<property name="text">
<string>新游戏</string>
<string>New Game</string>
</property>
</widget>
</item>
Expand All @@ -48,7 +48,7 @@
</sizepolicy>
</property>
<property name="text">
<string>载入</string>
<string>Load Game</string>
</property>
</widget>
</item>
Expand All @@ -60,7 +60,7 @@
</font>
</property>
<property name="text">
<string>五子棋小游戏</string>
<string>FiveChess</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand All @@ -78,10 +78,36 @@
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuLang">
<property name="title">
<string>Language</string>
</property>
<addaction name="actionEnglish"/>
<addaction name="actionChinese"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>About</string>
</property>
</widget>
<addaction name="menuLang"/>
<addaction name="menuAbout"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionEnglish">
<property name="text">
<string>English</string>
</property>
</action>
<action name="actionChinese">
<property name="text">
<string>Chinese</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<resources>
<include location="fivechessresources.qrc"/>
</resources>
<connections/>
</ui>
Loading

0 comments on commit fb4189e

Please sign in to comment.