From 17fb2a98d6518738dc8e278de9ca4b12e1d32dfc Mon Sep 17 00:00:00 2001 From: pokamest Date: Wed, 24 May 2023 12:18:40 +0100 Subject: [PATCH] Fix question when removing server from list --- client/core/sshclient.cpp | 2 -- client/ui/pages_logic/ServerSettingsLogic.cpp | 5 +++++ client/ui/pages_logic/ServerSettingsLogic.h | 2 ++ client/ui/qml/Pages/PageServerSettings.qml | 7 ++++++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/client/core/sshclient.cpp b/client/core/sshclient.cpp index 795af965..cd58ba79 100644 --- a/client/core/sshclient.cpp +++ b/client/core/sshclient.cpp @@ -257,7 +257,6 @@ namespace libssh { int bytesWritten = sftp_write(file, buffer, bufferSize); std::string chunk(buffer, bufferSize); - qDebug() << "sftp write: " << QString(chunk.c_str()); if (bytesWritten != bufferSize) { fin.close(); @@ -272,7 +271,6 @@ namespace libssh { fin.read(buffer, lastChunkSize); std::string chunk(buffer, lastChunkSize); - qDebug() << "sftp write: " << QString(chunk.c_str()); int bytesWritten = sftp_write(file, buffer, lastChunkSize); diff --git a/client/ui/pages_logic/ServerSettingsLogic.cpp b/client/ui/pages_logic/ServerSettingsLogic.cpp index 92b093a5..a17f0159 100644 --- a/client/ui/pages_logic/ServerSettingsLogic.cpp +++ b/client/ui/pages_logic/ServerSettingsLogic.cpp @@ -100,6 +100,11 @@ void ServerSettingsLogic::onLineEditDescriptionEditingFinished() uiLogic()->onUpdateAllPages(); } +bool ServerSettingsLogic::isCurrentServerHasCredentials() +{ + return m_settings->haveAuthData(uiLogic()->m_selectedServerIndex); +} + #if defined(Q_OS_ANDROID) /* Auth result handler for Android */ void authResultReceiver::handleActivityResult(int receiverRequestCode, int resultCode, const QJniObject &data) diff --git a/client/ui/pages_logic/ServerSettingsLogic.h b/client/ui/pages_logic/ServerSettingsLogic.h index a75dfa47..3ce26164 100644 --- a/client/ui/pages_logic/ServerSettingsLogic.h +++ b/client/ui/pages_logic/ServerSettingsLogic.h @@ -31,6 +31,8 @@ public: Q_INVOKABLE void onPushButtonClearClientCacheClicked(); Q_INVOKABLE void onLineEditDescriptionEditingFinished(); + Q_INVOKABLE bool isCurrentServerHasCredentials(); + public: explicit ServerSettingsLogic(UiLogic *uiLogic, QObject *parent = nullptr); ~ServerSettingsLogic() = default; diff --git a/client/ui/qml/Pages/PageServerSettings.qml b/client/ui/qml/Pages/PageServerSettings.qml index f1eee906..4ef22ce4 100644 --- a/client/ui/qml/Pages/PageServerSettings.qml +++ b/client/ui/qml/Pages/PageServerSettings.qml @@ -110,13 +110,18 @@ PageBase { Layout.topMargin: 10 text: qsTr("Forget this server") onClicked: { + if (ServerSettingsLogic.isCurrentServerHasCredentials()) { + popupForgetServer.questionText = "Attention! This action will not remove any data from the server, it will just remove server from the list. Continue?" + } + else { + popupForgetServer.questionText = "Remove server from the list?" + } popupForgetServer.open() } } PopupWithQuestion { id: popupForgetServer - questionText: "Attention! This action will not remove the container on the server, it will only remove the container information from the application. Continue?" yesFunc: function() { ServerSettingsLogic.onPushButtonForgetServer() close()