You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.8 KiB
173 lines
4.8 KiB
From 77aaa88eb2a148f0955eb35b3043d3f0f81fae5b Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= <mgraesslin@kde.org>
|
|
Date: Wed, 5 Oct 2016 09:07:08 +0200
|
|
Subject: [PATCH 13/19] [klipper] Move notification from tray to Klipper
|
|
|
|
Summary:
|
|
Klipper shows a notification when the shortcuts next/prev history item
|
|
gets triggered. This notification used to be implemented in the class
|
|
KlipperTray. With the switch from SNI based clipper to a Plasmoid the
|
|
notification got lost as the Plasmoid doesn't use the KlipperTray class
|
|
at all.
|
|
|
|
This change moves the notification handling from KlipperTray to Klipper
|
|
so that it gets emitted for both SNI and Plasmoid based klipper.
|
|
|
|
BUG: 368808
|
|
FIXED-IN: 5.8.1
|
|
|
|
Test Plan: Set the shortcuts, triggered them and verified the notification gets shown.
|
|
|
|
Reviewers: #plasma
|
|
|
|
Subscribers: plasma-devel
|
|
|
|
Tags: #plasma
|
|
|
|
Differential Revision: https://phabricator.kde.org/D2942
|
|
---
|
|
klipper/CMakeLists.txt | 1 +
|
|
klipper/klipper.cpp | 12 ++++++++++++
|
|
klipper/klipper.h | 3 +++
|
|
klipper/tray.cpp | 13 -------------
|
|
klipper/tray.h | 5 -----
|
|
5 files changed, 16 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/klipper/CMakeLists.txt b/klipper/CMakeLists.txt
|
|
index d152d0f..d9538fd 100644
|
|
--- a/klipper/CMakeLists.txt
|
|
+++ b/klipper/CMakeLists.txt
|
|
@@ -82,6 +82,7 @@ target_link_libraries(plasma_engine_clipboard
|
|
KF5::IconThemes
|
|
KF5::KIOWidgets # PreviewJob
|
|
KF5::Plasma
|
|
+ KF5::Notifications
|
|
KF5::Service
|
|
KF5::TextWidgets # KTextEdit
|
|
KF5::WidgetsAddons # KMessageBox
|
|
diff --git a/klipper/klipper.cpp b/klipper/klipper.cpp
|
|
index 79060d8..8de19fb 100644
|
|
--- a/klipper/klipper.cpp
|
|
+++ b/klipper/klipper.cpp
|
|
@@ -36,6 +36,7 @@
|
|
|
|
#include <KGlobalAccel>
|
|
#include <KMessageBox>
|
|
+#include <KNotification>
|
|
#include <KActionCollection>
|
|
#include <KToggleAction>
|
|
#include <KTextEdit>
|
|
@@ -227,6 +228,17 @@ Klipper::Klipper(QObject* parent, const KSharedConfigPtr& config, KlipperMode mo
|
|
if (m_mode == KlipperMode::Standalone) {
|
|
connect(qApp, &QGuiApplication::commitDataRequest, this, &Klipper::saveSession);
|
|
}
|
|
+
|
|
+ connect(this, &Klipper::passivePopup, this,
|
|
+ [this] (const QString &caption, const QString &text) {
|
|
+ if (m_notification) {
|
|
+ m_notification->setTitle(caption);
|
|
+ m_notification->setText(text);
|
|
+ } else {
|
|
+ m_notification = KNotification::event(KNotification::Notification, caption, text, QStringLiteral("klipper"));
|
|
+ }
|
|
+ }
|
|
+ );
|
|
}
|
|
|
|
Klipper::~Klipper()
|
|
diff --git a/klipper/klipper.h b/klipper/klipper.h
|
|
index f6e5da6..99c71f3 100644
|
|
--- a/klipper/klipper.h
|
|
+++ b/klipper/klipper.h
|
|
@@ -26,6 +26,7 @@
|
|
#include <QTime>
|
|
#include <QTimer>
|
|
#include <QClipboard>
|
|
+#include <QPointer>
|
|
|
|
#include "urlgrabber.h"
|
|
|
|
@@ -39,6 +40,7 @@ class QAction;
|
|
class QMenu;
|
|
class QMimeData;
|
|
class HistoryItem;
|
|
+class KNotification;
|
|
|
|
enum class KlipperMode {
|
|
Standalone,
|
|
@@ -207,6 +209,7 @@ private:
|
|
KActionCollection* m_collection;
|
|
KlipperMode m_mode;
|
|
QTimer *m_saveFileTimer = nullptr;
|
|
+ QPointer<KNotification> m_notification;
|
|
};
|
|
|
|
#endif
|
|
diff --git a/klipper/tray.cpp b/klipper/tray.cpp
|
|
index 48a9661..75fbe7f 100644
|
|
--- a/klipper/tray.cpp
|
|
+++ b/klipper/tray.cpp
|
|
@@ -23,7 +23,6 @@
|
|
#include "tray.h"
|
|
|
|
#include <KLocalizedString>
|
|
-#include <KNotification>
|
|
|
|
#include "klipper.h"
|
|
#include "history.h"
|
|
@@ -46,7 +45,6 @@ KlipperTray::KlipperTray()
|
|
setAssociatedWidget( m_klipper->popup() );
|
|
connect( m_klipper->history(), &History::changed, this, &KlipperTray::slotSetToolTipFromHistory);
|
|
slotSetToolTipFromHistory();
|
|
- connect(m_klipper, &Klipper::passivePopup, this, &KlipperTray::slotPassivePopup);
|
|
}
|
|
|
|
void KlipperTray::slotSetToolTipFromHistory()
|
|
@@ -64,15 +62,4 @@ void KlipperTray::slotSetToolTipFromHistory()
|
|
}
|
|
}
|
|
|
|
-void KlipperTray::slotPassivePopup(const QString& caption, const QString& text)
|
|
-{
|
|
- if (m_notification) {
|
|
- m_notification->setTitle(caption);
|
|
- m_notification->setText(text);
|
|
- } else {
|
|
- m_notification = KNotification::event(KNotification::Notification, caption, text,
|
|
- QIcon::fromTheme(QStringLiteral("klipper")).pixmap(QSize(16, 16)));
|
|
- }
|
|
-}
|
|
-
|
|
|
|
diff --git a/klipper/tray.h b/klipper/tray.h
|
|
index 388674c..d4b0716 100644
|
|
--- a/klipper/tray.h
|
|
+++ b/klipper/tray.h
|
|
@@ -20,11 +20,8 @@
|
|
#ifndef TRAY_H
|
|
#define TRAY_H
|
|
|
|
-#include <QPointer>
|
|
-
|
|
#include <KStatusNotifierItem>
|
|
|
|
-class KNotification;
|
|
class Klipper;
|
|
|
|
class KlipperTray : public KStatusNotifierItem
|
|
@@ -36,11 +33,9 @@ public:
|
|
|
|
public Q_SLOTS:
|
|
void slotSetToolTipFromHistory();
|
|
- void slotPassivePopup(const QString& caption, const QString& text);
|
|
|
|
private:
|
|
Klipper* m_klipper;
|
|
- QPointer<KNotification> m_notification;
|
|
};
|
|
|
|
#endif
|
|
--
|
|
2.7.4
|
|
|