summaryrefslogtreecommitdiff
authorpaule <paule>2007-01-31 09:12:36 (UTC)
committer paule <paule>2007-01-31 09:12:36 (UTC)
commite9c5c237e27d908c890779215b19c22a3706b614 (patch) (side-by-side diff)
tree246a2447df7b7a1e4236d8dd8bd589041734a6a9
parent3a2db1ba1395a6d33de421ed5f3b04df53ced5bc (diff)
downloadopie-e9c5c237e27d908c890779215b19c22a3706b614.zip
opie-e9c5c237e27d908c890779215b19c22a3706b614.tar.gz
opie-e9c5c237e27d908c890779215b19c22a3706b614.tar.bz2
Don't allow configuring buttons with no remote layout selected
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/remote/configtab.cpp8
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)
QVBoxLayout *layout = new QVBoxLayout(this);
topGroupConf = new TopGroupConf(this, "topGroupConf");
layout->addWidget(topGroupConf, 1);
layout->addSpacing(1);
dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf");
layout->addWidget(dvdGroupConf, 1);
layout->addSpacing(1);
vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf");
layout->addWidget(vcrGroupConf, 1);
layout->addSpacing(1);
channelGroupConf = new ChannelGroupConf(this, "channelGroupConf");
layout->addWidget(channelGroupConf, 1);
}
void ConfigTab::setConfig(Config *newCfg)
{
cfg = newCfg;
cfg->setGroup("Remotes");
topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') );
cfg->setGroup("Default");
const QObject *obj;
const QObjectList *objList = topGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(!cfg->hasKey((QString)obj->name()+"Label"))
{
cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
}
}
}
objList = dvdGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(!cfg->hasKey((QString)obj->name()+"Label"))
{
cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
}
}
}
objList = vcrGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(!cfg->hasKey((QString)obj->name()+"Label"))
{
cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
}
}
}
objList = channelGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(!cfg->hasKey((QString)obj->name()+"Label"))
{
cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
}
}
}
cfg->write();
cfg->setGroup("Remotes");
QString curr_remote = topGroupConf->getRemotesText();
if(curr_remote != "")
remoteSelected(curr_remote);
}
void ConfigTab::newPressed()
{
QStringList list;
QString newname = topGroupConf->getRemotesText();
if(newname.stripWhiteSpace()=="")
QMessageBox::warning(this, tr("Error"), tr("Please enter a name\nfirst"), QMessageBox::Ok, QMessageBox::NoButton);
else if(newname=="Remotes")
QMessageBox::warning(this, tr("Error"), tr("The name 'Remotes' is\nnot allowed"), QMessageBox::Ok, QMessageBox::NoButton);
else {
cfg->setGroup("Remotes");
list=cfg->readListEntry("remoteList", ',');
if(list.findIndex(newname) == -1) {
list+=newname;
cfg->writeEntry("remoteList", list, ',');
cfg->setGroup(newname);
topGroupConf->updateRemotes(QStringList(newname) );
cfg->write();
emit remotesChanged();
remoteSelected(newname);
}
else {
QMessageBox::warning(this, tr("Already exists"), tr("A layout named %1\nalready exists").arg(newname), QMessageBox::Ok, QMessageBox::NoButton);
// Re-select existing layout
remoteSelected(newname);
}
}
}
void ConfigTab::remoteSelected(const QString &string)
{
cfg->setGroup(string);
const QObject *obj;
const QObjectList *objList = topGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(cfg->hasKey((QString)obj->name()+"Label"))
{
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
}
else
{
cfg->setGroup("Default");
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
cfg->setGroup(string);
}
}
}
objList = dvdGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(cfg->hasKey((QString)obj->name()+"Label"))
{
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
}
else
{
cfg->setGroup("Default");
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
cfg->setGroup(string);
}
}
}
objList = vcrGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(cfg->hasKey((QString)obj->name()+"Label"))
{
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
}
else
{
cfg->setGroup("Default");
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
cfg->setGroup(string);
}
}
}
objList = channelGroupConf->children();
for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
{
if(obj->inherits("QPushButton"))
{
if(cfg->hasKey((QString)obj->name()+"Label"))
{
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
}
else
{
cfg->setGroup("Default");
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
cfg->setGroup(string);
}
}
}
}
void ConfigTab::buttonPressed()
{
+ QString curr_remote = topGroupConf->getRemotesText();
+ if(curr_remote != "")
+ cfg->setGroup(curr_remote);
+ else {
+ QMessageBox::warning(this, tr("Error"), tr("Please select or create\na remote layout"), QMessageBox::Ok, QMessageBox::NoButton);
+ return;
+ }
+
const QObject *button = sender();
QString string = button->name();
QString action = cfg->readEntry(string);
ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), action, this, "BD", true, 0);
if( bd->exec() == 1)
{
cfg->writeEntry(string, bd->getAction().latin1());
cfg->writeEntry(string+"Label", bd->getLabel().latin1());
cfg->write();
((QPushButton *)button)->setText(bd->getLabel());
}
delete bd;
}