diff --git a/src/cursorthemesmodel.cpp b/src/cursorthemesmodel.cpp index 926a666..c1ba1f2 100644 --- a/src/cursorthemesmodel.cpp +++ b/src/cursorthemesmodel.cpp @@ -1,87 +1,89 @@ /* KDE GTK Configuration Module * * Copyright 2016 Jason A. Donenfeld * Copyright 2016 Andrey Bondrov * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "cursorthemesmodel.h" #include #include #include #include #include #include #include CursorThemesModel::CursorThemesModel(QObject* parent) : IconThemesModel(parent) { reload(); } QList CursorThemesModel::installedThemesPaths() { QList availableIcons; QStringList dirs(QString(XcursorLibraryPath()).split(':', QString::SkipEmptyParts)); std::transform(dirs.begin(), dirs.end(), dirs.begin(), KShell::tildeExpand); dirs.removeDuplicates(); foreach(const QString& dir, dirs) { QDir userIconsDir(dir); QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs|QDir::NoSymLinks); while(it.hasNext()) { QString currentPath = it.next(); QDir dir(currentPath); if(dir.exists() && dir.exists("cursors")) availableIcons << dir; } } return availableIcons; } void CursorThemesModel::fillItem(const QDir& dir, QStandardItem* item) { KIconTheme theme(dir.dirName()); if(!theme.name().isEmpty()) item->setText(theme.name()); else item->setText(dir.dirName()); item->setToolTip(theme.description()); item->setData(theme.inherits(), CursorThemesModel::InheritsRole); } void CursorThemesModel::reload() { clear(); QList paths = installedThemesPaths(); Q_FOREACH(const QDir& dir, paths) { QStandardItem* themeit = new QStandardItem(dir.dirName()); themeit->setData(dir.path(), PathRole); themeit->setData(dir.dirName(), DirNameRole); fillItem(dir, themeit); appendRow(themeit); } + + sort(0); } diff --git a/src/cursorthemesmodel.h b/src/cursorthemesmodel.h index 4acfa4b..f802070 100644 --- a/src/cursorthemesmodel.h +++ b/src/cursorthemesmodel.h @@ -1,41 +1,41 @@ /* KDE GTK Configuration Module * * Copyright 2016 Andrey Bondrov * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef CURSORTHEMESMODEL_H #define CURSORTHEMESMODEL_H #include "iconthemesmodel.h" class QDir; class CursorThemesModel : public IconThemesModel { public: explicit CursorThemesModel(QObject* parent = 0); - void reload(); + void reload() override; private: static void fillItem(const QDir& dir, QStandardItem* item); QList installedThemesPaths(); }; #endif // CURSORTHEMESMODEL_H diff --git a/src/dialog_installer.cpp b/src/dialog_installer.cpp index 96ef10e..aac0445 100644 --- a/src/dialog_installer.cpp +++ b/src/dialog_installer.cpp @@ -1,211 +1,211 @@ /* * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "dialog_installer.h" #include "ui_dialog_installer.h" #include #include "installer.h" #include "thread.h" #include #include #include static bool fileIsTar(const QString& path) { QFileInfo file(path); if(file.isDir() || !file.exists()) return false; QMimeDatabase db; QMimeType type = db.mimeTypeForUrl(QUrl::fromLocalFile(path)); return type.isValid() && (type.inherits("application/x-tar") || type.inherits("application/x-bzip-compressed-tar") || type.inherits("application/x-compressed-tar")); } DialogInstaller::DialogInstaller(QWidget *parent) : QDialog(parent), ui(new Ui::dialog_installer) { ui->setupUi(this); //TODO: make sure it's a good idea to have the threads always instanciated threadForTheme = new Thread("theme"); threadForIcon = new Thread("icon"); threadAnalisysTheme = new ThreadAnalisysTheme; threadAnalisysThemeIcon = new ThreadAnalisysThemeIcon; //installation ui connect(ui->theme_file, &KUrlRequester::textChanged, this, &DialogInstaller::themeAnalisys); connect(ui->icon_file, &KUrlRequester::textChanged, this, &DialogInstaller::themeIconAnalisys); - connect(ui->but_icon_install, SIGNAL(clicked()), this, SLOT(installThemeIcon())); - connect(ui->but_theme_install, SIGNAL(clicked()), this, SLOT(installTheme())); + connect(ui->but_icon_install, &QAbstractButton::clicked, this, &DialogInstaller::installThemeIcon); + connect(ui->but_theme_install, &QAbstractButton::clicked, this, &DialogInstaller::installTheme); connect(threadAnalisysTheme, &KJob::finished, this, &DialogInstaller::checkThemeAnalisys); connect(threadAnalisysThemeIcon, &KJob::finished, this, &DialogInstaller::checkThemeIconAnalisys); connect(threadForTheme, &Thread::started, this, &DialogInstaller::disableGUIThemeInstaller); connect(threadForIcon, &Thread::started, this, &DialogInstaller::disableGUIThemeIconInstaller); connect(threadForTheme, &KJob::finished, this, &DialogInstaller::enableGUIThemeInstaller); connect(threadForIcon, &KJob::finished, this, &DialogInstaller::enableGUIThemeIconInstaller); //ui refresh connect(threadForTheme, &KJob::finished, this, &DialogInstaller::refreshGUITheme); connect(threadForIcon, &KJob::finished, this, &DialogInstaller::refreshGUIIconTheme); } DialogInstaller::~DialogInstaller() { delete ui; delete threadAnalisysTheme; delete threadAnalisysThemeIcon; delete threadForIcon; delete threadForTheme; } void DialogInstaller::installTheme() { QString file = ui->theme_file->text(); // qDebug()<< "File to install" << file; if(!fileIsTar(file)) { KMessageBox::error(this, i18n("Could not install the %1 theme.", file), i18n("Cannot install theme")); return; } threadForTheme->setUrlPackage(file); threadForTheme->start(); } void DialogInstaller::installThemeIcon() { QString file = ui->icon_file->text(); // qDebug()<< "File to install" << file; if(!fileIsTar(file)) { KMessageBox::error(this, i18n("Could not install the %1 theme.", file), i18n("Cannot install theme")); return; } threadForIcon->setUrlPackage(file); threadForIcon->start(); } void DialogInstaller::themeAnalisys() { ui->lb_theme_notice->setText(i18n("Parsing theme...")); ui->theme_file->setEnabled(false); ui->but_icon_install->setEnabled(false); QString archivo = ui->theme_file->text(); threadAnalisysTheme->setPackageTheme(archivo); threadAnalisysTheme->start(); } void DialogInstaller::checkThemeAnalisys() { ui->theme_file->setEnabled(true); if(threadAnalisysTheme->isSuccess()) { ui->lb_theme_notice->setText(i18n("This GTK theme can be installed")); ui->but_theme_install->setEnabled(true); } else { ui->lb_theme_notice->setText(i18n("This GTK theme cannot be installed")); ui->but_theme_install->setEnabled(false); } } void DialogInstaller::themeIconAnalisys() { ui->lb_icon_notice->setText(i18n("Parsing theme...")); ui->icon_file->setEnabled(false); ui->but_icon_install->setEnabled(false); QString archivo = ui->icon_file->text(); threadAnalisysThemeIcon->setPackageTheme(archivo); threadAnalisysThemeIcon->start(); } void DialogInstaller::checkThemeIconAnalisys() { ui->icon_file->setEnabled(true); if(threadAnalisysThemeIcon->isSuccess()) { ui->lb_icon_notice->setText(i18n("This icons theme can be installed")); ui->but_icon_install->setEnabled(true); } else { ui->lb_icon_notice->setText(i18n("This icons theme cannot be installed")); ui->but_icon_install->setEnabled(false); } } void DialogInstaller::enableGUIThemeInstaller() { ui->but_theme_install->setEnabled(true); ui->theme_file->setEnabled(true); } void DialogInstaller::enableGUIThemeIconInstaller() { ui->but_icon_install->setEnabled(true); ui->icon_file->setEnabled(true); ui->buttonBox->button(QDialogButtonBox::Close)->setEnabled(true); } void DialogInstaller::disableGUIThemeInstaller() { ui->lb_theme_notice->setText(i18n("Installing GTK theme...")); ui->but_theme_install->setEnabled(false); ui->theme_file->setEnabled(false); } void DialogInstaller::disableGUIThemeIconInstaller() { ui->lb_icon_notice->setText(i18n("Installing icons...")); ui->but_icon_install->setEnabled(false); ui->icon_file->setEnabled(false); ui->buttonBox->button(QDialogButtonBox::Close)->setEnabled(false); } void DialogInstaller::refreshGUIIconTheme() { if(threadForIcon->isSuccess()) { ui->lb_icon_notice->setText(i18n("Icons Successfully Installed")); ui->icon_file->clear(); emit themeInstalled(); } else { ui->lb_icon_notice->setText(i18n("The icons theme cannot be installed")); ui->icon_file->clear(); } } // Esto se ejecuta cuando un tema es tratado a instalar void DialogInstaller::refreshGUITheme() { if(threadForTheme->isSuccess()) { ui->lb_theme_notice->setText(i18n("GTK Theme Successfully Installed")); emit themeInstalled(); } else { ui->lb_theme_notice->setText(i18n("The GTK theme cannot be installed")); } ui->theme_file->clear(); } diff --git a/src/dialog_uninstaller.cpp b/src/dialog_uninstaller.cpp index 8683880..f6c5f5a 100644 --- a/src/dialog_uninstaller.cpp +++ b/src/dialog_uninstaller.cpp @@ -1,140 +1,140 @@ /* KDE GTK Configuration Module * * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "dialog_uninstaller.h" #include "abstractappearance.h" #include "iconthemesmodel.h" #include "ui_dialog_uninstaller.h" #include "thread.h" #include "appearencegtk.h" #include #include #include DialogUninstaller::DialogUninstaller(QWidget* parent, AppearenceGTK *app) : QDialog(parent) , ui(new Ui::dialog_uninstaller) , appareance(app) { ui->setupUi(this); refreshListsForUninstall(); - connect(ui->but_uninstall_theme, SIGNAL(clicked()), this, SLOT(uninstallTheme())); - connect(ui->but_uninstall_icon, SIGNAL(clicked()), this, SLOT(uninstallIcon())); + connect(ui->but_uninstall_theme, &QAbstractButton::clicked, this, &DialogUninstaller::uninstallTheme); + connect(ui->but_uninstall_icon, &QAbstractButton::clicked, this, &DialogUninstaller::uninstallIcon); } DialogUninstaller::~DialogUninstaller() { delete ui; } void DialogUninstaller::refreshListsForUninstall() { ui->lb_notice_uninstall_icon->clear(); ui->lb_notice_uninstall_theme->clear(); QStringList themes = appareance->gtk2Appearance()->installedThemes(); themes = themes.filter(QDir::homePath()); //we only one the locally installed themes //Just leave the theme name for(QStringList::iterator it=themes.begin(); it!=themes.end(); ++it) *it = QDir(*it).dirName(); ui->cb_uninstall_theme->clear(); ui->cb_uninstall_theme->addItems(themes); ui->cb_uninstall_icon->setModel(new IconThemesModel(true)); } void DialogUninstaller::uninstallTheme() { if(ui->cb_uninstall_theme->currentIndex() < 0) return; QString tema = ui->cb_uninstall_theme->currentText(); QStringList themes = appareance->gtk2Appearance()->installedThemes(); themes = themes.filter(QRegExp('/'+tema+'$')); Q_ASSERT(themes.size()==1); ui->cb_uninstall_theme->setEnabled(false); ui->but_uninstall_theme->setEnabled(false); ui->lb_notice_uninstall_theme->setText(i18n("Uninstalling GTK theme...")); ThreadErase* threadEraseTheme = new ThreadErase; threadEraseTheme->setThemeForErase(themes.first()); - connect(threadEraseTheme, SIGNAL(finished(KJob*)), this, SLOT(threadUninstalledThemeFinished(KJob*))); + connect(threadEraseTheme, &KJob::finished, this, &DialogUninstaller::threadUninstalledThemeFinished); threadEraseTheme->start(); } void DialogUninstaller::uninstallIcon() { int themeIndex = ui->cb_uninstall_icon->currentIndex(); if(themeIndex<0) return; QAbstractItemModel* model = ui->cb_uninstall_icon->model(); QString theme = model->data(model->index(themeIndex, 0), IconThemesModel::PathRole).toString(); ui->cb_uninstall_icon->setEnabled(false); ui->but_uninstall_icon->setEnabled(false); ui->lb_notice_uninstall_icon->setText(i18n("Uninstalling icons...")); ThreadErase* threadEraseIcon = new ThreadErase; threadEraseIcon->setThemeForErase(theme); - connect(threadEraseIcon, SIGNAL(finished(KJob*)), this, SLOT(threadUninstalledThemeIconFinished(KJob*))); + connect(threadEraseIcon, &KJob::finished, this, &DialogUninstaller::threadUninstalledThemeIconFinished); threadEraseIcon->start(); } void DialogUninstaller::threadUninstalledThemeFinished(KJob* job) { if(job->error()==0) { ui->lb_notice_uninstall_theme->setText(i18n("GTK theme successfully uninstalled.")); emit(themeUninstalled()); } else { ui->lb_notice_uninstall_theme->setText(i18n("Could not uninstall the GTK theme.")); } ui->cb_uninstall_theme->setEnabled(true); ui->but_uninstall_theme->setEnabled(true); refreshListsForUninstall(); } void DialogUninstaller::threadUninstalledThemeIconFinished(KJob* job) { if(job->error()==0) { ui->lb_notice_uninstall_icon->setText(i18n("Icons successfully uninstalled.")); emit(themeUninstalled()); } else { ui->lb_notice_uninstall_icon->setText(i18n("Could not uninstall the icon theme.")); } ui->cb_uninstall_icon->setEnabled(true); ui->but_uninstall_icon->setEnabled(true); refreshListsForUninstall(); } diff --git a/src/gtkconfigkcmodule.cpp b/src/gtkconfigkcmodule.cpp index dd8a609..d364a6a 100644 --- a/src/gtkconfigkcmodule.cpp +++ b/src/gtkconfigkcmodule.cpp @@ -1,469 +1,525 @@ /* KDE GTK Configuration Module * * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "gtkconfigkcmodule.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "ui_gui.h" #include "abstractappearance.h" #include "iconthemesmodel.h" #include "fontshelpers.h" +#include K_PLUGIN_FACTORY_WITH_JSON(GTKConfigKCModuleFactory, "kde-gtk-config.json", registerPlugin();) QMap gtkToolbarInit() { QMap gtkToolbar; gtkToolbar["GTK_TOOLBAR_ICONS"] = 0; gtkToolbar["GTK_TOOLBAR_TEXT"] = 1; gtkToolbar["GTK_TOOLBAR_BOTH"] = 2; gtkToolbar["GTK_TOOLBAR_BOTH_HORIZ"] = 3; return gtkToolbar; } static QMap gtkToolbar = gtkToolbarInit(); GTKConfigKCModule::GTKConfigKCModule(QWidget* parent, const QVariantList& args ) : KCModule(parent) , ui(new Ui::GUI) , installer(0) , uninstaller(0) , m_saveEnabled(true) { Q_UNUSED(args); KAboutData *acercade = new KAboutData("cgc", i18n("KDE GTK Config"), PROJECT_VERSION, i18n("Configure your GTK Applications"), KAboutLicense::LGPL_V3, i18n("Copyright 2011 José Antonio Sánchez Reynaga")); acercade->addAuthor(i18n("José Antonio Sánchez Reynaga (antonioJASR)"),i18n("Main Developer"), "joanzare@gmail.com"); acercade->addAuthor(i18n("Aleix Pol i Gonzalez"), i18n("Feature development. Previews, code refactoring."), "aleixpol@blue-systems.com"); acercade->addCredit(i18n("Manuel Tortosa (manutortosa)"), i18n("Ideas, tester, internationalization")); acercade->addCredit(i18n("Adrián Chaves Fernández (Gallaecio)"), i18n("Internationalization")); setAboutData(acercade); setButtons(KCModule::Default | KCModule::Apply); ui->setupUi(this); appareance = new AppearenceGTK; m_cursorsModel = new CursorThemesModel(this); ui->cb_cursor->setModel(m_cursorsModel); m_iconsModel = new IconThemesModel(false, this); ui->cb_icon->setModel(m_iconsModel); ui->cb_icon_fallback->setModel(m_iconsModel); m_tempGtk2Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/gtkrc-2.0"; m_tempGtk3Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/.config/gtk-3.0/settings.ini"; const QIcon previewIcon = QIcon::fromTheme("document-preview"); ui->gtk2Preview->setIcon(previewIcon); ui->gtk3Preview->setIcon(previewIcon); QString gtk2Preview = QStandardPaths::findExecutable("gtk_preview", {CMAKE_INSTALL_FULL_LIBEXECDIR}); QString gtk3Preview = QStandardPaths::findExecutable("gtk3_preview", {CMAKE_INSTALL_FULL_LIBEXECDIR}); m_p2 = new KProcess(this); m_p2->setEnv("GTK2_RC_FILES", m_tempGtk2Preview, true); if(!gtk2Preview.isEmpty()) { *m_p2 << gtk2Preview; connect(m_p2, SIGNAL(finished(int)), this, SLOT(untogglePreview())); } m_p3 = new KProcess(this); m_p3->setEnv("XDG_CONFIG_HOME", QStandardPaths::writableLocation(QStandardPaths::TempLocation)+"/.config"); if(!gtk3Preview.isEmpty()) { *m_p3 << gtk3Preview; connect(m_p3, SIGNAL(finished(int)), this, SLOT(untogglePreview())); } ui->gtk2Preview->setVisible(!gtk2Preview.isEmpty()); ui->gtk3Preview->setVisible(!gtk3Preview.isEmpty()); //UI changes connect(ui->cb_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); connect(ui->cb_theme_gtk3, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); - connect(ui->checkBox_theme_gtk3_prefer_dark, SIGNAL(clicked(bool)), this, SLOT(appChanged())); + connect(ui->checkBox_theme_gtk3_prefer_dark, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); connect(ui->cb_cursor, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); connect(ui->cb_icon, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); connect(ui->cb_icon_fallback ,SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); - connect(ui->font, SIGNAL(fontSelected(QFont)), this, SLOT(appChanged())); + connect(ui->font, &KFontRequester::fontSelected, this, >KConfigKCModule::appChanged); connect(ui->cb_toolbar_icons, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); - connect(ui->checkBox_icon_gtk_menus, SIGNAL(clicked(bool)), this, SLOT(appChanged())); - connect(ui->checkBox_icon_gtk_buttons, SIGNAL(clicked(bool)), this, SLOT(appChanged())); + connect(ui->checkBox_icon_gtk_menus, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); + connect(ui->checkBox_icon_gtk_buttons, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); connect(ui->buttonGroup_primary_button_warps_slider, SIGNAL(buttonToggled(QAbstractButton*, bool)), this, SLOT(appChanged())); //preview updates connect(ui->cb_icon_fallback, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); connect(ui->cb_icon, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); - connect(ui->gtk2Preview, SIGNAL(clicked(bool)), this, SLOT(runGtk2IfNecessary(bool))); - connect(ui->gtk3Preview, SIGNAL(clicked(bool)), this, SLOT(runGtk3IfNecessary(bool))); + connect(ui->gtk2Preview, &QAbstractButton::clicked, this, >KConfigKCModule::runGtk2IfNecessary); + connect(ui->gtk3Preview, &QAbstractButton::clicked, this, >KConfigKCModule::runGtk3IfNecessary); QMenu* m = new QMenu(this); m->addAction(QIcon::fromTheme("get-hot-new-stuff"), i18n("Download GTK2 themes..."), this, SLOT(showThemeGHNS())); m->addAction(QIcon::fromTheme("get-hot-new-stuff"), i18n("Download GTK3 themes..."), this, SLOT(installThemeGTK3GHNS())); m->addAction(QIcon::fromTheme("archive-insert"), i18n("Install a local theme..."), this, SLOT(showDialogForInstall())); m->addAction(QIcon::fromTheme("archive-remove"), i18n("Uninstall a local theme..."), this, SLOT(showDialogForUninstall())); ui->newThemes->setMenu(m); ui->newThemes->setIcon(QIcon::fromTheme("get-hot-new-stuff")); } GTKConfigKCModule::~GTKConfigKCModule() { m_p2->kill(); m_p3->kill(); QFile::remove(m_tempGtk2Preview); QFile::remove(m_tempGtk3Preview); delete appareance; m_p2->waitForFinished(); m_p3->waitForFinished(); delete ui; } void GTKConfigKCModule::syncUI() { appareance->setThemeGtk3(ui->cb_theme_gtk3->currentText()); appareance->setTheme(ui->cb_theme->currentText()); appareance->setApplicationPreferDarkTheme(ui->checkBox_theme_gtk3_prefer_dark->isChecked()); appareance->setCursor(ui->cb_cursor->itemData(ui->cb_cursor->currentIndex(), CursorThemesModel::DirNameRole).toString()); appareance->setIcon(ui->cb_icon->itemData(ui->cb_icon->currentIndex(), IconThemesModel::DirNameRole).toString()); appareance->setIconFallback(ui->cb_icon_fallback->itemData(ui->cb_icon_fallback->currentIndex(), IconThemesModel::DirNameRole).toString()); appareance->setFont(fontToString(ui->font->font())); appareance->setToolbarStyle(gtkToolbar.key(ui->cb_toolbar_icons->currentIndex())); appareance->setShowIconsInButtons(ui->checkBox_icon_gtk_buttons->isChecked()); appareance->setShowIconsInMenus(ui->checkBox_icon_gtk_menus->isChecked()); appareance->setPrimaryButtonWarpsSlider(ui->buttonGroup_primary_button_warps_slider->checkedButton() == ui->radioButton_warp); } void GTKConfigKCModule::showThemeGHNS() { KNS3::DownloadDialog d("cgctheme.knsrc", this); if(d.exec()) { refreshLists(); } } void GTKConfigKCModule::installThemeGTK3GHNS() { KNS3::DownloadDialog d("cgcgtk3.knsrc", this); if(d.exec()) { refreshLists(); } } void GTKConfigKCModule::refreshLists() { refreshThemesUi(true); - QString font = appareance->getFont(); -// Q_ASSERT(!font.isEmpty()); - ui->font->setFont(stringToFont(font)); + const auto newFont = stringToFont(appareance->getFont()); + if (newFont != ui->font->font()) + ui->font->setFont(newFont); ui->cb_toolbar_icons->setCurrentIndex(gtkToolbar[appareance->getToolbarStyle()]); ui->checkBox_icon_gtk_buttons->setChecked(appareance->getShowIconsInButtons()); ui->checkBox_icon_gtk_menus->setChecked(appareance->getShowIconsInMenus()); const bool warps = appareance->getPrimaryButtonWarpsSlider(); ui->radioButton_warp->setChecked(warps); ui->radioButton_dont_warp->setChecked(!warps); makePreviewIconTheme(); } void tryIcon(QLabel* label, const QString& fallback, const QString& theme, const QString& iconName) { label->setToolTip(iconName); QString ret; if(!theme.isEmpty()) ret = IconThemesModel::findIconRecursivelyByName(iconName, QDir(theme)); if(!ret.isEmpty()) { QPixmap p(ret); Q_ASSERT(!p.isNull()); label->setPixmap(p); return; } if(!fallback.isEmpty()) ret = IconThemesModel::findIconRecursivelyByName(iconName, fallback); if(!ret.isEmpty()) { QPixmap p(ret); Q_ASSERT(!p.isNull()); label->setPixmap(p); return; } QIcon notFoundIcon = QIcon::fromTheme("application-x-zerosize"); QPixmap noIcon(notFoundIcon.pixmap(48,48)); label->setPixmap(noIcon); qWarning() << "could not find icon" << iconName; } void GTKConfigKCModule::makePreviewIconTheme() { int icon_fallback = ui->cb_icon_fallback->currentIndex(); QString path_fallback = ui->cb_icon->itemData(icon_fallback, IconThemesModel::PathRole).toString(); int icon = ui->cb_icon->currentIndex(); QString path_icon = ui->cb_icon->itemData(icon, IconThemesModel::PathRole).toString(); tryIcon(ui->lb_prev_1, path_fallback, path_icon, "user-home"); tryIcon(ui->lb_prev_2, path_fallback, path_icon, "folder"); tryIcon(ui->lb_prev_3, path_fallback, path_icon, "user-trash"); tryIcon(ui->lb_prev_4, path_fallback, path_icon, "document-print"); tryIcon(ui->lb_prev_5, path_fallback, path_icon, "user-desktop"); tryIcon(ui->lb_prev_6, path_fallback, path_icon, "network-server"); tryIcon(ui->lb_prev_7, path_fallback, path_icon, "system-help"); tryIcon(ui->lb_prev_8, path_fallback, path_icon, "start-here"); tryIcon(ui->lb_prev_9, path_fallback, path_icon, "go-up"); } void GTKConfigKCModule::appChanged() { + if (m_loading) + return; + savePreviewConfig(); emit changed(true); } void GTKConfigKCModule::savePreviewConfig() { if(!m_saveEnabled || !(ui->gtk2Preview->isChecked() || ui->gtk3Preview->isChecked())) return; // qDebug() << "saving UI..."; syncUI(); if(ui->gtk3Preview->isChecked()) { //we don't want to recursively loop between savePreviewConfig and runIfNecessary m_saveEnabled = false; m_p3->kill(); appareance->gtk3Appearance()->saveSettings(m_tempGtk3Preview); //need to make sure runIfNecessary() to know that it's not running m_p3->waitForFinished(); m_p3->start(); ui->gtk3Preview->setChecked(true); m_saveEnabled = true; } else if(ui->gtk2Preview->isChecked()) { appareance->gtk2Appearance()->saveSettings(m_tempGtk2Preview); } } void GTKConfigKCModule::runGtk2IfNecessary(bool checked) { KProcess* p = m_p2; KProcess* np = m_p3; if(checked) { np->kill(); np->waitForFinished(); savePreviewConfig(); if(p->state() == QProcess::NotRunning) p->start(); } else { p->kill(); p->waitForFinished(); } } void GTKConfigKCModule::runGtk3IfNecessary(bool checked) { KProcess* p = m_p3; KProcess* np = m_p2; if(checked) { np->kill(); np->waitForFinished(); savePreviewConfig(); if(p->state() == QProcess::NotRunning) p->start(); } else { p->kill(); p->waitForFinished(); } } void GTKConfigKCModule::save() { /* qDebug() << "******************************************* INSTALLATION :\n" << "theme : " << appareance->getTheme() << "\n" << "themeGTK3 : " << appareance->getThemeGtk3() << "\n" << "icons : " << appareance->getIcon() << "\n" << "fallback icons : " << appareance->getIconFallback() << "\n" << "cursors : " << appareance->getCursor() << "\n" << "font family : " << appareance->getFont() << "\n" << "toolbar style : " << appareance->getToolbarStyle() << "\n" << "icons in buttons : " << appareance->getShowIconsInButtons() << "\n" << "icons in menus : " << appareance->getShowIconsInMenus() << "\n" << "********************************************************"; */ syncUI(); if(!appareance->saveFileConfig()) KMessageBox::error(this, i18n("Failed to save configuration.")); } void setComboItem(QComboBox* combo, const QStringList& texts) { foreach(const QString& text, texts) { int pos = combo->findText(text); if(pos>=0) { combo->setCurrentIndex(pos); return; } } } void GTKConfigKCModule::defaults() { refreshThemesUi(false); // qDebug() << "loading defaults..."; m_saveEnabled = false; ui->font->setFont(font()); bool showIcons = !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); ui->checkBox_icon_gtk_buttons->setChecked(showIcons); ui->checkBox_icon_gtk_menus->setChecked(showIcons); // this makes it consistent with Qt apps and restores the old Gtk behavior ui->radioButton_dont_warp->setChecked(true); setComboItem(ui->cb_theme, QStringList("oxygen-gtk") << "Clearlooks"); setComboItem(ui->cb_theme_gtk3, QStringList("oxygen-gtk") << "Adwaita"); QStringList icons; icons << KIconLoader::global()->theme()->name() << "GNOME"; setComboItem(ui->cb_icon, icons); int idx = ui->cb_icon->currentIndex(); if(idx>=0) { setComboItem(ui->cb_icon_fallback, icons.mid(icons.indexOf(ui->cb_icon->currentText())+1)); } m_saveEnabled = true; makePreviewIconTheme(); appChanged(); } void GTKConfigKCModule::load() { m_saveEnabled = false; bool someCorrect = appareance->loadFileConfig(); + m_loading = true; if(someCorrect) { refreshLists(); } else { defaults(); } + m_loading = false; m_saveEnabled = true; } +class MyStringListModel : public QAbstractListModel +{ +public: + MyStringListModel(const QStringList &texts, QObject* parent) : QAbstractListModel(parent), m_texts(texts) + { + } + + QVariant data(const QModelIndex & index, int role) const override + { + if (role != Qt::DisplayRole || !index.isValid() || index.row()>=m_texts.count()) + return {}; + + return m_texts[index.row()]; + } + + int rowCount(const QModelIndex & parent) const override { return parent.isValid() ? 0 : m_texts.count(); } + + void setStrings(const QSet &list) { + const auto current = m_texts.toSet(); + + const auto oldRows = QSet(current).subtract(list); + const auto newRows = QSet(list).subtract(current); + if (!newRows.isEmpty()) { + beginInsertRows({}, m_texts.count(), m_texts.count() + newRows.count()); + m_texts += newRows.toList(); + endInsertRows(); + } + + int from = -1; + for(const auto &row: oldRows) { + for(; fromclear(); - combo->addItems(texts); - int idx = combo->findText(temp); - if(idx>=0) - combo->setCurrentIndex(idx); + const auto model = dynamic_cast(combo->model()); + if (!model) { + combo->setModel(new MyStringListModel(texts, combo)); + } else { + model->setStrings(texts.toSet()); + } + + const int idx = combo->findText(temp); + combo->setCurrentIndex(qMax(0, idx)); } void GTKConfigKCModule::refreshThemesUi(bool useConfig) { //theme gtk2 bool wasenabled = m_saveEnabled; m_saveEnabled = false; refreshComboSameCurrentValue(ui->cb_theme, useConfig ? appareance->getTheme() : ui->cb_theme->currentText(), appareance->gtk2Appearance()->installedThemesNames()); //theme gtk3 refreshComboSameCurrentValue(ui->cb_theme_gtk3, useConfig ? appareance->getThemeGtk3() : ui->cb_theme_gtk3->currentText(), appareance->gtk3Appearance()->installedThemesNames()); // dark theme for gtk3 ui->checkBox_theme_gtk3_prefer_dark->setChecked(appareance->getApplicationPreferDarkTheme()); //cursors QString currentCursor = useConfig ? appareance->getCursor() : ui->cb_cursor->currentText(); int currentCursorIdx = ui->cb_cursor->findData(currentCursor, CursorThemesModel::DirNameRole); ui->cb_cursor->setCurrentIndex(qMax(currentCursorIdx, 0)); //icons QString currentIcon = useConfig ? appareance->getIcon() : ui->cb_icon->currentText(), currentFallback = useConfig ? appareance->getIconFallback() : ui->cb_icon_fallback->currentText(); int currentIconIdx = ui->cb_icon->findData(currentIcon, IconThemesModel::DirNameRole); int currentFallbackIdx = ui->cb_icon_fallback->findData(currentFallback, IconThemesModel::DirNameRole); ui->cb_icon->setCurrentIndex(qMax(currentIconIdx, 0)); ui->cb_icon_fallback->setCurrentIndex(qMax(currentFallbackIdx, 0)); m_saveEnabled = wasenabled; if(currentCursorIdx<0 || currentIconIdx<0 || currentFallbackIdx<0) emit changed(true); } void GTKConfigKCModule::showDialogForInstall() { if(!installer) { installer = new DialogInstaller(this); - connect(installer, SIGNAL(themeInstalled()), SLOT(refreshLists())); + connect(installer, &DialogInstaller::themeInstalled, this, >KConfigKCModule::refreshLists); } installer->exec(); refreshThemesUi(); } void GTKConfigKCModule::showDialogForUninstall() { if(!uninstaller) { uninstaller = new DialogUninstaller(this, appareance); - connect(uninstaller, SIGNAL(themeUninstalled()), SLOT(refreshLists())); + connect(uninstaller, &DialogUninstaller::themeUninstalled, this, >KConfigKCModule::refreshLists); } uninstaller->refreshListsForUninstall(); uninstaller->exec(); refreshThemesUi(); } void GTKConfigKCModule::untogglePreview() { if(sender()==m_p2) ui->gtk2Preview->setChecked(false); else ui->gtk3Preview->setChecked(false); } #include "gtkconfigkcmodule.moc" diff --git a/src/gtkconfigkcmodule.h b/src/gtkconfigkcmodule.h index 7fed1f2..50ddd8d 100644 --- a/src/gtkconfigkcmodule.h +++ b/src/gtkconfigkcmodule.h @@ -1,90 +1,91 @@ /* KDE GTK Configuration Module * * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef GTKCONFIGKCMODULE_H #define GTKCONFIGKCMODULE_H #include #include "appearencegtk.h" #include "dialog_installer.h" #include "dialog_uninstaller.h" #include #include "iconthemesmodel.h" #include "cursorthemesmodel.h" class KProcess; class QX11EmbedContainer; namespace Ui { class Modulo; class GUI; } class GTKConfigKCModule : public KCModule { Q_OBJECT public: explicit GTKConfigKCModule(QWidget* parent = 0 ,const QVariantList& args = QVariantList() ); ~GTKConfigKCModule(); void refreshThemesUi(bool useConfig=false); void save() override; void defaults() override; void load() override; public slots: void refreshLists(); void makePreviewIconTheme(); ///it is called whenever something in the UI has changed void appChanged(); void savePreviewConfig(); void showThemeGHNS(); void installThemeGTK3GHNS(); void showDialogForInstall(); void showDialogForUninstall(); void runGtk2IfNecessary(bool); void runGtk3IfNecessary(bool); void untogglePreview(); signals: void selectedIconTheme(); private: void syncUI(); + bool m_loading = false; Ui::GUI *ui; AppearenceGTK *appareance; DialogInstaller *installer; DialogUninstaller *uninstaller; KProcess* m_p2; KProcess* m_p3; QString m_tempGtk2Preview; QString m_tempGtk3Preview; bool m_saveEnabled; CursorThemesModel* m_cursorsModel; IconThemesModel* m_iconsModel; }; #endif // MODULO_H diff --git a/src/iconthemesmodel.cpp b/src/iconthemesmodel.cpp index 7f4473b..f642ecc 100644 --- a/src/iconthemesmodel.cpp +++ b/src/iconthemesmodel.cpp @@ -1,125 +1,133 @@ /* KDE GTK Configuration Module * * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "iconthemesmodel.h" #include #include #include #include #include #include IconThemesModel::IconThemesModel(bool onlyHome, QObject* parent) : QStandardItemModel(parent) , m_onlyHome(onlyHome) { + setSortRole(Qt::DisplayRole); reload(); } QList IconThemesModel::installedThemesPaths() { QList availableIcons; QSet dirs; dirs += QDir::home().filePath(".icons"); if(!m_onlyHome) { dirs += QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "icons", QStandardPaths::LocateDirectory).toSet(); } foreach(const QString& dir, dirs) { QDir userIconsDir(dir); QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs|QDir::NoSymLinks); while(it.hasNext()) { QString currentPath = it.next(); QDir dir(currentPath); if(dir.exists() && dir.exists("index.theme")) { availableIcons << dir; } } } return availableIcons; } bool greatSizeIs48(const QString& a, const QString& b) { bool a48=a.contains("48"), b48=b.contains("48"); if((a48 && b48) || (!a48 && !b48)) return a done; QList paths = installedThemesPaths(); Q_FOREACH(const QDir& dir, paths) { KIconTheme theme(dir.dirName()); - if (!theme.isValid()) { - qWarning() << "invalid theme" << dir.dirName(); + if (!theme.isValid()) { //most likely a cursor theme +// qWarning() << "invalid theme" << dir.dirName(); continue; } + if (done.contains(dir.dirName())) + continue; + + done << dir.dirName(); + QStandardItem* item = new QStandardItem(dir.dirName()); item->setData(dir.path(), PathRole); item->setData(dir.dirName(), DirNameRole); item->setText(theme.name()); item->setToolTip(theme.description()); item->setData(theme.inherits(), IconThemesModel::InheritsRole); QString iconName = theme.example(); if (iconName.isEmpty()) iconName = QStringLiteral("folder"); QString path = theme.iconPathByName(iconName, 16, KIconLoader::MatchBest); item->setIcon(QIcon(path)); appendRow(item); } + sort(0); } diff --git a/src/iconthemesmodel.h b/src/iconthemesmodel.h index be75105..1e03332 100644 --- a/src/iconthemesmodel.h +++ b/src/iconthemesmodel.h @@ -1,45 +1,45 @@ /* KDE GTK Configuration Module * * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef ICONTHEMESMODEL_H #define ICONTHEMESMODEL_H #include class QDir; class IconThemesModel : public QStandardItemModel { public: enum ThemesRoles { PathRole=Qt::UserRole+1, InheritsRole, DirNameRole }; explicit IconThemesModel(bool onlyHome=false, QObject* parent = 0); - void reload(); + virtual void reload(); static QString findIconRecursivelyByName(const QString& name, const QDir& directory); private: static QString findFilesRecursively(const QStringList& wildcard, const QDir& directory); QList installedThemesPaths(); bool m_onlyHome; }; #endif // ICONTHEMESMODEL_H diff --git a/src/thread.cpp b/src/thread.cpp index 47b0771..1abf7cb 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -1,210 +1,210 @@ /* KDE GTK Configuration Module * * Copyright 2011 José Antonio Sanchez Reynaga * Copyright 2011 Aleix Pol Gonzalez * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "thread.h" #include #include #include #include #include #include #include #include Thread::Thread(const QString& accion) : action(accion) {} void Thread::start() { emit started(); bool success = false; if(urlPackage.isEmpty()) { qWarning() << "*** ERROR: There's nothing to do"; } else if(action == "icon") { // qDebug() << "Installing icons theme"; success = Installer::installIconTheme(urlPackage); } else if(action == "theme") { // qDebug() << "Installing GTK theme"; success = Installer::installTheme(urlPackage); } setError(success); emitResult(); } void Thread::setUrlPackage(const QString& package) { urlPackage = package; } bool Thread::isSuccess() const { return error()==0; } void ThreadAnalisysTheme::start() { bool success = false; // qDebug()<< "File to install" << packageTheme; KTar package(packageTheme); if(!package.open(QIODevice::ReadOnly)) { // qDebug() << "ERROR extracting the package theme" << packageTheme; setError(1); emitResult(); return; } // qDebug() << "** EXTRACTING ICONS TO A TEMPORAL FOLDER"; //We proceed unpacking the package in a temporal directory QDir temporal(QDir::tempPath()+"/CGC/theme"); //Make sure it's already created temporal.mkpath(temporal.path()); package.directory()->copyTo(temporal.path()); // Package extracted in the temp dir. Now we want to know the name QString folder=temporal.entryList(QDir::AllDirs|QDir::NoDotAndDotDot).first(); // qDebug() << "FOUND THEME FOLDER = " << folder; // qDebug() << "\n******* THEME " << temporal.path()+'/'+folder; //We know the path of the folder to analyze QDirIterator it(temporal.path()+'/'+folder); while(it.hasNext()) { QString file = it.next(); // qDebug() << "trying file" << file; if(it.fileName()=="gtkrc") { // qDebug() << "FILE : " << file; success = true; break; } } QUrl tempUrl = QUrl::fromLocalFile(temporal.path()); // qDebug() << "Deleting temps. Successful:" << success; if(!KIO::del(tempUrl, KIO::HideProgressInfo)->exec()) qWarning() << "There was not cleanning"; // else // qDebug() << "Cleanning complete" << temporal.path(); if(!success) setError(2); emitResult(); } void ThreadAnalisysTheme::setPackageTheme(const QString& theme) { packageTheme = theme; } bool ThreadAnalisysTheme::isSuccess() const { return error()==0; } void ThreadAnalisysThemeIcon::start() { bool success = false; // qDebug()<< "*************** GTK THEME INSTALLATION"; // qDebug()<< "File to install" << packageTheme; KTar package(packageTheme); if(!package.open(QIODevice::ReadOnly)) { qWarning() << "ERROR extracting the package theme" << packageTheme; return; } // qDebug() << "** EXTRACTING ICONS TO A TEMPORAL FOLDER"; QDir temporal(QDir::tempPath()+"/CGC/icon"); temporal.mkpath(temporal.path()); package.directory()->copyTo(temporal.path()); //archive extracted in the temp directory QString folder= temporal.entryList(QDir::AllDirs|QDir::NoDotAndDotDot).first(); // qDebug() << "FOUND THEME FOLDER = " << folder; // qDebug() << "\n******* THEME " << temporal.path()+'/'+folder; QDirIterator it(temporal.path()+'/'+folder); while(it.hasNext()) { QString file = it.next(); if(it.fileName()=="index.theme") { //archivo index.theme // qDebug() << "FILE : " << file; success = true; break; } } QUrl tempUrl = QUrl::fromLocalFile(temporal.path()); // qDebug() << "Deleting temps. Successful:" << success; if(KIO::del(tempUrl, KIO::HideProgressInfo)->exec()) { qWarning() << "Cleaning was not succesful"; } // else // qDebug() << "Cleanning complete." << temporal.path(); if(!success) setError(2); emitResult(); } void ThreadAnalisysThemeIcon::setPackageTheme(const QString& theme) { packageTheme = theme; } bool ThreadAnalisysThemeIcon::isSuccess() { return error()==0; } bool ThreadErase::isSuccess() { return error()==0; } void ThreadErase::setThemeForErase(const QString& theme) { Q_ASSERT(!theme.isEmpty()); themeForErase = theme; } void ThreadErase::start() { KIO::DeleteJob* job = KIO::del(QUrl::fromLocalFile(themeForErase), KIO::HideProgressInfo); - connect(job, SIGNAL(finished(KJob*)), SLOT(deleted(KJob*))); + connect(job, &KJob::finished, this, &ThreadErase::deleted); } void ThreadErase::deleted(KJob* job) { setError(job->error()); setErrorText(job->errorText()); emitResult(); }