ShareLinkWidget::getLinkShare()
-{
- return _linkShare;
-}
-
-void ShareLinkWidget::focusPasswordLineEdit()
-{
- _ui->lineEdit_password->setFocus();
-}
-
-void ShareLinkWidget::setupUiOptions()
-{
- connect(_linkShare.data(), &LinkShare::noteSet, this, &ShareLinkWidget::slotNoteSet);
- connect(_linkShare.data(), &LinkShare::passwordSet, this, &ShareLinkWidget::slotPasswordSet);
- connect(_linkShare.data(), &LinkShare::passwordSetError, this, &ShareLinkWidget::slotPasswordSetError);
- connect(_linkShare.data(), &LinkShare::labelSet, this, &ShareLinkWidget::slotLabelSet);
-
- // Prepare permissions check and create group action
- const QDate expireDate = _linkShare.data()->getExpireDate().isValid() ? _linkShare.data()->getExpireDate() : QDate();
- const SharePermissions perm = _linkShare.data()->getPermissions();
- auto checked = false;
- auto *permissionsGroup = new QActionGroup(this);
-
- // Prepare sharing menu
- _linkContextMenu = new QMenu(this);
-
- // radio button style
- permissionsGroup->setExclusive(true);
-
- if (_isFile) {
- checked = (perm & SharePermissionRead) && (perm & SharePermissionUpdate);
- _allowEditingLinkAction = _linkContextMenu->addAction(tr("Allow editing"));
- _allowEditingLinkAction->setCheckable(true);
- _allowEditingLinkAction->setChecked(checked);
-
- } else {
- checked = (perm == SharePermissionRead);
- _readOnlyLinkAction = permissionsGroup->addAction(tr("View only"));
- _readOnlyLinkAction->setCheckable(true);
- _readOnlyLinkAction->setChecked(checked);
-
- checked = (perm & SharePermissionRead) && (perm & SharePermissionCreate)
- && (perm & SharePermissionUpdate) && (perm & SharePermissionDelete);
- _allowUploadEditingLinkAction = permissionsGroup->addAction(tr("Allow upload and editing"));
- _allowUploadEditingLinkAction->setCheckable(true);
- _allowUploadEditingLinkAction->setChecked(checked);
-
- checked = (perm == SharePermissionCreate);
- _allowUploadLinkAction = permissionsGroup->addAction(tr("File drop (upload only)"));
- _allowUploadLinkAction->setCheckable(true);
- _allowUploadLinkAction->setChecked(checked);
- }
-
- _shareLinkElidedLabel = new OCC::ElidedLabel(this);
- _shareLinkElidedLabel->setElideMode(Qt::ElideRight);
- displayShareLinkLabel();
- _ui->horizontalLayout->insertWidget(2, _shareLinkElidedLabel);
-
- _shareLinkLayout = new QHBoxLayout(this);
-
- _shareLinkLabel = new QLabel(this);
- _shareLinkLabel->setPixmap(QString(":/client/theme/black/edit.svg"));
- _shareLinkLayout->addWidget(_shareLinkLabel);
-
- _shareLinkEdit = new QLineEdit(this);
- connect(_shareLinkEdit, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreateLabel);
- _shareLinkEdit->setPlaceholderText(tr("Link name"));
- _shareLinkEdit->setText(_linkShare.data()->getLabel());
- _shareLinkLayout->addWidget(_shareLinkEdit);
-
- _shareLinkButton = new QToolButton(this);
- connect(_shareLinkButton, &QToolButton::clicked, this, &ShareLinkWidget::slotCreateLabel);
- _shareLinkButton->setIcon(QIcon(":/client/theme/confirm.svg"));
- _shareLinkButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
- _shareLinkLayout->addWidget(_shareLinkButton);
-
- _shareLinkProgressIndicator = new QProgressIndicator(this);
- _shareLinkProgressIndicator->setVisible(false);
- _shareLinkLayout->addWidget(_shareLinkProgressIndicator);
-
- _shareLinkDefaultWidget = new QWidget(this);
- _shareLinkDefaultWidget->setLayout(_shareLinkLayout);
-
- _shareLinkWidgetAction = new QWidgetAction(this);
- _shareLinkWidgetAction->setDefaultWidget(_shareLinkDefaultWidget);
- _shareLinkWidgetAction->setCheckable(true);
- _linkContextMenu->addAction(_shareLinkWidgetAction);
-
- // Adds permissions actions (radio button style)
- if (_isFile) {
- _linkContextMenu->addAction(_allowEditingLinkAction);
- } else {
- _linkContextMenu->addAction(_readOnlyLinkAction);
- _linkContextMenu->addAction(_allowUploadEditingLinkAction);
- _linkContextMenu->addAction(_allowUploadLinkAction);
- }
-
- // Adds action to display note widget (check box)
- _noteLinkAction = _linkContextMenu->addAction(tr("Note to recipient"));
- _noteLinkAction->setCheckable(true);
-
- if (_linkShare->getNote().isSimpleText() && !_linkShare->getNote().isEmpty()) {
- _ui->textEdit_note->setText(_linkShare->getNote());
- _noteLinkAction->setChecked(true);
- toggleNoteOptions();
- }
-
- // Adds action to display password widget (check box)
- _passwordProtectLinkAction = _linkContextMenu->addAction(tr("Password protect"));
- _passwordProtectLinkAction->setCheckable(true);
-
- if (_linkShare.data()->isPasswordSet()) {
- _passwordProtectLinkAction->setChecked(true);
- _ui->lineEdit_password->setPlaceholderText(QString::fromUtf8(passwordIsSetPlaceholder));
- togglePasswordOptions();
- }
-
- // If password is enforced then don't allow users to disable it
- if (_account->capabilities().sharePublicLinkEnforcePassword()) {
- if (_linkShare.data()->isPasswordSet()) {
- _passwordProtectLinkAction->setChecked(true);
- _passwordProtectLinkAction->setEnabled(false);
- }
- _passwordRequired = true;
- }
-
- // Adds action to display expiration date widget (check box)
- _expirationDateLinkAction = _linkContextMenu->addAction(tr("Set expiration date"));
- _expirationDateLinkAction->setCheckable(true);
- if (!expireDate.isNull()) {
- _ui->calendar->setDate(expireDate);
- _expirationDateLinkAction->setChecked(true);
- toggleExpireDateOptions();
- }
- connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotSetExpireDate);
- connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireDateSet);
-
-
- // If expiredate is enforced do not allow disable and set max days
- if (_account->capabilities().sharePublicLinkEnforceExpireDate()) {
- _ui->calendar->setMaximumDate(QDate::currentDate().addDays(
- _account->capabilities().sharePublicLinkExpireDateDays()));
- _expirationDateLinkAction->setChecked(true);
- _expirationDateLinkAction->setEnabled(false);
- _expiryRequired = true;
- }
-
- // Adds action to unshare widget (check box)
- _unshareLinkAction.reset(_linkContextMenu->addAction(QIcon(":/client/theme/delete.svg"),
- tr("Delete link")));
-
- _linkContextMenu->addSeparator();
-
- _addAnotherLinkAction.reset(_linkContextMenu->addAction(QIcon(":/client/theme/add.svg"),
- tr("Add another link")));
-
- _ui->enableShareLink->setIcon(QIcon(":/client/theme/copy.svg"));
- disconnect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCreateShareLink);
- connect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCopyLinkShare);
-
- connect(_linkContextMenu, &QMenu::triggered,
- this, &ShareLinkWidget::slotLinkContextMenuActionTriggered);
-
- _ui->shareLinkToolButton->setMenu(_linkContextMenu);
- _ui->shareLinkToolButton->setEnabled(true);
- _ui->enableShareLink->setEnabled(true);
- _ui->enableShareLink->setChecked(true);
-
- // show sharing options
- _ui->shareLinkToolButton->show();
-
- customizeStyle();
-}
-
-void ShareLinkWidget::slotCreateNote()
-{
- const auto note = _ui->textEdit_note->toPlainText();
- if (!_linkShare || _linkShare->getNote() == note || note.isEmpty()) {
- return;
- }
-
- toggleButtonAnimation(_ui->confirmNote, _ui->noteProgressIndicator, _noteLinkAction);
- _ui->errorLabel->hide();
- _linkShare->setNote(note);
-}
-
-void ShareLinkWidget::slotNoteSet()
-{
- toggleButtonAnimation(_ui->confirmNote, _ui->noteProgressIndicator, _noteLinkAction);
-}
-
-void ShareLinkWidget::slotCopyLinkShare(const bool clicked) const
-{
- Q_UNUSED(clicked);
-
- QApplication::clipboard()->setText(_linkShare->getLink().toString());
-}
-
-void ShareLinkWidget::slotExpireDateSet()
-{
- toggleButtonAnimation(_ui->confirmExpirationDate, _ui->expirationDateProgressIndicator, _expirationDateLinkAction);
-}
-
-void ShareLinkWidget::slotSetExpireDate()
-{
- if (!_linkShare) {
- return;
- }
-
- toggleButtonAnimation(_ui->confirmExpirationDate, _ui->expirationDateProgressIndicator, _expirationDateLinkAction);
- _ui->errorLabel->hide();
- _linkShare->setExpireDate(_ui->calendar->date());
-}
-
-void ShareLinkWidget::slotCreatePassword()
-{
- if (!_linkShare || _ui->lineEdit_password->text().isEmpty()) {
- return;
- }
-
- toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction);
- _ui->errorLabel->hide();
- emit createPassword(_ui->lineEdit_password->text());
-}
-
-void ShareLinkWidget::slotCreateShareLink(const bool clicked)
-{
- Q_UNUSED(clicked);
- slotToggleShareLinkAnimation(true);
- emit createLinkShare();
-}
-
-void ShareLinkWidget::slotPasswordSet()
-{
- toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction);
-
- _ui->lineEdit_password->setText({});
-
- if (_linkShare->isPasswordSet()) {
- _ui->lineEdit_password->setEnabled(true);
- _ui->lineEdit_password->setPlaceholderText(QString::fromUtf8(passwordIsSetPlaceholder));
- } else {
- _ui->lineEdit_password->setPlaceholderText({});
- }
-
- emit createPasswordProcessed();
-}
-
-void ShareLinkWidget::slotPasswordSetError(const int code, const QString &message)
-{
- toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction);
-
- slotServerError(code, message);
- togglePasswordOptions();
- _ui->lineEdit_password->setFocus();
- emit createPasswordProcessed();
-}
-
-void ShareLinkWidget::slotDeleteShareFetched()
-{
- slotToggleShareLinkAnimation(false);
-
- _linkShare.clear();
- togglePasswordOptions(false);
- toggleNoteOptions(false);
- toggleExpireDateOptions(false);
- emit deleteLinkShare();
-}
-
-void ShareLinkWidget::toggleNoteOptions(const bool enable)
-{
- _ui->noteLabel->setVisible(enable);
- _ui->textEdit_note->setVisible(enable);
- _ui->confirmNote->setVisible(enable);
- _ui->textEdit_note->setText(enable && _linkShare ? _linkShare->getNote() : QString());
-
- if (!enable && _linkShare && !_linkShare->getNote().isEmpty()) {
- _linkShare->setNote({});
- }
-}
-
-void ShareLinkWidget::slotCreateLabel()
-{
- const auto labelText = _shareLinkEdit->text();
- if (!_linkShare || _linkShare->getLabel() == labelText || labelText.isEmpty()) {
- return;
- }
- _shareLinkWidgetAction->setChecked(true);
- toggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, _shareLinkWidgetAction);
- _ui->errorLabel->hide();
- _linkShare->setLabel(_shareLinkEdit->text());
-}
-
-void ShareLinkWidget::slotLabelSet()
-{
- toggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, _shareLinkWidgetAction);
- displayShareLinkLabel();
-}
-
-void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
-{
- slotToggleShareLinkAnimation(message.isEmpty());
-
- if (!message.isEmpty()) {
- _ui->errorLabel->setText(message);
- _ui->errorLabel->show();
- }
-
- _passwordRequired = true;
-
- togglePasswordOptions();
-}
-
-void ShareLinkWidget::togglePasswordOptions(const bool enable)
-{
- _ui->passwordLabel->setVisible(enable);
- _ui->lineEdit_password->setVisible(enable);
- _ui->confirmPassword->setVisible(enable);
- _ui->lineEdit_password->setFocus();
-
- if (!enable && _linkShare && _linkShare->isPasswordSet()) {
- _linkShare->setPassword({});
- }
-}
-
-void ShareLinkWidget::toggleExpireDateOptions(const bool enable)
-{
- _ui->expirationLabel->setVisible(enable);
- _ui->calendar->setVisible(enable);
- _ui->confirmExpirationDate->setVisible(enable);
-
- const auto date = enable ? _linkShare->getExpireDate() : QDate::currentDate().addDays(1);
- _ui->calendar->setDate(date);
- _ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
-
- if(_account->capabilities().sharePublicLinkEnforceExpireDate()) {
- _ui->calendar->setMaximumDate(QDate::currentDate().addDays(_account->capabilities().sharePublicLinkExpireDateDays()));
- }
-
- _ui->calendar->setFocus();
-
- if (!enable && _linkShare && _linkShare->getExpireDate().isValid()) {
- _linkShare->setExpireDate({});
- }
-}
-
-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()),
- QMessageBox::NoButton,
- this);
- QPushButton *yesButton =
- messageBox->addButton(tr("Delete"), QMessageBox::YesRole);
- messageBox->addButton(tr("Cancel"), QMessageBox::NoRole);
-
- connect(messageBox, &QMessageBox::finished, this,
- [messageBox, yesButton, this]() {
- if (messageBox->clickedButton() == yesButton) {
- this->slotToggleShareLinkAnimation(true);
- this->_linkShare->deleteShare();
- }
- });
- messageBox->open();
-}
-
-QString ShareLinkWidget::shareName() const
-{
- QString name = _linkShare->getName();
- if (!name.isEmpty())
- return name;
- if (!_namesSupported)
- return tr("Public link");
- return _linkShare->getToken();
-}
-
-void ShareLinkWidget::slotContextMenuButtonClicked()
-{
- _linkContextMenu->exec(QCursor::pos());
-}
-
-void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
-{
- const auto state = action->isChecked();
- SharePermissions perm = SharePermissionRead;
-
- if (action == _addAnotherLinkAction.data()) {
- emit createLinkShare();
-
- } else if (action == _readOnlyLinkAction && state) {
- _linkShare->setPermissions(perm);
-
- } else if (action == _allowEditingLinkAction && state) {
- perm |= SharePermissionUpdate;
- _linkShare->setPermissions(perm);
-
- } else if (action == _allowUploadEditingLinkAction && state) {
- perm |= SharePermissionCreate | SharePermissionUpdate | SharePermissionDelete;
- _linkShare->setPermissions(perm);
-
- } else if (action == _allowUploadLinkAction && state) {
- perm = SharePermissionCreate;
- _linkShare->setPermissions(perm);
-
- } else if (action == _passwordProtectLinkAction) {
- togglePasswordOptions(state);
-
- } else if (action == _expirationDateLinkAction) {
- toggleExpireDateOptions(state);
-
- } else if (action == _noteLinkAction) {
- toggleNoteOptions(state);
-
- } else if (action == _unshareLinkAction.data()) {
- confirmAndDeleteShare();
- }
-}
-
-void ShareLinkWidget::slotServerError(const int code, const QString &message)
-{
- slotToggleShareLinkAnimation(false);
-
- qCWarning(lcSharing) << "Error from server" << code << message;
- displayError(message);
-}
-
-void ShareLinkWidget::displayError(const QString &errMsg)
-{
- _ui->errorLabel->setText(errMsg);
- _ui->errorLabel->show();
-}
-
-void ShareLinkWidget::slotStyleChanged()
-{
- customizeStyle();
-}
-
-void ShareLinkWidget::customizeStyle()
-{
- if(_unshareLinkAction) {
- _unshareLinkAction->setIcon(Theme::createColorAwareIcon(":/client/theme/delete.svg"));
- }
-
- if(_addAnotherLinkAction) {
- _addAnotherLinkAction->setIcon(Theme::createColorAwareIcon(":/client/theme/add.svg"));
- }
-
- _ui->enableShareLink->setIcon(Theme::createColorAwareIcon(":/client/theme/copy.svg"));
-
- _ui->shareLinkIconLabel->setPixmap(Theme::createColorAwarePixmap(":/client/theme/public.svg"));
-
- _ui->shareLinkToolButton->setIcon(Theme::createColorAwareIcon(":/client/theme/more.svg"));
-
- _ui->confirmNote->setIcon(Theme::createColorAwareIcon(":/client/theme/confirm.svg"));
- _ui->confirmPassword->setIcon(Theme::createColorAwareIcon(":/client/theme/confirm.svg"));
- _ui->confirmExpirationDate->setIcon(Theme::createColorAwareIcon(":/client/theme/confirm.svg"));
-
- _ui->passwordProgressIndicator->setColor(QGuiApplication::palette().color(QPalette::Text));
-}
-
-void ShareLinkWidget::displayShareLinkLabel()
-{
- _shareLinkElidedLabel->clear();
- if (!_linkShare->getLabel().isEmpty()) {
- _shareLinkElidedLabel->setText(QString("(%1)").arg(_linkShare->getLabel()));
- }
-}
-
-}
diff --git a/src/gui/sharelinkwidget.h b/src/gui/sharelinkwidget.h
deleted file mode 100644
index 7ecd9691e443e..0000000000000
--- a/src/gui/sharelinkwidget.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) by Roeland Jago Douma
- * Copyright (C) 2015 by Klaas Freitag
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- */
-
-#ifndef SHARELINKWIDGET_H
-#define SHARELINKWIDGET_H
-
-#include "accountfwd.h"
-#include "sharepermissions.h"
-#include "QProgressIndicator.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-class QMenu;
-class QTableWidgetItem;
-
-namespace OCC {
-
-namespace Ui {
- class ShareLinkWidget;
-}
-
-class AbstractCredentials;
-class SyncResult;
-class LinkShare;
-class Share;
-class ElidedLabel;
-
-/**
- * @brief The ShareDialog class
- * @ingroup gui
- */
-class ShareLinkWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit ShareLinkWidget(AccountPtr account,
- const QString &sharePath,
- const QString &localPath,
- SharePermissions maxSharingPermissions,
- QWidget *parent = nullptr);
- ~ShareLinkWidget() override;
-
- void toggleButton(bool show);
- void setupUiOptions();
-
- void setLinkShare(QSharedPointer linkShare);
- QSharedPointer getLinkShare();
-
- void focusPasswordLineEdit();
-
-public slots:
- void slotDeleteShareFetched();
- void slotToggleShareLinkAnimation(const bool start);
- void slotServerError(const int code, const QString &message);
- void slotCreateShareRequiresPassword(const QString &message);
- void slotStyleChanged();
-
-private slots:
- void slotCreateShareLink(const bool clicked);
- void slotCopyLinkShare(const bool clicked) const;
-
- void slotCreatePassword();
- void slotPasswordSet();
- void slotPasswordSetError(const int code, const QString &message);
-
- void slotCreateNote();
- void slotNoteSet();
-
- void slotSetExpireDate();
- void slotExpireDateSet();
-
- void slotContextMenuButtonClicked();
- void slotLinkContextMenuActionTriggered(QAction *action);
-
- void slotCreateLabel();
- void slotLabelSet();
-
-signals:
- void createLinkShare();
- void deleteLinkShare();
- void visualDeletionDone();
- void createPassword(const QString &password);
- void createPasswordProcessed();
-
-private:
- void displayError(const QString &errMsg);
-
- void togglePasswordOptions(const bool enable = true);
- void toggleNoteOptions(const bool enable = true);
- void toggleExpireDateOptions(const bool enable = true);
- void toggleButtonAnimation(QToolButton *button, QProgressIndicator *progressIndicator, const QAction *checkedAction) const;
-
- /** Confirm with the user and then delete the share */
- void confirmAndDeleteShare();
-
- /** Retrieve a share's name, accounting for _namesSupported */
- [[nodiscard]] QString shareName() const;
-
- void customizeStyle();
-
- void displayShareLinkLabel();
-
- Ui::ShareLinkWidget *_ui;
- AccountPtr _account;
- QString _sharePath;
- QString _localPath;
- QString _shareUrl;
-
- QSharedPointer _linkShare;
-
- bool _isFile;
- bool _passwordRequired;
- bool _expiryRequired;
- bool _namesSupported;
- bool _noteRequired;
-
- QMenu *_linkContextMenu;
- QAction *_readOnlyLinkAction;
- QAction *_allowEditingLinkAction;
- QAction *_allowUploadEditingLinkAction;
- QAction *_allowUploadLinkAction;
- QAction *_passwordProtectLinkAction;
- QAction *_expirationDateLinkAction;
- QScopedPointer _unshareLinkAction;
- QScopedPointer _addAnotherLinkAction;
- QAction *_noteLinkAction;
- QHBoxLayout *_shareLinkLayout{};
- QLabel *_shareLinkLabel{};
- ElidedLabel *_shareLinkElidedLabel{};
- QLineEdit *_shareLinkEdit{};
- QToolButton *_shareLinkButton{};
- QProgressIndicator *_shareLinkProgressIndicator{};
- QWidget *_shareLinkDefaultWidget{};
- QWidgetAction *_shareLinkWidgetAction{};
-};
-}
-
-#endif // SHARELINKWIDGET_H
diff --git a/src/gui/sharelinkwidget.ui b/src/gui/sharelinkwidget.ui
deleted file mode 100644
index a0d5f3df93bbe..0000000000000
--- a/src/gui/sharelinkwidget.ui
+++ /dev/null
@@ -1,439 +0,0 @@
-
-
- OCC::ShareLinkWidget
-
-
-
- 0
- 0
- 400
- 238
-
-
-
-
- 0
- 0
-
-
-
-
- 0
-
-
- 12
-
-
- 0
-
-
- 20
-
-
- 0
-
- -
-
-
- 6
-
-
- 0
-
-
-
-
-
-
-
-
- :/client/theme/public.svg
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
- Share link
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 25
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 28
- 27
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 25
-
-
-
-
- -
-
-
-
-
-
-
- :/client/theme/add.svg:/client/theme/add.svg
-
-
- false
-
-
- true
-
-
-
- -
-
-
- false
-
-
-
- 0
- 0
-
-
-
-
- :/client/theme/more.svg:/client/theme/more.svg
-
-
- QToolButton::InstantPopup
-
-
- true
-
-
-
-
-
- -
-
-
- 22
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 78
- 0
-
-
-
- Note
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- 0
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 60
-
-
-
- QAbstractScrollArea::AdjustToContents
-
-
-
- -
-
-
-
- 28
- 27
-
-
-
-
- :/client/theme/confirm.svg:/client/theme/confirm.svg
-
-
- true
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 28
- 27
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 78
- 0
-
-
-
- Set password
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- 0
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
- QLineEdit::Password
-
-
-
- -
-
-
-
- 28
- 27
-
-
-
-
- :/client/theme/confirm.svg:/client/theme/confirm.svg
-
-
- true
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 28
- 27
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 78
- 0
-
-
-
- Expires
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- 0
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
-
- -
-
-
-
- 28
- 27
-
-
-
-
- :/client/theme/confirm.svg:/client/theme/confirm.svg
-
-
- true
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 28
- 27
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
- 255
- 0
- 0
-
-
-
-
-
-
-
-
- 255
- 0
- 0
-
-
-
-
-
-
-
-
- 123
- 121
- 134
-
-
-
-
-
-
-
- TextLabel
-
-
- Qt::PlainText
-
-
- true
-
-
-
-
-
-
-
-
-
-
- QProgressIndicator
- QWidget
-
- 1
-
-
-
-
-
-
-
diff --git a/src/gui/sharemanager.cpp b/src/gui/sharemanager.cpp
index 154bcbec31967..621ab6c47fe5b 100644
--- a/src/gui/sharemanager.cpp
+++ b/src/gui/sharemanager.cpp
@@ -58,7 +58,7 @@ Share::Share(AccountPtr account,
const ShareType shareType,
bool isPasswordSet,
const Permissions permissions,
- const QSharedPointer shareWith)
+ const ShareePtr shareWith)
: _account(account)
, _id(id)
, _uidowner(uidowner)
@@ -101,7 +101,7 @@ Share::ShareType Share::getShareType() const
return _shareType;
}
-QSharedPointer Share::getShareWith() const
+ShareePtr Share::getShareWith() const
{
return _shareWith;
}
@@ -316,7 +316,7 @@ UserGroupShare::UserGroupShare(AccountPtr account,
const ShareType shareType,
bool isPasswordSet,
const Permissions permissions,
- const QSharedPointer shareWith,
+ const ShareePtr shareWith,
const QDate &expireDate,
const QString ¬e)
: Share(account, id, owner, ownerDisplayName, path, shareType, isPasswordSet, permissions, shareWith)
@@ -461,7 +461,7 @@ void ShareManager::slotShareCreated(const QJsonDocument &reply)
{
//Parse share
auto data = reply.object().value("ocs").toObject().value("data").toObject();
- QSharedPointer share(parseShare(data));
+ SharePtr share(parseShare(data));
emit shareCreated(share);
@@ -478,18 +478,19 @@ void ShareManager::fetchShares(const QString &path)
void ShareManager::slotSharesFetched(const QJsonDocument &reply)
{
+ qDebug() << reply;
auto tmpShares = reply.object().value("ocs").toObject().value("data").toArray();
const QString versionString = _account->serverVersion();
qCDebug(lcSharing) << versionString << "Fetched" << tmpShares.count() << "shares";
- QList> shares;
+ QList shares;
foreach (const auto &share, tmpShares) {
auto data = share.toObject();
auto shareType = data.value("share_type").toInt();
- QSharedPointer newShare;
+ SharePtr newShare;
if (shareType == Share::TypeLink) {
newShare = parseLinkShare(data);
@@ -499,7 +500,7 @@ void ShareManager::slotSharesFetched(const QJsonDocument &reply)
newShare = parseShare(data);
}
- shares.append(QSharedPointer(newShare));
+ shares.append(SharePtr(newShare));
}
qCDebug(lcSharing) << "Sending " << shares.count() << "shares";
@@ -508,7 +509,7 @@ void ShareManager::slotSharesFetched(const QJsonDocument &reply)
QSharedPointer ShareManager::parseUserGroupShare(const QJsonObject &data)
{
- QSharedPointer sharee(new Sharee(data.value("share_with").toString(),
+ ShareePtr sharee(new Sharee(data.value("share_with").toString(),
data.value("share_with_displayname").toString(),
static_cast(data.value("share_type").toInt())));
@@ -577,13 +578,13 @@ QSharedPointer ShareManager::parseLinkShare(const QJsonObject &data)
data.value("label").toString()));
}
-QSharedPointer ShareManager::parseShare(const QJsonObject &data)
+SharePtr ShareManager::parseShare(const QJsonObject &data) const
{
- QSharedPointer sharee(new Sharee(data.value("share_with").toString(),
+ ShareePtr sharee(new Sharee(data.value("share_with").toString(),
data.value("share_with_displayname").toString(),
(Sharee::Type)data.value("share_type").toInt()));
- return QSharedPointer(new Share(_account,
+ return SharePtr(new Share(_account,
data.value("id").toVariant().toString(), // "id" used to be an integer, support both
data.value("uid_owner").toVariant().toString(),
data.value("displayname_owner").toVariant().toString(),
diff --git a/src/gui/sharemanager.h b/src/gui/sharemanager.h
index 16d2e47c3ded4..d5cff7c4699ea 100644
--- a/src/gui/sharemanager.h
+++ b/src/gui/sharemanager.h
@@ -36,6 +36,15 @@ class OcsShareJob;
class Share : public QObject
{
Q_OBJECT
+ Q_PROPERTY(AccountPtr account READ account CONSTANT)
+ Q_PROPERTY(QString path READ path CONSTANT)
+ Q_PROPERTY(QString id READ getId CONSTANT)
+ Q_PROPERTY(QString uidOwner READ getUidOwner CONSTANT)
+ Q_PROPERTY(QString ownerDisplayName READ getOwnerDisplayName CONSTANT)
+ Q_PROPERTY(ShareType shareType READ getShareType CONSTANT)
+ Q_PROPERTY(ShareePtr shareWith READ getShareWith CONSTANT)
+ Q_PROPERTY(Permissions permissions READ getPermissions WRITE setPermissions NOTIFY permissionsSet)
+ Q_PROPERTY(bool isPasswordSet READ isPasswordSet NOTIFY passwordSet)
public:
/**
@@ -43,14 +52,16 @@ class Share : public QObject
* Need to be in sync with Sharee::Type
*/
enum ShareType {
+ TypePlaceholderLink = -1,
TypeUser = Sharee::User,
TypeGroup = Sharee::Group,
TypeLink = 3,
TypeEmail = Sharee::Email,
TypeRemote = Sharee::Federated,
TypeCircle = Sharee::Circle,
- TypeRoom = Sharee::Room
+ TypeRoom = Sharee::Room,
};
+ Q_ENUM(ShareType);
using Permissions = SharePermissions;
@@ -65,7 +76,7 @@ class Share : public QObject
const ShareType shareType,
bool isPasswordSet = false,
const Permissions permissions = SharePermissionDefault,
- const QSharedPointer shareWith = QSharedPointer(nullptr));
+ const ShareePtr shareWith = ShareePtr(nullptr));
/**
* The account the share is defined on.
@@ -97,7 +108,7 @@ class Share : public QObject
/*
* Get the shareWith
*/
- [[nodiscard]] QSharedPointer getShareWith() const;
+ [[nodiscard]] ShareePtr getShareWith() const;
/*
* Get permissions
@@ -105,23 +116,23 @@ class Share : public QObject
[[nodiscard]] Permissions getPermissions() const;
/*
- * Set the permissions of a share
- *
- * On success the permissionsSet signal is emitted
- * In case of a server error the serverError signal is emitted.
+ * Get whether the share has a password set
*/
- void setPermissions(Permissions permissions);
+ [[nodiscard]] Q_REQUIRED_RESULT bool isPasswordSet() const;
- /*
- * Set the password for remote share
- *
- * On success the passwordSet signal is emitted
- * In case of a server error the passwordSetError signal is emitted.
+ /*
+ * Is it a share with a user or group (local or remote)
*/
- void setPassword(const QString &password);
+ [[nodiscard]] static bool isShareTypeUserGroupEmailRoomOrRemote(const ShareType type);
- [[nodiscard]] bool isPasswordSet() const;
+signals:
+ void permissionsSet();
+ void shareDeleted();
+ void serverError(int code, const QString &message);
+ void passwordSet();
+ void passwordSetError(int statusCode, const QString &message);
+public slots:
/*
* Deletes a share
*
@@ -130,17 +141,21 @@ class Share : public QObject
*/
void deleteShare();
- /*
- * Is it a share with a user or group (local or remote)
+ /*
+ * Set the permissions of a share
+ *
+ * On success the permissionsSet signal is emitted
+ * In case of a server error the serverError signal is emitted.
*/
- static bool isShareTypeUserGroupEmailRoomOrRemote(const ShareType type);
+ void setPermissions(Permissions permissions);
-signals:
- void permissionsSet();
- void shareDeleted();
- void serverError(int code, const QString &message);
- void passwordSet();
- void passwordSetError(int statusCode, const QString &message);
+ /*
+ * Set the password for remote share
+ *
+ * On success the passwordSet signal is emitted
+ * In case of a server error the passwordSetError signal is emitted.
+ */
+ void setPassword(const QString &password);
protected:
AccountPtr _account;
@@ -151,7 +166,7 @@ class Share : public QObject
ShareType _shareType;
bool _isPasswordSet;
Permissions _permissions;
- QSharedPointer _shareWith;
+ ShareePtr _shareWith;
protected slots:
void slotOcsError(int statusCode, const QString &message);
@@ -163,6 +178,8 @@ private slots:
void slotPermissionsSet(const QJsonDocument &, const QVariant &value);
};
+using SharePtr = QSharedPointer;
+
/**
* A Link share is just like a regular share but then slightly different.
* There are several methods in the API that either work differently for
@@ -171,6 +188,16 @@ private slots:
class LinkShare : public Share
{
Q_OBJECT
+ Q_PROPERTY(QUrl link READ getLink CONSTANT)
+ Q_PROPERTY(QUrl directDownloadLink READ getDirectDownloadLink CONSTANT)
+ Q_PROPERTY(bool publicCanUpload READ getPublicUpload CONSTANT)
+ Q_PROPERTY(bool publicCanReadDirectory READ getShowFileListing CONSTANT)
+ Q_PROPERTY(QString name READ getName WRITE setName NOTIFY nameSet)
+ Q_PROPERTY(QString note READ getNote WRITE setNote NOTIFY noteSet)
+ Q_PROPERTY(QString label READ getLabel WRITE setLabel NOTIFY labelSet)
+ Q_PROPERTY(QDate expireDate READ getExpireDate WRITE setExpireDate NOTIFY expireDateSet)
+ Q_PROPERTY(QString token READ getToken CONSTANT)
+
public:
explicit LinkShare(AccountPtr account,
const QString &id,
@@ -221,6 +248,23 @@ class LinkShare : public Share
*/
[[nodiscard]] QString getLabel() const;
+ /*
+ * Returns the token of the link share.
+ */
+ [[nodiscard]] QString getToken() const;
+
+ /*
+ * Get the expiration date
+ */
+ [[nodiscard]] QDate getExpireDate() const;
+
+ /*
+ * Create OcsShareJob and connect to signal/slots
+ */
+ template
+ OcsShareJob *createShareJob(const LinkShareSlot slotFunction);
+
+public slots:
/*
* Set the name of the link share.
*
@@ -233,16 +277,6 @@ class LinkShare : public Share
*/
void setNote(const QString ¬e);
- /*
- * Returns the token of the link share.
- */
- [[nodiscard]] QString getToken() const;
-
- /*
- * Get the expiration date
- */
- [[nodiscard]] QDate getExpireDate() const;
-
/*
* Set the expiration date
*
@@ -250,19 +284,12 @@ class LinkShare : public Share
* In case of a server error the serverError signal is emitted.
*/
void setExpireDate(const QDate &expireDate);
-
+
/*
* Set the label of the share link.
*/
void setLabel(const QString &label);
- /*
- * Create OcsShareJob and connect to signal/slots
- */
- template
- OcsShareJob *createShareJob(const LinkShareSlot slotFunction);
-
-
signals:
void expireDateSet();
void noteSet();
@@ -287,6 +314,8 @@ private slots:
class UserGroupShare : public Share
{
Q_OBJECT
+ Q_PROPERTY(QString note READ getNote WRITE setNote NOTIFY noteSet)
+ Q_PROPERTY(QDate expireDate READ getExpireDate WRITE setExpireDate NOTIFY expireDateSet)
public:
UserGroupShare(AccountPtr account,
const QString &id,
@@ -296,27 +325,26 @@ class UserGroupShare : public Share
const ShareType shareType,
bool isPasswordSet,
const Permissions permissions,
- const QSharedPointer shareWith,
+ const ShareePtr shareWith,
const QDate &expireDate,
const QString ¬e);
- void setNote(const QString ¬e);
-
[[nodiscard]] QString getNote() const;
-
- void slotNoteSet(const QJsonDocument &, const QVariant ¬e);
-
- void setExpireDate(const QDate &date);
-
[[nodiscard]] QDate getExpireDate() const;
- void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
+public slots:
+ void setNote(const QString ¬e);
+ void setExpireDate(const QDate &date);
signals:
void noteSet();
void noteSetError();
void expireDateSet();
+private slots:
+ void slotNoteSet(const QJsonDocument &json, const QVariant ¬e);
+ void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
+
private:
QString _note;
QDate _expireDate;
@@ -375,9 +403,9 @@ class ShareManager : public QObject
void fetchShares(const QString &path);
signals:
- void shareCreated(const QSharedPointer &share);
+ void shareCreated(const SharePtr &share);
void linkShareCreated(const QSharedPointer &share);
- void sharesFetched(const QList