summaryrefslogtreecommitdiff
path: root/noncore
authorpaule <paule>2007-01-28 06:46:41 (UTC)
committer paule <paule>2007-01-28 06:46:41 (UTC)
commit832877eac027c4593c7bd6079edb38ccd76fac95 (patch) (side-by-side diff)
tree5c7536836b82981d6f4431d2199abbf762dd41e8 /noncore
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 (limited to 'noncore') (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
@@ -88,49 +88,65 @@ void ConfigTab::setConfig(Config *newCfg)
{
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::savePressed()
{
cfg->setGroup(remotes->currentText());
ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0);
if( bd->exec() == 1)
{
printf("%s\n", bd->getList().join(" ").latin1());
}
}
*/
void ConfigTab::newPressed()
{
QStringList list;
- cfg->setGroup("Remotes");
- list=cfg->readListEntry("remoteList", ',');
- list+=topGroupConf->getRemotesText();
- cfg->writeEntry("remoteList", list, ',');
- cfg->setGroup(topGroupConf->getRemotesText());
- topGroupConf->updateRemotes(QStringList(topGroupConf->getRemotesText()) );
- cfg->write();
- emit remotesChanged();
- remoteSelected(topGroupConf->getRemotesText());
+ QString newname = topGroupConf->getRemotesText();
+ if(newname=="Remotes")
+ QMessageBox::warning(this, tr("Error"), tr("The name 'Remotes' is not 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"))
{
@@ -197,22 +213,26 @@ void ConfigTab::remoteSelected(const QString &string)
cfg->setGroup("Default");
((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
cfg->setGroup(string);
}
}
}
}
void ConfigTab::buttonPressed()
{
const QObject *button = sender();
QString string = button->name();
-
- ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), this, "BD", true, 0);
+
+ 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->getList().join(" ").latin1());
+ cfg->writeEntry(string, bd->getAction().latin1());
cfg->writeEntry(string+"Label", bd->getLabel().latin1());
+ cfg->write();
+ ((QPushButton *)button)->setText(bd->getLabel());
}
- cfg->write();
- ((QPushButton *)button)->setText(bd->getLabel());
+
+ delete bd;
}