[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:59 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=900fc08
The following commit has been merged in the master branch:
commit 900fc0843f539bf86e74319ba2c2e89c53a4b4d2
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date: Wed Mar 9 22:41:44 2011 +0000
Avoid duplicate tabs with the same name.
Added a getter method for the channel in the library.
On a new incoming channel, check open tabs for anything already using the same channel before creating a new tab.
---
app/chat-window.cpp | 42 +++++++++++++++++++++++++++++++++---------
app/chat-window.h | 7 ++++++-
app/telepathy-chat-ui.cpp | 5 ++---
lib/chat-widget.cpp | 4 ++++
lib/chat-widget.h | 3 +++
5 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 66f7c03..3ebe1c0 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -33,6 +33,8 @@
#include <KSettings/Dialog>
#include <KNotifyConfigWidget>
+#include <TelepathyQt4/TextChannel>
+
ChatWindow::ChatWindow()
{
//setup actions
@@ -61,18 +63,40 @@ ChatWindow::~ChatWindow()
{
}
-void ChatWindow::addTab(ChatWidget* chatWidget)
+void ChatWindow::startChat(Tp::TextChannelPtr incomingTextChannel)
{
- connect(chatWidget, SIGNAL(titleChanged(QString)), this, SLOT(updateTabText(QString)));
- connect(chatWidget, SIGNAL(iconChanged(KIcon)), this, SLOT(updateTabIcon(KIcon)));
- connect(chatWidget, SIGNAL(userTypingChanged(bool)), this, SLOT(onUserTypingChanged(bool)));
+ bool duplicateTab = false;
+
+ // check that the tab requested isn't already open
+ for(int index = 0; index < m_tabWidget->count() && !duplicateTab; index++) {
+
+ // get chatWidget object
+ ChatWidget *auxChatWidget = qobject_cast<ChatWidget*>(m_tabWidget->widget(index));
+
+ // this should never happen
+ if(!auxChatWidget)
+ return;
+
+ if(auxChatWidget->textChannel() == incomingTextChannel) { // got duplicate tab
+ duplicateTab = true;
+ m_tabWidget->setCurrentIndex(index); // set focus on selected tab
+ }
+ }
+
+ // got new chat, create it
+ if(!duplicateTab) {
+ ChatWidget *chatWidget = new ChatWidget(incomingTextChannel, m_tabWidget);
+ connect(chatWidget, SIGNAL(titleChanged(QString)), this, SLOT(updateTabText(QString)));
+ connect(chatWidget, SIGNAL(iconChanged(KIcon)), this, SLOT(updateTabIcon(KIcon)));
+ connect(chatWidget, SIGNAL(userTypingChanged(bool)), this, SLOT(onUserTypingChanged(bool)));
- m_tabWidget->addTab(chatWidget, chatWidget->icon(), chatWidget->title());
- m_tabWidget->setCurrentWidget(chatWidget);
+ m_tabWidget->addTab(chatWidget, chatWidget->icon(), chatWidget->title());
+ m_tabWidget->setCurrentWidget(chatWidget);
- if(m_tabWidget->isTabBarHidden()) {
- if(m_tabWidget->count() > 1) {
- m_tabWidget->setTabBarHidden(false);
+ if(m_tabWidget->isTabBarHidden()) {
+ if(m_tabWidget->count() > 1) {
+ m_tabWidget->setTabBarHidden(false);
+ }
}
}
diff --git a/app/chat-window.h b/app/chat-window.h
index b023241..e921d12 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -35,7 +35,12 @@ public:
ChatWindow();
virtual ~ChatWindow();
- void addTab(ChatWidget *chatWidget);
+ /**
+ * starts a new chat with the textChannelPtr given only if the
+ * chat doesn't already exist
+ * @param incomingTextChannel new text channel
+ */
+ void startChat(Tp::TextChannelPtr incomingTextChannel);
public slots:
void removeTab(QWidget *chatWidget);
diff --git a/app/telepathy-chat-ui.cpp b/app/telepathy-chat-ui.cpp
index 776c148..0845892 100644
--- a/app/telepathy-chat-ui.cpp
+++ b/app/telepathy-chat-ui.cpp
@@ -70,9 +70,8 @@ void TelepathyChatUi::handleChannels(const Tp::MethodInvocationContextPtr<> & co
}
Q_ASSERT(textChannel);
- ChatWidget* newChatWidget = new ChatWidget(textChannel, m_chatWindow);
-
- m_chatWindow->addTab(newChatWidget);
+ // create new chat
+ m_chatWindow->startChat(textChannel);
m_chatWindow->show();
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 5a8bab3..d0b0720 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -221,6 +221,10 @@ void ChatWidget::resizeEvent(QResizeEvent *e)
QWidget::resizeEvent(e);
}
+Tp::TextChannelPtr ChatWidget::textChannel() const
+{
+ return d->channel;
+}
QString ChatWidget::title() const
{
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 95d4eb6..ca24bc7 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -38,6 +38,9 @@ public:
explicit ChatWidget(const Tp::TextChannelPtr & channel, QWidget *parent = 0);
virtual ~ChatWidget();
+ /** Returns the text channel pointer of the chatWidget */
+ Tp::TextChannelPtr textChannel() const;
+
/** Returns the name of this chat window*/
QString title() const;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list