[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:23:04 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=c7509e1

The following commit has been merged in the master branch:
commit c7509e10727532376b0c87f162d1f9794db07aa4
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Fri Dec 28 13:58:47 2012 +0100

    Add action to clear current chat tab
    
    REVIEW: 107967
    BUG: 298319
    FIXED-IN: 0.6.0
---
 app/chat-window.cpp | 15 +++++++++
 app/chat-window.h   |  1 +
 app/chatwindow.rc   |  2 ++
 lib/chat-widget.cpp | 92 ++++++++++++++++++++++++++++++++---------------------
 lib/chat-widget.h   |  5 +++
 5 files changed, 78 insertions(+), 37 deletions(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 0423d70..1b4f618 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -510,6 +510,16 @@ void ChatWindow::onOpenLogTriggered()
     }
 }
 
+void ChatWindow::onClearViewTriggered()
+{
+    ChatWidget *chatWidget = qobject_cast<ChatWidget*>(m_tabWidget->currentWidget());
+
+    if (!chatWidget) {
+        return;
+    }
+
+    chatWidget->clear();
+}
 
 void ChatWindow::showSettingsDialog()
 {
@@ -620,6 +630,10 @@ void ChatWindow::setupCustomActions()
     m_accountIconLabel = new QLabel(this);
     accountIconAction->setDefaultWidget(m_accountIconLabel);
 
+    KAction *clearViewAction = new KAction(KIcon(QLatin1String("edit-clear-history")), i18n("&Clear View"), this);
+    clearViewAction->setToolTip(i18nc("Toolbar icon tooltip", "Clear all messages from current chat tab"));
+    connect(clearViewAction, SIGNAL(triggered()), this, SLOT(onClearViewTriggered()));
+
     // add custom actions to the collection
     actionCollection()->addAction(QLatin1String("next-tab"), nextTabAction);
     actionCollection()->addAction(QLatin1String("previous-tab"), previousTabAction);
@@ -632,6 +646,7 @@ void ChatWindow::setupCustomActions()
     actionCollection()->addAction(QLatin1String("account-icon"), accountIconAction);
     actionCollection()->addAction(QLatin1String("block-contact"), blockContactAction);
     actionCollection()->addAction(QLatin1String("open-log"), openLogAction);
+    actionCollection()->addAction(QLatin1String("clear-chat-view"), clearViewAction);
 }
 
 void ChatWindow::setAudioCallEnabled(bool enable)
diff --git a/app/chat-window.h b/app/chat-window.h
index a722105..759942f 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -98,6 +98,7 @@ private Q_SLOTS:
     void onUnblockContactTriggered();                           /** Unblocks contact when already blocked */
     void onShareDesktopTriggered();                             /** start a desktop share */
     void onOpenLogTriggered();                                  /** Starts ktp-log-viewer accountId contactId */
+    void onClearViewTriggered();                                /** Clears current view */
     void setTabSpellDictionary(const QString &dict);            /** set the spelling language for the current chat tab*/
     void toggleBlockButton(bool contactIsBlocked);              /** Toggle block/unblock action according to the flag */
     void updateAccountIcon();                                   /** Update account icon fake action */
diff --git a/app/chatwindow.rc b/app/chatwindow.rc
index 6e8c002..29f7c17 100644
--- a/app/chatwindow.rc
+++ b/app/chatwindow.rc
@@ -19,6 +19,8 @@
    <Action name="open-log"/>
    <Separator />
    <Action name="block-contact"/>
+   <Separator />
+   <Action name="clear-chat-view"/>
   </Menu>
   <Menu name="settings"/>
   <Menu name="help"/>
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index fb40ccc..568b7e2 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -58,7 +58,8 @@ class ChatWidgetPrivate
 public:
     ChatWidgetPrivate() :
         remoteContactChatState(Tp::ChannelChatStateInactive),
-        isGroupChat(false)
+        isGroupChat(false),
+        logsLoaded(false)
     {
     }
     /** Stores whether the channel is ready with all contacts upgraded*/
@@ -74,6 +75,7 @@ public:
     ChannelContactModel *contactModel;
     LogManager *logManager;
     QTimer *pausedStateTimer;
+    bool logsLoaded;
 
     QList< Tp::OutgoingFileTransferChannelPtr > tmpFileTransfers;
 
@@ -95,6 +97,7 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
     d->channel = channel;
     d->account = account;
     d->logManager = new LogManager(this);
+    connect(d->logManager, SIGNAL(fetched(QList<AdiumThemeContentInfo>)), SLOT(onHistoryFetched(QList<AdiumThemeContentInfo>)));
 
     connect(d->account.data(), SIGNAL(currentPresenceChanged(Tp::Presence)),
             this, SLOT(currentPresenceChanged(Tp::Presence)));
@@ -123,44 +126,13 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
 
     d->yourName = channel->groupSelfContact()->alias();
 
-    d->ui.chatArea->load((d->isGroupChat?AdiumThemeView::GroupChat:AdiumThemeView::SingleUserChat));
-
     d->ui.sendMessageBox->setAcceptDrops(false);
     d->ui.chatArea->setAcceptDrops(false);
     setAcceptDrops(true);
 
