Skip to content

Commit 1139c91

Browse files
committed
separate GUI done.
1 parent de74c21 commit 1139c91

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

include/QtUI/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ qt_add_executable(client
207207
board.hpp
208208
gameTile.hpp
209209
gameWindow.hpp
210+
clientConnect.hpp
210211
ChessCommon.hpp
211212
chess_client.cpp
212213
)

include/QtUI/chess_client.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
#include <QApplication>
22
#include "ChessCommon.hpp"
3-
3+
#include "clientConnect.hpp"
44

55
void* checkForUpdates(void* threadArg);
66

77
int main(int argc, char *argv[]){
88

99
QApplication app(argc, argv);
1010
std::string server_IP;
11+
// if(argc>1) {
12+
// server_IP = argv[1];
13+
// } else {
14+
// std::cout << "Enter IP addr to connect to : ";
15+
// std::cin >> server_IP;
16+
// }
1117

12-
if(argc>1) {
13-
server_IP = argv[1];
14-
} else {
15-
std::cout << "Enter IP addr to connect to : ";
16-
std::cin >> server_IP;
17-
}
1818

19+
clientConnect dialog;
20+
QObject::connect(&dialog, &clientConnect::exportIP6, [=](const std::string ip){
1921

20-
// Initialise the Client Game Object with args
21-
// (#serverIP, #serverPort, Affiliation)
22-
// { true/false : white/black }
23-
ChessClient* Client = new ChessClient(server_IP, 60000, false);
22+
// Initialise the Client Game Object with args
23+
// (#serverIP, #serverPort, Affiliation)
24+
// { true/false : white/black }
25+
ChessClient* Client = new ChessClient(server_IP, 60000, false);
2426

25-
// create new thread for this.
26-
pthread_t clientThread;
27-
int rc = pthread_create(&clientThread, NULL, checkForUpdates, (void*)Client);
28-
27+
// create new thread for this.
28+
pthread_t clientThread;
29+
int rc = pthread_create(&clientThread, NULL, checkForUpdates, (void*)Client);
30+
});
31+
32+
dialog.show();
2933
// GUI runs in main thread
3034
app.exec();
3135

0 commit comments

Comments
 (0)