diff options
author | Claudio Cambra <claudio.cambra@nextcloud.com> | 2022-09-15 20:55:25 +0300 |
---|---|---|
committer | Claudio Cambra <claudio.cambra@nextcloud.com> | 2022-10-31 20:06:07 +0300 |
commit | ec3c361c8988034b36edb7bf1016b6de276e6a1b (patch) | |
tree | c07898b21f77e7e6f81ad8169e57ae03f045406f | |
parent | d92bc91bdfe27e686ec2cecdd0b0801536f33ab4 (diff) |
Show password set errors in the popup where passwords are set rather than in the main dialog
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
-rw-r--r-- | src/gui/filedetails/ShareDelegate.qml | 37 | ||||
-rw-r--r-- | src/gui/filedetails/ShareView.qml | 3 | ||||
-rw-r--r-- | src/gui/filedetails/sharemodel.cpp | 3 | ||||
-rw-r--r-- | src/gui/filedetails/sharemodel.h | 2 |
4 files changed, 41 insertions, 4 deletions
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); |