added selecting user for password protected services

This commit is contained in:
Daniel Tartavel 2023-03-05 14:18:43 +01:00
parent 42a7376f58
commit 63bcc965b5
2 changed files with 32 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.2, 2023-03-05T10:17:18. -->
<!-- Written by QtCreator 4.14.2, 2023-03-05T14:17:52. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -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
{