[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:12:09 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=b2fa669

The following commit has been merged in the master branch:
commit b2fa669013ba31bd2717858cb0fadf991ef3edca
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Tue Dec 13 20:33:27 2011 +0100

    Improvements
---
 presence/CMakeLists.txt          |   1 -
 presence/src/presence-applet.cpp | 112 +++++++++++++--------------------------
 presence/src/presence-applet.h   |  11 ++--
 3 files changed, 41 insertions(+), 83 deletions(-)

diff --git a/presence/CMakeLists.txt b/presence/CMakeLists.txt
index 58f759e..9782ec5 100644
--- a/presence/CMakeLists.txt
+++ b/presence/CMakeLists.txt
@@ -43,7 +43,6 @@ target_link_libraries(telepathy-kde-presence-applet
                         ${KDE4_KDEUI_LIBS}
                         ${TELEPATHY_QT4_LIBRARIES}
                         ${KTELEPATHY_LIBRARIES}
-                        ${KTELEPATHY_MODELS_LIBRARIES}
                      )
 
 install(TARGETS telepathy-kde-presence-applet DESTINATION ${PLUGIN_INSTALL_DIR})
diff --git a/presence/src/presence-applet.cpp b/presence/src/presence-applet.cpp
index 047b2f5..0a9a675 100644
--- a/presence/src/presence-applet.cpp
+++ b/presence/src/presence-applet.cpp
@@ -25,14 +25,12 @@
 #include <KUser>
 
 #include <KTelepathy/global-presence.h>
-#include <KTelepathy/presence.h>
 
 #include <Plasma/ToolTipManager>
 
 #include <TelepathyQt/PendingOperation>
 #include <TelepathyQt/PendingReady>
 
-
 TelepathyPresenceApplet::TelepathyPresenceApplet(QObject* parent, const QVariantList& args)
     : Plasma::PopupApplet(parent, args)
     , m_globalPresence(new KTp::GlobalPresence(this))
@@ -47,7 +45,7 @@ TelepathyPresenceApplet::TelepathyPresenceApplet(QObject* parent, const QVariant
     int iconSize = IconSize(KIconLoader::Small);
     setMinimumSize(QSize(iconSize, iconSize));
 
-    connect(m_globalPresence, SIGNAL(currentPresenceChanged(Tp::Presence)), this, SLOT(onPresenceChanged(Tp::Presence)));
+    connect(m_globalPresence, SIGNAL(currentPresenceChanged(KTp::Presence)), this, SLOT(onPresenceChanged(KTp::Presence)));
 
     // register plasmoid for tooltip
     Plasma::ToolTipManager::self()->registerWidget(this);
@@ -87,23 +85,14 @@ void TelepathyPresenceApplet::setupAccountManager()
 
     Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
                                                                                Tp::Features() << Tp::Connection::FeatureCore
-                                                                               << Tp::Connection::FeatureRosterGroups
-                                                                               << Tp::Connection::FeatureRoster
                                                                                << Tp::Connection::FeatureSelfContact);
 
-    Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features()
-    << Tp::Contact::FeatureAlias
-    << Tp::Contact::FeatureAvatarData
-    << Tp::Contact::FeatureSimplePresence
-    << Tp::Contact::FeatureCapabilities);
-
     Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
 
     m_accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus(),
                                                   accountFactory,
                                                   connectionFactory,
-                                                  channelFactory,
-                                                  contactFactory);
+                                                  channelFactory);
 
     connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
 }
@@ -120,17 +109,24 @@ void TelepathyPresenceApplet::setupContextMenuActions()
     KAction *goHiddenAction = new KAction(KIcon("user-invisible"), i18n("Invisible"), this);
     KAction *goOfflineAction = new KAction(KIcon("user-offline"), i18n("Offline"), this);
 
