[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:20:50 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=9e9fd14
The following commit has been merged in the master branch:
commit 9e9fd14fb583ac0a7b5cc5e4c9e5e2158517c91b
Author: Lasath Fernando <kde at lasath.org>
Date: Wed Jan 4 20:01:57 2012 +1100
Made ConversationQueManager use d-pointers. Made MessagesModel Queable instead of Conversation, and updated the ui accordingly.
---
lib/conversation-que-manager.cpp | 57 ++++++++++++++++++++-------
lib/conversation-que-manager.h | 35 ++++++++++------
lib/conversation.cpp | 21 +++++-----
lib/conversation.h | 10 ++---
lib/messages-model.cpp | 7 ++++
lib/messages-model.h | 6 ++-
plasmoid/contents/ui/ConversationDelegate.qml | 13 ++++--
plasmoid/contents/ui/main.qml | 57 ++++++++++++++++++---------
8 files changed, 138 insertions(+), 68 deletions(-)
diff --git a/lib/conversation-que-manager.cpp b/lib/conversation-que-manager.cpp
index 8ac5083..dfec82f 100644
--- a/lib/conversation-que-manager.cpp
+++ b/lib/conversation-que-manager.cpp
@@ -20,16 +20,24 @@
#include "conversation-que-manager.h"
#include <KDebug>
-void Queable::push()
+class ConversationQueManager::ConversationQueManagerPrivate {
+public:
+ QList<Queable*> que;
+ KAction* gloablAction;
+};
+
+void Queable::enqueSelf()
{
- if(!m_queManager->que.contains(this)) {
- m_queManager->que.append(this);
- }
+ m_queManager->enque(this);
}
-Queable::~Queable()
+void Queable::removeSelfFromQue()
{
+ m_queManager->remove(this);
+}
+Queable::~Queable()
+{
}
Queable::Queable(ConversationQueManager* que)
@@ -51,23 +59,44 @@ ConversationQueManager* ConversationQueManager::instance()
return m_instance;
}
-ConversationQueManager::ConversationQueManager(QObject* parent): QObject(parent)
+ConversationQueManager::ConversationQueManager(QObject* parent):
+ QObject(parent),
+ d(new ConversationQueManagerPrivate)
{
kDebug();
//FIXME: think of a good name for this. What did Kopete call it?
- m_gloablAction = new KAction(this);
- m_gloablAction->setObjectName(QLatin1String("next-unread-conversation"));
- m_gloablAction->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_J), KAction::ActiveShortcut | KAction::DefaultShortcut, KAction::NoAutoloading);
+ d->gloablAction = new KAction(this);
+ d->gloablAction->setObjectName(QLatin1String("next-unread-conversation"));
+ d->gloablAction->setGlobalShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_I)/*, KAction::ActiveShortcut | KAction::DefaultShortcut, KAction::NoAutoloading*/);
- connect(m_gloablAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), SLOT(popConversation()));
+ connect(d->gloablAction, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), SLOT(dequeNext()));
}
-void ConversationQueManager::popConversation()
+void ConversationQueManager::dequeNext()
{
kDebug();
- if(!que.isEmpty()) {
- que.takeLast()->pop();
+ if(!d->que.isEmpty()) {
+ d->que.takeLast()->selfDequed();
+ }
+}
+
+void ConversationQueManager::enque(Queable* item)
+{
+ if(!d->que.contains(item)) {
+ d->que.append(item);
+ }
+}
+
+void ConversationQueManager::remove(Queable* item)
+{
+ if(d->que.contains(item)) {
+ d->que.removeAll(item);
}
-}
\ No newline at end of file
+}
+
+ConversationQueManager::~ConversationQueManager()
+{
+ delete d;
+}
diff --git a/lib/conversation-que-manager.h b/lib/conversation-que-manager.h
index dc8243f..b5d97ee 100644
--- a/lib/conversation-que-manager.h
+++ b/lib/conversation-que-manager.h
@@ -24,32 +24,41 @@
#include <KAction>
class ConversationQueManager;
-class Queable {
- friend class ConversationQueManager;
-public:
- Queable(ConversationQueManager* que = 0);
-private:
- ConversationQueManager* m_queManager;
+class Queable
+{
+friend class ConversationQueManager;
protected:
+ Queable(ConversationQueManager* que = 0);
virtual ~Queable();
- void push();
- virtual void pop() = 0;
+ void enqueSelf();
+ void removeSelfFromQue();
+ virtual void selfDequed() = 0;
+
+private:
+ ConversationQueManager* m_queManager;
};
+
class ConversationQueManager : public QObject
{
Q_OBJECT
- friend class Queable;
+
public:
static ConversationQueManager* instance();
+ void enque(Queable* item);
+ void remove(Queable* item);
+
+public Q_SLOTS:
+ void dequeNext();
+
private:
- QList<Queable*> que;
- KAction* m_gloablAction;
explicit ConversationQueManager(QObject* parent = 0);
-private Q_SLOTS:
- void popConversation();
+ virtual ~ConversationQueManager();
+
+ class ConversationQueManagerPrivate;
+ ConversationQueManagerPrivate *d;
};
#endif // CONVERSATION_QUE_MANAGER_H
diff --git a/lib/conversation.cpp b/lib/conversation.cpp
index 8eb40a2..99a77e1 100644
--- a/lib/conversation.cpp
+++ b/lib/conversation.cpp
@@ -33,7 +33,6 @@ public:
};
Conversation::Conversation(Tp::TextChannelPtr channel, Tp::AccountPtr account) :
- Queable(),
d (new ConversationPrivate)
{
kDebug();
@@ -43,7 +42,7 @@ Conversation::Conversation(Tp::TextChannelPtr channel, Tp::AccountPtr account) :
d->target = new ConversationTarget(channel->targetContact());
- connect(model(), SIGNAL(unreadCountChanged(int)), SLOT(onUnreadMessagesChanged()));
+// connect(model(), SIGNAL(unreadCountChanged(int)), SLOT(onUnreadMessagesChanged()));
// d->account = account;
}
@@ -63,15 +62,15 @@ ConversationTarget* Conversation::target() const
return d->target;
}
-void Conversation::onUnreadMessagesChanged()
-{
- push();
-}
-
-void Conversation::pop()
-{
- Q_EMIT popoutRequested();
-}
+// void Conversation::onUnreadMessagesChanged()
+// {
+// enqueSelf();
+// }
+//
+// void Conversation::selfDequed()
+// {
+// Q_EMIT popoutRequested();
+// }
Conversation::~Conversation()
{
diff --git a/lib/conversation.h b/lib/conversation.h
index f07c81c..1db0f5b 100644
--- a/lib/conversation.h
+++ b/lib/conversation.h
@@ -31,12 +31,13 @@
class ConversationTarget;
class MessagesModel;
-class KDE_TELEPATHY_CHAT_EXPORT Conversation : public QObject, public Queable
+class KDE_TELEPATHY_CHAT_EXPORT Conversation : public QObject
{
Q_OBJECT
-Q_PROPERTY(MessagesModel* model READ model NOTIFY modelChanged);
Q_PROPERTY(ConversationTarget* target READ target NOTIFY targetChanged);
+//TODO: rename this to messages
+Q_PROPERTY(MessagesModel* model READ model NOTIFY modelChanged);
public:
Conversation(Tp::TextChannelPtr channel, Tp::AccountPtr account);
@@ -50,11 +51,6 @@ public:
Q_SIGNALS:
void modelChanged(MessagesModel* newModel);
void targetChanged(ConversationTarget* target);
- void popoutRequested();
-
-private Q_SLOTS:
- virtual void pop();
- void onUnreadMessagesChanged();
private:
class ConversationPrivate;
diff --git a/lib/messages-model.cpp b/lib/messages-model.cpp
index 35b1e6d..d2244de 100644
--- a/lib/messages-model.cpp
+++ b/lib/messages-model.cpp
@@ -142,6 +142,7 @@ void MessagesModel::onMessageReceived(Tp::ReceivedMessage message)
if(d->visible) {
acknowledgeAllMessages();
} else {
+ enqueSelf();
Q_EMIT unreadCountChanged(unreadCount);
}
}
@@ -243,9 +244,15 @@ void MessagesModel::acknowledgeAllMessages()
kDebug() << "Conversation Visible, Acknowledging " << que.size() << " messages.";
d->textChannel->acknowledge(que);
+ removeSelfFromQue();
Q_EMIT unreadCountChanged(que.size());
}
+void MessagesModel::selfDequed()
+{
+ Q_EMIT popoutRequested();
+}
+
void MessagesModel::setVisibleToUser(bool visible)
{
kDebug() << visible;
diff --git a/lib/messages-model.h b/lib/messages-model.h
index 3328f31..39bedb3 100644
--- a/lib/messages-model.h
+++ b/lib/messages-model.h
@@ -24,9 +24,10 @@
#include <QAbstractItemModel>
#include <TelepathyQt/TextChannel>
+#include "conversation-que-manager.h"
-class KDE_TELEPATHY_CHAT_EXPORT MessagesModel : public QAbstractListModel
+class KDE_TELEPATHY_CHAT_EXPORT MessagesModel : public QAbstractListModel, public Queable
{
Q_OBJECT
Q_PROPERTY(bool visibleToUser READ isVisibleToUser WRITE setVisibleToUser NOTIFY visibleToUserChanged);
@@ -65,7 +66,9 @@ public:
Q_SIGNALS:
void textChannelChanged(Tp::TextChannelPtr newChannel);
void visibleToUserChanged(bool visible);
+ //TODO: figure out how to check if unread messages have been acknowledged by something else
void unreadCountChanged(int unreadMesssagesCount);
+ void popoutRequested();
public Q_SLOTS:
Tp::PendingSendMessage* sendNewMessage(QString message);
@@ -78,6 +81,7 @@ private Q_SLOTS:
private:
void setupChannelSignals(Tp::TextChannelPtr channel);
void removeChannelSignals(Tp::TextChannelPtr channel);
+ virtual void selfDequed();
class ConversationModelPrivate;
ConversationModelPrivate *d;
diff --git a/plasmoid/contents/ui/ConversationDelegate.qml b/plasmoid/contents/ui/ConversationDelegate.qml
index 5bc282b..3606b3c 100644
--- a/plasmoid/contents/ui/ConversationDelegate.qml
+++ b/plasmoid/contents/ui/ConversationDelegate.qml
@@ -13,7 +13,7 @@ Item {
property bool pressed: false
property string overlayText: "0"
- signal clicked
+ signal toggled
// Rectangle {
// anchors.fill: parent
@@ -80,15 +80,20 @@ Item {
hoverEnabled: true
//move le onClicked into main
- onClicked: base.clicked()
+ onClicked: toggle();
preventStealing: true
}
+ function toggle() {
+ base.pressed = !base.pressed;
+ base.toggled();
+ }
+
states: [
State {
- name: "focus"
- when: pressed
+ name: "pressed"
+ when: base.pressed
PropertyChanges {
target: canvas
prefix: "focus"
diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml
index 8111a54..91dad8a 100644
--- a/plasmoid/contents/ui/main.qml
+++ b/plasmoid/contents/ui/main.qml
@@ -6,7 +6,7 @@ import org.kde.plasma.components 0.1 as PlasmaComponents
// import "createDialog.js" as MyScript
Item {
-
+ id: top
ListView {
id: base
anchors.fill: parent
@@ -24,49 +24,70 @@ Item {
// text: model.conversation.target.nick
overlayText: model.conversation.model.unreadCount
- pressed: dialog.visible
- onClicked: popupApplet();
+// pressed: model.conversation.model.visibleToUser
+// onClicked: popupApplet();
//FIXME: put in a loader to not slow down the model
PlasmaCore.Dialog {
id: dialog
windowFlags: Qt.Dialog
+ visible: conv.pressed
+
mainItem: ChatWidget {
width: 250
height: 350
conv: model.conversation
- visible: model.conversation.model.visibleToUser
-
- onCloseRequested: conv.popupApplet()
+ onCloseRequested: {
+ conv.pressed = false;
+ }
onConversationEndRequested: {
model.conversation.model.printallmessages();
}
+ Binding {
+ target: model.conversation.model
+ property: "visibleToUser"
+ value: dialog.visible
+ }
}
+
+// x: top.x == top.y ? popupPosition()
}
Connections {
- target: model.conversation
- onPopoutRequested: popupApplet();
+ target: model.conversation.model
+ onPopoutRequested: {
+ conv.pressed = true;
+ }
}
- function popupApplet() {
- if(dialog.visible == false) {
+ onToggled: {
+ if(pressed) {
var point = dialog.popupPosition(conv, Qt.AlignBottom);
console.log("Showing dialog at (" + point.x + "," + point.y + ")");
dialog.x = point.x;
dialog.y = point.y;
-
- dialog.visible = true;
- model.conversation.model.visibleToUser = true;
- } else {
- console.log("height = " + dialog.height);
- console.log("width = " + dialog.width);
- dialog.visible = false;
- model.conversation.model.visibleToUser = false;
}
}
+
+// function popupApplet() {
+// if(model.conversation.model.visibleToUser == false) {
+// var point = dialog.popupPosition(conv, Qt.AlignBottom);
+// console.log("Showing dialog at (" + point.x + "," + point.y + ")");
+//
+// dialog.x = point.x;
+// dialog.y = point.y;
+//
+// // dialog.visible = true;
+// model.conversation.model.visibleToUser = true;
+// } else {
+// console.log("height = " + dialog.height);
+// console.log("width = " + dialog.width);
+// // dialog.visible = false;
+// model.conversation.model.visibleToUser = false;
+// }
+// }
}
}
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list