From b34862e469ca4390f72e4db6520068bb12c09d3b Mon Sep 17 00:00:00 2001 From: Han Young Date: Tue, 1 Dec 2020 14:25:28 +0000 Subject: [PATCH] add notification for successful screenshot taking --- CMakeLists.txt | 2 +- containments/panel/CMakeLists.txt | 3 ++- containments/panel/phonepanel.cpp | 10 ++++++++++ plasma_phone_components.notifyrc | 8 ++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 plasma_phone_components.notifyrc diff --git a/CMakeLists.txt b/CMakeLists.txt index 8824cc8d..1a9bdc8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ plasma_install_package(shell org.kde.plasma.phone shells) install(DIRECTORY kwinmultitasking/ DESTINATION ${DATA_INSTALL_DIR}/kwin/scripts/org.kde.phone.multitasking) install(FILES kwinmultitasking/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME kwin-script-org.kde.phone.multitasking.desktop) - +install(FILES plasma_phone_components.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR}) install(DIRECTORY components/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell) add_subdirectory(bin) diff --git a/containments/panel/CMakeLists.txt b/containments/panel/CMakeLists.txt index 97d81781..a7eaeea1 100644 --- a/containments/panel/CMakeLists.txt +++ b/containments/panel/CMakeLists.txt @@ -14,7 +14,8 @@ target_link_libraries(plasma_applet_phonepanel Qt5::Gui Qt5::DBus KF5::Plasma - KF5::I18n) + KF5::I18n + KF5::Notifications) install(TARGETS plasma_applet_phonepanel DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) #install(FILES plasma-phonepanel-default.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp index 031ee0a1..91c3fe53 100644 --- a/containments/panel/phonepanel.cpp +++ b/containments/panel/phonepanel.cpp @@ -24,6 +24,9 @@ #include #include +#include +#include + #include #include #include @@ -176,6 +179,13 @@ void PhonePanel::takeScreenshot() qDebug() << lImage; if(!lImage.save(filePath, "PNG")) { qWarning() << "Failed to save screenshot to" << filePath; + } else { + KNotification *notif = new KNotification("captured"); + notif->setComponentName(QStringLiteral("plasma_phone_components")); + notif->setTitle(i18n("New Screenshot")); + notif->setUrls({filePath}); + notif->setText(i18n("New screenshot saved to %1", filePath)); + notif->sendEvent(); } } ); diff --git a/plasma_phone_components.notifyrc b/plasma_phone_components.notifyrc new file mode 100644 index 00000000..82c1e6bc --- /dev/null +++ b/plasma_phone_components.notifyrc @@ -0,0 +1,8 @@ +[Global] +IconName=preferences-system-windows-effect-screenshot +Name=Plasma + +[Event/captured] +Name=Captured +Comment=Captured +Action=Popup