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:
parent
05e9b982cd
commit
a6be979f8e
7 changed files with 43 additions and 16 deletions
|
|
@ -207,13 +207,13 @@ void ConnectionConfigurationWidget::setData(const ConnectionConfig &cfg)
|
|||
edtPassword->setText("");
|
||||
|
||||
cmbDbname->setCurrentText(cfg.dbname());
|
||||
//cmbbxSsl->setCurrentIndex(static_cast<int>(cfg.sslMode()));
|
||||
cmbbxSsl->setCurrentText(cfg.getParameter("sslmode"));
|
||||
edtCert->setText(cfg.sslCert());
|
||||
edtKey->setText(cfg.sslKey());
|
||||
edtRootCert->setText(cfg.sslRootCert());
|
||||
edtCrl->setText(cfg.sslCrl());
|
||||
|
||||
edtPassword->setText(cfg.password());
|
||||
encodedPassword = cfg.encodedPassword();
|
||||
cbSavePassword->setCheckState(
|
||||
encodedPassword.isEmpty()
|
||||
|
|
@ -234,7 +234,7 @@ ConnectionConfig ConnectionConfigurationWidget::data() const
|
|||
cfg.setUser(edtUser->text());
|
||||
cfg.setPassword(edtPassword->text());
|
||||
cfg.setDbname(cmbDbname->currentText());
|
||||
cfg.setSslMode(static_cast<SslMode>(cmbbxSsl->currentIndex()));
|
||||
cfg.setParameter("sslmode", cmbbxSsl->currentText());
|
||||
cfg.setSslCert(edtCert->text());
|
||||
cfg.setSslKey(edtKey->text());
|
||||
cfg.setSslRootCert(edtRootCert->text());
|
||||
|
|
@ -248,14 +248,14 @@ QString ConnectionConfigurationWidget::group() const
|
|||
return cmbbxGroup->currentText();
|
||||
}
|
||||
|
||||
bool ConnectionConfigurationWidget::savePassword() const
|
||||
bool ConnectionConfigurationWidget::savePasswordEnabled() const
|
||||
{
|
||||
return cbSavePassword->isChecked() && !edtPassword->text().isEmpty() && passwordChanged;
|
||||
return cbSavePassword->isChecked();
|
||||
}
|
||||
|
||||
bool ConnectionConfigurationWidget::clearPassword() const
|
||||
bool ConnectionConfigurationWidget::passwordIsChanged() const
|
||||
{
|
||||
return !cbSavePassword->isChecked();
|
||||
return passwordChanged;
|
||||
}
|
||||
|
||||
void ConnectionConfigurationWidget::testConnection()
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ public:
|
|||
ConnectionConfig data() const;
|
||||
QString group() const;
|
||||
|
||||
bool savePassword() const;
|
||||
bool clearPassword() const;
|
||||
bool savePasswordEnabled() const;
|
||||
bool passwordIsChanged() const;
|
||||
|
||||
public slots:
|
||||
void testConnection();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
/// Starts the form for creating a new conncetion.
|
||||
/// This function returns immidiatly!
|
||||
void createConnection();
|
||||
void createConnection(ConnectionConfig *init = nullptr);
|
||||
/// Starts the form for editing a conncetion.
|
||||
/// This function returns immidiatly!
|
||||
void editConnection(QModelIndex index);
|
||||
|
|
|
|||
|
|
@ -443,6 +443,12 @@ void DatabaseWindow::on_actionShow_connection_manager_triggered()
|
|||
m_masterController->connectionController()->showConnectionManager();
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionSave_connection_triggered()
|
||||
{
|
||||
if (m_config.uuid().isNull())
|
||||
m_masterController->connectionController()->createConnection(&m_config);
|
||||
}
|
||||
|
||||
void DatabaseWindow::on_actionManual_triggered()
|
||||
{
|
||||
OpenManual();
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ private slots:
|
|||
void on_actionSave_query_as_triggered();
|
||||
void on_actionSave_copy_of_query_as_triggered();
|
||||
void on_actionShow_connection_manager_triggered();
|
||||
void on_actionSave_connection_triggered();
|
||||
|
||||
void on_actionManual_triggered();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1260</width>
|
||||
<height>29</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
@ -44,6 +44,7 @@
|
|||
<addaction name="actionSave_query_as"/>
|
||||
<addaction name="actionSave_copy_of_query_as"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSave_connection"/>
|
||||
<addaction name="actionExport_data"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClose"/>
|
||||
|
|
@ -331,6 +332,11 @@
|
|||
<string>Manual</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_connection">
|
||||
<property name="text">
|
||||
<string>Save connection</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue