diff --git a/klipper/CMakeLists.txt b/klipper/CMakeLists.txt --- a/klipper/CMakeLists.txt +++ b/klipper/CMakeLists.txt @@ -82,6 +82,7 @@ KF5::IconThemes KF5::KIOWidgets # PreviewJob KF5::Plasma + KF5::Notifications KF5::Service KF5::TextWidgets # KTextEdit KF5::WidgetsAddons # KMessageBox diff --git a/klipper/klipper.h b/klipper/klipper.h --- a/klipper/klipper.h +++ b/klipper/klipper.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "urlgrabber.h" @@ -39,6 +40,7 @@ class QMenu; class QMimeData; class HistoryItem; +class KNotification; enum class KlipperMode { Standalone, @@ -207,6 +209,7 @@ KActionCollection* m_collection; KlipperMode m_mode; QTimer *m_saveFileTimer = nullptr; + QPointer m_notification; }; #endif diff --git a/klipper/klipper.cpp b/klipper/klipper.cpp --- a/klipper/klipper.cpp +++ b/klipper/klipper.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -227,6 +228,17 @@ 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/tray.h b/klipper/tray.h --- a/klipper/tray.h +++ b/klipper/tray.h @@ -20,11 +20,8 @@ #ifndef TRAY_H #define TRAY_H -#include - #include -class KNotification; class Klipper; class KlipperTray : public KStatusNotifierItem @@ -36,11 +33,9 @@ public Q_SLOTS: void slotSetToolTipFromHistory(); - void slotPassivePopup(const QString& caption, const QString& text); private: Klipper* m_klipper; - QPointer m_notification; }; #endif diff --git a/klipper/tray.cpp b/klipper/tray.cpp --- a/klipper/tray.cpp +++ b/klipper/tray.cpp @@ -23,7 +23,6 @@ #include "tray.h" #include -#include #include "klipper.h" #include "history.h" @@ -46,7 +45,6 @@ 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::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))); - } -} -