mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
Fixes #534: interactions with expiration date and password.
- Fixes call for slot when date is set - it was the password slot for that. - Adds QProgressIndicator and function to toggle animation. - Fixes: when date was set, the date was not being correctly set and displayed. - Fixes: hides and 'deletes' passsword and expire. date widgets when the user unchecks it in the toolbox menu. Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
parent
eecbdb00de
commit
d5a0ec7d8b
3 changed files with 84 additions and 89 deletions
|
@ -66,20 +66,14 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
|||
|
||||
// the following progress indicator widgets are added to layouts which makes them
|
||||
// automatically deleted once the dialog dies.
|
||||
_pi_create = new QProgressIndicator();
|
||||
_pi_password = new QProgressIndicator();
|
||||
_pi_date = new QProgressIndicator();
|
||||
_pi_editing = new QProgressIndicator();
|
||||
|
||||
// TODO: where to loading should show up?
|
||||
// _ui->verticalLayout->addWidget(_pi_create, Qt::AlignCenter);
|
||||
// _ui->verticalLayout->addWidget(_pi_password, Qt::AlignCenter);
|
||||
// _ui->verticalLayout->addWidget(_pi_editing, Qt::AlignCenter);
|
||||
_pi_indicator = new QProgressIndicator();
|
||||
_ui->horizontalLayout->insertWidget(1, _pi_indicator, Qt::AlignCenter);
|
||||
_ui->indicatorWidget->hide();
|
||||
|
||||
connect(_ui->enableShareLink, &QCheckBox::toggled, this, &ShareLinkWidget::slotCreateOrDeleteShareLink);
|
||||
connect(_ui->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword);
|
||||
connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword);
|
||||
connect(_ui->confirmExpirationDate, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword);
|
||||
connect(_ui->confirmExpirationDate, &QAbstractButton::clicked, this, &ShareLinkWidget::slotSetExpireDate);
|
||||
connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotExpireDateChanged);
|
||||
|
||||
_ui->errorLabel->hide();
|
||||
|
@ -144,9 +138,19 @@ ShareLinkWidget::~ShareLinkWidget()
|
|||
delete _ui;
|
||||
}
|
||||
|
||||
void ShareLinkWidget::toggleAnimation(bool start){
|
||||
if(start && !_pi_indicator->isAnimated())
|
||||
_pi_indicator->startAnimation();
|
||||
else
|
||||
_pi_indicator->stopAnimation();
|
||||
|
||||
_ui->indicatorWidget->setVisible(start);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::getShares()
|
||||
{
|
||||
if (_manager) {
|
||||
toggleAnimation(true);
|
||||
_manager->fetchShares(_sharePath);
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +169,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
|||
// Connect all shares signals to gui slots
|
||||
connect(share.data(), &Share::serverError, this, &ShareLinkWidget::slotServerError);
|
||||
connect(share.data(), &Share::shareDeleted, this, &ShareLinkWidget::slotDeleteShareFetched);
|
||||
//TODO connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireSet);
|
||||
connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireDateSet);
|
||||
connect(_linkShare.data(), &LinkShare::passwordSet, this, &ShareLinkWidget::slotPasswordSet);
|
||||
connect(_linkShare.data(), &LinkShare::passwordSetError, this, &ShareLinkWidget::slotPasswordSetError);
|
||||
|
||||
|
@ -241,6 +245,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
|||
_expirationDateLinkAction = _linkContextMenu->addAction(tr("Expiration Date"));
|
||||
_expirationDateLinkAction->setCheckable(true);
|
||||
if(_linkShare->getExpireDate().isValid()){
|
||||
_ui->calendar->setDate(_linkShare->getExpireDate());
|
||||
_expirationDateLinkAction->setChecked(true);
|
||||
_ui->expirationShareProperty->show();
|
||||
}
|
||||
|
@ -270,80 +275,42 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
|||
// show sharing options
|
||||
_ui->shareLinkToolButton->show();
|
||||
}
|
||||
|
||||
toggleAnimation(false);
|
||||
}
|
||||
|
||||
// TODO
|
||||
//void ShareLinkWidget::slotShareSelectionChanged()
|
||||
//{
|
||||
// // Disable running progress indicators
|
||||
// _pi_create->stopAnimation();
|
||||
// _pi_editing->stopAnimation();
|
||||
// _pi_date->stopAnimation();
|
||||
// _pi_password->stopAnimation();
|
||||
|
||||
// _ui->errorLabel->hide();
|
||||
// _ui->passwordShareProperty->show();
|
||||
// _ui->expirationShareProperty->show();
|
||||
|
||||
// if (!_account->capabilities().sharePublicLinkAllowUpload()) {
|
||||
// _allowUploadEditingLinkAction->setEnabled(false);
|
||||
// _allowUploadLinkAction->setEnabled(false);
|
||||
// }
|
||||
|
||||
// // Password state
|
||||
// _ui->lineEdit_password->setEnabled(_linkShare->isPasswordSet());
|
||||
// if(_linkShare->isPasswordSet()) _ui->lineEdit_password->setPlaceholderText("********");
|
||||
// _ui->lineEdit_password->setText(QString());
|
||||
// _ui->lineEdit_password->setEnabled(_linkShare->isPasswordSet());
|
||||
// _ui->confirmPassword->setEnabled(_linkShare->isPasswordSet());
|
||||
|
||||
// // Expiry state
|
||||
// _ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
|
||||
// if (_linkShare->getExpireDate().isValid()) {
|
||||
// _ui->calendar->setDate(_linkShare->getExpireDate());
|
||||
// _ui->calendar->setEnabled(true);
|
||||
// }
|
||||
// // Public upload state (box is hidden for files)
|
||||
// if (!_isFile) {
|
||||
// if (_linkShare->getPublicUpload()) {
|
||||
// if (_linkShare->getShowFileListing()) {
|
||||
// _allowUploadEditingLinkAction->setChecked(true);
|
||||
// } else {
|
||||
// _allowUploadLinkAction->setChecked(true);
|
||||
// }
|
||||
// } else {
|
||||
// _readOnlyLinkAction->setChecked(true);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void ShareLinkWidget::setExpireDate(const QDate &date)
|
||||
{
|
||||
if (_linkShare) {
|
||||
_pi_date->startAnimation();
|
||||
toggleAnimation(true);
|
||||
_ui->errorLabel->hide();
|
||||
_linkShare->setExpireDate(date);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
//void ShareLinkWidget::slotExpireSet()
|
||||
//{
|
||||
// if (sender() == _linkShare.data()) {
|
||||
// slotShareSelectionChanged();
|
||||
// }
|
||||
//}
|
||||
void ShareLinkWidget::slotExpireDateSet()
|
||||
{
|
||||
toggleAnimation(false);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotExpireDateChanged(const QDate &date)
|
||||
{
|
||||
setExpireDate(date);
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotSetExpireDate()
|
||||
{
|
||||
slotExpireDateChanged(_ui->calendar->date());
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCreatePassword()
|
||||
{
|
||||
if (!_manager) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggleAnimation(true);
|
||||
|
||||
if (!_linkShare) {
|
||||
// If share creation requires a password, we'll be in this case
|
||||
if (_ui->lineEdit_password->text().isEmpty()) {
|
||||
|
@ -351,7 +318,6 @@ void ShareLinkWidget::slotCreatePassword()
|
|||
return;
|
||||
}
|
||||
|
||||
_pi_create->startAnimation();
|
||||
_manager->createLinkShare(_sharePath, QString(), _ui->lineEdit_password->text());
|
||||
} else {
|
||||
setPassword(_ui->lineEdit_password->text());
|
||||
|
@ -365,7 +331,8 @@ void ShareLinkWidget::slotCreateOrDeleteShareLink(bool checked)
|
|||
return;
|
||||
}
|
||||
|
||||
_pi_create->startAnimation();
|
||||
toggleAnimation(true);
|
||||
|
||||
if(checked){
|
||||
_manager->createLinkShare(_sharePath, QString(), QString());
|
||||
} else {
|
||||
|
@ -380,7 +347,8 @@ void ShareLinkWidget::slotCreateOrDeleteShareLink(bool checked)
|
|||
void ShareLinkWidget::setPassword(const QString &password)
|
||||
{
|
||||
if (_linkShare) {
|
||||
_pi_password->startAnimation();
|
||||
toggleAnimation(true);
|
||||
|
||||
_ui->errorLabel->hide();
|
||||
_linkShare->setPassword(password);
|
||||
}
|
||||
|
@ -391,7 +359,6 @@ void ShareLinkWidget::slotPasswordSet()
|
|||
if (!_linkShare)
|
||||
return;
|
||||
|
||||
_pi_password->stopAnimation();
|
||||
_ui->lineEdit_password->setText(QString());
|
||||
if (_linkShare->isPasswordSet()) {
|
||||
_ui->lineEdit_password->setPlaceholderText("********");
|
||||
|
@ -400,6 +367,8 @@ void ShareLinkWidget::slotPasswordSet()
|
|||
_ui->lineEdit_password->setPlaceholderText(QString());
|
||||
}
|
||||
|
||||
toggleAnimation(false);
|
||||
|
||||
/*
|
||||
* When setting/deleting a password from a share the old share is
|
||||
* deleted and a new one is created. So we need to refetch the shares
|
||||
|
@ -412,25 +381,26 @@ void ShareLinkWidget::slotPasswordSet()
|
|||
|
||||
void ShareLinkWidget::slotDeleteShareFetched()
|
||||
{
|
||||
toggleAnimation(true);
|
||||
_linkShare.clear();
|
||||
_ui->enableShareLink->setChecked(false);
|
||||
_ui->shareLinkToolButton->setEnabled(false);
|
||||
_ui->shareLinkToolButton->hide();
|
||||
togglePasswordOptions(false);
|
||||
toggleExpireDateOptions(false);
|
||||
getShares();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCreateShareFetched()
|
||||
{
|
||||
_pi_create->stopAnimation();
|
||||
_pi_password->stopAnimation();
|
||||
toggleAnimation(true);
|
||||
getShares();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
|
||||
{
|
||||
// Prepare password entry
|
||||
_pi_create->stopAnimation();
|
||||
_pi_password->stopAnimation();
|
||||
toggleAnimation(true);
|
||||
|
||||
_ui->passwordShareProperty->show();
|
||||
if (!message.isEmpty()) {
|
||||
_ui->errorLabel->setText(message);
|
||||
|
@ -445,7 +415,14 @@ void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
|
|||
void ShareLinkWidget::togglePasswordOptions(bool enable)
|
||||
{
|
||||
_ui->passwordShareProperty->setVisible(enable);
|
||||
if(enable) _ui->lineEdit_password->setFocus();
|
||||
|
||||
if(enable) {
|
||||
_ui->lineEdit_password->setFocus();
|
||||
} else {
|
||||
// 'deletes' password
|
||||
if(_linkShare)
|
||||
_linkShare->setPassword(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void ShareLinkWidget::toggleExpireDateOptions(bool enable)
|
||||
|
@ -453,9 +430,13 @@ void ShareLinkWidget::toggleExpireDateOptions(bool enable)
|
|||
_ui->expirationShareProperty->setVisible(enable);
|
||||
if (enable) {
|
||||
const QDate date = QDate::currentDate().addDays(1);
|
||||
setExpireDate(date);
|
||||
_ui->calendar->setDate(date);
|
||||
_ui->calendar->setMinimumDate(date);
|
||||
_ui->calendar->setFocus();
|
||||
} else {
|
||||
// 'deletes' expire date
|
||||
if(_linkShare)
|
||||
_linkShare->setExpireDate(QDate());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,10 +514,7 @@ void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
|
|||
|
||||
void ShareLinkWidget::slotServerError(int code, const QString &message)
|
||||
{
|
||||
_pi_create->stopAnimation();
|
||||
_pi_date->stopAnimation();
|
||||
_pi_password->stopAnimation();
|
||||
_pi_editing->stopAnimation();
|
||||
toggleAnimation(false);
|
||||
|
||||
qCWarning(lcSharing) << "Error from server" << code << message;
|
||||
displayError(message);
|
||||
|
|
|
@ -65,6 +65,7 @@ private slots:
|
|||
void slotCreatePassword();
|
||||
|
||||
void slotExpireDateChanged(const QDate &date);
|
||||
void slotSetExpireDate();
|
||||
|
||||
void slotContextMenuButtonClicked();
|
||||
void slotLinkContextMenuActionTriggered(QAction *action);
|
||||
|
@ -72,8 +73,9 @@ private slots:
|
|||
void slotDeleteShareFetched();
|
||||
void slotCreateShareFetched();
|
||||
void slotCreateShareRequiresPassword(const QString &message);
|
||||
|
||||
void slotPasswordSet();
|
||||
//void slotExpireSet();
|
||||
void slotExpireDateSet();
|
||||
|
||||
void slotServerError(int code, const QString &message);
|
||||
void slotPasswordSetError(int code, const QString &message);
|
||||
|
@ -95,10 +97,7 @@ private:
|
|||
/** Retrieve a share's name, accounting for _namesSupported */
|
||||
QString shareName() const;
|
||||
|
||||
/**
|
||||
* Retrieve the selected share, returning 0 if none.
|
||||
*/
|
||||
//QSharedPointer<LinkShare> selectedShare() const;
|
||||
void toggleAnimation(bool start);
|
||||
|
||||
Ui::ShareLinkWidget *_ui;
|
||||
AccountPtr _account;
|
||||
|
@ -106,10 +105,7 @@ private:
|
|||
QString _localPath;
|
||||
QString _shareUrl;
|
||||
|
||||
QProgressIndicator *_pi_create;
|
||||
QProgressIndicator *_pi_password;
|
||||
QProgressIndicator *_pi_date;
|
||||
QProgressIndicator *_pi_editing;
|
||||
QProgressIndicator *_pi_indicator;
|
||||
|
||||
ShareManager *_manager;
|
||||
QSharedPointer<LinkShare> _linkShare;
|
||||
|
|
|
@ -181,6 +181,27 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="indicatorWidget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="passwordShareProperty" native="true">
|
||||
<property name="sizePolicy">
|
||||
|
@ -266,7 +287,7 @@
|
|||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue