[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:04:59 UTC 2016


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

The following commit has been merged in the master branch:
commit dcf67f8e4fc7c1b8857ba5b17ea800b410c7311d
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Thu Feb 10 22:31:52 2011 +0100

    Created an AccountButton, which serves as a button (QToolButton) with integrated pop-up menu to set account presence for one account, which this button represents. Can be simply reused elsewhere.
---
 accountbutton.cpp                        | 121 +++++++++++++++++++++++++++++++
 contactsmodelfilter.h => accountbutton.h |  34 +++++----
 2 files changed, 142 insertions(+), 13 deletions(-)

diff --git a/accountbutton.cpp b/accountbutton.cpp
new file mode 100644
index 0000000..4a34694
--- /dev/null
+++ b/accountbutton.cpp
@@ -0,0 +1,121 @@
+/*
+    Tool button which controls account's presence
+    Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include <QAction>
+#include <QPainter>
+#include <QPixmap>
+
+#include <KIcon>
+#include <KLocale>
+
+#include "accountbutton.h"
+
+static Tp::ConnectionPresenceType accountPresenceTypes[] = { Tp::ConnectionPresenceTypeAvailable, Tp::ConnectionPresenceTypeAway,
+Tp::ConnectionPresenceTypeAway, Tp::ConnectionPresenceTypeBusy,
+Tp::ConnectionPresenceTypeBusy, Tp::ConnectionPresenceTypeExtendedAway,
+Tp::ConnectionPresenceTypeHidden, Tp::ConnectionPresenceTypeOffline };
+
+static const char *accountPresenceStatuses[] = { "available", "away", "brb", "busy",
+"dnd", "xa", "hidden", "offline" };
+
+AccountButton::AccountButton(const Tp::AccountPtr &account, QWidget* parent): QToolButton(parent)
+{
+    m_account = account;
+    
+    QString iconPath = account->iconName();
+    
+    //if the icon has not been set, we use the protocol icon    
+    if(iconPath.isEmpty()) {
+        iconPath = QString("im-%1").arg(account->protocolName());
+    }
+    
+    setIcon(KIcon(iconPath));
+    
+    if(!account->isValid()) {
+        //we paint a warning symbol in the right-bottom corner
+        QPixmap pixmap = icon().pixmap(32, 32);
+        QPainter painter(&pixmap);
+        KIcon("dialog-error").paint(&painter, 15, 15, 16, 16);
+        
+        setIcon(KIcon(pixmap));
+    }
+    
+    setToolTip(QString(account->displayName()));
+    setMaximumWidth(24);
+    
+    setAutoRaise(true);
+    setPopupMode(QToolButton::InstantPopup);
+    setArrowType(Qt::NoArrow);
+    
+    QActionGroup *presenceActions = new QActionGroup(this);
+    presenceActions->setExclusive(true);
+    
+    QAction *onlineAction =     new QAction(KIcon("user-online"), i18nc("@action:inmenu", "Available"), this);
+    QAction *awayAction =       new QAction(KIcon("user-away"), i18nc("@action:inmenu", "Away"), this);
+    QAction *brbAction =        new QAction(KIcon("user-busy"), i18nc("@action:inmenu", "Be right back"), this);
+    QAction *busyAction =       new QAction(KIcon("user-busy"), i18nc("@action:inmenu", "Busy"), this);
+    QAction *dndAction =        new QAction(KIcon("user-busy"), i18nc("@action:inmenu", "Do not disturb"), this);
+    QAction *xaAction =         new QAction(KIcon("user-away-extended"), i18nc("@action:inmenu", "Extended Away"), this);
+    QAction *invisibleAction =  new QAction(KIcon("user-invisible"), i18nc("@action:inmenu", "Invisible"), this);
+    QAction *offlineAction =    new QAction(KIcon("user-offline"), i18nc("@action:inmenu", "Offline"), this);
+    
+    //let's set the indexes as data(), so we don't have to rely on putting the actions into indexed list/menu/etc
+    onlineAction->setData(0);
+    awayAction->setData(1);
+    brbAction->setData(2);
+    busyAction->setData(3);
+    dndAction->setData(4);
+    xaAction->setData(5);
+    invisibleAction->setData(6);
+    offlineAction->setData(7);
+    
+    presenceActions->addAction(onlineAction);
+    presenceActions->addAction(awayAction);
+    presenceActions->addAction(brbAction);
+    presenceActions->addAction(busyAction);
+    presenceActions->addAction(dndAction);
+    presenceActions->addAction(xaAction);
+    presenceActions->addAction(invisibleAction);
+    presenceActions->addAction(offlineAction);
+    
+    addActions(presenceActions->actions());
+    
+    //make all the actions checkable
+    foreach(QAction *a, actions())
+    {
+        a->setCheckable(true);
+    }
+    
+    connect(this, SIGNAL(triggered(QAction*)),
+            this, SLOT(setAccountStatus(QAction*)));
+}
+
+void AccountButton::setAccountStatus(QAction *action)
+{
+    int statusIndex = action->data().toInt();
+    Q_ASSERT(statusIndex >= 0 && statusIndex <= 7);
+    
+    Tp::SimplePresence presence;
+    presence.type = accountPresenceTypes[statusIndex];
+    presence.status = QLatin1String(accountPresenceStatuses[statusIndex]);
+    
+    Q_ASSERT(!m_account.isNull());
+    
+    Tp::PendingOperation* presenceRequest = m_account->setRequestedPresence(presence);
+}
\ No newline at end of file
diff --git a/contactsmodelfilter.h b/accountbutton.h
similarity index 56%
copy from contactsmodelfilter.h
copy to accountbutton.h
index a1a41e4..531e4fd 100644
--- a/contactsmodelfilter.h
+++ b/accountbutton.h
@@ -1,6 +1,6 @@
 /*
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 2011  Martin Klapetek <email>
+    Tool button which controls account's presence
+    Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -18,22 +18,30 @@
 */
 
 
-#ifndef CONTACTSMODELFILTER_H
-#define CONTACTSMODELFILTER_H
+#ifndef ACCOUNTBUTTON_H
+#define ACCOUNTBUTTON_H
 
-#include <QSortFilterProxyModel>
+#include <QToolButton>
+#include <QLineEdit>
 
+#include <TelepathyQt4/Account>
 
-class ContactsModelFilter : public QSortFilterProxyModel
+class QAction;
+
+class AccountButton : public QToolButton
 {
     Q_OBJECT
-
-protected:
-    virtual bool filterAcceptsRow ( int source_row, const QModelIndex& source_parent ) const;
-
+    
 public:
-    ContactsModelFilter(QObject *parent = 0);
-    virtual ~ContactsModelFilter();
+    AccountButton(const Tp::AccountPtr &account, QWidget *parent = 0);
+    
+public Q_SLOTS:
+    void setAccountStatus(QAction *action);
+    void onAccountStatusHover(QAction *action);
+    void showStatusMessageEditLine();
+    
+private:
+    Tp::AccountPtr m_account;
 };
 
-#endif // CONTACTSMODELFILTER_H
+#endif // ACCOUNTBUTTON_H

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list