2013-03-10 17:23:10 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Felix Geyer <debfx@fobos.de>
|
2023-08-15 07:52:48 -04:00
|
|
|
* Copyright (C) 2022 KeePassXC Team <team@keepassxc.org>
|
2013-03-10 17:23:10 -04: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 17:33:36 -05:00
|
|
|
#include <QComboBox>
|
2022-04-03 11:31:15 -04:00
|
|
|
#include <QTimer>
|
2013-03-10 17:23:10 -04:00
|
|
|
|
2017-03-04 09:10:50 -05:00
|
|
|
#include "core/PassphraseGenerator.h"
|
2018-03-31 16:01:30 -04:00
|
|
|
#include "core/PasswordGenerator.h"
|
2013-03-10 17:23:10 -04:00
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
namespace Ui
|
|
|
|
{
|
2013-03-10 17:23:10 -04:00
|
|
|
class PasswordGeneratorWidget;
|
|
|
|
}
|
|
|
|
|
2014-01-12 17:33:36 -05:00
|
|
|
class PasswordGenerator;
|
2020-02-01 08:42:34 -05:00
|
|
|
class PasswordHealth;
|
2017-03-04 09:10:50 -05:00
|
|
|
class PassphraseGenerator;
|
2014-01-12 17:33:36 -05:00
|
|
|
|
2023-08-15 07:52:48 -04:00
|
|
|
class PasswordGeneratorWidget : public QWidget
|
2013-03-10 17:23:10 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-03-04 09:10:50 -05:00
|
|
|
enum GeneratorTypes
|
|
|
|
{
|
|
|
|
Password = 0,
|
|
|
|
Diceware = 1
|
|
|
|
};
|
2020-07-19 09:30:00 -04:00
|
|
|
|
2015-07-24 12:28:12 -04:00
|
|
|
explicit PasswordGeneratorWidget(QWidget* parent = nullptr);
|
2022-04-11 19:33:11 -04:00
|
|
|
~PasswordGeneratorWidget() override;
|
2020-07-19 09:30:00 -04:00
|
|
|
|
2013-06-28 22:29:03 -04:00
|
|
|
void loadSettings();
|
2016-11-23 21:59:24 -05:00
|
|
|
void saveSettings();
|
2020-02-25 18:02:46 -05:00
|
|
|
void setPasswordLength(int length);
|
2016-11-23 21:59:24 -05:00
|
|
|
void setStandaloneMode(bool standalone);
|
2018-02-17 22:16:45 -05:00
|
|
|
QString getGeneratedPassword();
|
2018-05-13 17:21:43 -04:00
|
|
|
bool isPasswordVisible() const;
|
2022-01-30 10:59:29 -05:00
|
|
|
bool isPasswordGenerated() const;
|
2018-02-17 22:16:45 -05:00
|
|
|
|
2020-03-22 19:40:19 -04:00
|
|
|
static PasswordGeneratorWidget* popupGenerator(QWidget* parent = nullptr);
|
|
|
|
|
2022-04-03 11:31:15 -04:00
|
|
|
signals:
|
|
|
|
void appliedPassword(const QString& password);
|
|
|
|
void closed();
|
|
|
|
|
2018-02-17 22:16:45 -05:00
|
|
|
public slots:
|
2016-08-06 05:29:47 -04:00
|
|
|
void regeneratePassword();
|
2018-02-17 22:16:45 -05:00
|
|
|
void applyPassword();
|
|
|
|
void copyPassword();
|
2018-05-13 17:21:43 -04:00
|
|
|
void setPasswordVisible(bool visible);
|
2021-11-04 23:02:33 -04:00
|
|
|
void deleteWordList();
|
|
|
|
void addWordList();
|
2018-03-31 16:01:30 -04:00
|
|
|
|
2023-08-15 07:52:48 -04:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent* event) override;
|
|
|
|
|
2017-03-10 09:58:42 -05:00
|
|
|
private slots:
|
2017-06-04 15:06:27 -04:00
|
|
|
void updateButtonsEnabled(const QString& password);
|
2022-04-03 11:31:15 -04:00
|
|
|
void updatePasswordStrength();
|
2020-07-19 09:30:00 -04:00
|
|
|
void setAdvancedMode(bool advanced);
|
2018-06-10 22:37:09 -04:00
|
|
|
void excludeHexChars();
|
2014-01-12 17:33:36 -05:00
|
|
|
|
2020-03-08 22:22:01 -04:00
|
|
|
void passwordLengthChanged(int length);
|
|
|
|
void passphraseLengthChanged(int length);
|
2014-01-12 17:33:36 -05:00
|
|
|
|
|
|
|
void updateGenerator();
|
2013-03-10 17:23:10 -04:00
|
|
|
|
|
|
|
private:
|
2017-06-04 15:06:27 -04:00
|
|
|
bool m_standalone = false;
|
2022-01-30 10:59:29 -05:00
|
|
|
bool m_passwordGenerated = false;
|
2021-11-04 23:02:33 -04:00
|
|
|
int m_firstCustomWordlistIndex;
|
2014-01-12 17:33:36 -05:00
|
|
|
|
2013-03-12 17:42:06 -04:00
|
|
|
PasswordGenerator::CharClasses charClasses();
|
|
|
|
PasswordGenerator::GeneratorFlags generatorFlags();
|
|
|
|
|
2017-03-04 09:10:50 -05:00
|
|
|
const QScopedPointer<PasswordGenerator> m_passwordGenerator;
|
|
|
|
const QScopedPointer<PassphraseGenerator> m_dicewareGenerator;
|
2013-03-10 17:23:10 -04:00
|
|
|
const QScopedPointer<Ui::PasswordGeneratorWidget> m_ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KEEPASSX_PASSWORDGENERATORWIDGET_H
|