Skip to content

Commit

Permalink
SocketApi/Sharing: Add "copy public link" to menu #6356
Browse files Browse the repository at this point in the history
* The new menu option will fetch shares and create a new link share if
  no "context menu share" currently exists.
* Various cleanup of common operations in socketapi happened as well,
  in particular there's now FileData::get() that calculates all the
  relevant paths that are useful for most socketapi actions.
  • Loading branch information
ckamm committed Apr 16, 2018
1 parent aaa00c1 commit 93d8810
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 134 deletions.
2 changes: 2 additions & 0 deletions src/gui/ocsshareejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "ocsshareejob.h"

#include <QJsonDocument>

namespace OCC {

OcsShareeJob::OcsShareeJob(AccountPtr account)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ocssharejob.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <QList>
#include <QPair>

class QJsonDocument;

namespace OCC {

/**
Expand Down
4 changes: 2 additions & 2 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ void ownCloudGui::raiseDialog(QWidget *raiseWidget)
}


void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath)
void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath, ShareDialogStartPage startPage)
{
const auto folder = FolderMan::instance()->folderForPath(localPath);
if (!folder) {
Expand Down Expand Up @@ -1076,7 +1076,7 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l
w = _shareDialogs[localPath];
} else {
qCInfo(lcApplication) << "Opening share dialog" << sharePath << localPath << maxSharingPermissions;
w = new ShareDialog(accountState, sharePath, localPath, maxSharingPermissions, fileRecord.numericFileId());
w = new ShareDialog(accountState, sharePath, localPath, maxSharingPermissions, fileRecord.numericFileId(), startPage);
w->setAttribute(Qt::WA_DeleteOnClose, true);

_shareDialogs[localPath] = w;
Expand Down
7 changes: 6 additions & 1 deletion src/gui/owncloudgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Application;
class LogBrowser;
class AccountState;

enum class ShareDialogStartPage {
UsersAndGroups,
PublicLinks,
};

/**
* @brief The ownCloudGui class
* @ingroup gui
Expand Down Expand Up @@ -93,7 +98,7 @@ public slots:
* localPath is the absolute local path to it (so not relative
* to the folder).
*/
void slotShowShareDialog(const QString &sharePath, const QString &localPath);
void slotShowShareDialog(const QString &sharePath, const QString &localPath, ShareDialogStartPage startPage);

void slotRemoveDestroyedShareDialogs();

Expand Down
5 changes: 5 additions & 0 deletions src/gui/sharedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
const QString &localPath,
SharePermissions maxSharingPermissions,
const QByteArray &numericFileId,
ShareDialogStartPage startPage,
QWidget *parent)
: QDialog(parent)
, _ui(new Ui::ShareDialog)
Expand All @@ -47,6 +48,7 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
, _localPath(localPath)
, _maxSharingPermissions(maxSharingPermissions)
, _privateLinkUrl(accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded))
, _startPage(startPage)
, _linkWidget(NULL)
, _userGroupWidget(NULL)
, _progressIndicator(NULL)
Expand Down Expand Up @@ -217,6 +219,9 @@ void ShareDialog::showSharingUi()
_linkWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
_ui->shareWidgets->addTab(_linkWidget, tr("Public Links"));
_linkWidget->getShares();

if (_startPage == ShareDialogStartPage::PublicLinks)
_ui->shareWidgets->setCurrentWidget(_linkWidget);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/sharedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "accountstate.h"
#include "sharepermissions.h"
#include "owncloudgui.h"

#include <QPointer>
#include <QString>
Expand Down Expand Up @@ -44,6 +45,7 @@ class ShareDialog : public QDialog
const QString &localPath,
SharePermissions maxSharingPermissions,
const QByteArray &numericFileId,
ShareDialogStartPage startPage,
QWidget *parent = 0);
~ShareDialog();

Expand All @@ -64,6 +66,7 @@ private slots:
SharePermissions _maxSharingPermissions;
QByteArray _numericFileId;
QString _privateLinkUrl;
ShareDialogStartPage _startPage;

ShareLinkWidget *_linkWidget;
ShareUserGroupWidget *_userGroupWidget;
Expand Down
Loading

0 comments on commit 93d8810

Please sign in to comment.