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