Finishing PR #1154 adding note when sharing

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
Dominique Fuchs 2019-09-18 13:37:49 +02:00
parent 179bbffd76
commit 9d6780d6c1
11 changed files with 576 additions and 371 deletions

View file

@ -73,6 +73,17 @@ void OcsShareJob::setPassword(const QString &shareId, const QString &password)
start(); start();
} }
void OcsShareJob::setNote(const QString &shareId, const QString &note)
{
appendPath(shareId);
setVerb("PUT");
addParam(QString::fromLatin1("note"), note);
_value = note;
start();
}
void OcsShareJob::setPublicUpload(const QString &shareId, bool publicUpload) void OcsShareJob::setPublicUpload(const QString &shareId, bool publicUpload)
{ {
appendPath(shareId); appendPath(shareId);

View file

@ -61,6 +61,14 @@ public:
*/ */
void setExpireDate(const QString &shareId, const QDate &date); void setExpireDate(const QString &shareId, const QDate &date);
/**
* Set note a share
*
* @param note The note to a share, if the note is empty the
* share will be removed
*/
void setNote(const QString &shareId, const QString &note);
/** /**
* Set the password of a share * Set the password of a share
* *

View file

@ -165,7 +165,7 @@ void ShareDialog::initLinkShareWidget(){
_emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this); _emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this);
_linkWidgetList.append(_emptyShareLinkWidget); _linkWidgetList.append(_emptyShareLinkWidget);
// connect(_emptyShareLinkWidget, &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize); connect(_emptyShareLinkWidget, &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize);
// connect(this, &ShareDialog::toggleAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleAnimation); // connect(this, &ShareDialog::toggleAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleAnimation);
connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare); connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
@ -206,7 +206,6 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
emit toggleAnimation(false); emit toggleAnimation(false);
} }
// TODO
void ShareDialog::slotAdjustScrollWidgetSize() void ShareDialog::slotAdjustScrollWidgetSize()
{ {
int count = this->findChildren<ShareLinkWidget *>().count(); int count = this->findChildren<ShareLinkWidget *>().count();

View file

@ -6,28 +6,18 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>372</width> <width>385</width>
<height>150</height> <height>150</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="shareDialogVerticalLayout">
<property name="spacing">
<number>10</number>
</property>
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum> <enum>QLayout::SetFixedSize</enum>
</property> </property>
<property name="leftMargin"> <item>
<number>10</number> <layout class="QVBoxLayout" name="verticalLayout">
</property> <property name="sizeConstraint">
<property name="topMargin"> <enum>QLayout::SetFixedSize</enum>
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property> </property>
<item> <item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0"> <layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0">
@ -43,6 +33,31 @@
<property name="spacing"> <property name="spacing">
<number>10</number> <number>10</number>
</property> </property>
<item row="0" column="1">
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>315</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>share label</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label_sharePath"> <widget class="QLabel" name="label_sharePath">
<property name="sizePolicy"> <property name="sizePolicy">
@ -64,32 +79,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>ownCloud Path:</string> <string>Nextcloud Path:</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>315</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>share label</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::PlainText</enum> <enum>Qt::PlainText</enum>
@ -129,7 +119,7 @@
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -141,7 +131,7 @@
<enum>Qt::ScrollBarAlwaysOff</enum> <enum>Qt::ScrollBarAlwaysOff</enum>
</property> </property>
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum> <enum>QAbstractScrollArea::AdjustIgnored</enum>
</property> </property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
@ -151,8 +141,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>352</width> <width>69</width>
<height>68</height> <height>69</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/> <layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/>
@ -160,6 +150,8 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View file

@ -27,6 +27,7 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QTextEdit>
#include <QToolButton> #include <QToolButton>
#include <QPropertyAnimation> #include <QPropertyAnimation>
@ -46,6 +47,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
, _localPath(localPath) , _localPath(localPath)
, _linkShare(nullptr) , _linkShare(nullptr)
, _passwordRequired(false) , _passwordRequired(false)
, _noteRequired(false)
, _expiryRequired(false) , _expiryRequired(false)
, _namesSupported(true) , _namesSupported(true)
, _linkContextMenu(nullptr) , _linkContextMenu(nullptr)
@ -54,14 +56,13 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
, _allowUploadEditingLinkAction(nullptr) , _allowUploadEditingLinkAction(nullptr)
, _allowUploadLinkAction(nullptr) , _allowUploadLinkAction(nullptr)
, _passwordProtectLinkAction(nullptr) , _passwordProtectLinkAction(nullptr)
, _noteLinkAction(nullptr)
, _expirationDateLinkAction(nullptr) , _expirationDateLinkAction(nullptr)
, _unshareLinkAction(nullptr) , _unshareLinkAction(nullptr)
{ {
_ui->setupUi(this); _ui->setupUi(this);
QSizePolicy sp = _ui->shareLinkToolButton->sizePolicy(); QSizePolicy sp = _ui->shareLinkToolButton->sizePolicy();
sp.setRetainSizeWhenHidden(true);
_ui->shareLinkToolButton->setSizePolicy(sp);
_ui->shareLinkToolButton->hide(); _ui->shareLinkToolButton->hide();
//Is this a file or folder? //Is this a file or folder?
@ -71,6 +72,8 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
connect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCreateShareLink); connect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCreateShareLink);
connect(_ui->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword); connect(_ui->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword);
connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword); connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword);
connect(_ui->textEdit_note, &QTextEdit::textChanged, this, &ShareLinkWidget::slotCreateNote);
connect(_ui->confirmNote, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreateNote);
connect(_ui->confirmExpirationDate, &QAbstractButton::clicked, this, &ShareLinkWidget::slotSetExpireDate); connect(_ui->confirmExpirationDate, &QAbstractButton::clicked, this, &ShareLinkWidget::slotSetExpireDate);
connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotSetExpireDate); connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotSetExpireDate);
@ -96,6 +99,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
togglePasswordOptions(false); togglePasswordOptions(false);
toggleExpireDateOptions(false); toggleExpireDateOptions(false);
toggleNoteOptions(false);
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1)); _ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
// check if the file is already inside of a synced folder // check if the file is already inside of a synced folder
@ -110,7 +114,8 @@ ShareLinkWidget::~ShareLinkWidget()
delete _ui; delete _ui;
} }
void ShareLinkWidget::slotToggleAnimation(bool start){ void ShareLinkWidget::slotToggleAnimation(bool start)
{
if (start) { if (start) {
if (!_ui->progressIndicator->isAnimated()) if (!_ui->progressIndicator->isAnimated())
_ui->progressIndicator->startAnimation(); _ui->progressIndicator->startAnimation();
@ -119,21 +124,25 @@ void ShareLinkWidget::slotToggleAnimation(bool start){
} }
} }
void ShareLinkWidget::setLinkShare(QSharedPointer<LinkShare> linkShare){ void ShareLinkWidget::setLinkShare(QSharedPointer<LinkShare> linkShare)
{
_linkShare = linkShare; _linkShare = linkShare;
} }
QSharedPointer<LinkShare> ShareLinkWidget::getLinkShare(){ QSharedPointer<LinkShare> ShareLinkWidget::getLinkShare()
{
return _linkShare; return _linkShare;
} }
void ShareLinkWidget::setupUiOptions(){ void ShareLinkWidget::setupUiOptions()
{
connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireDateSet); connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireDateSet);
connect(_linkShare.data(), &LinkShare::noteSet, this, &ShareLinkWidget::slotNoteSet);
connect(_linkShare.data(), &LinkShare::passwordSet, this, &ShareLinkWidget::slotPasswordSet); connect(_linkShare.data(), &LinkShare::passwordSet, this, &ShareLinkWidget::slotPasswordSet);
connect(_linkShare.data(), &LinkShare::passwordSetError, this, &ShareLinkWidget::slotPasswordSetError); connect(_linkShare.data(), &LinkShare::passwordSetError, this, &ShareLinkWidget::slotPasswordSetError);
// Prepare permissions check and create group action // Prepare permissions check and create group action
const QDate expireDate = _linkShare.data()->getExpireDate().isValid()? _linkShare.data()->getExpireDate() : QDate(); const QDate expireDate = _linkShare.data()->getExpireDate().isValid() ? _linkShare.data()->getExpireDate() : QDate();
const SharePermissions perm = _linkShare.data()->getPermissions(); const SharePermissions perm = _linkShare.data()->getPermissions();
bool checked = false; bool checked = false;
QActionGroup *permissionsGroup = new QActionGroup(this); QActionGroup *permissionsGroup = new QActionGroup(this);
@ -144,7 +153,7 @@ void ShareLinkWidget::setupUiOptions(){
// radio button style // radio button style
permissionsGroup->setExclusive(true); permissionsGroup->setExclusive(true);
if(_isFile){ if (_isFile) {
checked = perm & (SharePermissionRead & SharePermissionUpdate); checked = perm & (SharePermissionRead & SharePermissionUpdate);
_allowEditingLinkAction = _linkContextMenu->addAction(tr("Allow Editing")); _allowEditingLinkAction = _linkContextMenu->addAction(tr("Allow Editing"));
_allowEditingLinkAction->setCheckable(true); _allowEditingLinkAction->setCheckable(true);
@ -156,10 +165,7 @@ void ShareLinkWidget::setupUiOptions(){
_readOnlyLinkAction->setCheckable(true); _readOnlyLinkAction->setCheckable(true);
_readOnlyLinkAction->setChecked(checked); _readOnlyLinkAction->setChecked(checked);
checked = perm & (SharePermissionRead & checked = perm & (SharePermissionRead & SharePermissionCreate & SharePermissionUpdate & SharePermissionDelete);
SharePermissionCreate &
SharePermissionUpdate &
SharePermissionDelete);
_allowUploadEditingLinkAction = permissionsGroup->addAction(tr("Allow Upload && Editing")); _allowUploadEditingLinkAction = permissionsGroup->addAction(tr("Allow Upload && Editing"));
_allowUploadEditingLinkAction->setCheckable(true); _allowUploadEditingLinkAction->setCheckable(true);
_allowUploadEditingLinkAction->setChecked(checked); _allowUploadEditingLinkAction->setChecked(checked);
@ -171,7 +177,7 @@ void ShareLinkWidget::setupUiOptions(){
} }
// Adds permissions actions (radio button style) // Adds permissions actions (radio button style)
if(_isFile){ if (_isFile) {
_linkContextMenu->addAction(_allowEditingLinkAction); _linkContextMenu->addAction(_allowEditingLinkAction);
} else { } else {
_linkContextMenu->addAction(_readOnlyLinkAction); _linkContextMenu->addAction(_readOnlyLinkAction);
@ -179,11 +185,21 @@ void ShareLinkWidget::setupUiOptions(){
_linkContextMenu->addAction(_allowUploadLinkAction); _linkContextMenu->addAction(_allowUploadLinkAction);
} }
// Adds action to display note widget (check box)
_noteLinkAction = _linkContextMenu->addAction(tr("Add note to recipient"));
_noteLinkAction->setCheckable(true);
if (_linkShare->getNote().isSimpleText()) {
_ui->textEdit_note->setText(_linkShare->getNote());
_noteLinkAction->setChecked(true);
showNoteOptions(true);
}
// Adds action to display password widget (check box) // Adds action to display password widget (check box)
_passwordProtectLinkAction = _linkContextMenu->addAction(tr("Password Protect")); _passwordProtectLinkAction = _linkContextMenu->addAction(tr("Password Protect"));
_passwordProtectLinkAction->setCheckable(true); _passwordProtectLinkAction->setCheckable(true);
if(_linkShare.data()->isPasswordSet()){ if (_linkShare.data()->isPasswordSet()) {
_passwordProtectLinkAction->setChecked(true); _passwordProtectLinkAction->setChecked(true);
_ui->lineEdit_password->setPlaceholderText("********"); _ui->lineEdit_password->setPlaceholderText("********");
showPasswordOptions(true); showPasswordOptions(true);
@ -199,7 +215,7 @@ void ShareLinkWidget::setupUiOptions(){
// Adds action to display expiration date widget (check box) // Adds action to display expiration date widget (check box)
_expirationDateLinkAction = _linkContextMenu->addAction(tr("Expiration Date")); _expirationDateLinkAction = _linkContextMenu->addAction(tr("Expiration Date"));
_expirationDateLinkAction->setCheckable(true); _expirationDateLinkAction->setCheckable(true);
if(!expireDate.isNull()){ if (!expireDate.isNull()) {
_ui->calendar->setDate(expireDate); _ui->calendar->setDate(expireDate);
_expirationDateLinkAction->setChecked(true); _expirationDateLinkAction->setChecked(true);
showExpireDateOptions(true); showExpireDateOptions(true);
@ -242,7 +258,27 @@ void ShareLinkWidget::setupUiOptions(){
//startAnimation(0, height()); //startAnimation(0, height());
} }
void ShareLinkWidget::slotCopyLinkShare(bool clicked){ void ShareLinkWidget::setNote(const QString &note)
{
if (_linkShare) {
slotToggleAnimation(true);
_ui->errorLabel->hide();
_linkShare->setNote(note);
}
}
void ShareLinkWidget::slotCreateNote()
{
setNote(_ui->textEdit_note->toPlainText());
}
void ShareLinkWidget::slotNoteSet()
{
slotToggleAnimation(false);
}
void ShareLinkWidget::slotCopyLinkShare(bool clicked)
{
Q_UNUSED(clicked); Q_UNUSED(clicked);
QApplication::clipboard()->setText(_linkShare->getLink().toString()); QApplication::clipboard()->setText(_linkShare->getLink().toString());
@ -255,7 +291,7 @@ void ShareLinkWidget::slotExpireDateSet()
void ShareLinkWidget::slotSetExpireDate() void ShareLinkWidget::slotSetExpireDate()
{ {
if(!_linkShare){ if (!_linkShare) {
return; return;
} }
@ -295,8 +331,8 @@ void ShareLinkWidget::slotPasswordSet()
slotToggleAnimation(false); slotToggleAnimation(false);
} }
void ShareLinkWidget::startAnimation(const int start, const int end){ void ShareLinkWidget::startAnimation(const int start, const int end)
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "maximumHeight", this); QPropertyAnimation *animation = new QPropertyAnimation(this, "maximumHeight", this);
animation->setDuration(500); animation->setDuration(500);
@ -304,7 +340,7 @@ void ShareLinkWidget::startAnimation(const int start, const int end){
animation->setEndValue(end); animation->setEndValue(end);
connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotAnimationFinished); connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotAnimationFinished);
if(end < start) // that is to remove the widget, not to show it if (end < start) // that is to remove the widget, not to show it
connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotDeleteAnimationFinished); connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotDeleteAnimationFinished);
connect(animation, &QVariantAnimation::valueChanged, this, &ShareLinkWidget::resizeRequested); connect(animation, &QVariantAnimation::valueChanged, this, &ShareLinkWidget::resizeRequested);
@ -320,10 +356,32 @@ void ShareLinkWidget::slotDeleteShareFetched()
_linkShare.clear(); _linkShare.clear();
togglePasswordOptions(false); togglePasswordOptions(false);
toggleNoteOptions(false);
toggleExpireDateOptions(false); toggleExpireDateOptions(false);
emit deleteLinkShare(); emit deleteLinkShare();
} }
void ShareLinkWidget::showNoteOptions(bool show)
{
_ui->noteLabel->setVisible(show);
_ui->textEdit_note->setVisible(show);
_ui->confirmNote->setVisible(show);
}
void ShareLinkWidget::toggleNoteOptions(bool enable)
{
showNoteOptions(enable);
if (enable) {
_ui->textEdit_note->setFocus();
} else {
// 'deletes' note
if (_linkShare)
_linkShare->setNote(QString());
}
}
void ShareLinkWidget::slotAnimationFinished() void ShareLinkWidget::slotAnimationFinished()
{ {
emit resizeRequested(); emit resizeRequested();
@ -364,11 +422,11 @@ void ShareLinkWidget::togglePasswordOptions(bool enable)
{ {
showPasswordOptions(enable); showPasswordOptions(enable);
if(enable) { if (enable) {
_ui->lineEdit_password->setFocus(); _ui->lineEdit_password->setFocus();
} else { } else {
// 'deletes' password // 'deletes' password
if(_linkShare) if (_linkShare)
_linkShare->setPassword(QString()); _linkShare->setPassword(QString());
} }
} }
@ -391,7 +449,7 @@ void ShareLinkWidget::toggleExpireDateOptions(bool enable)
_ui->calendar->setFocus(); _ui->calendar->setFocus();
} else { } else {
// 'deletes' expire date // 'deletes' expire date
if(_linkShare) if (_linkShare)
_linkShare->setExpireDate(QDate()); _linkShare->setExpireDate(QDate());
} }
} }
@ -437,11 +495,10 @@ void ShareLinkWidget::slotContextMenuButtonClicked()
void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action) void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
{ {
bool state = action->isChecked(); bool state = action->isChecked();
SharePermissions perm = SharePermissionRead; SharePermissions perm = SharePermissionRead;
if(action == _addAnotherLinkAction){ if (action == _addAnotherLinkAction) {
emit createLinkShare(); emit createLinkShare();
} else if (action == _readOnlyLinkAction && state) { } else if (action == _readOnlyLinkAction && state) {
@ -465,6 +522,9 @@ void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
} else if (action == _expirationDateLinkAction) { } else if (action == _expirationDateLinkAction) {
toggleExpireDateOptions(state); toggleExpireDateOptions(state);
} else if (action == _noteLinkAction) {
toggleNoteOptions(state);
} else if (action == _unshareLinkAction) { } else if (action == _unshareLinkAction) {
confirmAndDeleteShare(); confirmAndDeleteShare();
} }

View file

@ -73,6 +73,9 @@ private slots:
void slotPasswordSet(); void slotPasswordSet();
void slotPasswordSetError(int code, const QString &message); void slotPasswordSetError(int code, const QString &message);
void slotCreateNote();
void slotNoteSet();
void slotSetExpireDate(); void slotSetExpireDate();
void slotExpireDateSet(); void slotExpireDateSet();
@ -94,6 +97,10 @@ private:
void showPasswordOptions(bool show); void showPasswordOptions(bool show);
void togglePasswordOptions(bool enable); void togglePasswordOptions(bool enable);
void showNoteOptions(bool show);
void toggleNoteOptions(bool enable);
void setNote(const QString &note);
void showExpireDateOptions(bool show); void showExpireDateOptions(bool show);
void toggleExpireDateOptions(bool enable); void toggleExpireDateOptions(bool enable);
@ -119,6 +126,7 @@ private:
bool _passwordRequired; bool _passwordRequired;
bool _expiryRequired; bool _expiryRequired;
bool _namesSupported; bool _namesSupported;
bool _noteRequired;
QMenu *_linkContextMenu; QMenu *_linkContextMenu;
QAction *_readOnlyLinkAction; QAction *_readOnlyLinkAction;
@ -129,6 +137,7 @@ private:
QAction *_expirationDateLinkAction; QAction *_expirationDateLinkAction;
QAction *_unshareLinkAction; QAction *_unshareLinkAction;
QAction *_addAnotherLinkAction; QAction *_addAnotherLinkAction;
QAction *_noteLinkAction;
}; };
} }

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>350</width> <width>365</width>
<height>160</height> <height>192</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -16,166 +16,26 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin"> <item>
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="1">
<widget class="QDateEdit" name="calendar">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Password:</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="shareLinkToolButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="errorLabel">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>123</red>
<green>121</green>
<blue>134</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_password">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="confirmPassword">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="confirmExpirationDate">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="createShareButton"> <widget class="QLabel" name="shareLinkIconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">text-align: left</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Share link</string> <string notr="true"/>
</property> </property>
<property name="icon"> <property name="pixmap">
<iconset resource="../../client.qrc"> <pixmap resource="../../client.qrc">:/client/resources/public.svg</pixmap>
<normaloff>:/client/resources/public.svg</normaloff>:/client/resources/public.svg</iconset>
</property> </property>
<property name="flat"> <property name="alignment">
<bool>true</bool> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="shareLinkLabel">
<property name="text">
<string>Share link</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -225,21 +85,243 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="shareLinkToolButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QLabel" name="expirationLabel"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item>
<widget class="QLabel" name="noteLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>78</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Note:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="indent">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEdit_note">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="confirmNote">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="passwordLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>78</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Password:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="indent">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="confirmPassword">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="expirationLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>78</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Expiration date:</string> <string>Expires:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
<property name="indent"> <property name="indent">
<number>20</number> <number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="calendar">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="confirmExpirationDate">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>123</red>
<green>121</green>
<blue>134</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>

View file

@ -200,6 +200,11 @@ QString LinkShare::getName() const
return _name; return _name;
} }
QString LinkShare::getNote() const
{
return _note;
}
void LinkShare::setName(const QString &name) void LinkShare::setName(const QString &name)
{ {
OcsShareJob *job = new OcsShareJob(_account); OcsShareJob *job = new OcsShareJob(_account);
@ -208,6 +213,20 @@ void LinkShare::setName(const QString &name)
job->setName(getId(), name); job->setName(getId(), name);
} }
void LinkShare::setNote(const QString &note)
{
OcsShareJob *job = new OcsShareJob(_account);
connect(job, &OcsShareJob::shareJobFinished, this, &LinkShare::slotNoteSet);
connect(job, &OcsJob::ocsError, this, &LinkShare::slotOcsError);
job->setNote(getId(), note);
}
void LinkShare::slotNoteSet(const QJsonDocument &, const QVariant &note)
{
_note = note.toString();
emit noteSet();
}
QString LinkShare::getToken() const QString LinkShare::getToken() const
{ {
return _token; return _token;

View file

@ -183,6 +183,12 @@ public:
*/ */
QString getName() const; QString getName() const;
/*
* Returns the note of the link share.
*/
QString getNote() const;
/* /*
* Set the name of the link share. * Set the name of the link share.
* *
@ -190,6 +196,12 @@ public:
*/ */
void setName(const QString &name); void setName(const QString &name);
/*
* Set the note of the link share.
*/
void setNote(const QString &note);
/* /*
* Returns the token of the link share. * Returns the token of the link share.
*/ */
@ -224,11 +236,13 @@ public:
signals: signals:
void expireDateSet(); void expireDateSet();
void passwordSet(); void passwordSet();
void noteSet();
void passwordSetError(int statusCode, const QString &message); void passwordSetError(int statusCode, const QString &message);
void nameSet(); void nameSet();
private slots: private slots:
void slotPasswordSet(const QJsonDocument &, const QVariant &value); void slotPasswordSet(const QJsonDocument &, const QVariant &value);
void slotNoteSet(const QJsonDocument &, const QVariant &value);
void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value); void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
void slotSetPasswordError(int statusCode, const QString &message); void slotSetPasswordError(int statusCode, const QString &message);
void slotNameSet(const QJsonDocument &, const QVariant &value); void slotNameSet(const QJsonDocument &, const QVariant &value);
@ -237,6 +251,7 @@ private:
QString _name; QString _name;
QString _token; QString _token;
bool _passwordSet; bool _passwordSet;
QString _note;
QDate _expireDate; QDate _expireDate;
QUrl _url; QUrl _url;
}; };

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>350</width> <width>350</width>
<height>55</height> <height>70</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -17,30 +17,24 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="mainOwnerLabel"> <widget class="QLabel" name="mainOwnerLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="shareeHorizontalLayout"> <layout class="QHBoxLayout" name="shareeHorizontalLayout" stretch="0,0">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@ -55,6 +49,12 @@
</property> </property>
<item> <item>
<widget class="QLineEdit" name="shareeLineEdit"> <widget class="QLineEdit" name="shareeLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText"> <property name="placeholderText">
<string>Share with users or groups ...</string> <string>Share with users or groups ...</string>
</property> </property>

View file

@ -6,35 +6,26 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>350</width> <width>360</width>
<height>45</height> <height>58</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>360</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground"> <property name="autoFillBackground">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,2,2,2"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item> <item>
<widget class="QLabel" name="avatar"> <widget class="QLabel" name="avatar">
<property name="sizePolicy"> <property name="sizePolicy">
@ -57,7 +48,7 @@
<item> <item>
<widget class="OCC::ElidedLabel" name="sharedWith"> <widget class="OCC::ElidedLabel" name="sharedWith">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Maximum"> <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -70,6 +61,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QCheckBox" name="permissionsEdit"> <widget class="QCheckBox" name="permissionsEdit">
<property name="sizePolicy"> <property name="sizePolicy">
@ -89,6 +96,9 @@
<iconset resource="../../client.qrc"> <iconset resource="../../client.qrc">
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset> <normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
</property> </property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>