[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:11:34 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=ee55e1b
The following commit has been merged in the master branch:
commit ee55e1bbbd5dde11bede78d2f77b93d56e587b65
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date: Mon Aug 29 01:46:10 2011 +0200
Plasmoid loads and saves config
---
src/config.cpp | 17 +++++++++++++++
src/config.h | 9 ++++++++
src/contactWrapper.cpp | 11 +++++++++-
src/contactWrapper.h | 3 +++
src/telepathyContact.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++-
src/telepathyContact.h | 5 +++++
6 files changed, 99 insertions(+), 2 deletions(-)
diff --git a/src/config.cpp b/src/config.cpp
index 7ca6056..3998ffd 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -80,6 +80,21 @@ Config::~Config()
{
}
+Tp::AccountPtr Config::accountFromUniqueId(const QString& id) const
+{
+ Tp::AccountPtr account;
+
+ if (m_accountManager) {
+ foreach (account, m_accountManager->allAccounts()) {
+ if (account->uniqueIdentifier() == id) {
+ return account;
+ }
+ }
+ }
+
+ return account;
+}
+
void Config::activateOkButton()
{
button(Ok)->setEnabled(true);
@@ -127,6 +142,8 @@ void Config::onAccountManagerReady(Tp::PendingOperation* op)
// m_modelFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
setupContactsList();
+
+ emit(loadConfig());
}
void Config::setupContactsList()
diff --git a/src/config.h b/src/config.h
index f977afd..6d3e27d 100644
--- a/src/config.h
+++ b/src/config.h
@@ -41,7 +41,16 @@ public:
Config(QWidget *parent = 0);
~Config();
+ /** retrieve accountPtr by given unique identifier */
+ Tp::AccountPtr accountFromUniqueId(const QString &id) const;
+
+// /** retrieve contactPtr from given id */
+// Tp::ContactPtr contactFromUniqueId(const Tp::AccountPtr &account, const QString &id) const;
+
signals:
+ /** emitted when accountManager is ready so that the plasmoid can retrieve Account and Contact pointers */
+ void loadConfig();
+
void setNewContact(const Tp::ContactPtr &newContact, const Tp::AccountPtr &relatedAccount);
protected slots:
diff --git a/src/contactWrapper.cpp b/src/contactWrapper.cpp
index f3dbecf..59ace0b 100644
--- a/src/contactWrapper.cpp
+++ b/src/contactWrapper.cpp
@@ -31,8 +31,8 @@
ContactWrapper::ContactWrapper(QObject* parent)
: QObject(parent)
- , m_contact(0)
, m_account(0)
+ , m_contact(0)
{
}
@@ -40,6 +40,15 @@ ContactWrapper::~ContactWrapper()
{
}
+QString ContactWrapper::accountId() const
+{
+ if (m_account) {
+ return m_account.data()->uniqueIdentifier();
+ } else {
+ return QString();
+ }
+}
+
QString ContactWrapper::avatar() const
{
if (m_contact) {
diff --git a/src/contactWrapper.h b/src/contactWrapper.h
index 08cd867..fb266e3 100644
--- a/src/contactWrapper.h
+++ b/src/contactWrapper.h
@@ -39,6 +39,9 @@ public:
Q_PROPERTY(QString displayName READ displayName);
Q_PROPERTY(QString presenceStatus READ presenceStatus);
+ /** returns the account id related to the contact chosen */
+ QString accountId() const;
+
/** returns the avatar location for the contact */
QString avatar() const;
diff --git a/src/telepathyContact.cpp b/src/telepathyContact.cpp
index 9e2426d..444ed9a 100644
--- a/src/telepathyContact.cpp
+++ b/src/telepathyContact.cpp
@@ -21,14 +21,17 @@
#include "contactWrapper.h"
#include "telepathyContact.h"
+#include <KConfig>
#include <KStandardDirs>
+
#include <QObject>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
-// #include <Plasma/PackageStructure>
#include <QtGui/QPainter>
+#include <TelepathyQt4/ContactManager>
+
TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
: Plasma::Applet(parent, args)
@@ -45,6 +48,7 @@ TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
setAspectRatioMode(Plasma::FixedSize);
connect(m_config, SIGNAL(setNewContact(Tp::ContactPtr, Tp::AccountPtr)), this, SLOT(setContact(Tp::ContactPtr, Tp::AccountPtr)));
+ connect(m_config, SIGNAL(loadConfig()), this, SLOT(loadConfig()));
}
TelepathyContact::~TelepathyContact()
@@ -75,11 +79,59 @@ void TelepathyContact::init()
}
}
+void TelepathyContact::loadConfig()
+{
+ KSharedConfigPtr config = KSharedConfig::openConfig("telepathycontactappletrc");
+ KConfigGroup group(config, "Contact");
+
+ QString contactId = group.readEntry("id", QString());
+ QString relatedAcc = group.readEntry("relatedAccount", QString());
+
+
+ if (!contactId.isEmpty() && !relatedAcc.isEmpty()) {
+ Tp::AccountPtr account = m_config->accountFromUniqueId(relatedAcc);
+ Tp::ContactPtr contact;
+
+ // check on account. Shouldn't ever be invalid
+ if (!account->isValidAccount()) {
+ return;
+ }
+
+ if (account->connection()->isValid()) {
+ QList<Tp::ContactPtr> contactList = account->connection()->contactManager()->allKnownContacts().toList();
+ bool match = false;
+
+ for (int i = 0; i < contactList.count() && !match; ++i) {
+ if (contactList.at(i)->id() == contactId) {
+ contact = contactList.at(i);
+ match = true;
+ setContact(contact, account);
+ }
+ }
+ }/* else {
+ // just load avatar image
+ m_contact->
+ }*/
+ }
+}
+
void TelepathyContact::paintInterface(QPainter* p, const QStyleOptionGraphicsItem* option, const QRect& contentsRect)
{
Plasma::Applet::paintInterface(p, option, contentsRect);
}
+void TelepathyContact::saveConfig()
+{
+ KConfig config("telepathycontactappletrc");
+
+ KConfigGroup group(&config, "Contact");
+ group.writeEntry("id", m_contact->contact()->id());
+ group.writeEntry("avatar", m_contact->contact()->avatarData().fileName);
+ group.writeEntry("relatedAccount", m_contact->accountId());
+
+ config.sync();
+}
+
void TelepathyContact::setContact(const Tp::ContactPtr& newContact, const Tp::AccountPtr &relatedAccount)
{
Q_ASSERT(newContact);
@@ -87,6 +139,8 @@ void TelepathyContact::setContact(const Tp::ContactPtr& newContact, const Tp::Ac
if (!m_contact->contact() || m_contact->contact()->id() != newContact->id()) {
m_contact->setContact(newContact, relatedAccount);
}
+
+ saveConfig();
}
void TelepathyContact::showConfigurationInterface()
diff --git a/src/telepathyContact.h b/src/telepathyContact.h
index f7871c4..1b575af 100644
--- a/src/telepathyContact.h
+++ b/src/telepathyContact.h
@@ -50,7 +50,12 @@ public slots:
*/
void setContact(const Tp::ContactPtr &newContact, const Tp::AccountPtr &relatedAccount);
+private slots:
+ void loadConfig();
+
private:
+ void saveConfig();
+
Config *m_config;
Plasma::DeclarativeWidget *m_declarative;
ContactWrapper *m_contact;
--
ktp-contact-applet packaging
More information about the pkg-kde-commits
mailing list