mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Only show the password on explicit user request
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
AuthenticationWidget::AuthenticationWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_username = new QLineEdit();
|
||||
_password = new QLineEdit();
|
||||
_password = new PasswordEdit();
|
||||
|
||||
QFormLayout *layout = new QFormLayout();
|
||||
layout->addRow(tr("Username:"), _username);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include "passwordedit.h"
|
||||
|
||||
class AuthenticationWidget : public QWidget
|
||||
{
|
||||
@ -18,7 +19,8 @@ public:
|
||||
void setPassword(const QString &password) {_password->setText(password);}
|
||||
|
||||
private:
|
||||
QLineEdit *_username, *_password;
|
||||
QLineEdit *_username;
|
||||
PasswordEdit *_password;
|
||||
};
|
||||
|
||||
#endif // AUTHENTICATIONWIDGET_H
|
||||
|
@ -28,4 +28,7 @@
|
||||
#define MAPS_ICON ":/applications-internet_32.png"
|
||||
#define DEM_ICON ":/view-grid.png"
|
||||
|
||||
#define SHOW_PWD_ICON ":/document-encrypt.png"
|
||||
#define HIDE_PWD_ICON ":/document-decrypt.png"
|
||||
|
||||
#endif /* ICONS_H */
|
||||
|
24
src/GUI/passwordedit.cpp
Normal file
24
src/GUI/passwordedit.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <QAction>
|
||||
#include "icons.h"
|
||||
#include "passwordedit.h"
|
||||
|
||||
PasswordEdit::PasswordEdit(QWidget *parent) : QLineEdit(parent)
|
||||
{
|
||||
_show = false;
|
||||
_action = addAction(QIcon(SHOW_PWD_ICON), QLineEdit::TrailingPosition);
|
||||
connect(_action, &QAction::triggered, this, &PasswordEdit::showPassword);
|
||||
setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
|
||||
void PasswordEdit::showPassword()
|
||||
{
|
||||
if (_show) {
|
||||
_action->setIcon(QIcon(SHOW_PWD_ICON));
|
||||
setEchoMode(QLineEdit::Password);
|
||||
_show = false;
|
||||
} else {
|
||||
_action->setIcon(QIcon(HIDE_PWD_ICON));
|
||||
setEchoMode(QLineEdit::Normal);
|
||||
_show = true;
|
||||
}
|
||||
}
|
21
src/GUI/passwordedit.h
Normal file
21
src/GUI/passwordedit.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef PASSWORDEDIT_H
|
||||
#define PASSWORDEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class PasswordEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PasswordEdit(QWidget *parent = 0);
|
||||
|
||||
private slots:
|
||||
void showPassword();
|
||||
|
||||
private:
|
||||
QAction *_action;
|
||||
bool _show;
|
||||
};
|
||||
|
||||
#endif // PASSWORDEDIT_H
|
Reference in New Issue
Block a user