From 4d52838e2be909c45d85796199789200d42d9f53 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 19 Jan 2016 14:03:13 +0100 Subject: [PATCH] Share dialog: Error reporting with password policy #4209 --- src/gui/share.cpp | 2 +- src/gui/share.h | 9 ++++++++- src/gui/sharelinkwidget.cpp | 16 +++++++++++++--- src/gui/sharelinkwidget.h | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/gui/share.cpp b/src/gui/share.cpp index fcdf1b1ca..f362dd350 100644 --- a/src/gui/share.cpp +++ b/src/gui/share.cpp @@ -201,7 +201,7 @@ void ShareManager::slotLinkShareCreated(const QVariantMap &reply) * meant that a share was password protected */ if (code == 403) { - emit linkShareRequiresPassword(); + emit linkShareRequiresPassword(message); return; } diff --git a/src/gui/share.h b/src/gui/share.h index 0811e38ae..234986fd8 100644 --- a/src/gui/share.h +++ b/src/gui/share.h @@ -259,10 +259,17 @@ public: signals: void shareCreated(const QSharedPointer &share); void linkShareCreated(const QSharedPointer &share); - void linkShareRequiresPassword(); void sharesFetched(const QList> &shares); void serverError(int code, const QString &message); + /** Emitted when creating a link share with password fails. + * + * @param message the error message reported by the server + * + * See createLinkShare(). + */ + void linkShareRequiresPassword(const QString &message); + private slots: void slotSharesFetched(const QVariantMap &reply); void slotLinkShareCreated(const QVariantMap &reply); diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp index c5c5b0c30..1d14eb7d9 100644 --- a/src/gui/sharelinkwidget.cpp +++ b/src/gui/sharelinkwidget.cpp @@ -140,13 +140,14 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account, connect(_manager, SIGNAL(sharesFetched(QList>)), SLOT(slotSharesFetched(QList>))); connect(_manager, SIGNAL(linkShareCreated(QSharedPointer)), SLOT(slotCreateShareFetched(const QSharedPointer))); - connect(_manager, SIGNAL(linkShareRequiresPassword()), SLOT(slotCreateShareRequiresPassword())); + connect(_manager, SIGNAL(linkShareRequiresPassword(QString)), SLOT(slotCreateShareRequiresPassword(QString))); connect(_manager, SIGNAL(serverError(int, QString)), SLOT(displayError(int, QString))); } void ShareLinkWidget::setExpireDate(const QDate &date) { _pi_date->startAnimation(); + _ui->errorLabel->hide(); _share->setExpireDate(date); } @@ -185,6 +186,7 @@ void ShareLinkWidget::setPassword(const QString &password) { _pi_link->startAnimation(); _pi_password->startAnimation(); + _ui->errorLabel->hide(); _ui->checkBox_password->setEnabled(false); _ui->lineEdit_password->setEnabled(false); @@ -378,6 +380,7 @@ void ShareLinkWidget::slotCheckBoxShareLinkClicked() _pi_link->startAnimation(); _ui->checkBox_shareLink->setEnabled(false); + _ui->errorLabel->hide(); _manager->createLinkShare(_sharePath); } else { @@ -403,18 +406,24 @@ void ShareLinkWidget::slotCreateShareFetched(const QSharedPointer sha getShares(); } -void ShareLinkWidget::slotCreateShareRequiresPassword() +void ShareLinkWidget::slotCreateShareRequiresPassword(const QString& message) { // there needs to be a password - _pi_editing->stopAnimation(); + _pi_link->stopAnimation(); + _pi_password->stopAnimation(); _ui->checkBox_password->setChecked(true); _ui->checkBox_password->setEnabled(false); _ui->checkBox_password->setText(tr("Public shå requires a password")); + _ui->lineEdit_password->setEnabled(true); _ui->lineEdit_password->setFocus(); _ui->pushButton_copy->hide(); _ui->widget_shareLink->show(); _ui->checkBox_expire->setEnabled(false); _ui->checkBox_editing->setEnabled(false); + if (!message.isEmpty()) { + _ui->errorLabel->setText(message); + _ui->errorLabel->show(); + } _passwordRequired = true; @@ -477,6 +486,7 @@ void ShareLinkWidget::setPublicUpload(bool publicUpload) { _ui->checkBox_editing->setEnabled(false); _pi_editing->startAnimation(); + _ui->errorLabel->hide(); _share->setPublicUpload(publicUpload); } diff --git a/src/gui/sharelinkwidget.h b/src/gui/sharelinkwidget.h index 6ca2dde0f..9fa3e3d4d 100644 --- a/src/gui/sharelinkwidget.h +++ b/src/gui/sharelinkwidget.h @@ -56,7 +56,7 @@ public: private slots: void slotSharesFetched(const QList> &shares); void slotCreateShareFetched(const QSharedPointer share); - void slotCreateShareRequiresPassword(); + void slotCreateShareRequiresPassword(const QString& message); void slotDeleteShareFetched(); void slotPasswordSet(); void slotExpireSet();