[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:10:47 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=817a673
The following commit has been merged in the master branch:
commit 817a673ea5d38d2e327bbb309f16c57c80d9e122
Author: Abner Silva <abner.silva at kdemail.net>
Date: Tue Jul 21 22:56:02 2009 +0000
Big plasmoid refactoring.
- Code refactoring.
- Using new UI layout provided by AccountWidget.
- Handling Presence, Avatar, Alias and AccountName.
- Master presence removed for now. (TODO)
- Still have a lot to be done.
svn path=/trunk/playground/base/plasma/applets/presence/; revision=1000749
---
presence/src/presence.cpp | 241 ++++++++++++----------------------------------
presence/src/presence.h | 41 +++-----
2 files changed, 71 insertions(+), 211 deletions(-)
diff --git a/presence/src/presence.cpp b/presence/src/presence.cpp
index b2f8d15..b93099d 100644
--- a/presence/src/presence.cpp
+++ b/presence/src/presence.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2008 George Goldberg <grundleborg at googlemail.com>
* Copyright (C) 2009 Collabora Ltd <http://www.collabora.co.uk>
* Copyright (C) 2009 Andre Moreira Magalhaes <andrunko at gmail.com>
+ * Copyright (C) 2009 Abner Silva <abner.silva at kdemail.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,50 +20,43 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+// Own
#include "presence.h"
+#include "accountwidget.h"
-#include "presenceitemdelegate.h"
-
-#include <Plasma/Dialog>
-#include <Plasma/IconWidget>
+// Plasma
#include <Plasma/Theme>
+// Kde
#include <KColorScheme>
#include <KDebug>
-#include <KIcon>
-
-#include <QtCore/QList>
-#include <QtCore/QSharedPointer>
+//Qt
#include <QtGui/QGraphicsLinearLayout>
-#include <QtGui/QGraphicsProxyWidget>
-#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
-#include <QtGui/QTreeView>
-#include <QtGui/QVBoxLayout>
+
+using namespace Plasma;
PresenceApplet::PresenceApplet(QObject *parent, const QVariantList &args)
: Plasma::PopupApplet(parent, args),
m_engine(0),
- m_icon(0),
- m_colorScheme(0),
- m_masterStatusLayout(0),
- m_masterIconLabel(0),
- m_masterStatusMessageLabel(0),
- m_accountsModel(0),
- m_accountsView(0),
- m_layout(0),
m_widget(0),
- m_userSet(false)
+ m_layout(0),
+ m_colorScheme(0)
{
+ KGlobal::locale()->insertCatalog("plasma_applet_presence");
setBackgroundHints(StandardBackground);
+ setAspectRatioMode(IgnoreAspectRatio);
+ //setHasConfigurationInterface(true);
+ setPassivePopup(false);
+
+ setPopupIcon("user-offline");
+
+ (void) graphicsWidget();
}
PresenceApplet::~PresenceApplet()
{
- if (m_widget) {
- delete m_widget;
- }
delete m_colorScheme;
}
@@ -75,34 +69,12 @@ void PresenceApplet::init()
KColorScheme::View,
Plasma::Theme::defaultTheme()->colorScheme());
- // Set up the icon.
- Q_ASSERT(!m_icon); // Pointer should still be assigned to 0.
- m_icon = new Plasma::IconWidget(KIcon("user-offline", 0), QString());
- setPopupIcon(m_icon->icon());
-
- // The icon has been changed.
- updateMasterIcon();
-
- // Set up the accounts model.
- m_accountsModel = new QStandardItemModel(this);
- m_accountsModel->setColumnCount(4);
-
- // connect(m_accountsModel,
- // SIGNAL(itemChanged(QStandardItem*)),
- // SLOT(onItemChanged(QStandardItem*)));
-
- m_accountsModel->setHeaderData(1, Qt::Horizontal,
- QVariant("status-type"), Qt::DisplayRole);
- m_accountsModel->setHeaderData(2, Qt::Horizontal,
- QVariant("status-name"), Qt::DisplayRole);
- m_accountsModel->setHeaderData(3, Qt::Horizontal,
- QVariant("status-message"), Qt::DisplayRole);
-
+ // Set up the data engine
m_engine = dataEngine("presence");
+
QStringList sources = m_engine->sources();
- foreach(const QString &source, sources) {
+ foreach(const QString &source, sources)
onSourceAdded(source);
- }
connect(m_engine,
SIGNAL(sourceAdded(const QString &)),
@@ -112,43 +84,12 @@ void PresenceApplet::init()
SLOT(onSourceRemoved(const QString &)));
}
-QWidget *PresenceApplet::widget()
+QGraphicsWidget *PresenceApplet::graphicsWidget()
{
if (!m_widget) {
- // Set up the accounts view.
- m_accountsView = new QTreeView;
- m_accountsView->setItemDelegate(new PresenceItemDelegate);
- m_accountsView->setModel(m_accountsModel);
- m_accountsView->header()->setVisible(true);
- m_accountsView->setColumnHidden(0, true); // Hide the source id column
-
- // Set up the master status section.
- m_masterStatusLayout = new QHBoxLayout(m_widget);
-
- m_masterIconLabel = new QLabel;
- m_masterStatusMessageLabel = new QLabel;
-
- m_masterStatusLayout->addWidget(m_masterIconLabel);
- m_masterStatusLayout->addWidget(m_masterStatusMessageLabel);
-
- updateMasterIcon();
- setMasterStatusMessage(m_masterStatusMessage);
-
- // Set up the rest of the view/layout etc. stuff.
- m_widget = new QWidget();
- m_layout = new QVBoxLayout(m_widget);
- m_layout->addLayout(m_masterStatusLayout);
- m_layout->addWidget(m_accountsView);
- m_widget->setLayout(m_layout);
-
- // Apply the theme's color scheme to the widget.
- Q_ASSERT(m_colorScheme);
- QPalette editPalette = m_widget->palette();
- editPalette.setBrush(QPalette::Window,
- m_colorScheme->background());
- editPalette.setBrush(QPalette::WindowText,
- m_colorScheme->foreground());
- m_widget->setPalette(editPalette);
+ m_widget = new QGraphicsWidget(this);
+ m_layout = new QGraphicsLinearLayout(Qt::Vertical, m_widget);
+ m_widget->setLayout (m_layout);
}
return m_widget;
@@ -157,13 +98,27 @@ QWidget *PresenceApplet::widget()
void PresenceApplet::onSourceAdded(const QString &source)
{
kDebug() << "PresenceApplet::onSourceAdded: source:" << source;
- m_engine->connectSource(source, this);
+
+ if (!m_accounts.contains(source)) {
+ AccountWidget *account = new AccountWidget();
+ account->setId(source);
+ m_layout->addItem(account);
+ m_accounts[source] = account;
+ m_engine->connectSource(source, this);
+ }
}
void PresenceApplet::onSourceRemoved(const QString &source)
{
kDebug() << "PresenceApplet::onSourceAdded: source:" << source;
- m_engine->disconnectSource(source, this);
+
+ if (m_accounts.contains(source)) {
+ AccountWidget *account = m_accounts.value(source);
+ m_accounts.remove(source);
+ m_layout->removeItem(account);
+ delete account;
+ m_engine->disconnectSource(source, this);
+ }
}
void PresenceApplet::dataUpdated(const QString &source,
@@ -171,99 +126,22 @@ void PresenceApplet::dataUpdated(const QString &source,
{
kDebug() << "PresenceApplet::onDataUpdated: source:" << source;
- /*
- * the data has been updated for one or more sources.
- * We must see if there is already a row in the
- * model representing that source.
- * If there is, then we update the data for that
- * row. If not, then we create a new row with
- * the data for that source.
- */
- QStandardItem *presence_type = new QStandardItem;
- QStandardItem *presence_state = new QStandardItem;
- QStandardItem *message = new QStandardItem;
- QStandardItem *accountItem = new QStandardItem;
-
- // setup color roles
- presence_type->setData(Plasma::Theme::defaultTheme()->color(
- Plasma::Theme::BackgroundColor));
- presence_state->setData(Plasma::Theme::defaultTheme()->color(
- Plasma::Theme::BackgroundColor));
- message->setData(Plasma::Theme::defaultTheme()->color(
- Plasma::Theme::BackgroundColor));
-
- presence_type->setData(data.value("presence_type"),
- Qt::DisplayRole);
- presence_state->setData(data.value("presence_status"),
- Qt::DisplayRole);
- message->setData(data.value("presence_status_message"),
- Qt::DisplayRole);
- accountItem->setData(source, Qt::DisplayRole);
-
- /*
- * so, we need to look in the first column
- * to see if we can find a row with that value
- */
- QList<QStandardItem*> items;
- items = m_accountsModel->findItems(source, Qt::MatchExactly, 0);
- int itemsCount = items.count();
- if (itemsCount == 0) {
- /*
- * the source is new, so create
- * a new row for it.
- */
- QStandardItem *id = new QStandardItem;
- id->setData(source, Qt::DisplayRole);
- QList<QStandardItem*> row;
- row.append(id);
- row.append(presence_type);
- row.append(presence_state);
- row.append(message);
- m_accountsModel->appendRow(row);
- }
- else if (itemsCount == 1)
- {
- /*
- * the source is NOT new,
- * so we update the row that
- * is already there for it.
- */
- int row = items.first()->row();
- m_accountsModel->setItem(row, 0, accountItem);
- m_accountsModel->setItem(row, 1, presence_type);
- m_accountsModel->setItem(row, 2, presence_state);
- m_accountsModel->setItem(row, 3, message);
- }
+ if (m_accounts.contains(source)) {
+ // Get the stored account
+ AccountWidget *account = m_accounts[source];
- // Update the master presence.
- updateMasterPresence();
-}
+ // Set the DisplayName
+ account->setName(data["DisplayName"].toString());
-/*
-void PresenceApplet::onItemChanged(QStandardItem *item)
-{
- QModelIndex index = m_accountsModel->indexFromItem(item);
- QString source = m_accountsModel->data(m_accountsModel->index(index.row(), 0)).toString();
- uint type = m_accountsModel->data(m_accountsModel->index(index.row(), 1)).toUInt();
- QString status = m_accountsModel->data(m_accountsModel->index(index.row(), 2)).toString();
- QString statusMessage = m_accountsModel->data(m_accountsModel->index(index.row(), 3)).toString();
- //work around account object patch gets trimmed
- QString accountObjectPath = "/org/freedesktop/Telepath" + source;
- if (m_accountManager->isReady()) {
- Telepathy::Client::Account * account =
- m_accountManager->accountForPath(accountObjectPath).data();
- if (account) {
- Telepathy::SimplePresence simplePresence;
- simplePresence.type = type;
- simplePresence.status = status;
- simplePresence.statusMessage = statusMessage;
- account->setRequestedPresence(simplePresence);
- m_userSet = false;
- }
- }
+ // Set the Nickname
+ account->setAlias(data["Nickname"].toString());
+ // Set the account avatar
+ QPixmap avatar;
+ avatar.loadFromData(data["AccountAvatar"].toByteArray());
+ account->setImage(avatar);
+ }
}
-*/
/*
* Update the master presence state.
@@ -274,7 +152,7 @@ void PresenceApplet::onItemChanged(QStandardItem *item)
*/
void PresenceApplet::updateMasterPresence()
{
- // Get data we can use to iterate over the contents of the accounts model.
+/* // Get data we can use to iterate over the contents of the accounts model.
int rowCount = m_accountsModel->rowCount();
// First we workout the overall presence message.
@@ -380,27 +258,28 @@ void PresenceApplet::updateMasterPresence()
// call the method to update the masterPresenceIcon
setPopupIcon(m_icon->icon());
- updateMasterIcon();
+ updateMasterIcon();*/
}
void PresenceApplet::updateMasterIcon()
{
// The icon has been changed. We must update the pixmap of the icon for
// display in the main widget.
- if (m_masterIconLabel) {
+/* if (m_masterIconLabel) {
m_masterIconLabel->setPixmap(m_icon->icon().pixmap(QSize(32, 32)));
- }
+ }*/
}
void PresenceApplet::setMasterStatusMessage(const QString & message)
{
- // If m_masterStatusMessageLabel points to a valid QLabel, update it
+ Q_UNUSED(message);
+/* // If m_masterStatusMessageLabel points to a valid QLabel, update it
if (m_masterStatusMessageLabel) {
m_masterStatusMessageLabel->setText(message);
}
// Store the master presence message as a member var
- m_masterStatusMessage = message;
+ m_masterStatusMessage = message;*/
}
#include "presence.moc"
diff --git a/presence/src/presence.h b/presence/src/presence.h
index 2873219..cec275e 100644
--- a/presence/src/presence.h
+++ b/presence/src/presence.h
@@ -2,6 +2,7 @@
* Copyright (C) 2008 George Goldberg <grundleborg at googlemail.com>
* Copyright (C) 2009 Collabora Ltd <http://www.collabora.co.uk>
* Copyright (C) 2009 Andre Moreira Magalhaes <andrunko at gmail.com>
+ * Copyright (C) 2009 Abner Silva <abner.silva at kdemail.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,26 +23,17 @@
#ifndef PLASMA_APPLET_PRESENCE_H
#define PLASMA_APPLET_PRESENCE_H
-#include <plasma/popupapplet.h>
-#include <plasma/dataengine.h>
-
+// Qt
#include <QtCore/QString>
#include <QtGui/QLabel>
-#include <QtGui/QStandardItemModel>
-namespace Plasma
-{
- class IconWidget;
-}
+// Plasma
+#include <plasma/popupapplet.h>
+#include <plasma/dataengine.h>
class KColorScheme;
-class QHBoxLayout;
-class QStandardItemModel;
-class QString;
-class QTreeView;
-class QVBoxLayout;
-class QGraphicsProxyWidget;
+class AccountWidget;
class PresenceApplet : public Plasma::PopupApplet
{
@@ -50,11 +42,10 @@ class PresenceApplet : public Plasma::PopupApplet
public:
PresenceApplet(QObject *parent, const QVariantList &args);
~PresenceApplet();
-
- QWidget *widget();
-
void init();
+ QGraphicsWidget *graphicsWidget();
+
private Q_SLOTS:
void onSourceAdded(const QString &source);
void onSourceRemoved(const QString &source);
@@ -68,20 +59,10 @@ private:
void updateMasterPresence();
Plasma::DataEngine *m_engine;
- Plasma::IconWidget *m_icon;
-
+ QGraphicsWidget *m_widget;
+ QGraphicsLinearLayout *m_layout;
KColorScheme *m_colorScheme;
-
- QHBoxLayout *m_masterStatusLayout;
- QLabel *m_masterIconLabel;
- QLabel *m_masterStatusMessageLabel;
- QStandardItemModel *m_accountsModel;
- QTreeView *m_accountsView;
- QVBoxLayout *m_layout;
- QWidget *m_widget;
- bool m_userSet;
- QString m_currentPresence;
- QString m_masterStatusMessage;
+ QHash<QString, AccountWidget*> m_accounts;
};
K_EXPORT_PLASMA_APPLET(presence, PresenceApplet)
--
ktp-contact-applet packaging
More information about the pkg-kde-commits
mailing list