[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:19:35 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=af7a823
The following commit has been merged in the master branch:
commit af7a823892e4da7353b0a10e1319f66f1dd5fcb3
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date: Mon Jul 11 22:30:16 2011 +0200
Tidy up & fix of previous "Detach Tabs" patch
this patch is a tidy up of the previous feature add.
REVIEW: 101899
Reviewed by: David Edmundson
---
app/chat-tab.cpp | 16 ++++++------
app/chat-tab.h | 13 +++++++---
app/chat-window.cpp | 62 +++++++++++++++++++++++------------------------
app/chat-window.h | 38 ++++++++++++++---------------
app/telepathy-chat-ui.cpp | 53 +++++++++++++++++++++-------------------
app/telepathy-chat-ui.h | 25 ++++++++++---------
6 files changed, 107 insertions(+), 100 deletions(-)
diff --git a/app/chat-tab.cpp b/app/chat-tab.cpp
index 018868e..62c3c10 100644
--- a/app/chat-tab.cpp
+++ b/app/chat-tab.cpp
@@ -44,22 +44,22 @@ ChatTab::~ChatTab()
{
}
-void ChatTab::setWindow(ChatWindow* window)
+void ChatTab::setChatWindow(ChatWindow* window)
{
- kDebug();
-
- if(m_chatWindow) {
+ // remove the tab from current ChatWindow
+ if (m_chatWindow) {
m_chatWindow->removeTab(this);
}
m_chatWindow = window;
- if(window) {
- window->addTab(this);
+ // set tab in new chatWindow
+ if (m_chatWindow) {
+ m_chatWindow->addTab(this);
}
}
-ChatWindow* ChatTab::window() const
+ChatWindow* ChatTab::chatWindow() const
{
return m_chatWindow;
}
@@ -67,7 +67,7 @@ ChatWindow* ChatTab::window() const
void ChatTab::showOnTop()
{
kDebug() << "Show this widget on top" << title();
- if(m_chatWindow) {
+ if (m_chatWindow) {
m_chatWindow->focusChat(this);
} else {
kError() << "Attempting to focus chatTab without chatWindow being set!";
diff --git a/app/chat-tab.h b/app/chat-tab.h
index 408bb91..9b5fc59 100644
--- a/app/chat-tab.h
+++ b/app/chat-tab.h
@@ -27,9 +27,8 @@
#include <KIcon>
#include <KColorScheme>
-class ChatWindow;
-
class ChatWidgetPrivate;
+class ChatWindow;
class QShowEvent;
class ChatTab : public ChatWidget
@@ -40,8 +39,13 @@ public:
explicit ChatTab(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, QWidget *parent = 0);
virtual ~ChatTab();
- void setWindow(ChatWindow* tab);
- ChatWindow* window() const;
+ /** set's a new chatWindow for the tab
+ * @param window chatWindow to set tab to
+ */
+ void setChatWindow(ChatWindow* window);
+
+ /** returns currently set chatWindow */
+ ChatWindow* chatWindow() const;
public slots:
void showOnTop();
@@ -52,6 +56,7 @@ private slots:
void onConnectionStatusChanged(Tp::ConnectionStatus);
private:
+ /** pointer to chat window the tab is nested in */
ChatWindow *m_chatWindow;
};
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 28905fa..fc2e773 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
- Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
+ Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka at gmail.com>
This program is free software: you can redistribute it and/or modify
@@ -75,11 +75,11 @@ ChatWindow::ChatWindow()
m_tabWidget->setCloseButtonEnabled(true);
m_tabWidget->setHoverCloseButtonDelayed(true);
m_tabWidget->setTabBarHidden(true);
- connect(m_tabWidget, SIGNAL(closeRequest(QWidget*)), this, SLOT( destroyTab(QWidget*)));
+
+ connect(m_tabWidget, SIGNAL(closeRequest(QWidget*)), this, SLOT(destroyTab(QWidget*)));
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
- connect(qobject_cast<KTabBar*>(m_tabWidget->tabBar()), SIGNAL(mouseMiddleClick(int)),
- m_tabWidget, SLOT(removeTab(int)));
- connect(qobject_cast<KTabBar*>(m_tabWidget->tabBar()), SIGNAL(contextMenu(int,QPoint)), SLOT(tabBarContextMenu(int,QPoint)));
+ connect(qobject_cast<KTabBar*>(m_tabWidget->tabBar()), SIGNAL(mouseMiddleClick(int)),m_tabWidget, SLOT(removeTab(int)));
+ connect(qobject_cast<KTabBar*>(m_tabWidget->tabBar()), SIGNAL(contextMenu(int, QPoint)), SLOT(tabBarContextMenu(int, QPoint)));
setCentralWidget(m_tabWidget);
@@ -88,15 +88,15 @@ ChatWindow::ChatWindow()
ChatWindow::~ChatWindow()
{
- emit aboutToClose();
+ emit aboutToClose(this);
}
void ChatWindow::tabBarContextMenu(int index, const QPoint& globalPos)
{
- KAction close(KIcon("tab-close", KIconLoader::global()), "Close", this);
- KAction dettach(KIcon("tab-detach", KIconLoader::global()), "Dettach Tab", this);
- KAction moveLeft(KIcon("arrow-left", KIconLoader::global()), "Move Tab Left", this);
- KAction moveRight(KIcon("arrow-right", KIconLoader::global()),"Move Tab Right", this);
+ KAction close(KIcon("tab-close", KIconLoader::global()), i18n("Close"), this);
+ KAction dettach(KIcon("tab-detach", KIconLoader::global()), i18n("Dettach Tab"), this);
+ KAction moveLeft(KIcon("arrow-left", KIconLoader::global()), i18n("Move Tab Left"), this);
+ KAction moveRight(KIcon("arrow-right", KIconLoader::global()), i18n("Move Tab Right"), this);
KMenu* menu = new KMenu(this);
@@ -105,9 +105,9 @@ void ChatWindow::tabBarContextMenu(int index, const QPoint& globalPos)
menu->addAction(&dettach);
menu->addAction(&close);
- if(index == 0) {
+ if (index == 0) {
moveLeft.setEnabled(false);
- } else if(index == (m_tabWidget->count() - 1)) {
+ } else if (index == (m_tabWidget->count() - 1)) {
moveRight.setEnabled(false);
}
@@ -116,7 +116,7 @@ void ChatWindow::tabBarContextMenu(int index, const QPoint& globalPos)
if(result == &close) {
destroyTab(m_tabWidget->widget(index));
} else if (result == &dettach) {
- emit dettachRequested(qobject_cast<ChatTab*>(m_tabWidget->widget(index)));
+ emit detachRequested(qobject_cast<ChatTab*>(m_tabWidget->widget(index)));
} else if (result == &moveLeft) {
m_tabWidget->moveTab(index, index - 1);
} else if (result == &moveRight) {
@@ -124,21 +124,20 @@ void ChatWindow::tabBarContextMenu(int index, const QPoint& globalPos)
}
}
-void ChatWindow::focusChat ( ChatTab* tab )
+void ChatWindow::focusChat(ChatTab* tab)
{
kDebug();
m_tabWidget->setCurrentWidget(tab);
}
-ChatTab* ChatWindow::getTab ( const Tp::TextChannelPtr& incomingTextChannel )
+ChatTab* ChatWindow::getTab(const Tp::TextChannelPtr& incomingTextChannel)
{
- ChatTab* match = NULL;
+ ChatTab* match = 0;
// if targetHandle is None, targetId is also ""
if (!incomingTextChannel->targetHandleType() == Tp::HandleTypeNone) {
- kDebug() << "ChatWindow::startChat target handle type is NOT HandleTypeNone";
- // check that the tab requested isn't already open
+ // check that the tab requested isn't already open
for (int index = 0; index < m_tabWidget->count() && !match; ++index) {
// get chatWidget object
@@ -153,7 +152,6 @@ ChatTab* ChatWindow::getTab ( const Tp::TextChannelPtr& incomingTextChannel )
}
}
}
-
return match;
}
@@ -172,7 +170,7 @@ void ChatWindow::removeTab(ChatTab* tab)
}
}
-void ChatWindow::addTab ( ChatTab* tab )
+void ChatWindow::addTab(ChatTab* tab)
{
kDebug();
@@ -195,7 +193,7 @@ void ChatWindow::destroyTab(QWidget* chatWidget)
ChatTab* tab = qobject_cast<ChatTab*>(chatWidget);
Q_ASSERT(tab);
- tab->setWindow(NULL);
+ tab->setChatWindow(0);
chatWidget->deleteLater();
}
@@ -426,6 +424,16 @@ void ChatWindow::showNotificationsDialog()
KNotifyConfigWidget::configure(this, "ktelepathy");
}
+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(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
+ disconnect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
+}
+
void ChatWindow::sendNotificationToUser(ChatWindow::NotificationType type, const QString& errorMsg)
{
//The pointer is automatically deleted when the event is closed
@@ -451,16 +459,6 @@ void ChatWindow::setupChatTabSignals(ChatTab *chatTab)
connect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
}
-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(contactPresenceChanged(Tp::Presence)), this, SLOT(onTabStateChanged()));
- disconnect(chatTab->chatSearchBar(), SIGNAL(enableSearchButtonsSignal(bool)), this, SLOT(onEnableSearchActions(bool)));
-}
-
void ChatWindow::setupCustomActions()
{
KAction *separator = new KAction(this);
diff --git a/app/chat-window.h b/app/chat-window.h
index a46e41b..0f25ab0 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -1,6 +1,7 @@
/*
- Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
- Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
+ Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka at gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +26,6 @@
#include <KXmlGuiWindow>
#include <KTabWidget>
-class TelepathyChatUi;
class KIcon;
class ChatTab;
@@ -42,28 +42,26 @@ public:
SystemInfoMessage
};
- /**
- * starts a new chat with the textChannelPtr given only if the
- * chat doesn't already exist
- * @param incomingTextChannel new text channel
- */
- void destroyTab(ChatTab *chatWidget);
+ void destroyTab(ChatTab *tab);
void setTabText(int index, const QString &newTitle);
void setTabIcon(int index, const KIcon &newIcon);
void setTabTextColor(int index,const QColor &color);
+
+ /** retrieves tab with given textChannel if it exists
+ * @param incomingTextChannel textChannel to search for
+ */
ChatTab* getTab(const Tp::TextChannelPtr &incomingTextChannel);
+
void focusChat(ChatTab* tab);
- /** creats a new chat and adds it to the tab widget
- * @param channelPtr pointer to textChannel to use
- */
+
void addTab(ChatTab* tab);
void removeTab(ChatTab* tab);
- TelepathyChatUi* ui();
- void setUi(TelepathyChatUi* ui);
signals:
- void aboutToClose();
- void dettachRequested(ChatTab*);
+ /** to emit before closing a window. This signal tells telepathyChatUi to remove the closed
+ * window from it's list of open windows */
+ void aboutToClose(ChatWindow *window);
+ void detachRequested(ChatTab *tab);
public slots:
void destroyTab(QWidget *chatWidget);
@@ -98,11 +96,15 @@ private:
*/
void sendNotificationToUser(NotificationType type, const QString &errorMsg);
+ /** removes chat tab signals. This is used when reparenting the chat tab
+ * (see "detachTab" )
+ */
+ void removeChatTabSignals(ChatTab *chatTab);
+
/** connects the neccessary chat tab signals with slots in chatwindow
* @param chatTab chatTab object to connect
*/
void setupChatTabSignals(ChatTab *chatTab);
- void removeChatTabSignals(ChatTab *chatTab);
/** creates and adds custom actions for the chat window */
void setupCustomActions();
@@ -132,8 +134,6 @@ private:
void startVideoCall(const Tp::AccountPtr &account, const Tp::ContactPtr &contact);
KTabWidget *m_tabWidget;
-
- TelepathyChatUi* m_chatUi;
};
#endif // CHATWINDOW_H
diff --git a/app/telepathy-chat-ui.cpp b/app/telepathy-chat-ui.cpp
index 71ac4ee..fe0fb9b 100644
--- a/app/telepathy-chat-ui.cpp
+++ b/app/telepathy-chat-ui.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
- Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
+ Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka at gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -41,30 +42,30 @@ TelepathyChatUi::TelepathyChatUi()
KSharedConfigPtr config = KSharedConfig::openConfig("ktelepathyrc");
KConfigGroup tabConfig = config->group("Behavior");
+ // load the settings for new tab "open mode"
QString mode = tabConfig.readEntry("tabOpenMode", "NewWindow");
- if(mode == "NewWindow"){
- openMode = NewWindow;
- } else if (mode == "FirstWindow"){
- openMode = FirstWindow;
- } else if (mode == "LastWindow"){
- openMode = LastWindow;
+ if (mode == "NewWindow") {
+ m_openMode = NewWindow;
+ } else if (mode == "FirstWindow") {
+ m_openMode = FirstWindow;
+ } else if (mode == "LastWindow") {
+ m_openMode = LastWindow;
}
}
-void TelepathyChatUi::removeWindow()
+void TelepathyChatUi::removeWindow(ChatWindow *window)
{
- ChatWindow* window = qobject_cast<ChatWindow*>(sender());
Q_ASSERT(window);
m_chatWindows.removeOne(window);
}
ChatWindow* TelepathyChatUi::createWindow()
{
- kDebug();
-
ChatWindow* window = new ChatWindow();
- connect(window, SIGNAL(aboutToClose()), SLOT(removeWindow()));
- connect(window, SIGNAL(dettachRequested(ChatTab*)), SLOT(dettachTab(ChatTab*)));
+
+ connect(window, SIGNAL(detachRequested(ChatTab*)), this, SLOT(dettachTab(ChatTab*)));
+ connect(window, SIGNAL(aboutToClose(ChatWindow*)), this, SLOT(removeWindow(ChatWindow*)));
+
m_chatWindows.push_back(window);
return window;
@@ -73,13 +74,12 @@ ChatWindow* TelepathyChatUi::createWindow()
void TelepathyChatUi::dettachTab(ChatTab* tab)
{
ChatWindow* window = createWindow();
- tab->setWindow(window);
+ tab->setChatWindow(window);
window->show();
}
TelepathyChatUi::~TelepathyChatUi()
{
- kDebug();
}
void TelepathyChatUi::handleChannels(const Tp::MethodInvocationContextPtr<> & context,
@@ -107,25 +107,27 @@ void TelepathyChatUi::handleChannels(const Tp::MethodInvocationContextPtr<> & co
Q_ASSERT(textChannel);
bool tabFound = false;
- foreach(ChatWindow* window, m_chatWindows) {
+
+ for (int i = 0; i < m_chatWindows.count() && !tabFound; ++i) {
+ ChatWindow *window = m_chatWindows.at(i);
ChatTab* tab = window->getTab(textChannel);
- if(tab){
- tabFound = true;
- tab->showOnTop(); // set focus on selected tab
+ if (tab) {
+ tabFound = true;
+ window->focusChat(tab); // set focus on selected tab
// check if channel is invalid. Replace only if invalid
// You get this status if user goes offline and then back on without closing the chat
if (!tab->textChannel()->isValid()) {
tab->setTextChannel(textChannel); // replace with new one
- tab->setChatEnabled(true); // re-enable chat
+ tab->setChatEnabled(true); // re-enable chat
}
}
}
- if(!tabFound) {
- ChatWindow* window = NULL;
- switch (openMode) {
+ if (!tabFound) {
+ ChatWindow* window;
+ switch (m_openMode) {
case FirstWindow:
window = m_chatWindows.count()?m_chatWindows[0]:createWindow();
break;
@@ -134,8 +136,9 @@ void TelepathyChatUi::handleChannels(const Tp::MethodInvocationContextPtr<> & co
window = createWindow();
break;
}
+
ChatTab* tab = new ChatTab(textChannel, account);
- tab->setWindow(window);
+ tab->setChatWindow(window);
window->show();
}
diff --git a/app/telepathy-chat-ui.h b/app/telepathy-chat-ui.h
index ad6809f..f3cab67 100644
--- a/app/telepathy-chat-ui.h
+++ b/app/telepathy-chat-ui.h
@@ -1,6 +1,7 @@
/*
- Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
- Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2010 David Edmundson <kde at davidedmundson.co.uk>
+ Copyright (C) 2011 Dominik Schmidt <dev at dominik-schmidt.de>
+ Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka at gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,16 +21,15 @@
#ifndef TELEPATHYCHATUI_H
#define TELEPATHYCHATUI_H
-#include "chat-window.h"
-
#include <TelepathyQt4/AbstractClientHandler>
#include <KApplication>
+class ChatTab;
+class ChatWindow;
class TelepathyChatUi : public KApplication, public Tp::AbstractClientHandler
{
Q_OBJECT
-
public:
TelepathyChatUi();
~TelepathyChatUi();
@@ -45,19 +45,20 @@ public:
virtual bool bypassApproval() const;
private slots:
- void removeWindow();
- void dettachTab(ChatTab*);
+ void removeWindow(ChatWindow *window);
+ void dettachTab(ChatTab *tab);
private:
- ChatWindow* createWindow();
-
- QList<ChatWindow*> m_chatWindows;
-
enum TabOpenMode {
NewWindow,
FirstWindow,
LastWindow
- } openMode;
+ };
+
+ ChatWindow* createWindow();
+
+ QList<ChatWindow*> m_chatWindows;
+ TabOpenMode m_openMode;
};
#endif // TELEPATHYCHATUI_H
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list