Commit 92285a7b authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Add update script

This script copies the old history to each activity.
This way the user has the previous history in each activity.

Also the launch counts get copied to the new location.
parent 19badfab
......@@ -6,5 +6,8 @@ add_executable(krunnerglobalshortcuts ${krunnerglobalshortcuts_SRCS})
target_link_libraries(krunnerglobalshortcuts KF5::CoreAddons KF5::Service KF5::Runner KF5::ConfigCore KF5::GlobalAccel KF5::XmlGui)
install(TARGETS krunnerglobalshortcuts DESTINATION ${KDE_INSTALL_LIBDIR}/kconf_update_bin/)
install(FILES krunnerglobalshortcuts.upd DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
add_executable(krunnerhistory krunnerhistory.cpp)
target_link_libraries(krunnerhistory KF5::Runner KF5::ConfigCore KF5::Activities)
install(TARGETS krunnerglobalshortcuts krunnerhistory DESTINATION ${KDE_INSTALL_LIBDIR}/kconf_update_bin/)
install(FILES krunnerglobalshortcuts.upd krunnerhistory.upd DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
/***************************************************************************
* Copyright (C) 2020 by Alexander Lohnau <alexander.lohnau@gmx.de> *
* *
* 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 <QTimer>
#include <KActivities/Consumer>
#include <KSharedConfig>
#include <KConfigGroup>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
// Migrate data to state data file
KSharedConfigPtr krunnerrc = KSharedConfig::openConfig("krunnerrc");
KConfigGroup stateData = krunnerrc->group("PlasmaRunnerManager");
KSharedConfigPtr newStateLocation = KSharedConfig::openConfig("krunnerstaterc", KConfig::NoGlobals, QStandardPaths::GenericDataLocation);
stateData.reparent(newStateLocation.data());
stateData.sync();
// Migrate history to activity aware config
auto consumer = new KActivities::Consumer();
// Wait a bit for consumer to be initialized
QObject::connect(consumer, &KActivities::Consumer::serviceStatusChanged, consumer,
[consumer, newStateLocation, krunnerrc](){
const QString history = krunnerrc->group("General").readEntry("history");
QStringList activities = consumer->activities();
if (activities.isEmpty()) {
activities.append(QStringLiteral("00000000-0000-0000-0000-000000000000"));
}
KConfigGroup newHistory = newStateLocation->group("PlasmaRunnerManager").group("History");
for (const QString &activity : qAsConst(activities)) {
newHistory.writeEntry(activity, history);
}
newHistory.sync();
// Delete old values
krunnerrc->group("General").deleteEntry("history");
krunnerrc->deleteGroup("PlasmaRunnerManager");
krunnerrc->group("PlasmaRunnerManager").writeEntry("migrated", true);
krunnerrc->sync();
qApp->exit();
});
return QCoreApplication::exec();
}
Version=5
Id=5.21KRunnerHistory
Script=krunnerhistory
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment