summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Becker <[email protected]>2017-04-30 18:38:14 +0200
committerHeiko Becker <[email protected]>2017-08-04 17:46:42 +0200
commit379e7016c8461bc528834b475b5281fa428a3c38 (patch)
tree517a607d68fd20ad2151dfd6b0e8a691a26a54ec
parent40fe90153cb2e91f72a851f05985e23d1caf89b0 (diff)
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
-rw-r--r--CMakeLists.txt2
-rw-r--r--privacyfunctions.cpp24
-rw-r--r--sweeper.cpp6
3 files changed, 26 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa2dd3f..330ae15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/privacyfunctions.cpp b/privacyfunctions.cpp
index 68c87b1..b6140f5 100644
--- a/privacyfunctions.cpp
+++ b/privacyfunctions.cpp
@@ -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;
}
diff --git a/sweeper.cpp b/sweeper.cpp
index e247eeb..3bbc2bd 100644
--- a/sweeper.cpp
+++ b/sweeper.cpp
@@ -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));