summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/remote/remotetab.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/noncore/tools/remote/remotetab.cpp b/noncore/tools/remote/remotetab.cpp
index c89d8c2..065feac 100644
--- a/noncore/tools/remote/remotetab.cpp
+++ b/noncore/tools/remote/remotetab.cpp
@@ -1,172 +1,176 @@
1/* 1/*
2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. 2Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
3Copyright (C) 2002 Thomas Stephens 3Copyright (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 <qmessagebox.h> 17#include <qmessagebox.h>
18 18
19#include "remotetab.h" 19#include "remotetab.h"
20#include "lirchandler.h" 20#include "lirchandler.h"
21 21
22RemoteTab::RemoteTab(QWidget *parent, const char *name):QWidget(parent,name) 22RemoteTab::RemoteTab(QWidget *parent, const char *name):QWidget(parent,name)
23{ 23{
24 QVBoxLayout *layout = new QVBoxLayout(this); 24 QVBoxLayout *layout = new QVBoxLayout(this);
25 25
26 topGroup = new TopGroup(this); 26 topGroup = new TopGroup(this);
27 //topGroup->setMaximumHeight(22); 27 //topGroup->setMaximumHeight(22);
28 layout->addWidget(topGroup, 0, 0); 28 layout->addWidget(topGroup, 0, 0);
29 printf("%d %d", topGroup->width(), topGroup->height()); 29 printf("%d %d", topGroup->width(), topGroup->height());
30 30
31 layout->addSpacing(1); 31 layout->addSpacing(1);
32 32
33 dvdGroup = new DVDGroup(this); 33 dvdGroup = new DVDGroup(this);
34 //dvdGroup->setMaximumHeight(68); 34 //dvdGroup->setMaximumHeight(68);
35 layout->addWidget(dvdGroup, 0, 0); 35 layout->addWidget(dvdGroup, 0, 0);
36 36
37 layout->addSpacing(1); 37 layout->addSpacing(1);
38 38
39 vcrGroup = new VCRGroup(this); 39 vcrGroup = new VCRGroup(this);
40 layout->addWidget(vcrGroup, 0, 0); 40 layout->addWidget(vcrGroup, 0, 0);
41 //vcrGroup->setMaximumHeight(45); 41 //vcrGroup->setMaximumHeight(45);
42 42
43 layout->addSpacing(1); 43 layout->addSpacing(1);
44 44
45 channelGroup = new ChannelGroup(this); 45 channelGroup = new ChannelGroup(this);
46 //channelGroup->setMaximumHeight(91); 46 //channelGroup->setMaximumHeight(91);
47 layout->addWidget(channelGroup, 0, 0); 47 layout->addWidget(channelGroup, 0, 0);
48 48
49 this->setMaximumWidth(240); 49 this->setMaximumWidth(240);
50} 50}
51 51
52int RemoteTab::sendIR() 52int RemoteTab::sendIR()
53{ 53{
54 LircHandler lh;
55
56 if(!lh.checkLircdConfValid(false))
57 return 0;
58
54 QString curr_remote = topGroup->getRemotesText(); 59 QString curr_remote = topGroup->getRemotesText();
55 if(curr_remote != "") 60 if(curr_remote != "")
56 cfg->setGroup(curr_remote); 61 cfg->setGroup(curr_remote);
57 else { 62 else {
58 QMessageBox::warning(this, tr("Error"), tr("Please select or create\na remote layout"), QMessageBox::Ok, QMessageBox::NoButton); 63 QMessageBox::warning(this, tr("Error"), tr("Please select or create\na remote layout"), QMessageBox::Ok, QMessageBox::NoButton);
59 return 0; 64 return 0;
60 } 65 }
61 66
62 const QObject *button = sender(); 67 const QObject *button = sender();
63 QString string = cfg->readEntry(button->name()); 68 QString string = cfg->readEntry(button->name());
64 if(string != "") { 69 if(string != "") {
65 string+='\n'; 70 string+='\n';
66 LircHandler lh;
67 return lh.sendIR(string.latin1()); 71 return lh.sendIR(string.latin1());
68 } 72 }
69 else { 73 else {
70 QMessageBox::warning(this, tr("Error"), tr("This button has not\nbeen configured"), QMessageBox::Ok, QMessageBox::NoButton); 74 QMessageBox::warning(this, tr("Error"), tr("This button has not\nbeen configured"), QMessageBox::Ok, QMessageBox::NoButton);
71 return 0; 75 return 0;
72 } 76 }
73} 77}
74 78
75void RemoteTab::setConfig(Config *newCfg) 79void RemoteTab::setConfig(Config *newCfg)
76{ 80{
77 cfg = newCfg; 81 cfg = newCfg;
78 cfg->setGroup("Remotes"); 82 cfg->setGroup("Remotes");
79 topGroup->updateRemotes(cfg); 83 topGroup->updateRemotes(cfg);
80 84
81 QString curr_remote = topGroup->getRemotesText(); 85 QString curr_remote = topGroup->getRemotesText();
82 if(curr_remote != "") 86 if(curr_remote != "")
83 remoteSelected(curr_remote); 87 remoteSelected(curr_remote);
84} 88}
85 89
86void RemoteTab::remoteSelected(const QString &string) 90void RemoteTab::remoteSelected(const QString &string)
87{ 91{
88 printf("1%s\n", string.latin1() ); 92 printf("1%s\n", string.latin1() );
89 cfg->setGroup(string); 93 cfg->setGroup(string);
90 const QObject *obj; 94 const QObject *obj;
91 95
92 const QObjectList *objList = topGroup->children(); 96 const QObjectList *objList = topGroup->children();
93 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 97 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
94 { 98 {
95 if(obj->inherits("QPushButton")) 99 if(obj->inherits("QPushButton"))
96 { 100 {
97 if(cfg->hasKey((QString)obj->name()+"Label")) 101 if(cfg->hasKey((QString)obj->name()+"Label"))
98 { 102 {
99 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 103 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
100 } 104 }
101 else 105 else
102 { 106 {
103 cfg->setGroup("Default"); 107 cfg->setGroup("Default");
104 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 108 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
105 cfg->setGroup(string); 109 cfg->setGroup(string);
106 } 110 }
107 } 111 }
108 } 112 }
109 113
110 objList = dvdGroup->children(); 114 objList = dvdGroup->children();
111 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 115 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
112 { 116 {
113 if(obj->inherits("QPushButton")) 117 if(obj->inherits("QPushButton"))
114 { 118 {
115 if(cfg->hasKey((QString)obj->name()+"Label")) 119 if(cfg->hasKey((QString)obj->name()+"Label"))
116 { 120 {
117 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 121 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
118 } 122 }
119 else 123 else
120 { 124 {
121 cfg->setGroup("Default"); 125 cfg->setGroup("Default");
122 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 126 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
123 cfg->setGroup(string); 127 cfg->setGroup(string);
124 } 128 }
125 } 129 }
126 } 130 }
127 131
128 objList = vcrGroup->children(); 132 objList = vcrGroup->children();
129 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 133 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
130 { 134 {
131 if(obj->inherits("QPushButton")) 135 if(obj->inherits("QPushButton"))
132 { 136 {
133 if(cfg->hasKey((QString)obj->name()+"Label")) 137 if(cfg->hasKey((QString)obj->name()+"Label"))
134 { 138 {
135 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 139 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
136 } 140 }
137 else 141 else
138 { 142 {
139 cfg->setGroup("Default"); 143 cfg->setGroup("Default");
140 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 144 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
141 cfg->setGroup(string); 145 cfg->setGroup(string);
142 } 146 }
143 } 147 }
144 } 148 }
145 149
146 objList = channelGroup->children(); 150 objList = channelGroup->children();
147 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 151 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
148 { 152 {
149 if(obj->inherits("QPushButton")) 153 if(obj->inherits("QPushButton"))
150 { 154 {
151 if(cfg->hasKey((QString)obj->name()+"Label")) 155 if(cfg->hasKey((QString)obj->name()+"Label"))
152 { 156 {
153 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 157 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
154 } 158 }
155 else 159 else
156 { 160 {
157 cfg->setGroup("Default"); 161 cfg->setGroup("Default");
158 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 162 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
159 cfg->setGroup(string); 163 cfg->setGroup(string);
160 } 164 }
161 } 165 }
162 } 166 }
163} 167}
164 168
165void RemoteTab::updateRemotesList() 169void RemoteTab::updateRemotesList()
166{ 170{
167 topGroup->updateRemotes(cfg); 171 topGroup->updateRemotes(cfg);
168 172
169 QString curr_remote = topGroup->getRemotesText(); 173 QString curr_remote = topGroup->getRemotesText();
170 if(curr_remote != "") 174 if(curr_remote != "")
171 remoteSelected(curr_remote); 175 remoteSelected(curr_remote);
172} 176}