[SCM] ktp-approver packaging branch, master, updated. debian/15.12.1-1-299-g62cbbd7
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 09:13:07 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-approver.git;a=commitdiff;h=8211b56
The following commit has been merged in the master branch:
commit 8211b568ae8039d7e0905b4abc0ef4659aed2797
Author: George Kiagiadakis <george.kiagiadakis at collabora.co.uk>
Date: Thu Jan 27 15:45:40 2011 +0200
Use only one notification and update the text in it, instead of spawning a new notification each time.
---
src/textchannelapprover.cpp | 46 +++++++++++++++++++--------------------------
src/textchannelapprover.h | 3 +--
2 files changed, 20 insertions(+), 29 deletions(-)
diff --git a/src/textchannelapprover.cpp b/src/textchannelapprover.cpp
index 9298c1d..0ec5ea8 100644
--- a/src/textchannelapprover.cpp
+++ b/src/textchannelapprover.cpp
@@ -46,11 +46,10 @@ TextChannelApprover::TextChannelApprover(const Tp::TextChannelPtr & channel, QOb
TextChannelApprover::~TextChannelApprover()
{
- //destroy the notifications
- Q_FOREACH(KNotification *notification, m_notifications) {
- notification->close();
+ //destroy the notification
+ if (m_notification) {
+ m_notification.data()->close();
}
- m_notifications.clear();
}
void TextChannelApprover::onMessageReceived(const Tp::ReceivedMessage & msg)
@@ -63,36 +62,29 @@ void TextChannelApprover::onMessageReceived(const Tp::ReceivedMessage & msg)
return;
}
- KNotification *notification = new KNotification("new_text_message");
- notification->setComponentData(TpKDEApproverFactory::componentData());
- notification->setText(msg.text());
+ if (!m_notification) {
+ m_notification = new KNotification("new_text_message");
+ m_notification.data()->setComponentData(TpKDEApproverFactory::componentData());
- if (sender) {
- notification->setTitle(sender->alias());
+ if (sender) {
+ m_notification.data()->setTitle(sender->alias());
- QPixmap pixmap;
- if (pixmap.load(sender->avatarData().fileName)) {
- notification->setPixmap(pixmap);
+ QPixmap pixmap;
+ if (pixmap.load(sender->avatarData().fileName)) {
+ m_notification.data()->setPixmap(pixmap);
+ }
+ } else {
+ m_notification.data()->setTitle(i18n("Incoming message"));
}
- } else {
- notification->setTitle(i18n("Incoming message"));
- }
-
- notification->setActions(QStringList() << i18n("Respond"));
- connect(notification, SIGNAL(activated()), SIGNAL(channelAccepted()));
-
- notification->sendEvent();
- m_notifications.insert(notification);
- connect(notification, SIGNAL(destroyed(QObject*)), SLOT(onNotificationDestroyed(QObject*)));
-}
+ m_notification.data()->setActions(QStringList() << i18n("Respond"));
+ connect(m_notification.data(), SIGNAL(activated()), SIGNAL(channelAccepted()));
+ }
-void TextChannelApprover::onNotificationDestroyed(QObject *notification)
-{
- m_notifications.remove(reinterpret_cast<KNotification*>(notification));
+ m_notification.data()->setText(msg.text());
+ m_notification.data()->sendEvent();
}
-
K_GLOBAL_STATIC(QWeakPointer<KStatusNotifierItem>, s_notifierItem)
//static
diff --git a/src/textchannelapprover.h b/src/textchannelapprover.h
index ef3a6a2..ce57c5b 100644
--- a/src/textchannelapprover.h
+++ b/src/textchannelapprover.h
@@ -36,13 +36,12 @@ public:
private Q_SLOTS:
void onMessageReceived(const Tp::ReceivedMessage & msg);
- void onNotificationDestroyed(QObject *notification);
private:
static QSharedPointer<KStatusNotifierItem> getNotifierItem();
void updateNotifierItemTooltip();
- QSet<KNotification*> m_notifications;
+ QWeakPointer<KNotification> m_notification;
QSharedPointer<KStatusNotifierItem> m_notifierItem;
friend class MessageReceivedContactUpgrader;
--
ktp-approver packaging
More information about the pkg-kde-commits
mailing list