[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:14:22 UTC 2016


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

The following commit has been merged in the master branch:
commit a83ba1a605b74826b13fe3aaa7254ef198e4be20
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Sat May 26 17:49:19 2012 +0200

    Change from Plasma::PopupApplet to Plasma::Applet and use Plasma::IconWidget for the icon
    
    This ensures proper icon painting when the plasmoid is put in panels
    
    Reviewed-by: David Edmundson
    REVIEW: 104675
    BUG: 292476
---
 presence/plasma-applet-ktp-presence.desktop |  2 +-
 presence/src/presence-applet.cpp            | 62 +++++++++++++++--------------
 presence/src/presence-applet.h              |  9 ++---
 3 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/presence/plasma-applet-ktp-presence.desktop b/presence/plasma-applet-ktp-presence.desktop
index 5fa128d..25292d0 100644
--- a/presence/plasma-applet-ktp-presence.desktop
+++ b/presence/plasma-applet-ktp-presence.desktop
@@ -30,7 +30,7 @@ Name[x-test]=xxInstant Messaging Presencexx
 Name[zh_CN]=即时通讯状态
 Name[zh_TW]=即時訊息呈現
 Type=Service
-ServiceTypes=Plasma/Applet,Plasma/PopupApplet
+ServiceTypes=Plasma/Applet
 Icon=user-online
 
 X-Plasma-DefaultSize=128,128
diff --git a/presence/src/presence-applet.cpp b/presence/src/presence-applet.cpp
index de3ae5c..2e0a7de 100644
--- a/presence/src/presence-applet.cpp
+++ b/presence/src/presence-applet.cpp
@@ -20,6 +20,7 @@
 #include "presenceapplet.h"
 
 #include <QDBusAbstractAdaptor>
+#include <QGraphicsLinearLayout>
 
 #include <KAction>
 #include <KActionMenu>
@@ -41,20 +42,32 @@
 #include <TelepathyQt/Account>
 
 TelepathyPresenceApplet::TelepathyPresenceApplet(QObject *parent, const QVariantList &args)
-    : Plasma::PopupApplet(parent, args),
+    : Plasma::Applet(parent, args),
       m_globalPresence(new KTp::GlobalPresence(this))
 {
     setupContextMenuActions();
 
-    resize(128, 128);
-    setAspectRatioMode(Plasma::KeepAspectRatio);
+    setAspectRatioMode(Plasma::ConstrainedSquare);
+    setMinimumSize(16, 16);
     setBackgroundHints(NoBackground);
+    resize(150, 150);
+
+    m_icon = new Plasma::IconWidget(this);
+    connect(m_icon, SIGNAL(clicked()), this, SLOT(startContactList()));
+    m_icon->setIcon(m_globalPresence->currentPresence().icon());
+
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
+    layout->setContentsMargins(2, 2, 2, 2);
+    layout->setSpacing(0);
+    layout->setOrientation(Qt::Horizontal);
+    layout->addItem(m_icon);
+    layout->setAlignment(m_icon, Qt::AlignCenter);
+    setLayout(layout);
 
     int iconSize = IconSize(KIconLoader::Small);
     setMinimumSize(QSize(iconSize, iconSize));
 
     connect(m_globalPresence, SIGNAL(currentPresenceChanged(KTp::Presence)), this, SLOT(onPresenceChanged(KTp::Presence)));
-    connect(this, SIGNAL(activate()), this, SLOT(onActivated()));
 
     // register plasmoid for tooltip
     Plasma::ToolTipManager::self()->registerWidget(this);
@@ -74,8 +87,6 @@ QList<QAction*> TelepathyPresenceApplet::contextualActions()
 
 void TelepathyPresenceApplet::init()
 {
-    Plasma::Applet::init();
-
     m_dbusExporter = new DBusExporter(this);
     QDBusConnection::sessionBus().registerObject("/PresenceAppletActive", this, QDBusConnection::ExportAdaptors);
     QDBusConnection::sessionBus().registerService("org.kde.Telepathy.PresenceAppletActive");
@@ -103,11 +114,6 @@ void TelepathyPresenceApplet::init()
     connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
 }
 
-void TelepathyPresenceApplet::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
-{
-    Plasma::Applet::paintInterface(p, option, contentsRect);
-}
-
 void TelepathyPresenceApplet::setupContextMenuActions()
 {
     KActionMenu *moreMenu = new KActionMenu(i18n("More"), this);
@@ -169,12 +175,6 @@ void TelepathyPresenceApplet::onAccountManagerReady(Tp::PendingOperation* op)
 
     // set the manager to the globalpresence
     m_globalPresence->setAccountManager(m_accountManager);
-    setPopupIcon(m_globalPresence->currentPresence().icon());
-}
-
-void TelepathyPresenceApplet::onActivated()
-{
-    startContactList();
 }
 
 void TelepathyPresenceApplet::startAccountManager()
@@ -187,40 +187,43 @@ void TelepathyPresenceApplet::startContactList()
     KToolInvocation::startServiceByDesktopName("ktp-contactlist");
 }
 
-void TelepathyPresenceApplet::onAddContactRequest() {
+void TelepathyPresenceApplet::onAddContactRequest()
+{
     QWeakPointer<AccountsModel> accountModel = new AccountsModel();
     accountModel.data()->setAccountManager(m_accountManager);
-    
+
     QWeakPointer<KTp::AddContactDialog> dialog = new KTp::AddContactDialog(accountModel.data(), 0);
-    if (dialog.data()->exec() == QDialog::Accepted) {
+    if (dialog.data()->exec() == QDialog::Accepted)
+    {
         Tp::AccountPtr account = dialog.data()->account();
         if (account.isNull()) {
             KMessageBox::error(dialog.data(),
                                i18n("Seems like you forgot to select an account. Also do not forget to connect it first."),
                                i18n("No Account Selected"));
-        }
-        else if (account->connection().isNull()) {
+        } else if (account->connection().isNull()) {
             KMessageBox::error(dialog.data(),
                                i18n("An error we did not anticipate just happened and so the contact could not be added. Sorry."),
                                i18n("Account Error"));
         } else {
             QStringList identifiers = QStringList() << dialog.data()->screenName();
-            Tp::PendingContacts* pendingContacts = account->connection()->contactManager()->contactsForIdentifiers(identifiers);
-            connect(pendingContacts, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAddContactRequestFoundContacts(Tp::PendingOperation*)));
+            Tp::PendingContacts *pendingContacts = account->connection()->contactManager()->contactsForIdentifiers(identifiers);
+            connect(pendingContacts, SIGNAL(finished(Tp::PendingOperation*)),
+                    this, SLOT(onAddContactRequestFoundContacts(Tp::PendingOperation*)));
         }
     }
+
     delete dialog.data();
     delete accountModel.data();
 }
 
-void TelepathyPresenceApplet::onAddContactRequestFoundContacts(Tp::PendingOperation *operation) {
+void TelepathyPresenceApplet::onAddContactRequestFoundContacts(Tp::PendingOperation *operation)
+{
     Tp::PendingContacts *pendingContacts = qobject_cast<Tp::PendingContacts*>(operation);
 
-    if (! pendingContacts->isError()) {
+    if (!pendingContacts->isError()) {
         //request subscription
         pendingContacts->manager()->requestPresenceSubscription(pendingContacts->contacts());
-    }
-    else {
+    } else {
         kDebug() << pendingContacts->errorName();
         kDebug() << pendingContacts->errorMessage();
     }
@@ -228,13 +231,12 @@ void TelepathyPresenceApplet::onAddContactRequestFoundContacts(Tp::PendingOperat
 
 void TelepathyPresenceApplet::onPresenceChanged(KTp::Presence presence)
 {
-    setPopupIcon(presence.icon());
+    m_icon->setIcon(presence.icon());
 }
 
 void TelepathyPresenceApplet::onPresenceActionClicked()
 {
     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());
 
     m_globalPresence->setPresence(p);
diff --git a/presence/src/presence-applet.h b/presence/src/presence-applet.h
index 4f1a2d5..0bf936f 100644
--- a/presence/src/presence-applet.h
+++ b/presence/src/presence-applet.h
@@ -20,8 +20,9 @@
 #ifndef KTP_PRESENCE_APPLET_H
 #define KTP_PRESENCE_APPLET_H
 
-#include <Plasma/PopupApplet>
+#include <Plasma/Applet>
 #include <Plasma/DeclarativeWidget>
+#include <Plasma/IconWidget>
 
 #include <TelepathyQt/AccountManager>
 #include <TelepathyQt/ContactManager>
@@ -42,7 +43,7 @@ class KConfigDialog;
 class QAction;
 class DBusExporter;
 
-class TelepathyPresenceApplet: public Plasma::PopupApplet
+class TelepathyPresenceApplet: public Plasma::Applet
 {
     Q_OBJECT
 
@@ -52,13 +53,10 @@ public:
 
     QList<QAction*> contextualActions();
     void init();
-    void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
 
 private Q_SLOTS:
     void onAccountManagerReady(Tp::PendingOperation *op);
 
-    /** called when plasmoid is clicked */
-    void onActivated();
     void onPresenceChanged(KTp::Presence presence);
     void onPresenceActionClicked();
     void toolTipAboutToShow();
@@ -74,6 +72,7 @@ private:
     void setupContextMenuActions();
 
     QList<QAction*>       m_contextActions;
+    Plasma::IconWidget   *m_icon;
 
     Tp::AccountManagerPtr m_accountManager;
     KTp::GlobalPresence  *m_globalPresence;

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list