Changeset View
Changeset View
Standalone View
Standalone View
kcms/icons/main.cpp
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 115 | { | |||
---|---|---|---|---|---|
116 | return m_model; | 116 | return m_model; | ||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | QStringList IconModule::iconGroups() const | 119 | QStringList IconModule::iconGroups() const | ||
120 | { | 120 | { | ||
121 | return m_iconGroups; | 121 | return m_iconGroups; | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | bool IconModule::downloadingFile() const | ||||
125 | { | ||||
126 | return m_tempCopyJob; | ||||
127 | } | ||||
128 | | ||||
124 | int IconModule::iconSize(int group) const | 129 | int IconModule::iconSize(int group) const | ||
125 | { | 130 | { | ||
126 | return m_iconSizes[group]; | 131 | return m_iconSizes[group]; | ||
127 | } | 132 | } | ||
128 | 133 | | |||
129 | void IconModule::setIconSize(int group, int size) | 134 | void IconModule::setIconSize(int group, int size) | ||
130 | { | 135 | { | ||
131 | if (iconSize(group) == size) { | 136 | if (iconSize(group) == size) { | ||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Line(s) | |||||
301 | 306 | | |||
302 | void IconModule::installThemeFromFile(const QUrl &url) | 307 | void IconModule::installThemeFromFile(const QUrl &url) | ||
303 | { | 308 | { | ||
304 | if (url.isLocalFile()) { | 309 | if (url.isLocalFile()) { | ||
305 | installThemeFile(url.toLocalFile()); | 310 | installThemeFile(url.toLocalFile()); | ||
306 | return; | 311 | return; | ||
307 | } | 312 | } | ||
308 | 313 | | |||
314 | if (m_tempCopyJob) { | ||||
315 | return; | ||||
316 | } | ||||
317 | | ||||
309 | m_tempInstallFile.reset(new QTemporaryFile()); | 318 | m_tempInstallFile.reset(new QTemporaryFile()); | ||
310 | if (!m_tempInstallFile->open()) { | 319 | if (!m_tempInstallFile->open()) { | ||
311 | emit showErrorMessage(i18n("Unable to create a temporary file.")); | 320 | emit showErrorMessage(i18n("Unable to create a temporary file.")); | ||
312 | m_tempInstallFile.reset(); | 321 | m_tempInstallFile.reset(); | ||
313 | return; | 322 | return; | ||
314 | } | 323 | } | ||
315 | 324 | | |||
316 | KIO::FileCopyJob *job = KIO::file_copy(url,QUrl::fromLocalFile(m_tempInstallFile->fileName()), | 325 | m_tempCopyJob = KIO::file_copy(url,QUrl::fromLocalFile(m_tempInstallFile->fileName()), | ||
317 | -1, KIO::Overwrite); | 326 | -1, KIO::Overwrite); | ||
318 | job->uiDelegate()->setAutoErrorHandlingEnabled(true); | 327 | m_tempCopyJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | ||
328 | emit downloadingFileChanged(); | ||||
319 | 329 | | |||
320 | connect(job, &KIO::FileCopyJob::result, this, [this, url](KJob *job) { | 330 | connect(m_tempCopyJob, &KIO::FileCopyJob::result, this, [this, url](KJob *job) { | ||
321 | if (job->error() != KJob::NoError) { | 331 | if (job->error() != KJob::NoError) { | ||
322 | emit showErrorMessage(i18n("Unable to download the icon theme archive: %1", job->errorText())); | 332 | emit showErrorMessage(i18n("Unable to download the icon theme archive: %1", job->errorText())); | ||
323 | return; | 333 | return; | ||
324 | } | 334 | } | ||
325 | 335 | | |||
326 | installThemeFile(m_tempInstallFile->fileName()); | 336 | installThemeFile(m_tempInstallFile->fileName()); | ||
327 | m_tempInstallFile.reset(); | 337 | m_tempInstallFile.reset(); | ||
328 | }); | 338 | }); | ||
339 | connect(m_tempCopyJob, &QObject::destroyed, this, &IconModule::downloadingFileChanged); | ||||
329 | } | 340 | } | ||
330 | 341 | | |||
331 | void IconModule::installThemeFile(const QString &path) | 342 | void IconModule::installThemeFile(const QString &path) | ||
332 | { | 343 | { | ||
333 | const QStringList themesNames = findThemeDirs(path); | 344 | const QStringList themesNames = findThemeDirs(path); | ||
334 | if (themesNames.isEmpty()) { | 345 | if (themesNames.isEmpty()) { | ||
335 | emit showErrorMessage(i18n("The file is not a valid icon theme archive.")); | 346 | emit showErrorMessage(i18n("The file is not a valid icon theme archive.")); | ||
336 | return; | 347 | return; | ||
▲ Show 20 Lines • Show All 255 Lines • Show Last 20 Lines |