[effects] Show a notification when a screenshot got saved to file

Summary:
Inform the user about the path to where a screenshot got saved through a
notification. This is helpful on the one hand that the user sees that
the screenshot got saved and from a security perspective that the user
is informed when a screenshot is taken through the dbus interface. It
doesn't prevent non-authorized screenshot taking, but at least the user
is informed about it.

Reviewers: #kwin, #plasma, #vdg

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3376
icc-effect-5.14.5
Martin Gräßlin 2016-11-16 09:50:18 +01:00
parent 620663cb28
commit adfaac4d60
2 changed files with 8 additions and 0 deletions

View File

@ -20,6 +20,7 @@ set(kwin_effect_KDE_LIBS
KF5::Plasma # screenedge effect
KF5::IconThemes
KF5::Service
KF5::Notifications # screenshot effect
)
set(kwin_effect_QT_LIBS

View File

@ -30,6 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QMatrix4x4>
#include <xcb/xcb_image.h>
#include <KLocalizedString>
#include <KNotification>
namespace KWin
{
@ -240,6 +243,10 @@ QString ScreenShotEffect::saveTempImage(const QImage &img)
}
img.save(&temp);
temp.close();
KNotification::event(KNotification::Notification,
i18nc("Notification caption that a screenshot got saved to file", "Screenshot"),
i18nc("Notification with path to screenshot file", "Screenshot saved to %1", temp.fileName()),
QStringLiteral("spectacle"));
return temp.fileName();
}