pgLab/pglab/PasswordPromptDialog.cpp
eelke 2230a4bd61 Lot of password related changes all over the place.
Password is no longer saved with the connection list.
Password is not entered along with other connection credentials.
Password is now asked for when required.
Still working on saving the password and auto retrieving it from the password manager.
2018-11-04 11:44:40 +01:00

70 lines
2 KiB
C++

#include "PasswordPromptDialog.h"
#include <QtWidgets/QApplication>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
PasswordPromptDialog::PasswordPromptDialog(QWidget *parent)
: QDialog(parent)
{
m_connectionLabel = new QLabel(this);
auto dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
m_passwordLabel = new QLabel(this);
m_passwordInput = new QLineEdit(this);
m_passwordInput->setEchoMode(QLineEdit::Password);
m_saveCheck = new QCheckBox(this);
auto mainLayout = new QGridLayout;
int row = 0;
mainLayout->addWidget(m_connectionLabel, row, 0, 1, 2);
++row;
mainLayout->addWidget(m_passwordLabel, row, 0);
mainLayout->addWidget(m_passwordInput, row, 1);
++row;
mainLayout->addWidget(m_saveCheck, row, 1);
++row;
mainLayout->addWidget(dialog_buttons, row, 0, 1 ,2);
setLayout(mainLayout);
m_passwordInput->setFocus();
retranslateUi();
// QMetaObject::connectSlotsByName(BackupDialog);
connect(dialog_buttons, &QDialogButtonBox::accepted, this, &PasswordPromptDialog::accept);
connect(dialog_buttons, &QDialogButtonBox::rejected, this, &PasswordPromptDialog::reject);
}
void PasswordPromptDialog::retranslateUi()
{
const char * context = "PasswordPromptDialog";
setWindowTitle(QApplication::translate(context, "Connection password", nullptr));
m_passwordLabel->setText(QApplication::translate(context, "Password", nullptr));
m_passwordInput->setPlaceholderText(QApplication::translate(context, "Enter password", nullptr));
m_saveCheck->setText(QApplication::translate(context, "Save password", nullptr));
}
void PasswordPromptDialog::setConnectionDescription(const QString &description)
{
m_connectionLabel->setText(QString(tr("Please provide password for connection %1")).arg(description));
}
QString PasswordPromptDialog::password() const
{
return m_passwordInput->text();
}
//void PasswordPromptDialog::accept()
//{
//}
//void PasswordPromptDialog::reject()
//{
//}