Changeset View
Changeset View
Standalone View
Standalone View
kcms/icons/iconthemes.cpp
Show All 14 Lines | |||||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "iconthemes.h" | 20 | #include "iconthemes.h" | ||
21 | 21 | | |||
22 | #include <config-runtime.h> | 22 | #include <config-runtime.h> | ||
23 | #include "config.h" | ||||
23 | 24 | | |||
24 | #include <stdlib.h> | 25 | #include <stdlib.h> | ||
25 | #include <unistd.h> | 26 | #include <unistd.h> | ||
26 | 27 | | |||
27 | #include <QFileInfo> | 28 | #include <QFileInfo> | ||
28 | #include <QLabel> | 29 | #include <QLabel> | ||
29 | #include <QPixmap> | 30 | #include <QPixmap> | ||
30 | #include <QVBoxLayout> | 31 | #include <QVBoxLayout> | ||
31 | #include <QFrame> | 32 | #include <QFrame> | ||
32 | #include <QHBoxLayout> | 33 | #include <QHBoxLayout> | ||
33 | #include <QTreeWidget> | 34 | #include <QTreeWidget> | ||
34 | #include <QPainter> | 35 | #include <QPainter> | ||
35 | #include <QSvgRenderer> | 36 | #include <QSvgRenderer> | ||
36 | #include <QLoggingCategory> | 37 | #include <QLoggingCategory> | ||
37 | #include <QPushButton> | 38 | #include <QPushButton> | ||
38 | #include <QProgressDialog> | 39 | #include <QProgressDialog> | ||
39 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> | ||
40 | #include <QStandardPaths> | 41 | #include <QStandardPaths> | ||
41 | #include <QUrl> | 42 | #include <QUrl> | ||
42 | #include <qtemporaryfile.h> | 43 | #include <qtemporaryfile.h> | ||
43 | #include <QApplication> | 44 | #include <QApplication> | ||
45 | #include <QProcess> | ||||
44 | 46 | | |||
45 | #include <KBuildSycocaProgressDialog> | 47 | #include <KBuildSycocaProgressDialog> | ||
46 | #include <KLocalizedString> | 48 | #include <KLocalizedString> | ||
47 | #include <KSharedDataCache> | 49 | #include <KSharedDataCache> | ||
48 | #include <KIconTheme> | 50 | #include <KIconTheme> | ||
49 | #include <KConfig> | 51 | #include <KConfig> | ||
50 | #include <KConfigGroup> | 52 | #include <KConfigGroup> | ||
51 | #include <KSharedConfig> | 53 | #include <KSharedConfig> | ||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Line(s) | 291 | { | |||
314 | return foundThemes; | 316 | return foundThemes; | ||
315 | } | 317 | } | ||
316 | 318 | | |||
317 | void IconThemesConfig::getNewTheme() | 319 | void IconThemesConfig::getNewTheme() | ||
318 | { | 320 | { | ||
319 | KNS3::DownloadDialog dialog(QStringLiteral("icons.knsrc"), this); | 321 | KNS3::DownloadDialog dialog(QStringLiteral("icons.knsrc"), this); | ||
320 | dialog.exec(); | 322 | dialog.exec(); | ||
321 | if (!dialog.changedEntries().isEmpty()) { | 323 | if (!dialog.changedEntries().isEmpty()) { | ||
322 | for(int i = 0; i < dialog.changedEntries().size(); i ++) { | | |||
323 | if(dialog.changedEntries().at(i).status() == KNS3::Entry::Installed | | |||
324 | && !dialog.changedEntries().at(i).installedFiles().isEmpty()) { | | |||
325 | const QString themeTmpFile = dialog.changedEntries().at(i).installedFiles().at(0); | | |||
326 | const QString name = dialog.changedEntries().at(i).installedFiles().at(0).section('/', -2, -2); | | |||
327 | qCDebug(KCM_ICONS)<<"IconThemesConfig::getNewTheme() themeTmpFile="<<themeTmpFile<<"name="<<name; | | |||
328 | QStringList themeNames = findThemeDirs(themeTmpFile); | | |||
329 | if (themeNames.isEmpty()) { | | |||
330 | //dialog.changedEntries().at(i)->setStatus(KNS3::Entry::Invalid); | | |||
331 | } | | |||
332 | else if (! installThemes(themeNames, themeTmpFile)) { | | |||
333 | //dialog.changedEntries().at(i)->setStatus(KNS3::Entry::Invalid); | | |||
334 | } | | |||
335 | } | | |||
336 | } | | |||
337 | | ||||
338 | // reload the display icontheme items | 324 | // reload the display icontheme items | ||
339 | KIconLoader::global()->newIconLoader(); | 325 | KIconLoader::global()->newIconLoader(); | ||
340 | loadThemes(); | 326 | loadThemes(); | ||
341 | QTreeWidgetItem *item=iconThemeItem(KIconTheme::current()); | 327 | QTreeWidgetItem *item=iconThemeItem(KIconTheme::current()); | ||
342 | if (item) | 328 | if (item) | ||
343 | m_iconThemes->setCurrentItem(item); | 329 | m_iconThemes->setCurrentItem(item); | ||
344 | updateRemoveButton(); | 330 | updateRemoveButton(); | ||
345 | load(); | 331 | load(); | ||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Line(s) | |||||
473 | void IconThemesConfig::save() | 459 | void IconThemesConfig::save() | ||
474 | { | 460 | { | ||
475 | if (!m_bChanged) | 461 | if (!m_bChanged) | ||
476 | return; | 462 | return; | ||
477 | QTreeWidgetItem *selected = m_iconThemes->currentItem(); | 463 | QTreeWidgetItem *selected = m_iconThemes->currentItem(); | ||
478 | if (!selected) | 464 | if (!selected) | ||
479 | return; | 465 | return; | ||
480 | 466 | | |||
481 | KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig), "Icons"); | 467 | QProcess::startDetached(CMAKE_INSTALL_FULL_LIBEXECDIR "/plasma-changeicons", {selected->data(0, ThemeNameRole).toString()}); | ||
482 | config.writeEntry("Theme", selected->data(0, ThemeNameRole).toString()); | | |||
483 | config.sync(); | | |||
484 | 468 | | |||
485 | KIconTheme::reconfigure(); | | |||
486 | emit changed(false); | 469 | emit changed(false); | ||
487 | 470 | | |||
488 | KSharedDataCache::deleteCache(QStringLiteral("icon-cache")); | | |||
489 | | ||||
490 | for (int i=0; i<KIconLoader::LastGroup; i++) | | |||
491 | { | | |||
492 | KIconLoader::emitChange(KIconLoader::Group(i)); | | |||
493 | } | | |||
494 | | ||||
495 | KBuildSycocaProgressDialog::rebuildKSycoca(this); | | |||
496 | | ||||
497 | m_bChanged = false; | 471 | m_bChanged = false; | ||
498 | m_removeButton->setEnabled(false); | 472 | m_removeButton->setEnabled(false); | ||
499 | } | 473 | } | ||
500 | 474 | | |||
501 | void IconThemesConfig::defaults() | 475 | void IconThemesConfig::defaults() | ||
502 | { | 476 | { | ||
503 | if (m_iconThemes->currentItem()==m_defaultTheme) return; | 477 | if (m_iconThemes->currentItem()==m_defaultTheme) return; | ||
504 | 478 | | |||
505 | if (m_defaultTheme) | 479 | if (m_defaultTheme) | ||
506 | m_iconThemes->setCurrentItem(m_defaultTheme); | 480 | m_iconThemes->setCurrentItem(m_defaultTheme); | ||
507 | updateRemoveButton(); | 481 | updateRemoveButton(); | ||
508 | 482 | | |||
509 | emit changed(true); | 483 | emit changed(true); | ||
510 | m_bChanged = true; | 484 | m_bChanged = true; | ||
511 | } | 485 | } | ||
512 | 486 | |