[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kte-collaborative] kte-plugin/ui: Add a GUI widget to upload a document to an existing server.
From:       Sven Brauch <svenbrauch () googlemail ! com>
Date:       2013-09-10 15:35:32
Message-ID: E1VJPyW-0005si-Nq () scm ! kde ! org
[Download RAW message or body]

Git commit 58a0d16f7038139c6ca584333823643fff1921f5 by Sven Brauch.
Committed on 10/09/2013 at 15:35.
Pushed by brauch into branch 'master'.

Add a GUI widget to upload a document to an existing server.

M  +34   -2    kte-plugin/ui/sharedocumentdialog.cpp
M  +3    -0    kte-plugin/ui/sharedocumentdialog.h

http://commits.kde.org/kte-collaborative/58a0d16f7038139c6ca584333823643fff1921f5

diff --git a/kte-plugin/ui/sharedocumentdialog.cpp b/kte-plugin/ui/sharedocumentdialog.cpp
index f4f3758..7582db2 100644
--- a/kte-plugin/ui/sharedocumentdialog.cpp
+++ b/kte-plugin/ui/sharedocumentdialog.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "sharedocumentdialog.h"
+#include "opencollabdocumentdialog.h"
 
 #include <ktpintegration/inftube.h>
 #include <KTp/Widgets/join-chat-room-dialog.h>
@@ -30,6 +31,8 @@
 #include <KTextEditor/Document>
 #include <KMessageWidget>
 #include <KIO/Job>
+#include <KPushButton>
+#include <KFileDialog>
 
 #include <QLayout>
 #include <QCommandLinkButton>
@@ -69,8 +72,11 @@ ShareDocumentDialog::ShareDocumentDialog(KTextEditor::View* activeView)
     shareContactButton->setIcon(KIcon("im-user"));
     QCommandLinkButton* shareChatRoomButton = new QCommandLinkButton(i18n("Share document with chat room"));
     shareChatRoomButton->setIcon(KIcon("resource-group"));
+    QCommandLinkButton* shareExistingServerButton = new QCommandLinkButton(i18n("Upload document to an existing server"));
+    shareExistingServerButton->setIcon(KIcon("applications-internet"));
     newConnectionBox->layout()->addWidget(shareContactButton);
     newConnectionBox->layout()->addWidget(shareChatRoomButton);
+    newConnectionBox->layout()->addWidget(shareExistingServerButton);
     w->layout()->addWidget(newConnectionBox);
 
     QGroupBox* addToExistingBox = new QGroupBox();
@@ -83,6 +89,7 @@ ShareDocumentDialog::ShareDocumentDialog(KTextEditor::View* activeView)
 
     connect(shareContactButton, SIGNAL(clicked(bool)), SLOT(shareWithContact()));
     connect(shareChatRoomButton, SIGNAL(clicked(bool)), SLOT(shareWithChatRoom()));
+    connect(shareExistingServerButton, SIGNAL(clicked(bool)), SLOT(putOnExistingServer()));
     connect(connections, SIGNAL(connectionClicked(uint,QString)),
             this, SLOT(shareWithExistingConnection(uint,QString)));
 
@@ -117,6 +124,31 @@ void ShareDocumentDialog::shareWithExistingConnection(uint port, QString nicknam
     connect(job, SIGNAL(finished(KJob*)), SLOT(jobFinished(KJob*)));
 }
 
+void ShareDocumentDialog::putOnExistingServer()
+{
+    KDialog serverParametersDialog;
+    serverParametersDialog.button(KDialog::Ok)->setText(i18n("Connect"));
+    HostSelectionWidget* w = new HostSelectionWidget;
+    serverParametersDialog.setMainWidget(w);
+    serverParametersDialog.resize(450, 200);
+    if ( serverParametersDialog.exec() ) {
+        foreach ( QWidget* w, findChildren<QWidget*>() ) {
+            w->setDisabled(true);
+        }
+        KUrl result = KFileDialog::getSaveUrl(w->selectedUrl());
+        if ( result.isValid() ) {
+            KIO::FileCopyJob* copyJob = KIO::file_copy(m_view->document()->url(), result);
+            connect(copyJob, SIGNAL(finished(KJob*)), SLOT(jobFinished(KJob*)));
+        }
+        else {
+            reject();
+        }
+    }
+    else {
+        reject();
+    }
+}
+
 void ShareDocumentDialog::shareWithContact()
 {
     KTp::ContactGridDialog dialog(this);
@@ -132,11 +164,11 @@ void ShareDocumentDialog::shareWithContact()
                     this, SIGNAL(shouldOpenDocument(KUrl)));
         }
         else {
-            accept();
+            reject();
         }
     }
     else {
-        accept();
+        reject();
     }
 }
 
diff --git a/kte-plugin/ui/sharedocumentdialog.h b/kte-plugin/ui/sharedocumentdialog.h
index bdb4783..e331543 100644
--- a/kte-plugin/ui/sharedocumentdialog.h
+++ b/kte-plugin/ui/sharedocumentdialog.h
@@ -27,6 +27,7 @@
 class InfTubeRequester;
 class ServerManager;
 class KJob;
+class HostSelectionWidget;
 
 namespace KTextEditor {
     class View;
@@ -44,6 +45,7 @@ private slots:
     void shareWithChatRoom();
     void shareWithExistingConnection(uint, QString);
     void jobFinished(KJob* job);
+    void putOnExistingServer();
 
 signals:
     void shouldOpenDocument(const KUrl& url);
@@ -51,6 +53,7 @@ signals:
 private:
     KTextEditor::View* m_view;
     InfTubeRequester* m_tubeServer;
+    HostSelectionWidget* m_hostSelectionWidget;
 };
 
 #endif // SHAREDOCUMENTDIALOG_H
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic