[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:24:06 UTC 2016


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

The following commit has been merged in the master branch:
commit 398af1dd5eaef0adc7ea70b8b13f656f577901f0
Author: Sven Brauch <svenbrauch at googlemail.com>
Date:   Thu Aug 29 17:07:01 2013 +0200

    Add "share document" action to text-ui
    
    REVIEW:112354
---
 app/chat-window.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 app/chat-window.h   | 16 ++++++++++++++
 app/chatwindow.rc   |  3 ++-
 3 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index c698204..9e101c0 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -62,6 +62,7 @@
 #include "emoticon-text-edit-action.h"
 #include "invite-contact-dialog.h"
 #include "telepathy-chat-ui.h"
+#include "fileShareRequest.h"
 #include "text-chat-config.h"
 
 #define PREFERRED_RFB_HANDLER "org.freedesktop.Telepathy.Client.krfb_rfb_handler"
@@ -352,7 +353,19 @@ void ChatWindow::onCurrentIndexChanged(int index)
         setShareDesktopEnabled(false);
         setInviteToChatEnabled(true);
         setBlockEnabled(false);
+    }
 
+    if ( currentChatTab->account()->connection() ) {
+        const QString collab(QLatin1String("infinote"));
+        bool selfCanShare = currentChatTab->account()->connection()->selfContact()->capabilities().streamTubes(collab);
+        if (currentChatTab->isGroupChat()) {
+            // We can always share documents with a group chat if we support the service
+            setCollaborateDocumentEnabled(selfCanShare);
+        }
+        else {
+            bool otherCanShare = currentChatTab->textChannel()->targetContact()->capabilities().streamTubes(collab);
+            setCollaborateDocumentEnabled(selfCanShare && otherCanShare);
+        }
     }
 
     // only show enable the action if there are actually previous converstations
@@ -462,6 +475,21 @@ void ChatWindow::onSearchActionToggled()
     currChat->toggleSearchBar();
 }
 
+void ChatWindow::onCollaborateDocumentTriggered()
+{
+    ChatTab *currChat = qobject_cast<ChatTab*>(m_tabWidget->currentWidget());
+
+    if(!currChat) {
+        return;
+    }
+    if (currChat->isGroupChat()) {
+        offerDocumentToChatroom(currChat->account(), currChat->textChannel()->targetId());
+    }
+    else {
+        offerDocumentToContact(currChat->account(), currChat->textChannel()->targetContact());
+    }
+}
+
 void ChatWindow::onTabStateChanged()
 {
     kDebug();
@@ -680,6 +708,9 @@ void ChatWindow::setupCustomActions()
     shareDesktopAction->setToolTip(i18nc("Toolbar icon tooltip", "Start an application that allows this contact to see your desktop"));
     connect(shareDesktopAction, SIGNAL(triggered()), this, SLOT(onShareDesktopTriggered()));
 
+    KAction* collaborateDocumentAction = new KAction(KIcon(QLatin1String("document-share")), i18n("&Collaboratively edit a document"), this);
+    connect(collaborateDocumentAction, SIGNAL(triggered()), this, SLOT(onCollaborateDocumentTriggered()));
+
     m_spellDictCombo = new Sonnet::DictionaryComboBox();
     connect(m_spellDictCombo, SIGNAL(dictionaryChanged(QString)),
             this, SLOT(setTabSpellDictionary(QString)));
@@ -727,6 +758,23 @@ void ChatWindow::setupCustomActions()
     actionCollection()->addAction(QLatin1String("clear-chat-view"), clearViewAction);
     actionCollection()->addAction(QLatin1String("emoticons"), addEmoticonAction);
     actionCollection()->addAction(QLatin1String("send-message"), m_sendMessage);
+    actionCollection()->addAction(QLatin1String("collaborate-document"), collaborateDocumentAction);
+}
+
+void ChatWindow::setCollaborateDocumentEnabled(bool enable)
+{
+    QAction* action = actionCollection()->action(QLatin1String("collaborate-document"));
+
+    if (action) {
+        action->setEnabled(enable);
+        if ( enable ) {
+            action->setToolTip(i18nc("Toolbar icon tooltip", "Edit a plain-text document with this contact in real-time"));
+        }
+        else {
+            action->setToolTip(i18nc("Toolbar icon tooltip for a disabled action", "<p>Both you and the target contact "
+                                     "need to have the <i>kte-collaborative</i> package installed to share documents</p>"));
+        }
+    }
 }
 
 void ChatWindow::setAudioCallEnabled(bool enable)