-    AdiumThemeHeaderInfo info;
-
-    info.setGroupChat(d->isGroupChat);
-    //normal chat - self and one other person.
-    if (d->isGroupChat) {
-        info.setChatName(d->channel->targetId());
-    }
-    else
-    {
-        Tp::ContactPtr otherContact = d->channel->targetContact();
-
-        Q_ASSERT(otherContact);
-
-        d->contactName = otherContact->alias();
-        info.setDestinationDisplayName(otherContact->alias());
-        info.setDestinationName(otherContact->id());
-        info.setChatName(otherContact->alias());
-        info.setIncomingIconPath(otherContact->avatarData().fileName);
-        d->ui.contactsView->hide();
-    }
-
-    info.setSourceName(d->channel->connection()->protocolName());
-
-    //set up anything related to 'self'
-    info.setOutgoingIconPath(d->channel->groupSelfContact()->avatarData().fileName);
-    info.setTimeOpened(QDateTime::currentDateTime());
-    info.setServiceIconImage(KIconLoader::global()->iconPath(d->account->iconName(), KIconLoader::Panel));
+    /* Prepare the chat area */
     connect(d->ui.chatArea, SIGNAL(loadFinished(bool)), SLOT(chatViewReady()), Qt::QueuedConnection);
-    d->ui.chatArea->initialise(info);
-
-    //set the title of this chat.
-    d->title = info.chatName();
+    initChatArea();
 
     loadSpellCheckingOption();
 
@@ -169,6 +141,7 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
 
     // make the sendMessageBox a focus proxy for the chatview
     d->ui.chatArea->setFocusProxy(d->ui.sendMessageBox);
+
     connect(d->ui.sendMessageBox, SIGNAL(returnKeyPressed()), SLOT(sendMessage()));
 
     connect(d->ui.searchBar, SIGNAL(findTextSignal(QString,QWebPage::FindFlags)), this, SLOT(findTextInChat(QString,QWebPage::FindFlags)));
@@ -773,8 +746,11 @@ void ChatWidget::handleMessageSent(const Tp::Message &message, Tp::MessageSendin
 
 void ChatWidget::chatViewReady()
 {
-    connect(d->logManager, SIGNAL(fetched(QList<AdiumThemeContentInfo>)), SLOT(onHistoryFetched(QList<AdiumThemeContentInfo>)));
-    d->logManager->fetchLast();
+    if (!d->logsLoaded) {
+        d->logManager->fetchLast();
+    }
+
+    d->logsLoaded = true;
 }
 
 
@@ -1029,9 +1005,51 @@ bool ChatWidget::previousConversationAvailable()
     return m_previousConversationAvailable;
 }
 
+void ChatWidget::clear()
+{
+    // Don't reload logs when re-initializing */
+    d->logsLoaded = true;
+    initChatArea();
+}
+
+void ChatWidget::initChatArea()
+{
+    d->ui.chatArea->load((d->isGroupChat ? AdiumThemeView::GroupChat : AdiumThemeView::SingleUserChat));
+
+    AdiumThemeHeaderInfo info;
+
+    info.setGroupChat(d->isGroupChat);
+    //normal chat - self and one other person.
+    if (d->isGroupChat) {
+        info.setChatName(d->channel->targetId());
+    } else {
+        Tp::ContactPtr otherContact = d->channel->targetContact();
+
+        Q_ASSERT(otherContact);
+
+        d->contactName = otherContact->alias();
+        info.setDestinationDisplayName(otherContact->alias());
+        info.setDestinationName(otherContact->id());
+        info.setChatName(otherContact->alias());
+        info.setIncomingIconPath(otherContact->avatarData().fileName);
+        d->ui.contactsView->hide();
+    }
+
+    info.setSourceName(d->channel->connection()->protocolName());
+
+    //set up anything related to 'self'
+    info.setOutgoingIconPath(d->channel->groupSelfContact()->avatarData().fileName);
+    info.setTimeOpened(QDateTime::currentDateTime());
+    info.setServiceIconImage(KIconLoader::global()->iconPath(d->account->iconName(), KIconLoader::Panel));
+    d->ui.chatArea->initialise(info);
+
+    //set the title of this chat.
+    d->title = info.chatName();
+}
+
 void ChatWidget::onChatPausedTimerExpired()
 {
-        d->channel->requestChatState(Tp::ChannelChatStatePaused);
+     d->channel->requestChatState(Tp::ChannelChatStatePaused);
 }
 
 void ChatWidget::currentPresenceChanged(const Tp::Presence &presence)
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 30a24e0..a103a9b 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -91,6 +91,8 @@ public:
 
     bool previousConversationAvailable();
 
+    void clear();
+
 public Q_SLOTS:
     /** toggle the search bar visibility */
     void toggleSearchBar() const;
@@ -186,6 +188,9 @@ private:
     /** Loads language option for specified target Id */
     void loadSpellCheckingOption();
 
+    /** Loads theme into the the AdiumThemeView */
+    void initChatArea();
+
     virtual bool isOnTop() const;
     bool m_previousConversationAvailable;
 

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list