-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinputconf.cpp
More file actions
108 lines (92 loc) · 2.18 KB
/
inputconf.cpp
File metadata and controls
108 lines (92 loc) · 2.18 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "inputconf.h"
#include "ui_inputconf.h"
InputConf::InputConf(QWidget *parent) :
QDialog(parent),
ui(new Ui::InputConf)
{
ui->setupUi(this);
joyform = new joyconfig(this);
ui->listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
edjoy=new InputEdit(this);
}
InputConf::~InputConf()
{
delete ui;
delete joyform;
delete edjoy;
}
void InputConf::PressJoyButton(int dev, int ind)
{
joyform->PressJoyButton(dev, ind);
}
void InputConf::PressJoyAxis(int dev, int ind, int dir)
{
joyform->PressJoyAxis(dev, ind, dir);
}
void InputConf::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void InputConf::on_pushButton_clicked()
{
joyform->exec();
ui->listWidget->addItem(joyform->cfgstr);
}
void InputConf::on_pushButton_2_clicked()
{
delete ui->listWidget->currentItem();
}
void InputConf::on_pushButton_3_clicked()
{
if(!ui->listWidget->selectedItems().size())return;
joyform->exec();
ui->listWidget->currentItem()->setText(joyform->cfgstr);
}
void InputConf::on_pushButton_4_clicked()
{
if(!ui->listWidget->selectedItems().size())return;
edjoy->SetTextLine(ui->listWidget->currentItem()->text());
edjoy->exec();
ui->listWidget->currentItem()->setText(edjoy->GetTextLine());
}
void InputConf::showEvent ( QShowEvent * event )
{
int i,n;
QString tmp;
n=cfg->beginReadArray("Input");
ui->listWidget->clear();
jlist.clear();
for(i=0;i<n;i++)
{
cfg->setArrayIndex(i);
tmp=cfg->value("conf").toString();
ui->listWidget->addItem(tmp);
jlist.append(tmp);
}
cfg->endArray();
}
void InputConf::closeEvent (QCloseEvent * e)
{
int i,num=ui->listWidget->count();
jlist.clear();
cfg->remove("Input");
cfg->beginWriteArray("Input",num);
for(i=0;i<num;i++)
{
jlist.append(ui->listWidget->item(i)->text());
cfg->setArrayIndex(i);
cfg->setValue("conf",ui->listWidget->item(i)->text());
}
cfg->endArray();
}
void InputConf::on_buttonBox_accepted()
{
closeEvent(NULL);
}