[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:38 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=4b40402
The following commit has been merged in the master branch:
commit 4b40402f25f2acb07875384dfa7556c20dea19cf
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Fri Dec 23 11:54:26 2011 +0000
Fix message acking. Now messages are only acked when the window is activated.
Reviewed by: Daniele Domenichelli
---
app/chat-window.cpp | 10 +++++-----
lib/chat-widget.cpp | 49 +++++++++++++++++--------------------------------
lib/chat-widget.h | 12 +++++-------
3 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index c328606..288d5f3 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -255,7 +255,7 @@ void ChatWindow::onCurrentIndexChanged(int index)
}
ChatTab* currentChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
- currentChatTab->resetUnreadMessageCount();
+ currentChatTab->acknowledgeMessages();
setWindowTitle(currentChatTab->title());
setWindowIcon(currentChatTab->icon());
@@ -461,7 +461,7 @@ void ChatWindow::removeChatTabSignals(ChatTab* chatTab)
disconnect(chatTab, SIGNAL(titleChanged(QString)), this, SLOT(onTabTextChanged(QString)));
disconnect(chatTab, SIGNAL(iconChanged(KIcon)), this, SLOT(onTabIconChanged(KIcon)));
disconnect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onTabStateChanged()));
- disconnect(chatTab, SIGNAL(unreadMessagesChanged(int)), this, SLOT(onTabStateChanged()));
+ disconnect(chatTab, SIGNAL(unreadMessagesChanged()), this, SLOT(onTabStateChanged()));
disconnect(chatTab, SIGNAL(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
disconnect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
}
@@ -487,8 +487,8 @@ void ChatWindow::setupChatTabSignals(ChatTab *chatTab)
connect(chatTab, SIGNAL(iconChanged(KIcon)), this, SLOT(onTabIconChanged(KIcon)));
connect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onTabStateChanged()));
connect(chatTab, SIGNAL(userTypingChanged(bool)), this, SLOT(onUserTypingChanged()));
- connect(chatTab, SIGNAL(unreadMessagesChanged(int)), this, SLOT(onTabStateChanged()));
- connect(chatTab, SIGNAL(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
+ connect(chatTab, SIGNAL(unreadMessagesChanged()), this, SLOT(onTabStateChanged()));
+ connect(chatTab, SIGNAL(contactPresenceChanged(KTp::Presence)), this, SLOT(onTabStateChanged()));
connect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
}
@@ -669,7 +669,7 @@ bool ChatWindow::event(QEvent *e)
//when the window is activated reset the message count on the active tab.
ChatWidget *currChat = qobject_cast<ChatWidget*>(m_tabWidget->currentWidget());
Q_ASSERT(currChat);
- currChat->resetUnreadMessageCount();
+ currChat->acknowledgeMessages();
}
return KXmlGuiWindow::event(e);
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index d898ceb..9313c03 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -54,14 +54,12 @@ public:
{
isGroupChat = false;
remoteContactIsTyping = false;
- unreadMessages = 0;
}
/** Stores whether the channel is ready with all contacts upgraded*/
bool chatviewlInitialised;
bool remoteContactIsTyping;
QAction *showFormatToolbarAction;
bool isGroupChat;
- int unreadMessages;
QString title;
QString contactName;
QString yourName;
@@ -322,7 +320,6 @@ QString ChatWidget::title() const
QColor ChatWidget::titleColor() const
{
/*return a color to set the tab text as in order of importance
-
typing
unread messages
user offline
@@ -336,7 +333,7 @@ QColor ChatWidget::titleColor() const
return scheme.foreground(KColorScheme::PositiveText).color();
}
- if (d->unreadMessages > 0 && !isOnTop()) {
+ if (unreadMessageCount() > 0 && !isOnTop()) {
kDebug() << "unread messages";
return scheme.foreground(KColorScheme::ActiveText).color();
}
@@ -357,13 +354,6 @@ QColor ChatWidget::titleColor() const
return scheme.foreground(KColorScheme::NormalText).color();
}
-int ChatWidget::unreadMessageCount() const
-{
- kDebug() << title() << d->unreadMessages;
-
- return d->unreadMessages;
-}
-
void ChatWidget::toggleSearchBar() const
{
if(d->ui.searchBar->isVisible()) {
@@ -379,6 +369,8 @@ void ChatWidget::setupChannelSignals()
SLOT(handleIncomingMessage(Tp::ReceivedMessage)));
connect(d->channel.data(), SIGNAL(messageReceived(Tp::ReceivedMessage)),
SLOT(notifyAboutIncomingMessage(Tp::ReceivedMessage)));
+ connect(d->channel.data(), SIGNAL(pendingMessageRemoved(Tp::ReceivedMessage)),
+ SIGNAL(unreadMessagesChanged()));
connect(d->channel.data(), SIGNAL(messageSent(Tp::Message,Tp::MessageSendingFlags,QString)),
SLOT(handleMessageSent(Tp::Message,Tp::MessageSendingFlags,QString)));
connect(d->channel.data(), SIGNAL(chatStateChanged(Tp::ContactPtr,Tp::ChannelChatState)),
@@ -399,15 +391,6 @@ void ChatWidget::setupContactModelSignals()
SLOT(onContactAliasChanged(Tp::ContactPtr,QString)));
}
-void ChatWidget::incrementUnreadMessageCount()
-{
- kDebug();
-
- d->unreadMessages++;
-
- kDebug() << "emit" << d->unreadMessages;
- Q_EMIT unreadMessagesChanged(d->unreadMessages);
-}
void ChatWidget::onHistoryFetched(const QList<AdiumThemeContentInfo> &messages)
{
@@ -427,14 +410,18 @@ void ChatWidget::onHistoryFetched(const QList<AdiumThemeContentInfo> &messages)
d->logManager = 0;
}
+int ChatWidget::unreadMessageCount() const
+{
+ return d->channel->messageQueue().size();
+}
-void ChatWidget::resetUnreadMessageCount()
+void ChatWidget::acknowledgeMessages()
{
kDebug();
-
- if(d->unreadMessages > 0) {
- d->unreadMessages = 0;
- Q_EMIT unreadMessagesChanged(d->unreadMessages);
+ //if we're not initialised we can't have shown anything, even if we are on top, therefore ignore all requests to do so
+ if (d->chatviewlInitialised) {
+ //acknowledge everything in the message queue.
+ d->channel->acknowledge(d->channel->messageQueue());
}
}
@@ -572,16 +559,14 @@ void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message)
d->ui.chatArea->addContentMessage(messageInfo);
}
- d->channel->acknowledge(QList<Tp::ReceivedMessage>() << message);
-
- if (!isOnTop()) {
- incrementUnreadMessageCount();
+ //if the window is on top, ack straight away. Otherwise they stay in the message queue for acking when activated..
+ if (isOnTop()) {
+ d->channel->acknowledge(QList<Tp::ReceivedMessage>() << message);
+ } else {
+ Q_EMIT unreadMessagesChanged();
}
-
- Q_EMIT messageReceived();
}
- //if the window isn't ready, we don't acknowledge the message. We process them as soon as we are ready.
}
void ChatWidget::notifyAboutIncomingMessage(const Tp::ReceivedMessage & message)
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 0bf7718..30afa31 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -90,10 +90,9 @@ public Q_SLOTS:
/** toggle the search bar visibility */
void toggleSearchBar() const;
- /** Clear the list of unread messages
- call this when the widget is activated by the user.
+ /** Mark that the following messages have been seen by the user.
*/
- void resetUnreadMessageCount();
+ void acknowledgeMessages();
protected:
void changeEvent(QEvent *e);
@@ -134,8 +133,8 @@ Q_SIGNALS:
/** Emmitted if the icon for this channel changes*/
void iconChanged(const KIcon &icon);
- /** Emmited whenever a message is received in this channel*/
- void messageReceived();
+ /** Emmited whenever a message is received in this channel. It is up to the parent application to acknowledge these messages*/
+ void messageReceived(const Tp::ReceivedMessage &message);
/** emitted when searching for text */
void searchTextComplete(bool found);
@@ -145,7 +144,7 @@ Q_SIGNALS:
void contactPresenceChanged(KTp::Presence presence);
- void unreadMessagesChanged(int messages);
+ void unreadMessagesChanged();
/** Emitted when a notification for the chat window has been activated*/
void notificationClicked();
@@ -165,7 +164,6 @@ private:
/** connects necessary signals for the contactModel */
void setupContactModelSignals();
- void incrementUnreadMessageCount();
virtual bool isOnTop() const;
ChatWidgetPrivate * const d;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list