From af6149c9d0de1d4933bb62c3bbe43475b9434148 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 28 Oct 2014 15:01:03 +0100 Subject: [PATCH] use notifications actions to undo Change-Id: I4b9abf6047b94b4fc13aad672d1bc8e97203f502 --- CMakeLists.txt | 1 + src/plasma/CMakeLists.txt | 2 ++ src/plasma/data/notifications/plasmashell.notifyrc | 9 +++++++++ src/plasma/private/applet_p.cpp | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/plasma/data/notifications/plasmashell.notifyrc diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c0ef4db..b35cee1f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ find_package(KF5KIO ${KF5_DEP_VERSION} REQUIRED) find_package(KF5Service ${KF5_DEP_VERSION} REQUIRED) find_package(KF5WindowSystem ${KF5_DEP_VERSION} REQUIRED) find_package(KF5XmlGui ${KF5_DEP_VERSION} REQUIRED) +find_package(KF5Notifications ${KF5_DEP_VERSION} REQUIRED) find_package(KF5DocTools ${KF5_DEP_VERSION}) set_package_properties(KF5DocTools PROPERTIES DESCRIPTION "Tools to generate documentation" diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt index 7cc2fe3b9..f7aa38b86 100644 --- a/src/plasma/CMakeLists.txt +++ b/src/plasma/CMakeLists.txt @@ -125,6 +125,7 @@ PRIVATE KF5::Declarative #runtimePlatform KF5::XmlGui #KActionCollection KF5::GlobalAccel #Applet::setGlobalShortcut + KF5::Notifications ${PLASMA_EXTRA_LIBS} ) @@ -201,6 +202,7 @@ install(FILES install(FILES data/operations/dataengineservice.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) install(FILES data/operations/plasmoidservice.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) install(FILES data/operations/storage.operations DESTINATION ${PLASMA_DATA_INSTALL_DIR}/services) +install(FILES data/notifications/plasmashell.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR}) install(TARGETS KF5Plasma EXPORT KF5PlasmaTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/plasma/data/notifications/plasmashell.notifyrc b/src/plasma/data/notifications/plasmashell.notifyrc new file mode 100644 index 000000000..8cfb53e6a --- /dev/null +++ b/src/plasma/data/notifications/plasmashell.notifyrc @@ -0,0 +1,9 @@ +[Global] +IconName=plasma +Comment=Plasma +Name=plasmashell + +[Event/plasmoidDeleted] +Name=Plasmoid deleted +Comment=A plasmoid has been deleted +Action=Popup diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index eb9af97d9..571d35a61 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "containment.h" #include "corona.h" @@ -225,6 +226,17 @@ void AppletPrivate::askDestroy() cleanUpAndDelete(); } else { q->setStatus(Types::AwaitingDeletionStatus); + KNotification *notification = new KNotification("plasmoidDeleted", KNotification::Persistent | + KNotification::CloseWhenWidgetActivated, q); + QStringList actions; + notification->setText(i18n("The widget \"%1\" has been deleted.", q->title())); + actions.append(i18n("Undo")); + notification->setActions(actions); + QObject::connect(notification, &KNotification::action1Activated, + [=]() { + q->setStatus(Types::PassiveStatus); + }); + notification->sendEvent(); } /* if (q->isContainment()) { @@ -246,8 +258,6 @@ void AppletPrivate::askDestroy() return; }*/ - - } void AppletPrivate::globalShortcutChanged()