From: Claudio Cambra Date: Thu, 15 Sep 2022 17:55:25 +0000 (+0200) Subject: Show password set errors in the popup where passwords are set rather than in the... X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~169^2~22 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ec3c361c8988034b36edb7bf1016b6de276e6a1b;p=nextcloud-desktop.git Show password set errors in the popup where passwords are set rather than in the main dialog Signed-off-by: Claudio Cambra --- diff --git a/src/gui/filedetails/ShareDelegate.qml b/src/gui/filedetails/ShareDelegate.qml index 617e9af88..a7632f712 100644 --- a/src/gui/filedetails/ShareDelegate.qml +++ b/src/gui/filedetails/ShareDelegate.qml @@ -21,6 +21,7 @@ import QtGraphicalEffects 1.15 import com.nextcloud.desktopclient 1.0 import Style 1.0 import "../tray" +import "../" GridLayout { id: root @@ -87,6 +88,11 @@ GridLayout { property bool waitingForPasswordChange: false property bool waitingForNoteChange: false + function showPasswordSetError(message) { + passwordErrorBoxLoader.message = message !== "" ? + message : qsTr("An error occurred setting the share password."); + } + function resetNoteField() { noteTextEdit.text = note; waitingForNoteChange = false; @@ -468,6 +474,7 @@ GridLayout { !root.waitingForPasswordProtectEnabledChange onAccepted: if(text !== root.password && text !== root.passwordPlaceholder) { + passwordErrorBoxLoader.message = ""; root.setPassword(text); root.waitingForPasswordChange = true; } @@ -482,6 +489,36 @@ GridLayout { } } + Loader { + id: passwordErrorBoxLoader + + property string message: "" + + anchors.left: parent.left + anchors.right: parent.right + height: message !== "" ? implicitHeight : 0 + + active: message !== "" + visible: active + + sourceComponent: Item { + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + // Artificially add vertical padding + implicitHeight: passwordErrorBox.implicitHeight + (Style.smallSpacing * 2) + + ErrorBox { + id: passwordErrorBox + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + + text: passwordErrorBoxLoader.message + } + } + } + CheckBox { id: expireDateEnabledMenuItem diff --git a/src/gui/filedetails/ShareView.qml b/src/gui/filedetails/ShareView.qml index eb8da6f9e..43ada6d72 100644 --- a/src/gui/filedetails/ShareView.qml +++ b/src/gui/filedetails/ShareView.qml @@ -202,11 +202,12 @@ ColumnLayout { // password set has failed, meaning we won't be able to easily tell when we // have had a response from the server in QML. So we listen to this signal // directly from the model and do the reset of the password field manually. - function onPasswordSetError(shareId) { + function onPasswordSetError(shareId, errorCode, errorMessage) { if(shareId !== model.shareId) { return; } shareDelegate.resetPasswordField(); + shareDelegate.showPasswordSetError(errorMessage); } function onServerError() { diff --git a/src/gui/filedetails/sharemodel.cpp b/src/gui/filedetails/sharemodel.cpp index 3191ff22c..07294fc93 100644 --- a/src/gui/filedetails/sharemodel.cpp +++ b/src/gui/filedetails/sharemodel.cpp @@ -388,9 +388,8 @@ void ShareModel::slotAddShare(const SharePtr &share) connect(share.data(), &Share::serverError, this, &ShareModel::slotServerError); connect(share.data(), &Share::passwordSetError, this, [this, shareId](const int code, const QString &message) { _shareIdRecentlySetPasswords.remove(shareId); - slotServerError(code, message); slotSharePasswordSet(shareId); - Q_EMIT passwordSetError(shareId); + Q_EMIT passwordSetError(shareId, code, message); }); // Passing shareId by reference here will cause crashing, so we pass by value diff --git a/src/gui/filedetails/sharemodel.h b/src/gui/filedetails/sharemodel.h index aa4989744..4328aeff1 100644 --- a/src/gui/filedetails/sharemodel.h +++ b/src/gui/filedetails/sharemodel.h @@ -107,7 +107,7 @@ signals: void hasInitialShareFetchCompletedChanged(); void serverError(const int code, const QString &message); - void passwordSetError(const QString &shareId); + void passwordSetError(const QString &shareId, const int code, const QString &message); void requestPasswordForLinkShare(); void requestPasswordForEmailSharee(const ShareePtr &sharee);