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