Diffstat (limited to 'noncore/tools/remote/configtab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/remote/configtab.cpp | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/noncore/tools/remote/configtab.cpp b/noncore/tools/remote/configtab.cpp new file mode 100644 index 0000000..f5896a9 --- a/dev/null +++ b/noncore/tools/remote/configtab.cpp | |||
@@ -0,0 +1,218 @@ | |||
1 | /* | ||
2 | Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | ||
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | ||
7 | version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | ||
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
11 | Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | ||
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
15 | */ | ||
16 | |||
17 | #include "configtab.h" | ||
18 | |||
19 | ConfigTab::ConfigTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) | ||
20 | { | ||
21 | |||
22 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
23 | |||
24 | topGroupConf = new TopGroupConf(this, "topGroupConf"); | ||
25 | layout->addWidget(topGroupConf, 1); | ||
26 | layout->addSpacing(1); | ||
27 | |||
28 | dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf"); | ||
29 | layout->addWidget(dvdGroupConf, 1); | ||
30 | layout->addSpacing(1); | ||
31 | |||
32 | vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf"); | ||
33 | layout->addWidget(vcrGroupConf, 1); | ||
34 | layout->addSpacing(1); | ||
35 | |||
36 | channelGroupConf = new ChannelGroupConf(this, "channelGroupConf"); | ||
37 | layout->addWidget(channelGroupConf, 1); | ||
38 | |||
39 | |||
40 | } | ||
41 | |||
42 | void ConfigTab::setConfig(Config *newCfg) | ||
43 | { | ||
44 | cfg = newCfg; | ||
45 | cfg->setGroup("Remotes"); | ||
46 | topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') ); | ||
47 | cfg->setGroup("Default"); | ||
48 | const QObject *obj; | ||
49 | |||
50 | const QObjectList *objList = topGroupConf->children(); | ||
51 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
52 | { | ||
53 | if(obj->inherits("QPushButton")) | ||
54 | { | ||
55 | if(!cfg->hasKey((QString)obj->name()+"Label")) | ||
56 | { | ||
57 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | objList = dvdGroupConf->children(); | ||
63 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
64 | { | ||
65 | if(obj->inherits("QPushButton")) | ||
66 | { | ||
67 | if(!cfg->hasKey((QString)obj->name()+"Label")) | ||
68 | { | ||
69 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | |||
74 | objList = vcrGroupConf->children(); | ||
75 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
76 | { | ||
77 | if(obj->inherits("QPushButton")) | ||
78 | { | ||
79 | if(!cfg->hasKey((QString)obj->name()+"Label")) | ||
80 | { | ||
81 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | ||
82 | } | ||
83 | } | ||
84 | } | ||
85 | |||
86 | objList = channelGroupConf->children(); | ||
87 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
88 | { | ||
89 | if(obj->inherits("QPushButton")) | ||
90 | { | ||
91 | if(!cfg->hasKey((QString)obj->name()+"Label")) | ||
92 | { | ||
93 | cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | cfg->write(); | ||
98 | |||
99 | cfg->setGroup("Remotes"); | ||
100 | } | ||
101 | /* | ||
102 | void ConfigTab::savePressed() | ||
103 | { | ||
104 | cfg->setGroup(remotes->currentText()); | ||
105 | ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0); | ||
106 | if( bd->exec() == 1) | ||
107 | { | ||
108 | printf("%s\n", bd->getList().join(" ").latin1()); | ||
109 | } | ||
110 | } | ||
111 | */ | ||
112 | |||
113 | void ConfigTab::newPressed() | ||
114 | { | ||
115 | QStringList list; | ||
116 | cfg->setGroup("Remotes"); | ||
117 | list=cfg->readListEntry("remoteList", ','); | ||
118 | list+=topGroupConf->getRemotesText(); | ||
119 | cfg->writeEntry("remoteList", list, ','); | ||
120 | cfg->setGroup(topGroupConf->getRemotesText()); | ||
121 | topGroupConf->updateRemotes(QStringList(topGroupConf->getRemotesText()) ); | ||
122 | cfg->write(); | ||
123 | emit remotesChanged(); | ||
124 | remoteSelected(topGroupConf->getRemotesText()); | ||
125 | } | ||
126 | |||
127 | void ConfigTab::remoteSelected(const QString &string) | ||
128 | { | ||
129 | cfg->setGroup(string); | ||
130 | const QObject *obj; | ||
131 | |||
132 | const QObjectList *objList = topGroupConf->children(); | ||
133 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
134 | { | ||
135 | if(obj->inherits("QPushButton")) | ||
136 | { | ||
137 | if(cfg->hasKey((QString)obj->name()+"Label")) | ||
138 | { | ||
139 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | cfg->setGroup("Default"); | ||
144 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
145 | cfg->setGroup(string); | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | |||
150 | objList = dvdGroupConf->children(); | ||
151 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
152 | { | ||
153 | if(obj->inherits("QPushButton")) | ||
154 | { | ||
155 | if(cfg->hasKey((QString)obj->name()+"Label")) | ||
156 | { | ||
157 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | cfg->setGroup("Default"); | ||
162 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
163 | cfg->setGroup(string); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | |||
168 | objList = vcrGroupConf->children(); | ||
169 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
170 | { | ||
171 | if(obj->inherits("QPushButton")) | ||
172 | { | ||
173 | if(cfg->hasKey((QString)obj->name()+"Label")) | ||
174 | { | ||
175 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | cfg->setGroup("Default"); | ||
180 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
181 | cfg->setGroup(string); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | |||
186 | objList = channelGroupConf->children(); | ||
187 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | ||
188 | { | ||
189 | if(obj->inherits("QPushButton")) | ||
190 | { | ||
191 | if(cfg->hasKey((QString)obj->name()+"Label")) | ||
192 | { | ||
193 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | cfg->setGroup("Default"); | ||
198 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | ||
199 | cfg->setGroup(string); | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | void ConfigTab::buttonPressed() | ||
206 | { | ||
207 | const QObject *button = sender(); | ||
208 | QString string = button->name(); | ||
209 | |||
210 | ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), this, "BD", true, 0); | ||
211 | if( bd->exec() == 1) | ||
212 | { | ||
213 | cfg->writeEntry(string, bd->getList().join(" ").latin1()); | ||
214 | cfg->writeEntry(string+"Label", bd->getLabel().latin1()); | ||
215 | } | ||
216 | cfg->write(); | ||
217 | ((QPushButton *)button)->setText(bd->getLabel()); | ||
218 | } | ||