summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <[email protected]>2016-09-29 13:05:10 +0200
committerMarco Martin <[email protected]>2016-09-29 13:05:19 +0200
commitad9eda5d49f2b09fe46dce09a71d7d6905f1d8d0 (patch)
tree5f0650eb87fcd0094b4271a409e9457574648bf9
parent9216223782425796d68320075c693994efdd0729 (diff)
kconfig update script for enabled runners
Summary: migrate the enabled runners from enabledCategories to the more classic [Plugins] group the krunner framework supports both, so as long the enabledCategories entry isn't there, it will work correctly with the other config format Test Plan: ran on an existing krunnerrc with different sets of categories enabled, tested krunner and its kcm with it, all expected runner plugins were used both in the kcm and while searching with krunner Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D2873
-rw-r--r--krunner/CMakeLists.txt2
-rw-r--r--krunner/update/CMakeLists.txt12
-rw-r--r--krunner/update/krunnerplugins.upd3
-rw-r--r--krunner/update/main.cpp67
4 files changed, 84 insertions, 0 deletions
diff --git a/krunner/CMakeLists.txt b/krunner/CMakeLists.txt
index d3feb2f..c73216e 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 0000000..7654bf9
--- /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 0000000..b5de479
--- /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 0000000..68cf811
--- /dev/null
+++ b/krunner/update/main.cpp
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (C) 2016 by Marco Martin <[email protected]> *
+ * *
+ * 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 <QCoreApplication>
+#include <QStandardPaths>
+#include <QDebug>
+#include <QFile>
+#include <QDir>
+
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <kconfig.h>
+#include <KPluginInfo>
+#include <krunner/runnermanager.h>
+
+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;
+}