diff options
author | Christian Kamm <mail@ckamm.de> | 2017-05-10 10:37:10 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2017-07-07 11:49:51 +0300 |
commit | 0238a29c7cd8bffce79ac684d3aae15bed481412 (patch) | |
tree | 4593643a79402585a99c0476c2b22e2dd1e6a7ee /src/gui/sharelinkwidget.cpp | |
parent | d01065b9a12e69ca493a232f3a8e8f3d416fed52 (diff) |
Introduce private link sharing #5023
* SocketAPI has COPL_LOCAL_LINK / EMAIL_LOCAL_LINK commands
* The nautilus and dolphing shell integrations show a submenu from which
one can share as well as access the private link.
* The SocketAPI provides a new GET_STRINGS command to access localized
strings.
* The private link can also be accessed from the user/group sharing
dialog.
* The numeric file id is extracted from the full id to create the
private link url.
Diffstat (limited to 'src/gui/sharelinkwidget.cpp')
-rw-r--r-- | src/gui/sharelinkwidget.cpp | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp index b2f6d7c7d..f3b8e33da 100644 --- a/src/gui/sharelinkwidget.cpp +++ b/src/gui/sharelinkwidget.cpp @@ -19,6 +19,7 @@ #include "capabilities.h" #include "sharemanager.h" +#include "guiutility.h" #include "QProgressIndicator.h" #include <QBuffer> @@ -494,51 +495,18 @@ void ShareLinkWidget::slotCheckBoxExpireClicked() } } -#ifdef Q_OS_MAC -extern void copyToPasteboard(const QString &string); -#endif - -void ShareLinkWidget::copyShareLink(const QUrl &url) -{ -#ifdef Q_OS_MAC - copyToPasteboard(url.toString()); -#else - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(url.toString()); -#endif -} - void ShareLinkWidget::emailShareLink(const QUrl &url) { QString fileName = _sharePath.mid(_sharePath.lastIndexOf('/') + 1); - - if (!QDesktopServices::openUrl(QUrl(QString( - "mailto: " - "?subject=I shared %1 with you" - "&body=%2") - .arg( - fileName, - url.toString()), - QUrl::TolerantMode))) { - QMessageBox::warning( - this, - tr("Could not open email client"), - tr("There was an error when launching the email client to " - "create a new message. Maybe no default email client is " - "configured?")); - } + Utility::openEmailComposer( + QString("I shared %1 with you").arg(fileName), + url.toString(), + this); } void ShareLinkWidget::openShareLink(const QUrl &url) { - if (!QDesktopServices::openUrl(url)) { - QMessageBox::warning( - this, - tr("Could not open browser"), - tr("There was an error when launching the browser to " - "view the public link share. Maybe no default browser is " - "configured?")); - } + Utility::openBrowser(url, this); } void ShareLinkWidget::slotShareLinkButtonTriggered(QAction *action) @@ -546,9 +514,9 @@ void ShareLinkWidget::slotShareLinkButtonTriggered(QAction *action) auto share = sender()->property(propertyShareC).value<QSharedPointer<LinkShare>>(); if (action == _copyLinkAction) { - copyShareLink(share->getLink()); + QApplication::clipboard()->setText(share->getLink().toString()); } else if (action == _copyDirectLinkAction) { - copyShareLink(share->getDirectDownloadLink()); + QApplication::clipboard()->setText(share->getDirectDownloadLink().toString()); } else if (action == _emailLinkAction) { emailShareLink(share->getLink()); } else if (action == _emailDirectLinkAction) { |