+    goOnlineAction->setData(QVariant::fromValue(KTp::Presence(Tp::Presence::available())));
+    goBusyAction->setData(QVariant::fromValue(KTp::Presence(Tp::Presence::busy())));
+    goAwayAction->setData(QVariant::fromValue(KTp::Presence(Tp::Presence::away())));
+    goExtendedAwayAction->setData(QVariant::fromValue(KTp::Presence(Tp::Presence::xa())));
+    goHiddenAction->setData(QVariant::fromValue(KTp::Presence(Tp::Presence::hidden())));
+    goOfflineAction->setData(QVariant::fromValue(KTp::Presence(Tp::Presence::offline())));
+
     // application actions
     KAction *showAccountManagerAction = new KAction(KIcon("telepathy-kde"), i18n("Account Manager"), this);
     KAction *showContactListAction = new KAction(KIcon("meeting-attending"), i18n("Contact List"), this);
 
     // connect actions
-    connect(goOnlineAction, SIGNAL(triggered()), this, SLOT(setPresenceOnline()));
-    connect(goBusyAction, SIGNAL(triggered()), this, SLOT(setPresenceBusy()));
-    connect(goAwayAction, SIGNAL(triggered()), this, SLOT(setPresenceAway()));
-    connect(goExtendedAwayAction, SIGNAL(triggered()), this, SLOT(setPresenceXa()));
-    connect(goHiddenAction, SIGNAL(triggered()), this, SLOT(setPresenceHidden()));
-    connect(goOfflineAction, SIGNAL(triggered()), this, SLOT(setPresenceOffline()));
+    connect(goOnlineAction,       SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
+    connect(goBusyAction,         SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
+    connect(goAwayAction,         SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
+    connect(goExtendedAwayAction, SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
+    connect(goHiddenAction,       SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
+    connect(goOfflineAction,      SIGNAL(triggered()), this, SLOT(onPresenceActionClicked()));
 
     connect(showAccountManagerAction, SIGNAL(triggered()), this, SLOT(startAccountManager()));
     connect(showContactListAction, SIGNAL(triggered()), this, SLOT(startContactList()));
@@ -141,11 +137,10 @@ void TelepathyPresenceApplet::setupContextMenuActions()
     m_contextActions.append(goExtendedAwayAction);
     m_contextActions.append(goHiddenAction);
     m_contextActions.append(goOfflineAction);
-    m_contextActions.append(moreMenu->addSeparator());
 
-    moreMenu->addAction(showAccountManagerAction);
-    moreMenu->addAction(showContactListAction);
-    m_contextActions.append(moreMenu);
+    m_contextActions.append(moreMenu->addSeparator());
+    m_contextActions.append(showAccountManagerAction);
+    m_contextActions.append(showContactListAction);
 
     m_contextActions.append(moreMenu->addSeparator());
 }
@@ -159,57 +154,22 @@ void TelepathyPresenceApplet::onAccountManagerReady(Tp::PendingOperation* op)
 
     // set the manager to the globalpresence
     m_globalPresence->setAccountManager(m_accountManager);
+    setPopupIcon(m_globalPresence->currentPresence().icon());
 }
 
-void TelepathyPresenceApplet::onPresenceChanged(Tp::Presence presence)
-{
-    QString presenceStr = presence.status();
-
-    if (presenceStr == "available") {
-        setPopupIcon("user-online");
-    } else if (presenceStr == "busy" || presenceStr == "dnd") {
-        setPopupIcon("user-busy");
-    } else if (presenceStr == "away" || presenceStr == "brb") {
-        setPopupIcon("user-away");
-    } else if (presenceStr == "xa") {
-        setPopupIcon("user-away-extended");
-    } else if (presenceStr == "hidden") {
-        setPopupIcon("user-invisible");
-    } else if (presenceStr == "offline") {
-        setPopupIcon("user-offline");
-    } else {
-        setPopupIcon("user-offline");
-    }
-}
-
-void TelepathyPresenceApplet::setPresenceAway()
+void TelepathyPresenceApplet::onPresenceChanged(KTp::Presence presence)
 {
-    m_globalPresence->setPresence(Tp::Presence::away(m_globalPresence->currentPresence().statusMessage()));
+    setPopupIcon(presence.icon());
 }
 
-void TelepathyPresenceApplet::setPresenceBusy()
+void TelepathyPresenceApplet::onPresenceActionClicked()
 {
-    m_globalPresence->setPresence(Tp::Presence::busy(m_globalPresence->currentPresence().statusMessage()));
-}
+    KTp::Presence p = qobject_cast<KAction*>(sender())->data().value<KTp::Presence>();
+    //TODO: lobby for the setStatusMessage() in tp-qt4
+    p.setStatus(p.type(), p.status(), m_globalPresence->currentPresence().statusMessage());
 
-void TelepathyPresenceApplet::setPresenceHidden()
-{
-    m_globalPresence->setPresence(Tp::Presence::hidden(m_globalPresence->currentPresence().statusMessage()));
-}
-
-void TelepathyPresenceApplet::setPresenceOffline()
-{
-    m_globalPresence->setPresence(Tp::Presence::offline(m_globalPresence->currentPresence().statusMessage()));
-}
-
-void TelepathyPresenceApplet::setPresenceOnline()
-{
-    m_globalPresence->setPresence(Tp::Presence::available(m_globalPresence->currentPresence().statusMessage()));
-}
-
-void TelepathyPresenceApplet::setPresenceXa()
-{
-    m_globalPresence->setPresence(Tp::Presence::xa(m_globalPresence->currentPresence().statusMessage()));
+    m_globalPresence->setPresence(p);
+    setPopupIcon(p.icon());
 }
 
 void TelepathyPresenceApplet::startAccountManager() const
@@ -227,13 +187,19 @@ void TelepathyPresenceApplet::toolTipAboutToShow()
     Plasma::ToolTipContent content;
     KUser user;
 
-    QString presenceMsg("\"");
-    presenceMsg.append(m_globalPresence->currentPresence().statusMessage());
-    presenceMsg.append("\"");
+    QString presenceMsg = QString(m_globalPresence->currentPresence().statusMessage());
 
     content.setImage(KIcon("telepathy-kde"));
     content.setMainText(user.loginName());
-    content.setSubText(presenceMsg);
+
+    if (m_globalPresence->isChangingPresence()) {
+        content.setSubText(i18n("Connecting..."));
+    } else if (!presenceMsg.isEmpty() && !m_globalPresence->isChangingPresence()) {
+        content.setSubText(presenceMsg);
+    } else if (presenceMsg.isEmpty() && !m_globalPresence->isChangingPresence()) {
+        content.setSubText(m_globalPresence->currentPresence().displayString());
+    }
+
     Plasma::ToolTipManager::self()->setContent(this, content);
 }
 
@@ -242,9 +208,5 @@ void TelepathyPresenceApplet::toolTipHidden()
     Plasma::ToolTipManager::self()->clearContent(this);
 }
 
-
-
 // This is the command that links your applet to the .desktop file
 K_EXPORT_PLASMA_APPLET(telepathy-kde-presence-applet, TelepathyPresenceApplet)
-
-
diff --git a/presence/src/presence-applet.h b/presence/src/presence-applet.h
index 7c5b311..423f0b5 100644
--- a/presence/src/presence-applet.h
+++ b/presence/src/presence-applet.h
@@ -26,6 +26,8 @@
 #include <TelepathyQt/AccountManager>
 #include <TelepathyQt/Presence>
 
+#include <KTelepathy/presence.h>
+
 namespace KTp {
     class GlobalPresence;
 }
@@ -55,13 +57,8 @@ public:
 
 private Q_SLOTS:
     void onAccountManagerReady(Tp::PendingOperation *op);
-    void onPresenceChanged(Tp::Presence presence);
-    void setPresenceAway();
-    void setPresenceBusy();
-    void setPresenceHidden();
-    void setPresenceOffline();
-    void setPresenceOnline();
-    void setPresenceXa();
+    void onPresenceChanged(KTp::Presence presence);
+    void onPresenceActionClicked();
     void startAccountManager() const;
     void startContactList() const;
     void toolTipAboutToShow();

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list