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"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!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> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -673,14 +673,15 @@ void MainWindow::preparePopulateTree()
// setting savePath from settings // setting savePath from settings
this->downloading.savePath = this->settings.value(str).toString(); this->downloading.savePath = this->settings.value(str).toString();
} }
this->settings.beginGroup("Passwords/" + this->connexion.server + "/" + this->connexion.service);
logins = this->settings.allKeys(); getUserPassword(false);
//TODO choose login //this->settings.beginGroup("Passwords/" + this->connexion.server + "/" + this->connexion.service);
if (logins.count() != 0) //logins = this->settings.allKeys();
{ //if (logins.count() != 0)
this->connexion.user = logins[0]; //{
this->connexion.password = this->settings.value(logins[0]).toString(); // this->connexion.user = logins[0];
} // this->connexion.password = this->settings.value(logins[0]).toString();
//}
this->settings.endGroup(); this->settings.endGroup();
populateTree(); populateTree();
} }
@ -691,7 +692,9 @@ void MainWindow::preparePopulateTree()
bool MainWindow::getUserPassword(bool object = false) bool MainWindow::getUserPassword(bool object = false)
{ {
QStringList logins; QStringList logins;
QString login;
bool returnValue; bool returnValue;
bool ok = false;
if (object == false) if (object == false)
{ {
@ -701,11 +704,29 @@ bool MainWindow::getUserPassword(bool object = false)
this->settings.beginGroup("Passwords/" + this->downloading.server + "/" + this->downloading.service); this->settings.beginGroup("Passwords/" + this->downloading.server + "/" + this->downloading.service);
} }
logins = this->settings.allKeys(); logins = this->settings.allKeys();
//TODO choose login in case of multiples logins //TODO choose login in case of multiples logins
if (logins.count() != 0) if (logins.count() != 0)
{
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.user = logins[0];
this->downloading.password = this->settings.value(logins[0]).toString(); this->downloading.password = this->settings.value(logins[0]).toString();
}
returnValue = true; returnValue = true;
}else }else
{ {