9#include "ui_passworddialog.h"
27 m_passConfig(std::move(passConfig)) {
56 setWindowTitle(this->windowTitle() +
" " + m_file);
69 &PasswordDialog::close);
70 connect(
this, &PasswordDialog::accepted,
this, &PasswordDialog::on_accepted);
71 connect(
this, &PasswordDialog::rejected,
this, &PasswordDialog::on_rejected);
83void PasswordDialog::on_checkBoxShow_stateChanged(
int arg1) {
85 ui->lineEditPassword->setEchoMode(QLineEdit::Normal);
87 ui->lineEditPassword->setEchoMode(QLineEdit::Password);
96void PasswordDialog::on_createPasswordButton_clicked() {
97 ui->widget->setEnabled(
false);
99 static_cast<unsigned int>(ui->spinBox_pwdLength->value()),
101 ui->passwordTemplateSwitch->currentIndex())]);
102 if (newPass.length() > 0) {
103 ui->lineEditPassword->setText(newPass);
105 ui->widget->setEnabled(
true);
111void PasswordDialog::on_accepted() {
113 if (newValue.isEmpty()) {
117 if (newValue.right(1) !=
"\n") {
127void PasswordDialog::on_rejected() {
setPassword(QString()); }
135 password, m_templating ? m_fields : QStringList(), m_allFields);
136 ui->lineEditPassword->setText(fileContent.
getPassword());
138 QWidget *previous = ui->checkBoxShow;
141 for (QLineEdit *line :
AS_CONST(templateLines)) {
142 line->setText(namedValues.
takeValue(line->objectName()));
148 auto *line =
new QLineEdit();
149 line->setObjectName(nv.name);
150 line->setText(nv.value);
151 ui->formLayout->addRow(
new QLabel(nv.name), line);
152 setTabOrder(previous, line);
153 otherLines.append(line);
166 QString passFile = ui->lineEditPassword->text() +
"\n";
167 QList<QLineEdit *> allLines(templateLines);
168 allLines.append(otherLines);
169 for (QLineEdit *line : allLines) {
170 QString text = line->text();
171 if (text.isEmpty()) {
174 passFile += line->objectName() +
": " + text +
"\n";
176 passFile += ui->plainTextEdit->toPlainText();
185 m_fields = rawFields.split(
'\n');
186 m_templating = useTemplate;
187 templateLines.clear();
190 QWidget *previous = ui->checkBoxShow;
191 foreach (QString field, m_fields) {
192 if (field.isEmpty()) {
195 auto *line =
new QLineEdit();
196 line->setObjectName(field);
197 ui->formLayout->addRow(
new QLabel(field), line);
198 setTabOrder(previous, line);
199 templateLines.append(line);
227 ui->passwordTemplateSwitch->setCurrentIndex(t);
236 ui->passwordTemplateSwitch->setDisabled(
usePwgen);
237 ui->label_characterset->setDisabled(
usePwgen);
auto getRemainingData() const -> QString
auto getNamedValues() const -> NamedValues
auto getPassword() const -> QString
static auto parse(const QString &fileContent, const QStringList &templateFields, bool allFields) -> FileContent
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...
auto takeValue(const QString &name) -> QString
void finishedShow(const QString &)
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 setPassword(const QString &password)
Sets content in the password field in the interface.
PasswordDialog(PasswordConfiguration passConfig, QWidget *parent=nullptr)
PasswordDialog::PasswordDialog basic constructor.
~PasswordDialog()
Pass{}{}wordDialog::~PasswordDialog basic destructor.
void usePwgen(bool usePwgen)
PasswordDialog::usePwgen PasswordDialog::usePwgen don't use own password generator.
void setTemplate(const QString &rawFields, bool useTemplate)
Sets content in the template for the interface.
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.
void setPass(const QString &output)
auto getPassword() -> QString
Returns the password as set in the password field in the interface.
static auto getPass() -> Pass *
static auto getPasswordConfiguration() -> PasswordConfiguration
static auto isTemplateAllFields(const bool &defaultValue=QVariant().toBool()) -> bool
static auto isUseTemplate(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getPassTemplate(const QString &defaultValue=QVariant().toString()) -> QString
static auto isUsePwgen(const bool &defaultValue=QVariant().toBool()) -> bool
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.