pgLab/pglab/ConnectionConfigurationWidget.h
eelke da19c46d5e Improve editing of connection password
Previously only a new password was saved if the save password checkbox was checked, Which always
started in the unchecked state. Now when editing existing connection the save password checkbox now
reflects if a password has been saved. Only when the password field is edited the program will update
the saved password. If the save password checkbox is unchecked then clear the save password.
2022-09-05 14:35:45 +02:00

86 lines
1.9 KiB
C++

#ifndef CONNECTIONCONFIGURATIONWIDGET_H
#define CONNECTIONCONFIGURATIONWIDGET_H
#include <QWidget>
#include <QUuid>
#include <tuple>
#include "TestConnection.h"
class ConnectionController;
class ConnectionConfig;
class QCheckBox;
class QComboBox;
class QDataWidgetMapper;
class QFormLayout;
class QLabel;
class QLineEdit;
class QPushButton;
class QSpinBox;
class ConnectionTreeModel;
class ConnectionConfigurationWidget : public QWidget
{
Q_OBJECT
public:
static void editExistingInWindow(ConnectionController *ctrl, const ConnectionConfig &cfg,
std::function<void(ConnectionConfigurationWidget&)> save_func);
explicit ConnectionConfigurationWidget(
ConnectionController *connection_controller,
QWidget *parent = nullptr);
void retranslateUi();
void setData(const ConnectionConfig &cfg);
ConnectionConfig data() const;
QString group() const;
bool savePassword() const;
bool clearPassword() const;
public slots:
void testConnection();
private:
ConnectionController *m_connectionController;
ConnectionTreeModel *m_connectionModel;
QUuid m_uuid;
QByteArray encodedPassword;
bool passwordChanged;
QLabel *lblGroup;
QComboBox *cmbbxGroup;
QLabel *lblName;
QLineEdit *edtName;
QLabel *lblHost;
QLineEdit *edtHost;
QLabel *lblPort;
QSpinBox *spinPort;
QLabel *lblUser;
QLineEdit *edtUser;
QLabel *lblPassword;
QLineEdit *edtPassword;
QCheckBox *cbSavePassword;
QLabel *lblDbName;
QComboBox *cmbDbname;
QLabel *lblSsl;
QComboBox *cmbbxSsl;
QLabel *lblCert;
QLineEdit *edtCert;
QLabel *lblKey;
QLineEdit *edtKey;
QLabel *lblRootCert;
QLineEdit *edtRootCert;
QLabel *lblCrl;
QLineEdit *edtCrl;
QPushButton *btnTest;
QLabel *lblResult;
QFormLayout *formLayout;
void handleTestResult(TestConnectionResult result);
void passwordEdited(const QString &);
};
#endif // CONNECTIONCONFIGURATIONWIDGET_H