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

List:       kde-commits
Subject:    [kdeconnect-kde/filetransfer-debug] kded: Added button to open incoming file transfer's folder in br
From:       Albert Vaca <albertvaka () gmail ! com>
Date:       2013-10-01 1:18:43
Message-ID: E1VQobr-00064T-Ub () scm ! kde ! org
[Download RAW message or body]

Git commit a06cf677f417c9543b9f18e213f10b59be5d9c06 by Albert Vaca.
Committed on 01/10/2013 at 00:44.
Pushed by albertvaka into branch 'filetransfer-debug'.

Added button to open incoming file transfer's folder in browser

M  +2    -2    kded/filetransferjob.cpp
M  +9    -2    kded/plugins/filetransfer/filetransferplugin.cpp
M  +3    -1    kded/plugins/filetransfer/filetransferplugin.h

http://commits.kde.org/kdeconnect-kde/a06cf677f417c9543b9f18e213f10b59be5d9c06

diff --git a/kded/filetransferjob.cpp b/kded/filetransferjob.cpp
index ce597ee..bc40366 100644
--- a/kded/filetransferjob.cpp
+++ b/kded/filetransferjob.cpp
@@ -28,6 +28,7 @@
 FileTransferJob::FileTransferJob(const QSharedPointer<QIODevice>& origin, int size, \
const KUrl& destination): KJob()  {
     Q_ASSERT(destination.isLocalFile());
+    //TODO: Make a precondition before calling this function that destination file \
                exists
     QFile(destination.path()).open(QIODevice::WriteOnly | QIODevice::Truncate); \
//HACK: KIO is so dumb it can't create the file if it doesn't exist  mDestination = \
                KIO::open(destination, QIODevice::WriteOnly);
     connect(mDestination, SIGNAL(open(KIO::Job*)), this, SLOT(open(KIO::Job*)));
@@ -86,9 +87,8 @@ void FileTransferJob::readyRead()
     }
 
     if (mSize > -1 && mWritten >= mSize) { //At the end or expected size reached
-        qDebug() << "No more data to read";
-        disconnect(mOrigin.data(), SIGNAL(readyRead()),this, SLOT(readyRead()));
         mOrigin->close();
+        //sourceFinished();
     } else if (mOrigin->bytesAvailable() > 0) {
         QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
     }
diff --git a/kded/plugins/filetransfer/filetransferplugin.cpp \
b/kded/plugins/filetransfer/filetransferplugin.cpp index bbf5caf..13b56cb 100644
--- a/kded/plugins/filetransfer/filetransferplugin.cpp
+++ b/kded/plugins/filetransfer/filetransferplugin.cpp
@@ -65,12 +65,14 @@ bool FileTransferPlugin::receivePackage(const NetworkPackage& np)
 
     }
 */
+
     if (np.type() != PACKAGE_TYPE_FILETRANSFER) return false;
     qDebug() << "File transfer";
 
     if (np.hasPayload()) {
-        qDebug() << "receiving file";
+        //qDebug() << "receiving file";
         QString filename = np.get<QString>("filename", \
QString::number(QDateTime::currentMSecsSinceEpoch())); +        //TODO: Ask before \
                overwritting or rename file if it already exists
         FileTransferJob* job = np.createPayloadTransferJob(mDestinationDir + \
filename);  connect(job, SIGNAL(result(KJob*)), this, SLOT(finished(KJob*)));
         job->start();
@@ -111,7 +113,12 @@ void FileTransferPlugin::finished(KJob* job)
     notification->setComponentData(KComponentData("kdeconnect", "kdeconnect"));
     notification->setTitle(i18n("Transfer finished"));
     notification->setText(transferJob->destination().fileName());
-    //TODO: Add action "open destination folder"
+    notification->setActions(QStringList(i18n("Open destination folder")));
+    connect(notification, SIGNAL(action1Activated()), this, \
SLOT(openDestinationFolder()));  notification->sendEvent();
+}
 
+void FileTransferPlugin::openDestinationFolder()
+{
+    QDesktopServices::openUrl(mDestinationDir);
 }
diff --git a/kded/plugins/filetransfer/filetransferplugin.h \
b/kded/plugins/filetransfer/filetransferplugin.h index f9fa786..1b49f7a 100644
--- a/kded/plugins/filetransfer/filetransferplugin.h
+++ b/kded/plugins/filetransfer/filetransferplugin.h
@@ -39,9 +39,11 @@ public Q_SLOTS:
     virtual void connected() { }
     void finished(KJob*);
 
+private Q_SLOTS:
+    void openDestinationFolder();
+
 private:
     QString mDestinationDir;
 
 };
-
 #endif


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

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