6#include "ui_passworddialog.h"
51 setWindowTitle(this->windowTitle() +
" " + m_file);
64 &PasswordDialog::close);
65 connect(
this, &PasswordDialog::accepted,
this, &PasswordDialog::on_accepted);
66 connect(
this, &PasswordDialog::rejected,
this, &PasswordDialog::on_rejected);
78void PasswordDialog::on_checkBoxShow_stateChanged(
int arg1) {
80 ui->lineEditPassword->setEchoMode(QLineEdit::Normal);
82 ui->lineEditPassword->setEchoMode(QLineEdit::Password);
90void PasswordDialog::on_createPasswordButton_clicked() {
91 ui->widget->setEnabled(
false);
93 static_cast<unsigned int>(ui->spinBox_pwdLength->value()),
95 ui->passwordTemplateSwitch->currentIndex())]);
96 if (newPass.length() > 0)
97 ui->lineEditPassword->setText(newPass);
98 ui->widget->setEnabled(
true);
104void PasswordDialog::on_accepted() {
106 if (newValue.isEmpty())
109 if (newValue.right(1) !=
"\n")
118void PasswordDialog::on_rejected() {
setPassword(QString()); }
126 password, m_templating ? m_fields : QStringList(), m_allFields);
127 ui->lineEditPassword->setText(fileContent.
getPassword());
129 QWidget *previous = ui->checkBoxShow;
132 for (QLineEdit *line : qAsConst(templateLines)) {
133 line->setText(namedValues.
takeValue(line->objectName()));
138 for (
const NamedValue &nv : qAsConst(namedValues)) {
139 auto *line =
new QLineEdit();
140 line->setObjectName(nv.name);
141 line->setText(nv.value);
142 ui->formLayout->addRow(
new QLabel(nv.name), line);
143 setTabOrder(previous, line);
144 otherLines.append(line);
157 QString passFile = ui->lineEditPassword->text() +
"\n";
158 QList<QLineEdit *> allLines(templateLines);
159 allLines.append(otherLines);
160 for (QLineEdit *line : allLines) {
161 QString text = line->text();
164 passFile += line->objectName() +
": " + text +
"\n";
166 passFile += ui->plainTextEdit->toPlainText();
175 m_fields = rawFields.split(
'\n');
176 m_templating = useTemplate;
177 templateLines.clear();
180 QWidget *previous = ui->checkBoxShow;
181 foreach (QString field, m_fields) {
184 auto *line =
new QLineEdit();
185 line->setObjectName(field);
186 ui->formLayout->addRow(
new QLabel(field), line);
187 setTabOrder(previous, line);
188 templateLines.append(line);
216 ui->passwordTemplateSwitch->setCurrentIndex(t);
225 ui->passwordTemplateSwitch->setDisabled(
usePwgen);
226 ui->label_characterset->setDisabled(
usePwgen);
QString getRemainingData() const
QString getPassword() const
NamedValues getNamedValues() const
static FileContent parse(const QString &fileContent, const QStringList &templateFields, bool allFields)
parse parses the given fileContent in a FileContent object. The password is accessible through getPas...
The NamedValues class is mostly a list of NamedValue but also has a method to take a specific NamedVa...
QString takeValue(const QString &name)
void finishedShow(const QString &)
virtual void Show(QString file)=0
virtual void Insert(QString file, QString value, bool force)=0
virtual QString Generate_b(unsigned int length, const QString &charset)
Pass::Generate use either pwgen or internal password generator.
void processErrorExit(int exitCode, const QString &err)
PasswordDialog Handles the inserting and editing of passwords.
void setPasswordCharTemplate(int t)
PasswordDialog::setPasswordCharTemplate PasswordDialog::setPasswordCharTemplate chose the template st...
void setTemplate(QString rawFields, bool useTemplate)
Sets content in the template for the interface.
PasswordDialog(const PasswordConfiguration &passConfig, QWidget *parent=nullptr)
PasswordDialog::PasswordDialog basic constructor.
void setPassword(QString password)
Sets content in the password field in the interface.
~PasswordDialog()
Pass{}{}wordDialog::~PasswordDialog basic destructor.
void usePwgen(bool usePwgen)
PasswordDialog::usePwgen PasswordDialog::usePwgen don't use own password generator.
void templateAll(bool templateAll)
PasswordDialog::templateAll basic setter for use in PasswordDialog::setPassword templating all tokeni...
void setLength(int l)
PasswordDialog::setLength PasswordDialog::setLength password length.
QString getPassword()
Returns the password as set in the password field in the interface.
void setPass(const QString &output)
static bool isUseTemplate(const bool &defaultValue=QVariant().toBool())
static bool isTemplateAllFields(const bool &defaultValue=QVariant().toBool())
static QString getPassTemplate(const QString &defaultValue=QVariant().toString())
static bool isUsePwgen(const bool &defaultValue=QVariant().toBool())
static PasswordConfiguration getPasswordConfiguration()
Holds the Password configuration settings.
int length
Length of the password.
enum PasswordConfiguration::characterSet selected
characterSet
The selected character set.
QString Characters[CHARSETS_COUNT]
The different character sets.