Allow to unhide password in pilot form and server form

This commit is contained in:
Klaus Basan
2018-12-07 02:35:06 +01:00
parent 2e68a52a42
commit 9d85b70307
4 changed files with 68 additions and 22 deletions

View File

@@ -12,6 +12,7 @@
#include "blackgui/components/airportsmallcompleter.h"
#include "blackgui/guiapplication.h"
#include "blackgui/uppercasevalidator.h"
#include "blackgui/guiutility.h"
#include "blackmisc/aviation/aircrafticaocode.h"
#include "blackmisc/network/user.h"
#include "blackconfig/buildconfig.h"
@@ -139,12 +140,7 @@ namespace BlackGui
void CPilotForm::unhidePassword()
{
static const QLineEdit::EchoMode originalMode = ui->le_Password->echoMode();
ui->le_Password->setEchoMode(QLineEdit::Normal);
QTimer::singleShot(5000, this, [ = ]
{
ui->le_Password->setEchoMode(originalMode);
});
CGuiUtility::tempUnhidePassword(ui->le_Password);
}
void CPilotForm::doValidation()

View File

@@ -14,6 +14,7 @@
#include <QIntValidator>
#include <QLabel>
#include <QLineEdit>
#include <QToolButton>
using namespace BlackMisc;
using namespace BlackMisc::Audio;
@@ -33,6 +34,7 @@ namespace BlackGui
connect(ui->cbp_Ecosystem, &CEcosystemComboBox::currentTextChanged, this, &CServerForm::onChangedEcoSystem);
connect(ui->cb_ServerType, &QComboBox::currentTextChanged, this, &CServerForm::onChangedServerType);
connect(ui->tb_Unhide, &QToolButton::clicked, this, &CServerForm::tempUnhidePassword);
}
CServerForm::~CServerForm()
@@ -97,15 +99,16 @@ namespace BlackGui
ui->le_Password->setReadOnly(readOnly);
ui->cb_ServerType->setEnabled(!readOnly);
ui->cbp_Ecosystem->setEnabled(!readOnly);
ui->tb_Unhide->setVisible(!readOnly);
this->forceStyleSheetUpdate();
}
void CServerForm::showPasswordField(bool show)
{
if (ui->le_Password->isVisible() == show) { return; }
if (ui->wi_Password->isVisible() == show) { return; }
if (m_passwordNameLabel.isEmpty()) { m_passwordNameLabel = ui->lbl_IdPassword->text(); }
ui->lbl_IdPassword->setText(show ? m_passwordNameLabel : "Id");
ui->le_Password->setVisible(show);
ui->wi_Password->setVisible(show);
}
void CServerForm::initServerTypes()
@@ -140,6 +143,11 @@ namespace BlackGui
ui->cb_ServerType->setCurrentText(dummy.getServerTypeAsString());
}
void CServerForm::tempUnhidePassword()
{
CGuiUtility::tempUnhidePassword(ui->le_Password);
}
CStatusMessageList CServerForm::validate(bool nested) const
{
Q_UNUSED(nested);

View File

@@ -22,8 +22,6 @@
#include <QScopedPointer>
#include <QString>
class QWidget;
namespace Ui { class CNetworkServerForm; }
namespace BlackGui
{
@@ -63,6 +61,7 @@ namespace BlackGui
void initServerTypes();
void onChangedServerType(const QString &text);
void onChangedEcoSystem(const QString &text);
void tempUnhidePassword();
QScopedPointer<Ui::CNetworkServerForm> ui;
QString m_passwordNameLabel;

View File

@@ -231,16 +231,48 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="le_Password">
<property name="maxLength">
<number>32</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>password</string>
</property>
<widget class="QWidget" name="wi_Password" native="true">
<layout class="QHBoxLayout" name="hl_Password">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="le_Password">
<property name="maxLength">
<number>32</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>password</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tb_Unhide">
<property name="toolTip">
<string>unhide password</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<normaloff>:/diagona/icons/diagona/icons/question-button.png</normaloff>:/diagona/icons/diagona/icons/question-button.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@@ -327,9 +359,20 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>le_RealName</tabstop>
<tabstop>tw_ServerForm</tabstop>
<tabstop>le_Name</tabstop>
<tabstop>le_Description</tabstop>
<tabstop>cbp_Ecosystem</tabstop>
<tabstop>cb_ServerType</tabstop>
<tabstop>le_Address</tabstop>
<tabstop>le_Port</tabstop>
<tabstop>le_RealName</tabstop>
<tabstop>le_NetworkId</tabstop>
<tabstop>le_Password</tabstop>
<tabstop>tb_Unhide</tabstop>
</tabstops>
<resources/>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>