2013-03-10 21:23:10 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2013 Felix Geyer <debfx@fobos.de>
|
2022-01-30 15:59:29 +00:00
|
|
|
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
|
2013-03-10 21:23:10 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
|
* version 3 of the License.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef KEEPASSX_PASSWORDGENERATORWIDGET_H
|
|
|
|
|
#define KEEPASSX_PASSWORDGENERATORWIDGET_H
|
|
|
|
|
|
2014-01-12 22:33:36 +00:00
|
|
|
#include <QComboBox>
|
2022-04-03 15:31:15 +00:00
|
|
|
#include <QTimer>
|
2013-03-10 21:23:10 +00:00
|
|
|
|
2017-03-04 14:10:50 +00:00
|
|
|
#include "core/PassphraseGenerator.h"
|
2018-03-31 20:01:30 +00:00
|
|
|
#include "core/PasswordGenerator.h"
|
2013-03-10 21:23:10 +00:00
|
|
|
|
2018-03-31 20:01:30 +00:00
|
|
|
namespace Ui
|
|
|
|
|
{
|
2013-03-10 21:23:10 +00:00
|
|
|
class PasswordGeneratorWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-12 22:33:36 +00:00
|
|
|
class PasswordGenerator;
|
2020-02-01 13:42:34 +00:00
|
|
|
class PasswordHealth;
|
2017-03-04 14:10:50 +00:00
|
|
|
class PassphraseGenerator;
|
2014-01-12 22:33:36 +00:00
|
|
|
|
2013-03-10 21:23:10 +00:00
|
|
|
class PasswordGeneratorWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2017-03-04 14:10:50 +00:00
|
|
|
enum GeneratorTypes
|
|
|
|
|
{
|
|
|
|
|
Password = 0,
|
|
|
|
|
Diceware = 1
|
|
|
|
|
};
|
2020-07-19 13:30:00 +00:00
|
|
|
|
2015-07-24 16:28:12 +00:00
|
|
|
explicit PasswordGeneratorWidget(QWidget* parent = nullptr);
|
2022-04-11 23:33:11 +00:00
|
|
|
~PasswordGeneratorWidget() override;
|
2020-07-19 13:30:00 +00:00
|
|
|
|
2013-06-29 02:29:03 +00:00
|
|
|
void loadSettings();
|
2016-11-24 02:59:24 +00:00
|
|
|
void saveSettings();
|
2020-02-25 23:02:46 +00:00
|
|
|
void setPasswordLength(int length);
|
2016-11-24 02:59:24 +00:00
|
|
|
void setStandaloneMode(bool standalone);
|
2018-02-18 03:16:45 +00:00
|
|
|
QString getGeneratedPassword();
|
2018-05-13 21:21:43 +00:00
|
|
|
bool isPasswordVisible() const;
|
2022-01-30 15:59:29 +00:00
|
|
|
bool isPasswordGenerated() const;
|
2018-02-18 03:16:45 +00:00
|
|
|
|
2020-03-22 23:40:19 +00:00
|
|
|
static PasswordGeneratorWidget* popupGenerator(QWidget* parent = nullptr);
|
|
|
|
|
|
2022-04-03 15:31:15 +00:00
|
|
|
signals:
|
|
|
|
|
void appliedPassword(const QString& password);
|
|
|
|
|
void closed();
|
|
|
|
|
|
2018-02-18 03:16:45 +00:00
|
|
|
public slots:
|
2016-08-06 09:29:47 +00:00
|
|
|
void regeneratePassword();
|
2018-02-18 03:16:45 +00:00
|
|
|
void applyPassword();
|
|
|
|
|
void copyPassword();
|
2018-05-13 21:21:43 +00:00
|
|
|
void setPasswordVisible(bool visible);
|
2021-11-05 03:02:33 +00:00
|
|
|
void deleteWordList();
|
|
|
|
|
void addWordList();
|
2018-03-31 20:01:30 +00:00
|
|
|
|
2017-03-10 14:58:42 +00:00
|
|
|
private slots:
|
2017-06-04 19:06:27 +00:00
|
|
|
void updateButtonsEnabled(const QString& password);
|
2022-04-03 15:31:15 +00:00
|
|
|
void updatePasswordStrength();
|
2020-07-19 13:30:00 +00:00
|
|
|
void setAdvancedMode(bool advanced);
|
2018-06-11 02:37:09 +00:00
|
|
|
void excludeHexChars();
|
2014-01-12 22:33:36 +00:00
|
|
|
|
2020-03-09 02:22:01 +00:00
|
|
|
void passwordLengthChanged(int length);
|
|
|
|
|
void passphraseLengthChanged(int length);
|
2014-01-12 22:33:36 +00:00
|
|
|
|
|
|
|
|
void updateGenerator();
|
2013-03-10 21:23:10 +00:00
|
|
|
|
|
|
|
|
private:
|
2017-06-04 19:06:27 +00:00
|
|
|
bool m_standalone = false;
|
2022-01-30 15:59:29 +00:00
|
|
|
bool m_passwordGenerated = false;
|
2021-11-05 03:02:33 +00:00
|
|
|
int m_firstCustomWordlistIndex;
|
2014-01-12 22:33:36 +00:00
|
|
|
|
2022-04-11 23:33:11 +00:00
|
|
|
void closeEvent(QCloseEvent* event) override;
|
2013-03-12 21:42:06 +00:00
|
|
|
PasswordGenerator::CharClasses charClasses();
|
|
|
|
|
PasswordGenerator::GeneratorFlags generatorFlags();
|
|
|
|
|
|
2017-03-04 14:10:50 +00:00
|
|
|
const QScopedPointer<PasswordGenerator> m_passwordGenerator;
|
|
|
|
|
const QScopedPointer<PassphraseGenerator> m_dicewareGenerator;
|
2013-03-10 21:23:10 +00:00
|
|
|
const QScopedPointer<Ui::PasswordGeneratorWidget> m_ui;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // KEEPASSX_PASSWORDGENERATORWIDGET_H
|