diff --git a/krunner/CMakeLists.txt b/krunner/CMakeLists.txt index d3feb2fce..c73216e45 100644 --- a/krunner/CMakeLists.txt +++ b/krunner/CMakeLists.txt @@ -37,3 +37,5 @@ ecm_configure_package_config_file(KRunnerAppDBusInterfaceConfig.cmake.in INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KRunnerAppDBusInterfaceConfig.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) + +add_subdirectory(update) \ No newline at end of file diff --git a/krunner/update/CMakeLists.txt b/krunner/update/CMakeLists.txt new file mode 100644 index 000000000..7654bf9ed --- /dev/null +++ b/krunner/update/CMakeLists.txt @@ -0,0 +1,12 @@ +set(krunnerplugins_SRCS + main.cpp + ) + +add_executable(krunnerplugins ${krunnerplugins_SRCS}) + +target_link_libraries(krunnerplugins KF5::CoreAddons KF5::Service KF5::Runner KF5::ConfigCore) + +install(TARGETS krunnerplugins DESTINATION ${LIB_INSTALL_DIR}/kconf_update_bin/) +install(FILES krunnerplugins.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR}) + + diff --git a/krunner/update/krunnerplugins.upd b/krunner/update/krunnerplugins.upd new file mode 100644 index 000000000..b5de479b5 --- /dev/null +++ b/krunner/update/krunnerplugins.upd @@ -0,0 +1,3 @@ +Version=5 +Id=5.9KRunnerPlugins +Script=krunnerplugins diff --git a/krunner/update/main.cpp b/krunner/update/main.cpp new file mode 100644 index 000000000..68cf811d6 --- /dev/null +++ b/krunner/update/main.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2016 by Marco Martin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, 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 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 +#include +#include +#include + +void migrateEnabledPlugins() +{ + KSharedConfig::Ptr config = KSharedConfig::openConfig("krunnerrc"); + KConfigGroup runnerManagerGroup(config, "PlasmaRunnerManager"); + KConfigGroup pluginsGroup(config, "Plugins"); + + QStringList enabledCategories = runnerManagerGroup.readEntry("enabledCategories", QStringList()); + + if (enabledCategories.isEmpty()) { + return; + } + + Plasma::RunnerManager *manager = new Plasma::RunnerManager(); + manager->reloadConfiguration(); + for (Plasma::AbstractRunner *runner : manager->runners()) { + pluginsGroup.writeEntry(runner->metadata().pluginName() + QStringLiteral("Enabled"), false); + for (auto category : runner->categories()) { + if (enabledCategories.contains(category)) { + pluginsGroup.writeEntry(runner->metadata().pluginName() + QStringLiteral("Enabled"), true); + break; + } + } + } + + runnerManagerGroup.deleteEntry("enabledCategories"); +} + +int main(int argc, char **argv) +{ + + QCoreApplication app(argc, argv); + + migrateEnabledPlugins(); + + return 0; +}