@@ -829,6 +877,22 @@ void ChatWindow::startFileTransfer(const Tp::AccountPtr& account, const Tp::Cont
     }
 }
 
+void ChatWindow::offerDocumentToContact(const Tp::AccountPtr& account, const Tp::ContactPtr& targetContact)
+{
+    const KUrl url = KFileDialog::getOpenUrl();
+    if ( ! url.isEmpty() ) {
+        KTp::Actions::startCollaborativeEditing(account, targetContact, QList<KUrl>() << url, true);
+    }
+}
+
+void ChatWindow::offerDocumentToChatroom(const Tp::AccountPtr& account, const QString& roomName)
+{
+   const KUrl url = KFileDialog::getOpenUrl();
+    if ( ! url.isEmpty() ) {
+        KTp::Actions::startCollaborativeEditing(account, roomName, QList<KUrl>() << url, true);
+    }
+}
+
 void ChatWindow::startVideoCall(const Tp::AccountPtr& account, const Tp::ContactPtr& contact)
 {
     Tp::PendingChannelRequest* channelRequest = KTp::Actions::startAudioVideoCall(account, contact);
diff --git a/app/chat-window.h b/app/chat-window.h
index 30981d0..793ac55 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -109,6 +109,7 @@ private Q_SLOTS:
     void onZoomFactorChanged(qreal zoom);
     void updateSendMessageShortcuts();
     void onReloadTheme();
+    void onCollaborateDocumentTriggered();
 
 protected Q_SLOTS:
     void showSettingsDialog();
@@ -142,6 +143,7 @@ private:
     void setVideoCallEnabled(bool enable);
     void setShareDesktopEnabled(bool enable);
     void setPreviousConversationsEnabled(bool enable);
+    void setCollaborateDocumentEnabled(bool enable);
 
     /** starts audio call with given contact
      * @param account account sending the audio call request
@@ -170,6 +172,20 @@ private:
     /** Returns whether there's at least one tab with unread message */
     bool hasUnreadMessages() const;
 
+    /**
+     * Offers a collaborative document to a contact, asking the user for which document to offer first.
+     * @param account The account offering the document
+     * @param targetContact The contact to offer the document to
+     */
+    void offerDocumentToContact(const Tp::AccountPtr& account, const Tp::ContactPtr& targetContact);
+
+    /**
+     * @brief Offers a collaborative document to a chatroom.
+     * @param account The account offering the document
+     * @param roomName The chatroom identifier to offer the document to
+     */
+    void offerDocumentToChatroom(const Tp::AccountPtr& account, const QString& roomName);
+
     KAction *m_sendMessage;
 
     KTabWidget *m_tabWidget;
diff --git a/app/chatwindow.rc b/app/chatwindow.rc
index 01c27c5..6ce51bb 100644
--- a/app/chatwindow.rc
+++ b/app/chatwindow.rc
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gui name="ktp-text-ui"
-     version="5"
+     version="6"
      xmlns="http://www.kde.org/standards/kxmlgui/1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
@@ -31,6 +31,7 @@
   <Action name="audio-call"/>
   <Action name="video-call"/>
   <Action name="send-file"/>
+  <Action name="collaborate-document"/>
   <Separator />
   <Action name="edit_find"/>
  </ToolBar>

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list