Allow for saving the configuration used by a window opened from a URL.

Note when editing a copy save password works now too.
This commit is contained in:
eelke 2025-03-10 19:08:02 +01:00
parent 05e9b982cd
commit a6be979f8e
7 changed files with 43 additions and 16 deletions

View file

@ -84,10 +84,14 @@ void ConnectionController::openBackupDlgForConnection(QModelIndex index)
}
}
void ConnectionController::createConnection()
void ConnectionController::createConnection(ConnectionConfig *init)
{
ConnectionConfig cc;
cc.setUuid(QUuid::createUuid());
if (init)
{
cc = *init;
cc.setUuid(QUuid());
}
editConfig(cc);
}
@ -104,7 +108,7 @@ void ConnectionController::editCopy(QModelIndex index)
auto config = ConnectionTreeModel::getConfigFromModelIndex(index);
if (config) {
auto cc = *config;
cc.setUuid(QUuid::createUuid());
cc.setUuid(QUuid());
cc.setEncodedPassword({}); // maybe we should decode en reencode?
editConfig(cc);
}
@ -120,10 +124,20 @@ void ConnectionController::saveConnection(ConnectionConfigurationWidget &w)
{
auto cc = w.data();
auto grp = w.group();
if (w.savePassword())
encryptPassword(cc);
if (w.clearPassword())
bool isNew = cc.uuid().isNull();
if (isNew)
{
cc.setUuid(QUuid::createUuid());
}
if (w.savePasswordEnabled())
{
if (isNew || w.passwordIsChanged())
encryptPassword(cc);
}
else
{
cc.setEncodedPassword({});
}
m_connectionTreeModel->save(grp, cc);
}