From 63bcc965b5b6b9529943fbea030d51f93fb3b3ba Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sun, 5 Mar 2023 14:18:43 +0100 Subject: [PATCH] added selecting user for password protected services --- RsyncUI.pro.user | 2 +- mainwindow.cpp | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index ac7c24f..8882a05 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/mainwindow.cpp b/mainwindow.cpp index ddf819a..a5b28c8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -673,14 +673,15 @@ void MainWindow::preparePopulateTree() // setting savePath from settings this->downloading.savePath = this->settings.value(str).toString(); } - this->settings.beginGroup("Passwords/" + this->connexion.server + "/" + this->connexion.service); - logins = this->settings.allKeys(); - //TODO choose login - if (logins.count() != 0) - { - this->connexion.user = logins[0]; - this->connexion.password = this->settings.value(logins[0]).toString(); - } + + getUserPassword(false); + //this->settings.beginGroup("Passwords/" + this->connexion.server + "/" + this->connexion.service); + //logins = this->settings.allKeys(); + //if (logins.count() != 0) + //{ + // this->connexion.user = logins[0]; + // this->connexion.password = this->settings.value(logins[0]).toString(); + //} this->settings.endGroup(); populateTree(); } @@ -691,7 +692,9 @@ void MainWindow::preparePopulateTree() bool MainWindow::getUserPassword(bool object = false) { QStringList logins; + QString login; bool returnValue; + bool ok = false; if (object == false) { @@ -701,11 +704,29 @@ bool MainWindow::getUserPassword(bool object = false) this->settings.beginGroup("Passwords/" + this->downloading.server + "/" + this->downloading.service); } logins = this->settings.allKeys(); + //TODO choose login in case of multiples logins if (logins.count() != 0) { - this->downloading.user = logins[0]; - this->downloading.password = this->settings.value(logins[0]).toString(); + login = QInputDialog::getItem(this, + "RsincUI", + tr("There is many users for this service.\nSelect user you want to connect with."), + logins, + 0, + true, + &ok, + Qt::Popup, + Qt::ImhNoPredictiveText + ); + if (object == false) + { + this->connexion.user = logins[0]; + this->connexion.password = this->settings.value(logins[0]).toString(); + }else + { + this->downloading.user = logins[0]; + this->downloading.password = this->settings.value(logins[0]).toString(); + } returnValue = true; }else {