[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:05:13 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=15ea504

The following commit has been merged in the master branch:
commit 15ea504468318ee12c93721dc9c4fe8452e7b039
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Tue Mar 1 00:55:28 2011 +0100

    Add status info to the AccountButton tooltip
---
 accountbutton.cpp | 37 ++++++++++++++++++++++++++++++++++---
 accountbutton.h   |  2 ++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/accountbutton.cpp b/accountbutton.cpp
index 024eca6..8b83f59 100644
--- a/accountbutton.cpp
+++ b/accountbutton.cpp
@@ -25,6 +25,8 @@
 #include <KIcon>
 #include <KLocale>
 
+#include <TelepathyQt4/PendingOperation>
+
 #include "accountbutton.h"
 
 static Tp::ConnectionPresenceType accountPresenceTypes[] = { Tp::ConnectionPresenceTypeAvailable, Tp::ConnectionPresenceTypeAway,
@@ -38,6 +40,7 @@ static const char *accountPresenceStatuses[] = { "available", "away", "brb", "bu
 AccountButton::AccountButton(const Tp::AccountPtr &account, QWidget* parent): QToolButton(parent)
 {
     m_account = account;
+    m_statusIndex = -1;
     
     QString iconPath = account->iconName();
     
@@ -57,7 +60,6 @@ AccountButton::AccountButton(const Tp::AccountPtr &account, QWidget* parent): QT
         setIcon(KIcon(pixmap));
     }
     
-    setToolTip(QString(account->displayName()));
     setMaximumWidth(24);
     
     setAutoRaise(true);
@@ -101,10 +103,21 @@ AccountButton::AccountButton(const Tp::AccountPtr &account, QWidget* parent): QT
     foreach(QAction *a, actions())
     {
         a->setCheckable(true);
+        
+        if(m_account->currentPresence().status() == QLatin1String(accountPresenceStatuses[a->data().toInt()])) {
+            a->setChecked(true);
+            m_statusIndex = a->data().toInt();
+        }
     }
     
     connect(this, SIGNAL(triggered(QAction*)),
             this, SLOT(setAccountStatus(QAction*)));
+    
+    if(m_statusIndex == -1) {
+        m_statusIndex = 7;
+    }
+    
+    updateToolTip();
 }
 
 void AccountButton::setAccountStatus(QAction *action)
@@ -112,11 +125,29 @@ void AccountButton::setAccountStatus(QAction *action)
     int statusIndex = action->data().toInt();
     Q_ASSERT(statusIndex >= 0 && statusIndex <= 7);
     
+    m_statusIndex = statusIndex;
+    
     Tp::SimplePresence presence;
     presence.type = accountPresenceTypes[statusIndex];
     presence.status = QLatin1String(accountPresenceStatuses[statusIndex]);
     
     Q_ASSERT(!m_account.isNull());
     
-    m_account->setRequestedPresence(presence);
-}
\ No newline at end of file
+    Tp::PendingOperation* presenceRequest = m_account->setRequestedPresence(presence);
+    
+    connect(presenceRequest, SIGNAL(finished(Tp::PendingOperation*)),
+            this, SLOT(updateToolTip()));
+}
+
+void AccountButton::updateToolTip()
+{
+    if(m_account->currentPresence().statusMessage().isEmpty()) {
+        setToolTip(QString("%1
%2").arg(m_account->displayName())
+                                    .arg(actions().value(m_statusIndex)->text()));
+    }
+    else {
+        setToolTip(QString("%1
%2
%3").arg(m_account->displayName())
+                                        .arg(actions().value(m_statusIndex)->text())
+                                        .arg(m_account->currentPresence().statusMessage()));
+    }
+}   
\ No newline at end of file
diff --git a/accountbutton.h b/accountbutton.h
index 3f590fe..e93fbef 100644
--- a/accountbutton.h
+++ b/accountbutton.h
@@ -37,9 +37,11 @@ public:
     
 public Q_SLOTS:
     void setAccountStatus(QAction *action);
+    void updateToolTip();
     
 private:
     Tp::AccountPtr m_account;
+    int            m_statusIndex;
 };
 
 #endif // TELEPATHY_ACCOUNTBUTTON_H

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list