Commit 379e7016 authored by Heiko Becker's avatar Heiko Becker 🏃

Fix clearing recent usage history

Summary:
The old method is gone with Plasma 4. Instead we can use
KActivitiesStats. Also, instead of checking at build time for
Q_WS_X11 (gone with Qt4), look at dbus if kactivitymanagerd's
service is registered to determine if the action should be
displayed.

Test Plan:
Checked with kactivitymanagerd available/unavailable on dbus.
Successfully removed the history.

Reviewers: kde-utils-devel

Differential Revision: https://phabricator.kde.org/D5677
parent 40fe9015
......@@ -19,6 +19,7 @@ add_definitions(
)
find_package(KF5 5.23.0 REQUIRED COMPONENTS
ActivitiesStats
Bookmarks
Crash
Config
......@@ -56,6 +57,7 @@ target_link_libraries(sweeper
Qt5::Core
Qt5::DBus
Qt5::Widgets
KF5::ActivitiesStats
KF5::Bookmarks
KF5::Crash
KF5::I18n
......
......@@ -25,6 +25,10 @@
#include <KConfigGroup>
#include <KRecentDocument>
#include <KToolInvocation>
#include <KActivities/Stats/Cleaning>
#include <KActivities/Stats/ResultSet>
#include <KActivities/Stats/Terms>
#include <QDBusConnectionInterface>
#include <QDBusInterface>
......@@ -39,6 +43,11 @@
#include "config-sweeper.h"
namespace KAStats = KActivities::Stats;
using namespace KAStats;
using namespace KAStats::Terms;
bool ClearThumbnailsAction::action()
{
// http://freedesktop.org/Standards/Home
......@@ -153,6 +162,13 @@ bool ClearWebCacheAction::action()
bool ClearRecentDocumentsAction::action()
{
auto query = UsedResources
| Agent::any()
| Type::any()
| Url::file();
KAStats::forgetResources(query);
KRecentDocument::clear();
return KRecentDocument::recentDocuments().isEmpty();
}
......@@ -228,9 +244,11 @@ bool ClearFaviconsAction::action()
bool ClearRecentApplicationAction::action()
{
QDBusMessage message =
QDBusMessage::createSignal(QLatin1String( "/kickoff/RecentAppDoc" ), QLatin1String( "org.kde.plasma" ), QLatin1String( "clearRecentDocumentsAndApplications" ));
QDBusConnection::sessionBus().send(message);
auto query = UsedResources
| Agent::any()
| Type::any()
| Url::startsWith(QStringLiteral("applications:"));
KAStats::forgetResources(query);
return true;
}
......
......@@ -154,9 +154,9 @@ void Sweeper::InitActions() {
checklist.append(new ClearSavedClipboardContentsAction(generalCLI));
checklist.append(new ClearRecentDocumentsAction(generalCLI));
checklist.append(new ClearRunCommandHistoryAction(generalCLI));
#ifdef Q_WS_X11
checklist.append( new ClearRecentApplicationAction( generalCLI ) );
#endif
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.ActivityManager"))) {
checklist.append( new ClearRecentApplicationAction( generalCLI ) );
}
checklist.append(new ClearThumbnailsAction(generalCLI));
checklist.append(new ClearAllCookiesAction(webbrowsingCLI));
......
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