Changeset View
Changeset View
Standalone View
Standalone View
src/config/theme_config.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 46 | { | |||
---|---|---|---|---|---|
54 | 54 | | |||
55 | connect(iconThemeIndex, &QListWidget::currentRowChanged, this, &Theme_Config::updatePreview); | 55 | connect(iconThemeIndex, &QListWidget::currentRowChanged, this, &Theme_Config::updatePreview); | ||
56 | connect(iconThemeIndex, &QListWidget::itemSelectionChanged, this, &Theme_Config::updateButtons); | 56 | connect(iconThemeIndex, &QListWidget::itemSelectionChanged, this, &Theme_Config::updateButtons); | ||
57 | connect(iconThemeIndex, &QListWidget::itemSelectionChanged, this, &Theme_Config::modified); | 57 | connect(iconThemeIndex, &QListWidget::itemSelectionChanged, this, &Theme_Config::modified); | ||
58 | connect(installButton, &QPushButton::clicked, this, &Theme_Config::installTheme); | 58 | connect(installButton, &QPushButton::clicked, this, &Theme_Config::installTheme); | ||
59 | connect(removeButton, &QPushButton::clicked, this, &Theme_Config::removeTheme); | 59 | connect(removeButton, &QPushButton::clicked, this, &Theme_Config::removeTheme); | ||
60 | } | 60 | } | ||
61 | 61 | | |||
62 | Theme_Config::~Theme_Config() | 62 | Theme_Config::~Theme_Config() = default; | ||
63 | { | | |||
64 | } | | |||
65 | 63 | | |||
66 | void Theme_Config::loadSettings() | 64 | void Theme_Config::loadSettings() | ||
67 | { | 65 | { | ||
68 | // get list of theme dirs | 66 | // get list of theme dirs | ||
69 | QStringList paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "konversation/themes/", QStandardPaths::LocateDirectory); | 67 | QStringList paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "konversation/themes/", QStandardPaths::LocateDirectory); | ||
70 | m_dirs.clear(); | 68 | m_dirs.clear(); | ||
71 | 69 | | |||
72 | foreach(const QString& path, paths) | 70 | foreach(const QString& path, paths) | ||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 201 | { | |||
204 | int errorCode = fileCopyJob->error(); | 202 | int errorCode = fileCopyJob->error(); | ||
205 | QString errorString; | 203 | QString errorString; | ||
206 | 204 | | |||
207 | if (errorCode != 0) | 205 | if (errorCode != 0) | ||
208 | errorString = fileCopyJob->errorString(); | 206 | errorString = fileCopyJob->errorString(); | ||
209 | else | 207 | else | ||
210 | errorString = i18n("Unknown error (0)"); | 208 | errorString = i18n("Unknown error (0)"); | ||
211 | 209 | | |||
212 | KMessageBox::error(0L, | 210 | KMessageBox::error(nullptr, | ||
213 | errorString, | 211 | errorString, | ||
214 | i18n("Failed to Download Theme"), | 212 | i18n("Failed to Download Theme"), | ||
215 | KMessageBox::Notify | 213 | KMessageBox::Notify | ||
216 | ); | 214 | ); | ||
217 | return; | 215 | return; | ||
218 | 216 | | |||
219 | } | 217 | } | ||
220 | tmpThemeFile = tmpUrl.toLocalFile(); | 218 | tmpThemeFile = tmpUrl.toLocalFile(); | ||
Show All 9 Lines | |||||
230 | { | 228 | { | ||
231 | if(themeInstallDir.exists("index.desktop")) | 229 | if(themeInstallDir.exists("index.desktop")) | ||
232 | { | 230 | { | ||
233 | KIO::CopyJob* job = KIO::copy(QUrl(tmpThemeFile), QUrl(themesDir)); | 231 | KIO::CopyJob* job = KIO::copy(QUrl(tmpThemeFile), QUrl(themesDir)); | ||
234 | job->exec(); //FIXME error handling | 232 | job->exec(); //FIXME error handling | ||
235 | } | 233 | } | ||
236 | else | 234 | else | ||
237 | { | 235 | { | ||
238 | KMessageBox::error(0L, | 236 | KMessageBox::error(nullptr, | ||
239 | i18n("Theme archive is invalid."), | 237 | i18n("Theme archive is invalid."), | ||
240 | i18n("Cannot Install Theme"), | 238 | i18n("Cannot Install Theme"), | ||
241 | KMessageBox::Notify | 239 | KMessageBox::Notify | ||
242 | ); | 240 | ); | ||
243 | } | 241 | } | ||
244 | } | 242 | } | ||
245 | else // we got a file | 243 | else // we got a file | ||
246 | { | 244 | { | ||
Show All 13 Lines | |||||
260 | themeArchive->open(QIODevice::ReadOnly); | 258 | themeArchive->open(QIODevice::ReadOnly); | ||
261 | qApp->processEvents(); | 259 | qApp->processEvents(); | ||
262 | 260 | | |||
263 | const KArchiveDirectory* themeDir = themeArchive->directory(); | 261 | const KArchiveDirectory* themeDir = themeArchive->directory(); | ||
264 | QStringList allEntries = themeDir->entries(); | 262 | QStringList allEntries = themeDir->entries(); | ||
265 | 263 | | |||
266 | for(QStringList::ConstIterator it=allEntries.constBegin(); it != allEntries.constEnd(); ++it) | 264 | for(QStringList::ConstIterator it=allEntries.constBegin(); it != allEntries.constEnd(); ++it) | ||
267 | { | 265 | { | ||
268 | if(themeDir->entry(*it+"/index.desktop") == NULL) | 266 | if(themeDir->entry(*it+"/index.desktop") == nullptr) | ||
269 | { | 267 | { | ||
270 | KMessageBox::error(0L, | 268 | KMessageBox::error(nullptr, | ||
271 | i18n("Theme archive is invalid."), | 269 | i18n("Theme archive is invalid."), | ||
272 | i18n("Cannot Install Theme"), | 270 | i18n("Cannot Install Theme"), | ||
273 | KMessageBox::Notify | 271 | KMessageBox::Notify | ||
274 | ); | 272 | ); | ||
275 | break; | 273 | break; | ||
276 | } | 274 | } | ||
277 | else | 275 | else | ||
278 | themeDir->copyTo(themesDir); | 276 | themeDir->copyTo(themesDir); | ||
279 | 277 | | |||
280 | } | 278 | } | ||
281 | themeArchive->close(); | 279 | themeArchive->close(); | ||
282 | delete themeArchive; | 280 | delete themeArchive; | ||
283 | } | 281 | } | ||
284 | 282 | | |||
285 | loadSettings(); | 283 | loadSettings(); | ||
286 | } | 284 | } | ||
287 | 285 | | |||
288 | void Theme_Config::removeTheme() | 286 | void Theme_Config::removeTheme() | ||
289 | { | 287 | { | ||
290 | QString dir; | 288 | QString dir; | ||
291 | QString themeName = iconThemeIndex->currentItem() ? iconThemeIndex->currentItem()->text() : QString(); | 289 | QString themeName = iconThemeIndex->currentItem() ? iconThemeIndex->currentItem()->text() : QString(); | ||
292 | 290 | | |||
293 | dir = m_dirs[iconThemeIndex->currentRow()]; | 291 | dir = m_dirs[iconThemeIndex->currentRow()]; | ||
294 | 292 | | |||
295 | int remove = KMessageBox::warningContinueCancel(0L, | 293 | int remove = KMessageBox::warningContinueCancel(nullptr, | ||
296 | i18n("Do you want to remove %1?", themeName), | 294 | i18n("Do you want to remove %1?", themeName), | ||
297 | i18n("Remove Theme"), | 295 | i18n("Remove Theme"), | ||
298 | KStandardGuiItem::del(),KStandardGuiItem::cancel(), | 296 | KStandardGuiItem::del(),KStandardGuiItem::cancel(), | ||
299 | "warningRemoveTheme" | 297 | "warningRemoveTheme" | ||
300 | ); | 298 | ); | ||
301 | 299 | | |||
302 | if(remove == KMessageBox::Continue) | 300 | if(remove == KMessageBox::Continue) | ||
303 | { | 301 | { | ||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |