-
Notifications
You must be signed in to change notification settings - Fork 0
/
connectionwizard.cpp
58 lines (49 loc) · 1.11 KB
/
connectionwizard.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
#define _MAX 100
#include "connectionwizard.h"
#include "ui_connectionwizard.h"
ConnectionWizard::ConnectionWizard(wiimote* board, QWidget *parent) :
QDialog(parent),
ui(new Ui::ConnectionWizard),
m_connected(false),
m_board(board),
m_timer(this),
m_counter(0)
{
ui->setupUi(this);
setWindowTitle("Connecting..");
setResult(QDialog::Accepted);
}
ConnectionWizard::~ConnectionWizard()
{
delete ui;
}
void ConnectionWizard::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void ConnectionWizard::connectBoard()
{
if (!m_connected && m_counter < _MAX)
{
m_connected = m_board->Connect(wiimote::FIRST_AVAILABLE);
m_counter++;
ui->progressBar->setValue((100/_MAX)*m_counter);
} else {
m_timer.stop();
reject();
}
}
bool ConnectionWizard::connectToBoard()
{
connect(&m_timer,SIGNAL(timeout()),this,SLOT(connectBoard()));
m_timer.start(100);
exec();
return m_connected;
}