Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colorscm.cpp
Show First 20 Lines • Show All 155 Lines • ▼ Show 20 Line(s) | 146 | { | |||
---|---|---|---|---|---|
156 | { | 156 | { | ||
157 | // load it | 157 | // load it | ||
158 | const QString name = currentItem->text(); | 158 | const QString name = currentItem->text(); | ||
159 | m_currentColorScheme = name; | 159 | m_currentColorScheme = name; | ||
160 | const QString fileBaseName = currentItem->data(Qt::UserRole).toString(); | 160 | const QString fileBaseName = currentItem->data(Qt::UserRole).toString(); | ||
161 | if (name == i18nc("Default color scheme", "Default")) | 161 | if (name == i18nc("Default color scheme", "Default")) | ||
162 | { | 162 | { | ||
163 | schemeRemoveButton->setEnabled(false); | 163 | schemeRemoveButton->setEnabled(false); | ||
164 | schemeEditButton->setEnabled(false); | 164 | schemeEditButton->setEnabled(false); | ||
davidedmundson: This patch doesn't actually address the actual issue that I know you were trying to fix - this… | |||||
165 | 165 | | |||
166 | KSharedConfigPtr config = m_config; | 166 | KSharedConfigPtr config = m_config; | ||
167 | config->setReadDefaults(true); | 167 | config->setReadDefaults(true); | ||
168 | loadScheme(config); | 168 | loadScheme(config); | ||
169 | config->setReadDefaults(false); | 169 | config->setReadDefaults(false); | ||
170 | // load the default scheme | 170 | // load the default scheme | ||
171 | emit changed(true); | 171 | emit changed(true); | ||
172 | } | 172 | } | ||
173 | else | 173 | else | ||
174 | { | 174 | { | ||
175 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | 175 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||
176 | "color-schemes/" + fileBaseName + ".colors"); | 176 | "color-schemes/" + fileBaseName + ".colors"); | ||
177 | 177 | | |||
178 | const int permissions = QFile(path).permissions(); | 178 | const int permissions = QFile(path).permissions(); | ||
179 | const bool canWrite = (permissions & QFile::WriteUser); | 179 | const bool canWrite = (permissions & QFile::WriteUser); | ||
180 | qDebug() << "checking permissions of " << path; | 180 | qDebug() << "checking permissions of " << path; | ||
181 | schemeRemoveButton->setEnabled(canWrite); | 181 | schemeRemoveButton->setEnabled(canWrite); | ||
182 | | ||||
183 | if (canWrite && QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | ||||
184 | "color-schemes/" + fileBaseName + ".colors").length() > 1) { | ||||
185 | schemeRemoveButton->setText(i18n("Default Values")); | ||||
186 | } else { | ||||
187 | schemeRemoveButton->setText(i18n("Remove Scheme")); | ||||
188 | } | ||||
189 | | ||||
182 | schemeEditButton->setEnabled(true); | 190 | schemeEditButton->setEnabled(true); | ||
183 | 191 | | |||
184 | KSharedConfigPtr config = KSharedConfig::openConfig(path); | 192 | KSharedConfigPtr config = KSharedConfig::openConfig(path); | ||
185 | loadScheme(config); | 193 | loadScheme(config); | ||
186 | 194 | | |||
187 | emit changed(true); | 195 | emit changed(true); | ||
188 | } | 196 | } | ||
189 | } else { | 197 | } else { | ||
190 | schemeEditButton->setEnabled(false); | 198 | schemeEditButton->setEnabled(false); | ||
191 | schemeRemoveButton->setEnabled(false); | 199 | schemeRemoveButton->setEnabled(false); | ||
192 | } | 200 | } | ||
193 | } | 201 | } | ||
194 | 202 | | |||
195 | void KColorCm::on_schemeRemoveButton_clicked() | 203 | void KColorCm::on_schemeRemoveButton_clicked() | ||
196 | { | 204 | { | ||
197 | if (schemeList->currentItem() != NULL) | 205 | if (schemeList->currentItem() != NULL) | ||
198 | { | 206 | { | ||
199 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | 207 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||
200 | "color-schemes/" + schemeList->currentItem()->data(Qt::UserRole).toString() + | 208 | "color-schemes/" + schemeList->currentItem()->data(Qt::UserRole).toString() + | ||
201 | ".colors"); | 209 | ".colors"); | ||
202 | KIO::DeleteJob *job = KIO::del(QUrl::fromLocalFile(path)); | 210 | KIO::DeleteJob *job = KIO::del(QUrl::fromLocalFile(path)); | ||
203 | job->uiDelegate()->setParent(this); | 211 | job->uiDelegate()->setParent(this); | ||
204 | if (job->exec()) | 212 | if (job->exec()) | ||
205 | { | 213 | { | ||
214 | //no more fallback files for this scheme? | ||||
215 | if (QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||||
216 | "color-schemes/" + schemeList->currentItem()->data(Qt::UserRole).toString() + ".colors").isEmpty()) { | ||||
206 | delete schemeList->takeItem(schemeList->currentRow()); | 217 | delete schemeList->takeItem(schemeList->currentRow()); | ||
218 | } else { | ||||
219 | schemeRemoveButton->setText(i18n("Remove Scheme")); | ||||
and you need to set it to disabled otherwise if you edit a theme then reset it, you'll now have an option to remove a system theme. davidedmundson: and you need to set it to disabled
otherwise if you edit a theme then reset it, you'll now… | |||||
220 | } | ||||
207 | } | 221 | } | ||
208 | else | 222 | else | ||
209 | { | 223 | { | ||
210 | // deletion failed, so show an error message | 224 | // deletion failed, so show an error message | ||
211 | KMessageBox::error(this, i18n("You do not have permission to delete that scheme"), i18n("Error")); | 225 | KMessageBox::error(this, i18n("You do not have permission to delete that scheme"), i18n("Error")); | ||
212 | } | 226 | } | ||
213 | } | 227 | } | ||
214 | } | 228 | } | ||
▲ Show 20 Lines • Show All 328 Lines • Show Last 20 Lines |
This patch doesn't actually address the actual issue that I know you were trying to fix - this line.