[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:07:43 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=e227e45
The following commit has been merged in the master branch:
commit e227e454de31fd93e2d02b371289ba95bfa571b9
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Tue Sep 27 17:54:52 2011 +0200
Use KComboBox instead of QComboBox and enable adding custom presence messages
---
global-presence-chooser.cpp | 42 +++++++++++++++++++++++++++++++++++++++++-
global-presence-chooser.h | 9 +++++++--
2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/global-presence-chooser.cpp b/global-presence-chooser.cpp
index fab3f4a..125e625 100644
--- a/global-presence-chooser.cpp
+++ b/global-presence-chooser.cpp
@@ -4,13 +4,17 @@
#include <KIcon>
#include <KLocale>
+#include <KLineEdit>
#include <TelepathyQt4/Presence>
GlobalPresenceChooser::GlobalPresenceChooser(QWidget *parent) :
- QComboBox(parent),
+ KComboBox(parent),
m_globalPresence(new GlobalPresence(this))
{
+ setEditable(true);
+ setInsertPolicy(NoInsert);
+// setTrapReturnKey(true);
addItem(KIcon("user-online"), i18n("Available"), qVariantFromValue(Tp::Presence::available()));
addItem(KIcon("user-away"), i18n("Away"), qVariantFromValue(Tp::Presence::away()));
addItem(KIcon("user-away"), i18n("Be Right Back"), qVariantFromValue(Tp::Presence::brb()));
@@ -25,6 +29,7 @@ GlobalPresenceChooser::GlobalPresenceChooser(QWidget *parent) :
connect(this, SIGNAL(activated(int)), SLOT(onCurrentIndexChanged(int)));
connect(m_globalPresence, SIGNAL(currentPresenceChanged(Tp::Presence)), SLOT(onPresenceChanged(Tp::Presence)));
+ connect(this, SIGNAL(returnPressed(QString)), SLOT(onPresenceMessageChanged(QString)));
}
void GlobalPresenceChooser::setAccountManager(const Tp::AccountManagerPtr &accountManager)
@@ -52,3 +57,38 @@ void GlobalPresenceChooser::onPresenceChanged(const Tp::Presence &presence)
//FIXME if we can't find the correct value, create an entry.
}
+// void GlobalPresenceChooser::enterEvent(QEvent* event)
+// {
+// setEditable(true);
+// }
+//
+// void GlobalPresenceChooser::leaveEvent(QEvent* event)
+// {
+// setEditable(false);
+// }
+
+void GlobalPresenceChooser::onPresenceMessageChanged(const QString &message)
+{
+ Tp::Presence presence = m_globalPresence->currentPresence();
+ presence.setStatus(presence.type(), presence.status(), message);
+
+ bool presenceExists = false;
+ int currentPresenceIndex;
+ for (int i=0; i < count() ; i++) {
+ Tp::Presence itemPresence = itemData(i).value<Tp::Presence>();
+ if (itemPresence.type() == presence.type()) {
+ currentPresenceIndex = i;
+ }
+ if (itemPresence.type() == presence.type() && itemPresence.status() == presence.status() && itemPresence.statusMessage() == presence.statusMessage()) {
+ qDebug() << "This presence already exists, setting this one instead";
+ setCurrentIndex(i);
+ presenceExists = true;
+ break;
+ }
+ }
+
+ if (!presenceExists) {
+ qDebug() << "Adding new presence";
+ insertItem(currentPresenceIndex, itemIcon(currentIndex()), message, qVariantFromValue(presence));
+ }
+}
diff --git a/global-presence-chooser.h b/global-presence-chooser.h
index 337a135..d998682 100644
--- a/global-presence-chooser.h
+++ b/global-presence-chooser.h
@@ -1,22 +1,27 @@
#ifndef GLOBALPRESENCECHOOSER_H
#define GLOBALPRESENCECHOOSER_H
-#include <QComboBox>
+#include <KComboBox>
#include <TelepathyQt4/AccountManager>
class GlobalPresence;
-class GlobalPresenceChooser : public QComboBox
+class GlobalPresenceChooser : public KComboBox
{
Q_OBJECT
public:
explicit GlobalPresenceChooser(QWidget *parent = 0);
void setAccountManager(const Tp::AccountManagerPtr &accountManager);
+// protected:
+// void enterEvent(QEvent *event);
+// void leaveEvent(QEvent *event);
+
private slots:
void onCurrentIndexChanged(int index);
void onPresenceChanged(const Tp::Presence &presence);
+ void onPresenceMessageChanged(const QString &message);
private:
GlobalPresence *m_globalPresence;
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list