diff --git a/kcms/icons/CMakeLists.txt b/kcms/icons/CMakeLists.txt --- a/kcms/icons/CMakeLists.txt +++ b/kcms/icons/CMakeLists.txt @@ -26,9 +26,16 @@ target_link_libraries(kcm_icons Qt5::X11Extras) endif() -install(TARGETS kcm_icons DESTINATION ${PLUGIN_INSTALL_DIR} ) +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/config.h CONTENT "#define CMAKE_INSTALL_FULL_LIBEXECDIR \"${CMAKE_INSTALL_FULL_LIBEXECDIR}\"") + +add_executable(plasma-changeicons changeicons.cpp) +target_link_libraries(plasma-changeicons PRIVATE Qt5::Core KF5::KIOWidgets KF5::IconThemes) -########### install files ############### +install(TARGETS kcm_icons DESTINATION ${PLUGIN_INSTALL_DIR} ) install( FILES icons.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) -install( FILES icons.knsrc DESTINATION ${CONFIG_INSTALL_DIR} ) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/icons.knsrc ${CMAKE_BINARY_DIR}/icons.knsrc) +install( FILES ${CMAKE_BINARY_DIR}/icons.knsrc DESTINATION ${CONFIG_INSTALL_DIR} ) + +install(TARGETS plasma-changeicons DESTINATION ${LIBEXEC_INSTALL_DIR} ) diff --git a/kcms/icons/changeicons.cpp b/kcms/icons/changeicons.cpp new file mode 100644 --- /dev/null +++ b/kcms/icons/changeicons.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 20016 Aleix Pol Gonzalez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program 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 General Public License for more details + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + QApplication app(argc, argv); + + if (app.arguments().count() != 2) { + return 1; + } + + { + //KNS will give us a path + QString themeName = app.arguments().last(); + int idx = themeName.lastIndexOf('/'); + if (idx>=0) { + themeName = themeName.mid(idx); + } + + KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig), "Icons"); + config.writeEntry("Theme", themeName); + } + + KIconTheme::reconfigure(); + + KSharedDataCache::deleteCache(QStringLiteral("icon-cache")); + + for (int i=0; i +#include "config.h" #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include @@ -319,22 +321,6 @@ KNS3::DownloadDialog dialog(QStringLiteral("icons.knsrc"), this); dialog.exec(); if (!dialog.changedEntries().isEmpty()) { - for(int i = 0; i < dialog.changedEntries().size(); i ++) { - if(dialog.changedEntries().at(i).status() == KNS3::Entry::Installed - && !dialog.changedEntries().at(i).installedFiles().isEmpty()) { - const QString themeTmpFile = dialog.changedEntries().at(i).installedFiles().at(0); - const QString name = dialog.changedEntries().at(i).installedFiles().at(0).section('/', -2, -2); - qCDebug(KCM_ICONS)<<"IconThemesConfig::getNewTheme() themeTmpFile="<setStatus(KNS3::Entry::Invalid); - } - else if (! installThemes(themeNames, themeTmpFile)) { - //dialog.changedEntries().at(i)->setStatus(KNS3::Entry::Invalid); - } - } - } - // reload the display icontheme items KIconLoader::global()->newIconLoader(); loadThemes(); @@ -478,22 +464,10 @@ if (!selected) return; - KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig), "Icons"); - config.writeEntry("Theme", selected->data(0, ThemeNameRole).toString()); - config.sync(); + QProcess::startDetached(CMAKE_INSTALL_FULL_LIBEXECDIR "/plasma-changeicons", {selected->data(0, ThemeNameRole).toString()}); - KIconTheme::reconfigure(); emit changed(false); - KSharedDataCache::deleteCache(QStringLiteral("icon-cache")); - - for (int i=0; isetEnabled(false); }