author | paule <paule> | 2007-01-28 06:46:41 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-28 06:46:41 (UTC) |
commit | 832877eac027c4593c7bd6079edb38ccd76fac95 (patch) (unidiff) | |
tree | 5c7536836b82981d6f4431d2199abbf762dd41e8 | |
parent | a70f2692462053c1b76f990919f698a2eaa56fb5 (diff) | |
download | opie-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
-rw-r--r-- | noncore/tools/remote/configtab.cpp | 48 |
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 | |||
@@ -97,6 +97,10 @@ void ConfigTab::setConfig(Config *newCfg) | |||
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 | /* |
102 | void ConfigTab::savePressed() | 106 | void ConfigTab::savePressed() |
@@ -113,15 +117,27 @@ void ConfigTab::savePressed() | |||
113 | void ConfigTab::newPressed() | 117 | void 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 | ||
127 | void ConfigTab::remoteSelected(const QString &string) | 143 | void ConfigTab::remoteSelected(const QString &string) |
@@ -206,13 +222,17 @@ void 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 | } |