[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:18:07 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=77de0e1
The following commit has been merged in the master branch:
commit 77de0e19389c75a2850415f12d896b6587ea4ae2
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Tue Sep 28 01:35:20 2010 +0000
Library has titleChanged() iconChanged() methods emmited to be emitted
when a contact name changes, or presence changes for single user chats.
Application updated to set tab name/icon appropriately.
svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1180440
---
app/mainwindow.cpp | 29 ++++++++++++++++++++++++++++-
app/mainwindow.h | 8 +++++++-
lib/chatwindow.cpp | 41 +++++++++++++++++++++++++++++++++++++++--
lib/chatwindow.h | 3 +++
4 files changed, 77 insertions(+), 4 deletions(-)
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index af8d40e..8bca32d 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -20,6 +20,7 @@
#include "mainwindow.h"
#include "chatwindow.h"
+
inline ChannelClassList channelClassList()
{
ChannelClassList filters;
@@ -44,6 +45,8 @@ MainWindow::MainWindow() :
KTabWidget(),
AbstractClientHandler(channelClassList())
{
+ setTabReorderingEnabled(true);
+ connect(this, SIGNAL(currentChanged(int)), SLOT(onCurrentIndexChanged(int)));
}
void MainWindow::handleChannels(const MethodInvocationContextPtr<> &context,
@@ -58,8 +61,11 @@ void MainWindow::handleChannels(const MethodInvocationContextPtr<> &context,
ChatConnection* chatConnection = new ChatConnection(this, account, connection, channels);
ChatWindow* newWindow = new ChatWindow(chatConnection, this);
+ addTab(newWindow,KIcon("user-online"),"");
+
connect(newWindow, SIGNAL(titleChanged(QString)), SLOT(updateTabText(QString)));
- addTab(newWindow, "");
+ connect(newWindow,SIGNAL(iconChanged(KIcon)), SLOT(updateTabIcon(KIcon)));
+
resize(newWindow->sizeHint() - QSize(50, 50));// FUDGE
context->setFinished();
@@ -72,5 +78,26 @@ void MainWindow::updateTabText(QString newTitle)
if (sender) {
int tabIndexToChange = indexOf(sender);
setTabText(tabIndexToChange, newTitle);
+
+ if (tabIndexToChange == currentIndex())
+ {
+ onCurrentIndexChanged(tabIndexToChange);
+ }
+ }
+}
+
+void MainWindow::updateTabIcon(KIcon newIcon)
+{
+ //find out which widget made the call, and update the correct tab.
+ QWidget* sender = qobject_cast<QWidget*>(QObject::sender());
+ if (sender) {
+ int tabIndexToChange = indexOf(sender);
+ setTabIcon(tabIndexToChange, newIcon);
}
}
+
+
+void MainWindow::onCurrentIndexChanged(int index)
+{
+ setWindowTitle(tabText(index));
+}
diff --git a/app/mainwindow.h b/app/mainwindow.h
index cf2e5d6..bedffda 100644
--- a/app/mainwindow.h
+++ b/app/mainwindow.h
@@ -21,13 +21,15 @@
#define REALCLIENTHANDLER_H
#include <KTabWidget>
+#include <KIcon>
#include <TelepathyQt4/AbstractClientHandler>
#include <TelepathyQt4/types.h>
#include <TelepathyQt4/Channel>
#include <TelepathyQt4/TextChannel>
#include <TelepathyQt4/ReceivedMessage>
-#include <chatconnection.h>
+
+#include "chatconnection.h"
using namespace Tp;
@@ -56,6 +58,10 @@ public:
private slots:
void updateTabText(QString newTitle);
+ void updateTabIcon(KIcon newIcon);
+
+ /** keep the main window title in line with active tab */
+ void onCurrentIndexChanged(int index);
};
diff --git a/lib/chatwindow.cpp b/lib/chatwindow.cpp
index e7ff964..9b955d6 100644
--- a/lib/chatwindow.cpp
+++ b/lib/chatwindow.cpp
@@ -45,7 +45,8 @@ ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
ui(new Ui::ChatWindow),
m_chatConnection(chat),
m_chatviewlInitialised(false),
- m_showFormatToolbarAction(new QAction(i18n("Show format options"), this))
+ m_showFormatToolbarAction(new QAction(i18n("Show format options"), this)),
+ m_isGroupChat(false)
{
ui->setupUi(this);
ui->statusLabel->setText("");
@@ -219,7 +220,6 @@ void ChatWindow::updateChatStatus(Tp::ContactPtr contact, ChannelChatState state
ui->statusLabel->setText(i18n("%1 is typing a message").arg(contact->alias()));
}
- //FIXME work out if _any_ user is typing and emit contactIsTypingChanged();
}
@@ -266,6 +266,13 @@ void ChatWindow::onContactPresenceChange(Tp::ContactPtr contact, uint type)
ui->chatArea->addStatusMessage(statusMessage);
}
+
+ //if in a non-group chat situation, and the other contact has changed state...
+ if (! m_isGroupChat && ! isYou)
+ {
+ KIcon icon = iconForPresence(type);
+ Q_EMIT iconChanged(icon);
+ }
}
void ChatWindow::updateEnabledState(bool enable)
@@ -298,6 +305,7 @@ void ChatWindow::updateEnabledState(bool enable)
} else {
//some sort of group chat scenario.. Not sure how to create this yet.
info.setChatName("Group Chat");
+ m_isGroupChat = true;
}
info.setSourceName(m_chatConnection->connection()->protocolName());
@@ -309,6 +317,7 @@ void ChatWindow::updateEnabledState(bool enable)
//inform anyone using the class of the new name for this chat.
Q_EMIT titleChanged(info.chatName());
+ //FIXME emit the correct icon here too
}
}
@@ -352,3 +361,31 @@ void ChatWindow::onFormatColorReleased()
KColorDialog::getColor(color,this);
ui->sendMessageBox->setTextColor(color);
}
+
+KIcon ChatWindow::iconForPresence(uint presence)
+{
+ QString iconName;
+
+ switch (presence) {
+ case Tp::ConnectionPresenceTypeAvailable:
+ iconName = QLatin1String("user-online");
+ break;
+ case Tp::ConnectionPresenceTypeAway:
+ iconName = QLatin1String("user-away");
+ break;
+ case Tp::ConnectionPresenceTypeExtendedAway:
+ iconName = QLatin1String("user-away-extended");
+ break;
+ case Tp::ConnectionPresenceTypeHidden:
+ iconName = QLatin1String("user-invisible");
+ break;
+ case Tp::ConnectionPresenceTypeBusy:
+ iconName = QLatin1String("user-busy");
+ break;
+ default:
+ iconName = QLatin1String("user-offline");
+ break;
+ }
+
+ return KIcon(iconName);
+}
diff --git a/lib/chatwindow.h b/lib/chatwindow.h
index 4e19aae..dc9c1b6 100644
--- a/lib/chatwindow.h
+++ b/lib/chatwindow.h
@@ -107,9 +107,12 @@ private:
/** Stores whether the channel is ready with all contacts upgraded*/
bool m_chatviewlInitialised;
+ KIcon iconForPresence(uint presence);
+
MessageBoxEventFilter* messageBoxEventFilter;
ChannelChatState lastRequestedChannelChatState;
QAction* m_showFormatToolbarAction;
+ bool m_isGroupChat;
};
#endif // CHATWINDOW_H
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list