2014-01-12 15:57:01 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2014 Felix Geyer <debfx@fobos.de>
|
2017-06-09 21:40:36 +00:00
|
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
2014-01-12 15:57:01 +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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-04-13 09:46:47 +00:00
|
|
|
#ifndef KEEPASSX_PASSWORDWIDGET_H
|
|
|
|
|
#define KEEPASSX_PASSWORDWIDGET_H
|
2014-01-12 15:57:01 +00:00
|
|
|
|
2019-08-31 00:18:41 +00:00
|
|
|
#include <QAction>
|
2014-01-12 15:57:01 +00:00
|
|
|
#include <QLineEdit>
|
2018-11-23 12:49:55 +00:00
|
|
|
#include <QPointer>
|
2022-04-13 09:46:47 +00:00
|
|
|
#include <QWidget>
|
2014-01-12 15:57:01 +00:00
|
|
|
|
2022-04-13 09:46:47 +00:00
|
|
|
namespace Ui
|
|
|
|
|
{
|
|
|
|
|
class PasswordWidget;
|
|
|
|
|
}
|
2020-02-25 23:02:46 +00:00
|
|
|
|
2022-04-13 09:46:47 +00:00
|
|
|
class PasswordWidget : public QWidget
|
2014-01-12 15:57:01 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2022-04-13 09:46:47 +00:00
|
|
|
explicit PasswordWidget(QWidget* parent = nullptr);
|
|
|
|
|
~PasswordWidget() override;
|
2020-02-25 23:02:46 +00:00
|
|
|
void enablePasswordGenerator();
|
2022-11-02 18:13:48 +00:00
|
|
|
void setRepeatPartner(PasswordWidget* repeatPartner);
|
2022-04-13 09:46:47 +00:00
|
|
|
void setQualityVisible(bool state);
|
|
|
|
|
|
2018-10-30 13:16:49 +00:00
|
|
|
bool isPasswordVisible() const;
|
2022-04-13 09:46:47 +00:00
|
|
|
QString text();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void textChanged(QString text);
|
2014-01-12 15:57:01 +00:00
|
|
|
|
2017-03-10 14:58:42 +00:00
|
|
|
public slots:
|
2022-04-13 09:46:47 +00:00
|
|
|
void setText(const QString& text);
|
2014-01-12 15:57:01 +00:00
|
|
|
void setShowPassword(bool show);
|
2022-04-13 09:46:47 +00:00
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
void selectAll();
|
|
|
|
|
void setReadOnly(bool state);
|
|
|
|
|
void setEchoMode(QLineEdit::EchoMode mode);
|
|
|
|
|
void setClearButtonEnabled(bool enabled);
|
2014-01-12 15:57:01 +00:00
|
|
|
|
2019-10-21 08:49:09 +00:00
|
|
|
protected:
|
|
|
|
|
bool event(QEvent* event) override;
|
|
|
|
|
|
2017-03-10 14:58:42 +00:00
|
|
|
private slots:
|
2018-10-28 11:49:32 +00:00
|
|
|
void autocompletePassword(const QString& password);
|
2020-03-09 02:22:01 +00:00
|
|
|
void popupPasswordGenerator();
|
2022-04-13 09:46:47 +00:00
|
|
|
void updateRepeatStatus();
|
|
|
|
|
void updatePasswordStrength(const QString& password);
|
2014-01-12 15:57:01 +00:00
|
|
|
|
|
|
|
|
private:
|
2022-04-13 09:46:47 +00:00
|
|
|
void checkCapslockState();
|
|
|
|
|
void setParentPasswordEdit(PasswordWidget* parent);
|
|
|
|
|
|
|
|
|
|
const QScopedPointer<Ui::PasswordWidget> m_ui;
|
|
|
|
|
|
2019-08-31 00:18:41 +00:00
|
|
|
QPointer<QAction> m_errorAction;
|
|
|
|
|
QPointer<QAction> m_correctAction;
|
2020-03-09 02:22:01 +00:00
|
|
|
QPointer<QAction> m_toggleVisibleAction;
|
|
|
|
|
QPointer<QAction> m_passwordGeneratorAction;
|
2019-10-21 08:49:09 +00:00
|
|
|
QPointer<QAction> m_capslockAction;
|
2022-11-02 18:13:48 +00:00
|
|
|
QPointer<PasswordWidget> m_repeatPasswordWidget;
|
|
|
|
|
QPointer<PasswordWidget> m_parentPasswordWidget;
|
2022-04-13 09:46:47 +00:00
|
|
|
|
2019-10-21 08:49:09 +00:00
|
|
|
bool m_capslockState = false;
|
2014-01-12 15:57:01 +00:00
|
|
|
};
|
|
|
|
|
|
2022-04-13 09:46:47 +00:00
|
|
|
#endif // KEEPASSX_PASSWORDWIDGET_H
|