&share)
+void ShareLinkWidget::confirmAndDeleteShare()
{
auto messageBox = new QMessageBox(
QMessageBox::Question,
tr("Confirm Link Share Deletion"),
tr("Do you really want to delete the public link share %1?
"
"Note: This action cannot be undone.
")
- .arg(shareName(*share)),
+ .arg(shareName()),
QMessageBox::NoButton,
this);
QPushButton *yesButton =
@@ -564,91 +468,64 @@ void ShareLinkWidget::confirmAndDeleteShare(const QSharedPointer &sha
messageBox->addButton(tr("Cancel"), QMessageBox::NoRole);
connect(messageBox, &QMessageBox::finished, this,
- [messageBox, yesButton, share]() {
- if (messageBox->clickedButton() == yesButton)
- share->deleteShare();
+ [messageBox, yesButton, this]() {
+ if (messageBox->clickedButton() == yesButton){
+ // TODO: dlete is not hapenning correctly
+ this->_linkShare->deleteShare();
+ this->_ui->enableShareLink->setChecked(false);
+ this->_ui->shareLinkToolButton->setEnabled(false);
+ }
});
messageBox->open();
}
-QString ShareLinkWidget::shareName(const LinkShare &share) const
+QString ShareLinkWidget::shareName() const
{
- QString name = share.getName();
+ QString name = _linkShare->getName();
if (!name.isEmpty())
return name;
if (!_namesSupported)
return tr("Public link");
- return share.getToken();
+ return _linkShare->getToken();
}
void ShareLinkWidget::slotContextMenuButtonClicked()
{
- auto share = sender()->property(propertyShareC).value>();
- bool downloadEnabled = share->getShowFileListing();
- _copyDirectLinkAction->setVisible(downloadEnabled);
- _emailDirectLinkAction->setVisible(downloadEnabled);
-
- _linkContextMenu->setProperty(propertyShareC, QVariant::fromValue(share));
_linkContextMenu->exec(QCursor::pos());
}
void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
{
- auto share = sender()->property(propertyShareC).value>();
- if (action == _deleteLinkAction) {
- confirmAndDeleteShare(share);
- } else if (action == _copyLinkAction) {
- QApplication::clipboard()->setText(share->getLink().toString());
- } else if (action == _copyDirectLinkAction) {
- QApplication::clipboard()->setText(share->getDirectDownloadLink().toString());
- } else if (action == _emailLinkAction) {
- emailShareLink(share->getLink());
- } else if (action == _emailDirectLinkAction) {
- emailShareLink(share->getDirectDownloadLink());
- } else if (action == _openLinkAction) {
- openShareLink(share->getLink());
- }
-}
+ bool state = action->isChecked();
+ SharePermissions perm = SharePermissionRead;
-void ShareLinkWidget::slotDeleteShareClicked()
-{
- auto share = sender()->property(propertyShareC).value>();
- confirmAndDeleteShare(share);
-}
+ if (action == _copyLinkAction) {
+ QApplication::clipboard()->setText(_linkShare->getLink().toString());
-void ShareLinkWidget::slotPermissionsClicked()
-{
- if (auto current = selectedShare()) {
- _ui->widget_editing->setEnabled(false);
- _pi_editing->startAnimation();
- _ui->errorLabel->hide();
+ } else if (action == _readOnlyLinkAction && state) {
+ _linkShare->setPermissions(perm);
- SharePermissions perm = SharePermissionRead;
- if (_ui->radio_readWrite->isChecked()) {
- perm = SharePermissionRead | SharePermissionCreate
- | SharePermissionUpdate | SharePermissionDelete;
- } else if (_ui->radio_uploadOnly->isChecked()) {
- perm = SharePermissionCreate;
- }
- current->setPermissions(perm);
- }
-}
+ } else if (action == _allowEditingLinkAction && state) {
+ perm |= SharePermissionUpdate;
+ _linkShare->setPermissions(perm);
-QSharedPointer ShareLinkWidget::selectedShare() const
-{
- const auto items = _ui->linkShares->selectedItems();
- if (items.isEmpty()) {
- return QSharedPointer();
- }
+ } else if (action == _allowUploadEditingLinkAction && state) {
+ perm |= SharePermissionCreate | SharePermissionUpdate | SharePermissionDelete;
+ _linkShare->setPermissions(perm);
- return items.first()->data(Qt::UserRole).value>();
-}
+ } else if (action == _allowUploadLinkAction && state) {
+ perm = SharePermissionCreate;
+ _linkShare->setPermissions(perm);
-void ShareLinkWidget::slotPermissionsSet()
-{
- if (sender() == selectedShare().data()) {
- slotShareSelectionChanged();
+ } else if (action == _passwordProtectLinkAction) {
+ togglePasswordOptions(state);
+
+ } else if (action == _expirationDateLinkAction) {
+ toggleExpireDateOptions(state);
+
+ } else if (action == _unshareLinkAction) {
+ confirmAndDeleteShare();
}
}
@@ -666,9 +543,6 @@ void ShareLinkWidget::slotServerError(int code, const QString &message)
void ShareLinkWidget::slotPasswordSetError(int code, const QString &message)
{
slotServerError(code, message);
-
- _ui->checkBox_password->setEnabled(!_passwordRequired);
- _ui->lineEdit_password->setEnabled(true);
_ui->lineEdit_password->setFocus();
}
diff --git a/src/gui/sharelinkwidget.h b/src/gui/sharelinkwidget.h
index 365c596b7..fc3c6d6f7 100644
--- a/src/gui/sharelinkwidget.h
+++ b/src/gui/sharelinkwidget.h
@@ -55,30 +55,25 @@ public:
QWidget *parent = 0);
~ShareLinkWidget();
void getShares();
+ void toggleButton(bool show);
private slots:
void slotSharesFetched(const QList> &shares);
- void slotShareSelectionChanged();
+ //void slotShareSelectionChanged();
+
+ void slotCreateorDeleteShareLink(bool checked);
+ void slotCreatePassword();
- void slotShareNameEntered();
- void slotDeleteShareClicked();
- void slotCheckBoxPasswordClicked();
- void slotCheckBoxExpireClicked();
- void slotPasswordReturnPressed();
- void slotPermissionsClicked();
void slotExpireDateChanged(const QDate &date);
- void slotPasswordChanged(const QString &newText);
- void slotNameEdited(QTableWidgetItem *item);
void slotContextMenuButtonClicked();
void slotLinkContextMenuActionTriggered(QAction *action);
void slotDeleteShareFetched();
- void slotCreateShareFetched(const QSharedPointer &share);
+ void slotCreateShareFetched();
void slotCreateShareRequiresPassword(const QString &message);
void slotPasswordSet();
- void slotExpireSet();
- void slotPermissionsSet();
+ //void slotExpireSet();
void slotServerError(int code, const QString &message);
void slotPasswordSetError(int code, const QString &message);
@@ -86,23 +81,24 @@ private slots:
private:
void displayError(const QString &errMsg);
+ void togglePasswordOptions(bool enable);
void setPassword(const QString &password);
+
+ void toggleExpireDateOptions(bool enable);
void setExpireDate(const QDate &date);
void copyShareLink(const QUrl &url);
- void emailShareLink(const QUrl &url);
- void openShareLink(const QUrl &url);
/** Confirm with the user and then delete the share */
- void confirmAndDeleteShare(const QSharedPointer &share);
+ void confirmAndDeleteShare();
/** Retrieve a share's name, accounting for _namesSupported */
- QString shareName(const LinkShare &share) const;
+ QString shareName() const;
/**
* Retrieve the selected share, returning 0 if none.
*/
- QSharedPointer selectedShare() const;
+ //QSharedPointer selectedShare() const;
Ui::ShareLinkWidget *_ui;
AccountPtr _account;
@@ -116,28 +112,22 @@ private:
QProgressIndicator *_pi_editing;
ShareManager *_manager;
+ QSharedPointer _linkShare;
bool _isFile;
bool _passwordRequired;
bool _expiryRequired;
bool _namesSupported;
- // For maintaining the selection and temporary ui state
- // when getShares() finishes, but the selection didn't
- // change.
- QString _selectedShareId;
-
- // When a new share is created, we want to select it
- // the next time getShares() finishes. This stores its id.
- QString _newShareOverrideSelectionId;
-
- QMenu *_linkContextMenu = nullptr;
- QAction *_deleteLinkAction = nullptr;
- QAction *_openLinkAction = nullptr;
- QAction *_copyLinkAction = nullptr;
- QAction *_copyDirectLinkAction = nullptr;
- QAction *_emailLinkAction = nullptr;
- QAction *_emailDirectLinkAction = nullptr;
+ QMenu *_linkContextMenu;
+ QAction *_copyLinkAction;
+ QAction *_readOnlyLinkAction;
+ QAction *_allowEditingLinkAction;
+ QAction *_allowUploadEditingLinkAction;
+ QAction *_allowUploadLinkAction;
+ QAction *_passwordProtectLinkAction;
+ QAction *_expirationDateLinkAction;
+ QAction *_unshareLinkAction;
};
}
diff --git a/src/gui/sharelinkwidget.ui b/src/gui/sharelinkwidget.ui
index 5c4b2e648..5b47b0cbf 100644
--- a/src/gui/sharelinkwidget.ui
+++ b/src/gui/sharelinkwidget.ui
@@ -6,82 +6,74 @@
0
0
- 441
- 568
+ 350
+ 126
+
+
+ 0
+ 0
+
+
+
+
+ 350
+ 110
+
+
+
+
+ 16777215
+ 16777215
+
+
Share NewDocument.odt
+
+ 10
+
+
+ QLayout::SetFixedSize
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
-
-
-
- Anyone with the link has access to the file/folder
-
-
- Qt::PlainText
-
-
+
+
true
-
-
- -
-
-
-
-
-
- Enter a name to create a new public link...
-
-
-
- -
-
-
- &Create new
-
-
-
-
-
- -
-
-
+
0
0
-
- Qt::ScrollBarAlwaysOff
+
+
+ 350
+ 0
+
-
- QAbstractItemView::SingleSelection
-
-
- QAbstractItemView::SelectRows
-
-
- false
-
-
- 3
-
-
- false
-
-
- false
-
-
-
-
-
-
- -
-
-
+
+
+ 3
+
+
+ QLayout::SetFixedSize
+
0
@@ -94,201 +86,341 @@
0
-
-
-
-
+
-
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+
+ 242
+ 26
+
+
+
+
+ 350
+ 26
+
+
+
+ Qt::LeftToRight
+
+
+ false
+
+
+ text-align: left
+
+
+ &Share link
+
+
+
+ :/client/resources/public.svg:/client/resources/public.svg
+
+
+ false
+
+
+ true
+
+
+
+ -
+
+
+
+ 82
+ 26
+
+
+
+ Enable
+
+
+
+ -
+
+
+ false
+
+
+
+ 26
+ 26
+
+
+
+ Qt::ActionsContextMenu
+
+
+
+
+
+
+
+
+
+ :/client/resources/more.svg:/client/resources/more.svg
+
+
+ QToolButton::InstantPopup
+
+
+ Qt::ToolButtonIconOnly
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 300
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+
+ 0
+
+
+ QLayout::SetFixedSize
+
+
+ 18
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 162
+ 0
+
+
+
+ Password:
+
+
0
-
-
-
-
- Set &expiration date
-
-
-
- -
-
-
- true
-
-
-
-
+
- -
-
-
- 20
+
-
+
+
+
+ 0
+ 0
+
-
-
-
-
- QLineEdit::Password
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Set &password
-
-
-
-
+
+
+ 120
+ 26
+
+
+
+
+ 100
+ 16777215
+
+
+
+ QLineEdit::Password
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
- -
-
-
-
-
-
-
- 0
- 0
-
-
-
- Set password
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 18
+ 26
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ false
+
+
+ background-color: rgba(255, 255, 255, 0);
+
+
+
+
+
+
+ :/client/resources/confirm.svg:/client/resources/confirm.svg
+
+
+ true
+
+
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 0
- 0
-
-
-
- Recipients can view or download contents.
-
-
- true
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 6
-
-
-
-
- -
-
-
- Upload only (File Drop)
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Receive files from others without revealing the contents of the folder.
-
-
- true
-
-
-
- -
-
-
- Download / View
-
-
-
- -
-
-
- Download / View / Upload
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Recipients can view, download, edit, delete and upload contents.
-
-
- true
-
-
-
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 6
-
-
-
-
-
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 300
+ 0
+
+
+
+
+ 0
+
+
+ QLayout::SetFixedSize
+
+
+ 18
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 162
+ 26
+
+
+
+ Expiration date:
+
+
+ 0
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 120
+ 26
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 18
+ 26
+
+
+
+
+ 18
+ 16777215
+
+
+
+
+
+
+
+ :/client/resources/confirm.svg:/client/resources/confirm.svg
+
+
+ true
+
@@ -297,11 +429,23 @@
-
-
+
0
0
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
@@ -345,21 +489,25 @@
Qt::PlainText
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+ true
+
+
+ 0
+
+
+ 0
+