[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:10:55 UTC 2016


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

The following commit has been merged in the master branch:
commit 99f81b5bf9f6030c52903b0fde26b1dc912609c0
Author: Dominik Cermak <d.cermak at arcor.de>
Date:   Sun Jul 15 22:19:59 2012 +0200

    Show the 'phone' client type in contact list
    
    This adds a phone icon left of the presence icon for contact that are
    online using a mobile phone.
    
    BUG: 302963
    FIXED-IN: 0.5
    REVIEW: 105514
---
 contact-delegate-compact.cpp | 24 +++++++++++++++++++++---
 contact-delegate.cpp         | 24 +++++++++++++++++++++---
 main-widget.cpp              |  3 ++-
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/contact-delegate-compact.cpp b/contact-delegate-compact.cpp
index 91f3497..4a4c1a5 100644
--- a/contact-delegate-compact.cpp
+++ b/contact-delegate-compact.cpp
@@ -2,6 +2,7 @@
  * Contact Delegate - compact version
  *
  * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ * Copyright (C) 2012 Dominik Cermak <d.cermak at arcor.de>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,6 +44,7 @@
 const int SPACING = 4;
 const int AVATAR_SIZE = 22;
 const int PRESENCE_ICON_SIZE = 16;
+const int CLIENT_TYPE_ICON_SIZE = 16;
 const int ACCOUNT_ICON_SIZE = 13;
 
 ContactDelegateCompact::ContactDelegateCompact(QObject * parent)
@@ -85,15 +87,31 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
 
     KTp::Presence presence = index.data(AccountsModel::PresenceRole).value<KTp::Presence>();
 
+    // This value is used to set the correct width for the username and the presence message.
+    int rightIconsWidth = PRESENCE_ICON_SIZE + SPACING;
+
     QPixmap icon = presence.icon().pixmap(KIconLoader::SizeSmallMedium);
 
     QRect statusIconRect = optV4.rect;
     statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
-    statusIconRect.moveTo(QPoint(optV4.rect.right() - PRESENCE_ICON_SIZE - SPACING,
+    statusIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
                                  optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
 
     painter->drawPixmap(statusIconRect, icon);
 
+    // Right now we only check for 'phone', as that's the most interesting type.
+    if (index.data(AccountsModel::ClientTypesRole).toStringList().contains(QLatin1String("phone"))) {
+        // Additional space is needed for the icons, don't add too much spacing between the two icons
+        rightIconsWidth += CLIENT_TYPE_ICON_SIZE + (SPACING / 2);
+
+        QPixmap phone = QIcon::fromTheme("phone").pixmap(CLIENT_TYPE_ICON_SIZE);
+        QRect phoneIconRect = optV4.rect;
+        phoneIconRect.setSize(QSize(CLIENT_TYPE_ICON_SIZE, CLIENT_TYPE_ICON_SIZE));
+        phoneIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
+                                    optV4.rect.top() + (optV4.rect.height() - CLIENT_TYPE_ICON_SIZE) / 2));
+        painter->drawPixmap(phoneIconRect, phone);
+    }
+
     QFont nameFont = KGlobalSettings::generalFont();
 
     const QFontMetrics nameFontMetrics(nameFont);
@@ -103,14 +121,14 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
     QRect userNameRect = optV4.rect;
     userNameRect.setX(iconRect.x() + iconRect.width() + SPACING * 2);
     userNameRect.setY(userNameRect.y() + (userNameRect.height()/2 - nameFontMetrics.height()/2));
-    userNameRect.setWidth(userNameRect.width() - PRESENCE_ICON_SIZE - SPACING);
+    userNameRect.setWidth(userNameRect.width() - rightIconsWidth);
 
     painter->drawText(userNameRect,
                       nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
 
     QRect presenceMessageRect = optV4.rect;
     presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + SPACING * 2);
-    presenceMessageRect.setWidth(optV4.rect.width() - presenceMessageRect.x() - PRESENCE_ICON_SIZE - SPACING);
+    presenceMessageRect.setWidth(optV4.rect.width() - presenceMessageRect.x() - rightIconsWidth);
     presenceMessageRect.setY(presenceMessageRect.y() + (presenceMessageRect.height()/2 - nameFontMetrics.height()/2));
 
     QPen presenceMessagePen = painter->pen();
diff --git a/contact-delegate.cpp b/contact-delegate.cpp
index 2b8a863..af77d0e 100644
--- a/contact-delegate.cpp
+++ b/contact-delegate.cpp
@@ -4,6 +4,7 @@
  * Copyright (C) 2010-2011 Collabora Ltd. <info at collabora.co.uk>
  *   @Author Dario Freddi <dario.freddi at collabora.co.uk>
  * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ * Copyright (C) 2012 Dominik Cermak <d.cermak at arcor.de>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,6 +44,7 @@
 const int SPACING = 4;
 const int AVATAR_SIZE = 32;
 const int PRESENCE_ICON_SIZE = 22;
+const int CLIENT_TYPE_ICON_SIZE = 22;
 const int ACCOUNT_ICON_SIZE = 13;
 
 ContactDelegate::ContactDelegate(QObject * parent)
@@ -99,19 +101,35 @@ void ContactDelegate::paintContact(QPainter *painter, const QStyleOptionViewItem
 
     KTp::Presence presence = index.data(AccountsModel::PresenceRole).value<KTp::Presence>();
 
+    // This value is used to set the correct width for the username and the presence message.
+    int rightIconsWidth = PRESENCE_ICON_SIZE + SPACING;
+
     QPixmap icon = presence.icon().pixmap(KIconLoader::SizeSmallMedium);
 
     QRect statusIconRect = optV4.rect;
     statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
-    statusIconRect.moveTo(QPoint(optV4.rect.right() - PRESENCE_ICON_SIZE - SPACING,
+    statusIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
                                  optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
 
     painter->drawPixmap(statusIconRect, icon);
 
+    // Right now we only check for 'phone', as that's the most interesting type.
+    if (index.data(AccountsModel::ClientTypesRole).toStringList().contains(QLatin1String("phone"))) {
+        // Additional space is needed for the icons, don't add too much spacing between the two icons
+        rightIconsWidth += CLIENT_TYPE_ICON_SIZE + (SPACING / 2);
+
+        QPixmap phone = QIcon::fromTheme("phone").pixmap(CLIENT_TYPE_ICON_SIZE);
+        QRect phoneIconRect = optV4.rect;
+        phoneIconRect.setSize(QSize(CLIENT_TYPE_ICON_SIZE, CLIENT_TYPE_ICON_SIZE));
+        phoneIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
+                                    optV4.rect.top() + (optV4.rect.height() - CLIENT_TYPE_ICON_SIZE) / 2));
+        painter->drawPixmap(phoneIconRect, phone);
+    }
+
     QRect userNameRect = optV4.rect;
     userNameRect.setX(iconRect.x() + iconRect.width() + SPACING);
     userNameRect.setY(userNameRect.y() + 2);
-    userNameRect.setWidth(userNameRect.width() - PRESENCE_ICON_SIZE - SPACING);
+    userNameRect.setWidth(userNameRect.width() - rightIconsWidth);
 
     const QFontMetrics nameFontMetrics(KGlobalSettings::generalFont());
 
@@ -123,7 +141,7 @@ void ContactDelegate::paintContact(QPainter *painter, const QStyleOptionViewItem
     QRect statusMsgRect = optV4.rect;
     statusMsgRect.setX(iconRect.x() + iconRect.width() + SPACING);
     statusMsgRect.setY(userNameRect.bottom() - statusFontMetrics.height() - 4);
-    statusMsgRect.setWidth(statusMsgRect.width() - PRESENCE_ICON_SIZE - SPACING);
+    statusMsgRect.setWidth(statusMsgRect.width() - rightIconsWidth);
 
     QColor fadingColor(m_palette->color(QPalette::Disabled, QPalette::Text));
 
diff --git a/main-widget.cpp b/main-widget.cpp
index ac4fd41..79869b8 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -111,7 +111,8 @@ MainWidget::MainWidget(QWidget *parent)
     Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features()  << Tp::Contact::FeatureAlias
                                                                       << Tp::Contact::FeatureAvatarData
                                                                       << Tp::Contact::FeatureSimplePresence
-                                                                      << Tp::Contact::FeatureCapabilities);
+                                                                      << Tp::Contact::FeatureCapabilities
+                                                                      << Tp::Contact::FeatureClientTypes);
 
     Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
 

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list