From: Claudio Cambra Date: Fri, 28 Oct 2022 18:22:27 +0000 (+0200) Subject: Show edit locally loading dialog sooner, improve feedback for user X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~177^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ae12519dd5f3609e5845cf07598514d0cc9cb121;p=nextcloud-desktop.git Show edit locally loading dialog sooner, improve feedback for user Signed-off-by: Claudio Cambra --- diff --git a/src/gui/editlocallyhandler.cpp b/src/gui/editlocallyhandler.cpp index 64210a7ff..74396b20c 100644 --- a/src/gui/editlocallyhandler.cpp +++ b/src/gui/editlocallyhandler.cpp @@ -18,7 +18,6 @@ #include #include -#include "accountmanager.h" #include "editlocallymanager.h" #include "folder.h" #include "folderman.h" @@ -50,6 +49,10 @@ void EditLocallyHandler::startSetup() return; } + // Show the loading dialog but don't show the filename until we have + // verified the token + Systray::instance()->createEditFileLocallyLoadingDialog({}); + // We check the input data locally first, without modifying any state or // showing any potentially misleading data to the user if (!isTokenValid(_token)) { @@ -110,6 +113,7 @@ void EditLocallyHandler::remoteTokenCheckResultReceived(const int statusCode) if (!_tokenVerified) { showError(tr("Could not validate the request to open a file from server."), tr("Please try again.")); + return; } proceedWithSetup(); @@ -149,17 +153,13 @@ void EditLocallyHandler::proceedWithSetup() _fileName = relPathSplit.last(); + Systray::instance()->destroyEditFileLocallyLoadingDialog(); Q_EMIT setupFinished(); } QString EditLocallyHandler::prefixSlashToPath(const QString &path) { - auto slashPrefixedPath = path; - if (!slashPrefixedPath.startsWith('/')) { - slashPrefixedPath.prepend('/'); - } - - return slashPrefixedPath; + return path.startsWith('/') ? path : QChar::fromLatin1('/') + path; } bool EditLocallyHandler::isTokenValid(const QString &token) @@ -173,12 +173,7 @@ bool EditLocallyHandler::isTokenValid(const QString &token) const QRegularExpression tokenRegex("^[a-zA-Z0-9]{128}$"); const auto regexMatch = tokenRegex.match(token); - // Means invalid token type received, be cautious with bad token - if(!regexMatch.hasMatch()) { - return false; - } - - return true; + return regexMatch.hasMatch(); } bool EditLocallyHandler::isRelPathValid(const QString &relPath) @@ -207,7 +202,7 @@ bool EditLocallyHandler::isRelPathValid(const QString &relPath) bool EditLocallyHandler::isRelPathExcluded(const QString &relPath) { if (relPath.isEmpty()) { - return true; + return false; } const auto folderMap = FolderMan::instance()->map(); @@ -216,16 +211,17 @@ bool EditLocallyHandler::isRelPathExcluded(const QString &relPath) const auto excludedThroughSelectiveSync = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &result); for (const auto &excludedPath : excludedThroughSelectiveSync) { if (relPath.startsWith(excludedPath)) { - return false; + return true; } } } - return true; + return false; } void EditLocallyHandler::showError(const QString &message, const QString &informativeText) { + Systray::instance()->destroyEditFileLocallyLoadingDialog(); showErrorNotification(message, informativeText); // to make sure the error is not missed, show a message box in addition showErrorMessageBox(message, informativeText); diff --git a/src/gui/editlocallyhandler.h b/src/gui/editlocallyhandler.h index f7b27b71a..05b3076e7 100644 --- a/src/gui/editlocallyhandler.h +++ b/src/gui/editlocallyhandler.h @@ -49,9 +49,9 @@ signals: public slots: void startSetup(); void startEditLocally(); - void startTokenRemoteCheck(); private slots: + void startTokenRemoteCheck(); void proceedWithSetup(); void showError(const QString &message, const QString &informativeText); diff --git a/src/gui/tray/EditFileLocallyLoadingDialog.qml b/src/gui/tray/EditFileLocallyLoadingDialog.qml index f7fbe965b..12e8f757b 100644 --- a/src/gui/tray/EditFileLocallyLoadingDialog.qml +++ b/src/gui/tray/EditFileLocallyLoadingDialog.qml @@ -65,13 +65,14 @@ Window { font.pixelSize: root.fontPixelSize color: Style.ncTextColor horizontalAlignment: Text.AlignHCenter + visible: root.fileName !== "" } Label { id: labelMessage Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true Layout.bottomMargin: Style.standardSpacing - text: qsTr("Opening for local editing") + text: qsTr("Opening file for local editing") elide: Text.ElideRight font.pixelSize: root.fontPixelSize color: Style.ncTextColor