[SCM] ktp-contact-applet packaging branch, master, updated. debian/15.12.1-1-966-gde83ac5
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:18:30 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=5b609fe
The following commit has been merged in the master branch:
commit 5b609fe8d5d14fd4fa17f3475d00deadea59dc98
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Thu Mar 21 11:02:20 2013 +0100
Open & close contact list when clicking the presence plasmoid
If the contact list is opened already, it will be given focus and made
an active window. If it's active window, it will close. If it's not
running, it will be started.
REVIEW: 109599
BUG: 294991
FIXED-IN: 0.6.0
---
presence/src/presence-applet.cpp | 67 +++++++++++++++++++++++++++++++++++++---
presence/src/presence-applet.h | 9 +++++-
2 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/presence/src/presence-applet.cpp b/presence/src/presence-applet.cpp
index e7f94cf..06b2291 100644
--- a/presence/src/presence-applet.cpp
+++ b/presence/src/presence-applet.cpp
@@ -59,8 +59,18 @@ TelepathyPresenceApplet::TelepathyPresenceApplet(QObject *parent, const QVariant
setBackgroundHints(NoBackground);
resize(150, 150);
+ m_contactListRunning = false;
+
+ //find out if contact list is already running
+ QDBusPendingCall async = QDBusConnection::sessionBus().interface()->asyncCall(QLatin1String("NameHasOwner"),
+ QLatin1String("org.kde.ktp-contactlist"));
+
+ QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this);
+ connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(serviceNameFetchFinished(QDBusPendingCallWatcher*)));
+
m_icon = new Plasma::IconWidget(this);
- connect(m_icon, SIGNAL(clicked()), this, SLOT(startContactList()));
+ connect(m_icon, SIGNAL(clicked()), this, SLOT(toggleContactList()));
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
layout->setContentsMargins(0,0,0,0);
@@ -130,7 +140,8 @@ void TelepathyPresenceApplet::init()
connect(m_accountManager.data(), SIGNAL(newAccount(Tp::AccountPtr)), SLOT(onAccountsChanged()));
connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
- connect(this, SIGNAL(activate()), SLOT(startContactList()));
+ connect(this, SIGNAL(activate()), this, SLOT(toggleContactList()));
+
}
KIcon TelepathyPresenceApplet::getThemedIcon(const QString &iconBaseName) const
@@ -185,7 +196,7 @@ void TelepathyPresenceApplet::setupContextMenuActions()
connect(goOfflineAction, SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
connect(showAccountManagerAction, SIGNAL(triggered()), this, SLOT(startAccountManager()));
- connect(showContactListAction, SIGNAL(triggered()), this, SLOT(startContactList()));
+ connect(showContactListAction, SIGNAL(triggered()), this, SLOT(toggleContactList()));
connect(addContactAction, SIGNAL(triggered()), this, SLOT(onAddContactRequest()));
connect(joinChatroomAction, SIGNAL(triggered()), this, SLOT(onJoinChatRoomRequest()));
if (makeCallAction) {
@@ -241,9 +252,19 @@ void TelepathyPresenceApplet::startAccountManager()
KToolInvocation::startServiceByDesktopName("kcm_ktp_accounts");
}
-void TelepathyPresenceApplet::startContactList()
+void TelepathyPresenceApplet::toggleContactList()
{
- KToolInvocation::startServiceByDesktopName("ktp-contactlist");
+ if (!m_contactListRunning) {
+ KToolInvocation::startServiceByDesktopName(QLatin1String("ktp-contactlist"));
+ } else {
+ //contact list is registered, call toggleWindowVisibility in contact list
+ QDBusMessage methodCall = QDBusMessage::createMethodCall(QLatin1String("org.kde.ktp-contactlist"),
+ QLatin1String("/ktp_contactlist/MainWindow"),
+ QLatin1String("org.kde.KTp.ContactList"),
+ QLatin1String("toggleWindowVisibility"));
+
+ QDBusConnection::sessionBus().asyncCall(methodCall);
+ }
}
void TelepathyPresenceApplet::onAddContactRequest()
@@ -340,6 +361,42 @@ void TelepathyPresenceApplet::toolTipHidden()
Plasma::ToolTipManager::self()->clearContent(this);
}
+void TelepathyPresenceApplet::serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher)
+{
+ QDBusPendingReply<bool> reply = *callWatcher;
+ if (reply.isError()) {
+ kWarning() << reply.error();
+ return;
+ }
+
+ m_contactListRunning = reply.value();
+
+ callWatcher->deleteLater();
+
+ //start watching for contact list appearing on the bus
+ m_contactListWatcher = new QDBusServiceWatcher(QLatin1String("org.kde.ktp-contactlist"),
+ QDBusConnection::sessionBus(),
+ QDBusServiceWatcher::WatchForRegistration
+ | QDBusServiceWatcher::WatchForUnregistration,
+ this);
+
+ connect(m_contactListWatcher, SIGNAL(serviceRegistered(QString)),
+ this, SLOT(contactListServiceRegistered()));
+
+ connect(m_contactListWatcher, SIGNAL(serviceUnregistered(QString)),
+ this, SLOT(contactListServiceUnregistered()));
+}
+
+void TelepathyPresenceApplet::contactListServiceRegistered()
+{
+ m_contactListRunning = true;
+}
+
+void TelepathyPresenceApplet::contactListServiceUnregistered()
+{
+ m_contactListRunning = false;
+}
+
#include "presence-applet.moc"
// This is the command that links your applet to the .desktop file
diff --git a/presence/src/presence-applet.h b/presence/src/presence-applet.h
index f4889d6..d55d889 100644
--- a/presence/src/presence-applet.h
+++ b/presence/src/presence-applet.h
@@ -66,10 +66,14 @@ private Q_SLOTS:
void toolTipHidden();
void startAccountManager();
- void startContactList();
+ void toggleContactList();
void onAddContactRequest();
void onMakeCallRequest();
+ void contactListServiceRegistered();
+ void contactListServiceUnregistered();
+ void serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher);
+
private:
/** used to get the correct icon from either the Plasma theme or the Oxygen icon set */
@@ -86,6 +90,9 @@ private:
Tp::AccountManagerPtr m_accountManager;
KTp::GlobalPresence *m_globalPresence;
+
+ QDBusServiceWatcher *m_contactListWatcher;
+ bool m_contactListRunning;
};
#endif // KTP_PRESENCE_APPLET_H
--
ktp-contact-applet packaging
More information about the pkg-kde-commits
mailing list