diff --git a/kcms/baloo/kcm.cpp b/kcms/baloo/kcm.cpp index ff82aa63d..508f4a448 100644 --- a/kcms/baloo/kcm.cpp +++ b/kcms/baloo/kcm.cpp @@ -1,118 +1,115 @@ /* This file is part of the KDE Project Copyright (c) 2007-2010 Sebastian Trueg Copyright (c) 2012-2014 Vishesh Handa Copyright (c) 2020 Benjamin Port This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kcm.h" #include "fileexcludefilters.h" #include #include #include #include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY_WITH_JSON(KCMColorsFactory, "kcm_baloofile.json", registerPlugin();) using namespace Baloo; ServerConfigModule::ServerConfigModule(QObject* parent, const QVariantList& args) : KQuickAddons::ManagedConfigModule(parent, args) , m_settings(new BalooSettings(this)) , m_filteredFolderModel(new FilteredFolderModel(m_settings, this)) { qmlRegisterType(); qmlRegisterType(); KAboutData* about = new KAboutData( QStringLiteral("kcm_baloofile"), i18n("File Search"), QStringLiteral("0.1"), QString(), KAboutLicense::GPL, i18n("Copyright 2007-2010 Sebastian Trüg")); about->addAuthor(i18n("Sebastian Trüg"), QString(), QStringLiteral("trueg@kde.org")); about->addAuthor(i18n("Vishesh Handa"), QString(), QStringLiteral("vhanda@kde.org")); about->addAuthor(i18n("Tomaz Canabrava"), QString(), QStringLiteral("tcnaabrava@kde.org")); setAboutData(about); setButtons(Help | Apply | Default); connect(m_settings, &BalooSettings::excludedFoldersChanged, m_filteredFolderModel, &FilteredFolderModel::updateDirectoryList); connect(m_settings, &BalooSettings::foldersChanged, m_filteredFolderModel, &FilteredFolderModel::updateDirectoryList); m_filteredFolderModel->updateDirectoryList(); } ServerConfigModule::~ServerConfigModule() { } void ServerConfigModule::load() { ManagedConfigModule::load(); - m_previouslyEnabled = m_settings->indexingEnabled(); } void ServerConfigModule::save() { ManagedConfigModule::save(); - Baloo::IndexerConfig config; - config.setFirstRun(m_previouslyEnabled != m_settings->indexingEnabled()); - - m_previouslyEnabled = m_settings->indexingEnabled(); - - // Start Baloo + // Update Baloo config or start Baloo if (m_settings->indexingEnabled()) { + // Update the baloo_file's config cache - if it not yet running, + // the DBus call goes nowhere + Baloo::IndexerConfig config; + config.refresh(); + + // Trying to start baloo when it is already running is fine const QString exe = QStandardPaths::findExecutable(QStringLiteral("baloo_file")); QProcess::startDetached(exe, QStringList()); } else { QDBusMessage message = QDBusMessage::createMethodCall( QStringLiteral("org.kde.baloo"), QStringLiteral("/"), QStringLiteral("org.kde.baloo.main"), QStringLiteral("quit") ); QDBusConnection::sessionBus().asyncCall(message); } - - // Update the baloo_file's config cache - config.refresh(); } FilteredFolderModel *ServerConfigModule::filteredModel() const { return m_filteredFolderModel; } BalooSettings *ServerConfigModule::balooSettings() const { return m_settings; } #include "kcm.moc" diff --git a/kcms/baloo/kcm.h b/kcms/baloo/kcm.h index cb409958f..1d3b8d450 100644 --- a/kcms/baloo/kcm.h +++ b/kcms/baloo/kcm.h @@ -1,57 +1,56 @@ /* This file is part of the KDE Project Copyright (c) 2007 Sebastian Trueg Copyright (c) 2012-2014 Vishesh Handa Copyright (c) 2020 Benjamin Port This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _BALOO_FILE_KCM_H_ #define _BALOO_FILE_KCM_H_ #include #include "filteredfoldermodel.h" class BalooSettings; namespace Baloo { class ServerConfigModule : public KQuickAddons::ManagedConfigModule { Q_OBJECT Q_PROPERTY(FilteredFolderModel *filteredModel READ filteredModel CONSTANT) Q_PROPERTY(BalooSettings *balooSettings READ balooSettings CONSTANT) public: ServerConfigModule(QObject* parent, const QVariantList& args); virtual ~ServerConfigModule() override; BalooSettings *balooSettings() const; FilteredFolderModel *filteredModel() const; public Q_SLOTS: void load() override; void save() override; private: BalooSettings *m_settings; FilteredFolderModel *m_filteredFolderModel; - bool m_previouslyEnabled; }; } #endif