Share dialog: Add option to copy/email direct links #5627
authorChristian Kamm <mail@ckamm.de>
Tue, 2 May 2017 10:58:01 +0000 (12:58 +0200)
committerMarkus Goetz <markus@woboq.com>
Wed, 3 May 2017 08:26:27 +0000 (10:26 +0200)
src/gui/sharelinkwidget.cpp
src/gui/sharelinkwidget.h
src/gui/sharemanager.cpp
src/gui/sharemanager.h

index 5413cc55518dfffe2054620e74fb9c77b02ab40c..1195edb7f9956f583f2c6b04a4f70cf8b10eb468 100644 (file)
@@ -153,7 +153,9 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
     _shareLinkMenu = new QMenu(this);
     _openLinkAction = _shareLinkMenu->addAction(tr("Open link in browser"));
     _copyLinkAction = _shareLinkMenu->addAction(tr("Copy link to clipboard"));
+    _copyDirectLinkAction = _shareLinkMenu->addAction(tr("Copy link to clipboard (direct download)"));
     _emailLinkAction = _shareLinkMenu->addAction(tr("Send link by email"));
+    _emailDirectLinkAction = _shareLinkMenu->addAction(tr("Send link by email (direct download)"));
 
     /*
      * Create the share manager and connect it properly
@@ -533,14 +535,17 @@ void ShareLinkWidget::openShareLink(const QUrl &url)
 void ShareLinkWidget::slotShareLinkButtonTriggered(QAction *action)
 {
     auto share = sender()->property(propertyShareC).value<QSharedPointer<LinkShare>>();
-    QUrl url = share->getLink();
 
     if (action == _copyLinkAction) {
-        copyShareLink(url);
+        copyShareLink(share->getLink());
+    } else if (action == _copyDirectLinkAction) {
+        copyShareLink(share->getDirectDownloadLink());
     } else if (action == _emailLinkAction) {
-        emailShareLink(url);
+        emailShareLink(share->getLink());
+    } else if (action == _emailDirectLinkAction) {
+        emailShareLink(share->getDirectDownloadLink());
     } else if (action == _openLinkAction) {
-        openShareLink(url);
+        openShareLink(share->getLink());
     }
 }
 
index 898b79a49dc0ccbb5af20f503e08ada3d8dab164..7426f2219e9428dfd8abd66950775a8b55e549d8 100644 (file)
@@ -123,7 +123,9 @@ private:
     QMenu *_shareLinkMenu;
     QAction *_openLinkAction;
     QAction *_copyLinkAction;
+    QAction *_copyDirectLinkAction;
     QAction *_emailLinkAction;
+    QAction *_emailDirectLinkAction;
 };
 
 }
index 5d50fcea58b92ac168991baf0f834a35fb9cfca9..f4ee87cc2fde9419b05a4aa5e73c72a016e35fed 100644 (file)
@@ -109,6 +109,13 @@ QUrl LinkShare::getLink() const
     return _url;
 }
 
+QUrl LinkShare::getDirectDownloadLink() const
+{
+    QUrl url = _url;
+    url.setPath(url.path() + "/download");
+    return url;
+}
+
 QDate LinkShare::getExpireDate() const
 {
     return _expireDate;
index da97b4f371c60488b8badd0ebcdb80a0ca67965d..3331b53c64f0dd3647979a935d19c74053af11f1 100644 (file)
@@ -144,6 +144,11 @@ public:
      */
     QUrl getLink() const;
 
+    /*
+     * The share's link for direct downloading.
+     */
+    QUrl getDirectDownloadLink() const;
+
     /*
      * Get the publicUpload status of this share
      */