Commit f668bcda authored by Nate Graham's avatar Nate Graham
Browse files

[kcms/baloo] Offer to delete index after indexing is disabled

When the user disables indexing, the KCM now offers to remove the saved
index data. This may be useful for privacy or security purposes.

BUG: 414077
FIXED-IN:5.22
parent 90bbdf83
......@@ -22,6 +22,7 @@
#include "fileexcludefilters.h"
#include <KAboutData>
#include <KFormat>
#include <KLocalizedString>
#include <KPluginFactory>
#include <QStandardPaths>
......@@ -39,6 +40,17 @@
K_PLUGIN_FACTORY_WITH_JSON(KCMColorsFactory, "kcm_baloofile.json", registerPlugin<Baloo::ServerConfigModule>(); registerPlugin<BalooData>();)
static QString balooDatabaseLocation()
{
// First consult the environment variable, in case the index has been
// relocated manually
QString location = QString::fromLocal8Bit(qgetenv("BALOO_DB_PATH"));
if (location.isEmpty()) {
location = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/baloo/index");
}
return location;
}
using namespace Baloo;
ServerConfigModule::ServerConfigModule(QObject *parent, const QVariantList &args)
......@@ -109,4 +121,14 @@ BalooSettings *ServerConfigModule::balooSettings() const
return m_data->settings();
}
void ServerConfigModule::deleteIndex()
{
QFile(balooDatabaseLocation()).remove();
}
QString ServerConfigModule::indexFileSize()
{
return KFormat().formatByteSize(QFile(balooDatabaseLocation()).size());
}
#include "kcm.moc"
......@@ -43,6 +43,9 @@ public:
BalooSettings *balooSettings() const;
FilteredFolderModel *filteredModel() const;
Q_INVOKABLE void deleteIndex();
Q_INVOKABLE QString indexFileSize();
public Q_SLOTS:
void load() override;
void save() override;
......
......@@ -59,6 +59,25 @@ KCM.SimpleKCM {
anchors.fill: parent
anchors.margins: Kirigami.Units.largeSpacing
Kirigami.InlineMessage {
id: indexingDisabledWarning
Layout.fillWidth: true
visible: !kcm.balooSettings.indexingEnabled && !kcm.needsSave
type: Kirigami.MessageType.Warning
showCloseButton: true
text: i18n("Do you want to delete the saved index data? %1 of space will be freed, but if indexing is re-enabled later, the entire index will have to be re-created from scratch. This may take some time, depending on how many files you have.", kcm.indexFileSize());
actions: [
Kirigami.Action {
text: i18n("Delete Index Data")
icon.name: "edit-delete"
onTriggered: {
kcm.deleteIndex();
indexingDisabledWarning.visible = false;
}
}
]
}
QQC2.Label {
text: i18n("File Search helps you quickly locate all your files based on their content.")
}
......
Supports Markdown
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