-
Notifications
You must be signed in to change notification settings - Fork 0
/
stone.cpp
83 lines (61 loc) · 1.43 KB
/
stone.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "stone.hpp"
#include "ui_stone.h"
#include <QDebug>
#include <QDesktopWidget>
#include <QToolButton>
#include "rubotcp.hpp"
#include "log.hpp"
Stone::Stone(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Stone)
{
ui->setupUi(this);
}
Stone::~Stone()
{
delete ui;
}
void Stone::init_ui()
{
this->setWindowIcon(QIcon(":/UI/stone.ico"));
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect screen_rect = desktopWidget->availableGeometry();
Log("height:%d, width:%d", screen_rect.height(), screen_rect.width());
int width = screen_rect.width()/4;
int height = screen_rect.height()/4;
QRect stone_rect = QRect((screen_rect.width()-width)/2, (screen_rect.height()-height)/2, width, height);
this->setGeometry(stone_rect);
this->setFixedSize(width, height);
}
void Stone::on_connected()
{
QPushButton *connectBtn = this->findChild<QPushButton*>("connectBtn");
if(connectBtn)
{
connectBtn->setHidden(true);
}
}
void Stone::on_disconnected()
{
QPushButton *connectBtn = this->findChild<QPushButton*>("connectBtn");
if(connectBtn)
{
connectBtn->setHidden(false);
}
}
void Stone::init()
{
_tcp = new RuboTcp(this);
init_ui();
}
void Stone::on_connectBtn_clicked()
{
if(_tcp->doConnect() == false)
{
Log("connect to server failed");
}
else
{
Log("connect to server success");
}
}