-rw-r--r-- | noncore/tools/remote/configtab.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/noncore/tools/remote/configtab.cpp b/noncore/tools/remote/configtab.cpp index af2b5ff..7951772 100644 --- a/noncore/tools/remote/configtab.cpp +++ b/noncore/tools/remote/configtab.cpp | |||
@@ -22,208 +22,216 @@ ConfigTab::ConfigTab(QWidget *parent, const char *name):QWidget(parent,name) | |||
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 | ||
42 | void ConfigTab::setConfig(Config *newCfg) | 42 | void 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 | 100 | ||
101 | QString curr_remote = topGroupConf->getRemotesText(); | 101 | QString curr_remote = topGroupConf->getRemotesText(); |
102 | if(curr_remote != "") | 102 | if(curr_remote != "") |
103 | remoteSelected(curr_remote); | 103 | remoteSelected(curr_remote); |
104 | } | 104 | } |
105 | 105 | ||
106 | void ConfigTab::newPressed() | 106 | void ConfigTab::newPressed() |
107 | { | 107 | { |
108 | QStringList list; | 108 | QStringList list; |
109 | QString newname = topGroupConf->getRemotesText(); | 109 | QString newname = topGroupConf->getRemotesText(); |
110 | if(newname.stripWhiteSpace()=="") | 110 | if(newname.stripWhiteSpace()=="") |
111 | QMessageBox::warning(this, tr("Error"), tr("Please enter a name\nfirst"), QMessageBox::Ok, QMessageBox::NoButton); | 111 | QMessageBox::warning(this, tr("Error"), tr("Please enter a name\nfirst"), QMessageBox::Ok, QMessageBox::NoButton); |
112 | else if(newname=="Remotes") | 112 | else if(newname=="Remotes") |
113 | QMessageBox::warning(this, tr("Error"), tr("The name 'Remotes' is\nnot allowed"), QMessageBox::Ok, QMessageBox::NoButton); | 113 | QMessageBox::warning(this, tr("Error"), tr("The name 'Remotes' is\nnot allowed"), QMessageBox::Ok, QMessageBox::NoButton); |
114 | else { | 114 | else { |
115 | cfg->setGroup("Remotes"); | 115 | cfg->setGroup("Remotes"); |
116 | list=cfg->readListEntry("remoteList", ','); | 116 | list=cfg->readListEntry("remoteList", ','); |
117 | if(list.findIndex(newname) == -1) { | 117 | if(list.findIndex(newname) == -1) { |
118 | list+=newname; | 118 | list+=newname; |
119 | cfg->writeEntry("remoteList", list, ','); | 119 | cfg->writeEntry("remoteList", list, ','); |
120 | cfg->setGroup(newname); | 120 | cfg->setGroup(newname); |
121 | topGroupConf->updateRemotes(QStringList(newname) ); | 121 | topGroupConf->updateRemotes(QStringList(newname) ); |
122 | cfg->write(); | 122 | cfg->write(); |
123 | emit remotesChanged(); | 123 | emit remotesChanged(); |
124 | remoteSelected(newname); | 124 | remoteSelected(newname); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | QMessageBox::warning(this, tr("Already exists"), tr("A layout named %1\nalready exists").arg(newname), QMessageBox::Ok, QMessageBox::NoButton); | 127 | QMessageBox::warning(this, tr("Already exists"), tr("A layout named %1\nalready exists").arg(newname), QMessageBox::Ok, QMessageBox::NoButton); |
128 | // Re-select existing layout | 128 | // Re-select existing layout |
129 | remoteSelected(newname); | 129 | remoteSelected(newname); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | void ConfigTab::remoteSelected(const QString &string) | 134 | void ConfigTab::remoteSelected(const QString &string) |
135 | { | 135 | { |
136 | cfg->setGroup(string); | 136 | cfg->setGroup(string); |
137 | const QObject *obj; | 137 | const QObject *obj; |
138 | 138 | ||
139 | const QObjectList *objList = topGroupConf->children(); | 139 | const QObjectList *objList = topGroupConf->children(); |
140 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 140 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
141 | { | 141 | { |
142 | if(obj->inherits("QPushButton")) | 142 | if(obj->inherits("QPushButton")) |
143 | { | 143 | { |
144 | if(cfg->hasKey((QString)obj->name()+"Label")) | 144 | if(cfg->hasKey((QString)obj->name()+"Label")) |
145 | { | 145 | { |
146 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 146 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
147 | } | 147 | } |
148 | else | 148 | else |
149 | { | 149 | { |
150 | cfg->setGroup("Default"); | 150 | cfg->setGroup("Default"); |
151 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 151 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
152 | cfg->setGroup(string); | 152 | cfg->setGroup(string); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | objList = dvdGroupConf->children(); | 157 | objList = dvdGroupConf->children(); |
158 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 158 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
159 | { | 159 | { |
160 | if(obj->inherits("QPushButton")) | 160 | if(obj->inherits("QPushButton")) |
161 | { | 161 | { |
162 | if(cfg->hasKey((QString)obj->name()+"Label")) | 162 | if(cfg->hasKey((QString)obj->name()+"Label")) |
163 | { | 163 | { |
164 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 164 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
165 | } | 165 | } |
166 | else | 166 | else |
167 | { | 167 | { |
168 | cfg->setGroup("Default"); | 168 | cfg->setGroup("Default"); |
169 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 169 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
170 | cfg->setGroup(string); | 170 | cfg->setGroup(string); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | objList = vcrGroupConf->children(); | 175 | objList = vcrGroupConf->children(); |
176 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 176 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
177 | { | 177 | { |
178 | if(obj->inherits("QPushButton")) | 178 | if(obj->inherits("QPushButton")) |
179 | { | 179 | { |
180 | if(cfg->hasKey((QString)obj->name()+"Label")) | 180 | if(cfg->hasKey((QString)obj->name()+"Label")) |
181 | { | 181 | { |
182 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 182 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
183 | } | 183 | } |
184 | else | 184 | else |
185 | { | 185 | { |
186 | cfg->setGroup("Default"); | 186 | cfg->setGroup("Default"); |
187 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 187 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
188 | cfg->setGroup(string); | 188 | cfg->setGroup(string); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | objList = channelGroupConf->children(); | 193 | objList = channelGroupConf->children(); |
194 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) | 194 | for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) |
195 | { | 195 | { |
196 | if(obj->inherits("QPushButton")) | 196 | if(obj->inherits("QPushButton")) |
197 | { | 197 | { |
198 | if(cfg->hasKey((QString)obj->name()+"Label")) | 198 | if(cfg->hasKey((QString)obj->name()+"Label")) |
199 | { | 199 | { |
200 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 200 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
201 | } | 201 | } |
202 | else | 202 | else |
203 | { | 203 | { |
204 | cfg->setGroup("Default"); | 204 | cfg->setGroup("Default"); |
205 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); | 205 | ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); |
206 | cfg->setGroup(string); | 206 | cfg->setGroup(string); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | void ConfigTab::buttonPressed() | 212 | void ConfigTab::buttonPressed() |
213 | { | 213 | { |
214 | QString curr_remote = topGroupConf->getRemotesText(); | ||
215 | if(curr_remote != "") | ||
216 | cfg->setGroup(curr_remote); | ||
217 | else { | ||
218 | QMessageBox::warning(this, tr("Error"), tr("Please select or create\na remote layout"), QMessageBox::Ok, QMessageBox::NoButton); | ||
219 | return; | ||
220 | } | ||
221 | |||
214 | const QObject *button = sender(); | 222 | const QObject *button = sender(); |
215 | QString string = button->name(); | 223 | QString string = button->name(); |
216 | 224 | ||
217 | QString action = cfg->readEntry(string); | 225 | QString action = cfg->readEntry(string); |
218 | 226 | ||
219 | ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), action, this, "BD", true, 0); | 227 | ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), action, this, "BD", true, 0); |
220 | if( bd->exec() == 1) | 228 | if( bd->exec() == 1) |
221 | { | 229 | { |
222 | cfg->writeEntry(string, bd->getAction().latin1()); | 230 | cfg->writeEntry(string, bd->getAction().latin1()); |
223 | cfg->writeEntry(string+"Label", bd->getLabel().latin1()); | 231 | cfg->writeEntry(string+"Label", bd->getLabel().latin1()); |
224 | cfg->write(); | 232 | cfg->write(); |
225 | ((QPushButton *)button)->setText(bd->getLabel()); | 233 | ((QPushButton *)button)->setText(bd->getLabel()); |
226 | } | 234 | } |
227 | 235 | ||
228 | delete bd; | 236 | delete bd; |
229 | } | 237 | } |