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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/***************************************************************************
vbaconfigwidget.cpp
-------------------
begin : Thu Nov 29 2001
copyright : (C) 2001 by Sandy Meier
email : smeier@kdevelop.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "vbaconfigwidget.h"
#include <tqcheckbox.h>
#include <tqdir.h>
#include <tqlineedit.h>
#include <tqradiobutton.h>
#include <tqtoolbutton.h>
#include <kfiledialog.h>
#include "domutil.h"
using namespace VisualBoyAdvance;
VBAConfigWidget::VBAConfigWidget(VisualBoyAdvancePart* part,TQWidget *parent, const char *name ) : VBAConfigWidgetBase(parent,name) {
m_part = part;
TQDomDocument &doc = *m_part->projectDom();
// read
TQString emulator = DomUtil::readEntry(doc, "/kdevvisualadvance/emulator");
TQString binary = DomUtil::readEntry(doc, "/kdevvisualadvance/binary");
TQString graphicFilter = DomUtil::readEntry(doc, "/kdevvisualadvance/graphicFilter");
TQString scaling = DomUtil::readEntry(doc, "/kdevvisualadvance/scaling");
TQString addOptions = DomUtil::readEntry(doc, "/kdevvisualadvance/addOptions");
bool terminal = DomUtil::readBoolEntry(doc, "/kdevvisualadvance/terminal");
bool fullscreen = DomUtil::readBoolEntry(doc, "/kdevvisualadvance/fullscreen");
// set the widgets
if(emulator.isNull()){
emuPathEdit->setText("VisualBoyAdvance"); // default
}else{
emuPathEdit->setText(emulator);
}
binaryEdit->setText(binary);
// graphic
if(graphicFilter.isNull()){
normalModeButton->setChecked(true);
}else{
if(graphicFilter == "-f0"){
normalModeButton->setChecked(true);
}
if(graphicFilter == "-f1"){
tvModeButton->setChecked(true);
}
if(graphicFilter == "-f2"){
salModeButton->setChecked(true);
}
if(graphicFilter == "-f3"){
superSalModeButton->setChecked(true);
}
if(graphicFilter == "-f4"){
superEagleModeButton->setChecked(true);
}
}
// scaling
if(scaling.isNull()){
scaling1Button->setChecked(true);//default
}else{
if(scaling == "-1"){
scaling1Button->setChecked(true);
}
if(scaling == "-2"){
scaling2Button->setChecked(true);
}
if(scaling == "-3"){
scaling3Button->setChecked(true);
}
if(scaling == "-4"){
scaling4Button->setChecked(true);
}
}
if(fullscreen){
fullscreenCheckBox->setChecked(true);
}
if(terminal){
terminalCheckBox->setChecked(true);
}
addOptionsEdit->setText(addOptions);
connect(emuPathButton,TQT_SIGNAL(clicked()),this,TQT_SLOT(emuPathButtonClicked()));
}
VBAConfigWidget::~VBAConfigWidget(){
}
void VBAConfigWidget::accept(){
TQDomDocument &doc = *m_part->projectDom();
DomUtil::writeEntry(doc, "/kdevvisualadvance/emulator",emuPathEdit->text());
DomUtil::writeEntry(doc, "/kdevvisualadvance/binary",binaryEdit->text());
DomUtil::writeEntry(doc, "/kdevvisualadvance/addOptions",addOptionsEdit->text());
DomUtil::writeBoolEntry(doc, "/kdevvisualadvance/terminal",terminalCheckBox->isChecked());
DomUtil::writeBoolEntry(doc, "/kdevvisualadvance/fullscreen",fullscreenCheckBox->isChecked());
if(normalModeButton->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/graphicFilter","-f0");
}else if (tvModeButton->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/graphicFilter","-f1");
}else if (salModeButton->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/graphicFilter","-f2");
}else if (superSalModeButton->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/graphicFilter","-f3");
}else if (superEagleModeButton->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/graphicFilter","-f4");
}
if(scaling1Button->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/scaling","-1");
}else if(scaling2Button->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/scaling","-2");
}else if(scaling3Button->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/scaling","-3");
}else if(scaling4Button->isChecked()){
DomUtil::writeEntry(doc, "/kdevvisualadvance/scaling","-4");
}
}
void VBAConfigWidget::emuPathButtonClicked(){
TQString emu = KFileDialog::getOpenFileName(TQDir::homeDirPath());
if(!emu.isEmpty()){
emuPathEdit->setText(emu);
}
}
#include "vbaconfigwidget.moc"
|