From 9d85b703075dadeaa7986149af553a222c889e15 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 7 Dec 2018 02:35:06 +0100 Subject: [PATCH] Allow to unhide password in pilot form and server form --- src/blackgui/editors/pilotform.cpp | 8 +--- src/blackgui/editors/serverform.cpp | 12 +++++- src/blackgui/editors/serverform.h | 3 +- src/blackgui/editors/serverform.ui | 67 +++++++++++++++++++++++------ 4 files changed, 68 insertions(+), 22 deletions(-) diff --git a/src/blackgui/editors/pilotform.cpp b/src/blackgui/editors/pilotform.cpp index f5964a513..10ba6a14d 100644 --- a/src/blackgui/editors/pilotform.cpp +++ b/src/blackgui/editors/pilotform.cpp @@ -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() diff --git a/src/blackgui/editors/serverform.cpp b/src/blackgui/editors/serverform.cpp index 78c47a591..89ccc3d4a 100644 --- a/src/blackgui/editors/serverform.cpp +++ b/src/blackgui/editors/serverform.cpp @@ -14,6 +14,7 @@ #include #include #include +#include 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); diff --git a/src/blackgui/editors/serverform.h b/src/blackgui/editors/serverform.h index ac86397f8..6c6cff661 100644 --- a/src/blackgui/editors/serverform.h +++ b/src/blackgui/editors/serverform.h @@ -22,8 +22,6 @@ #include #include -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; QString m_passwordNameLabel; diff --git a/src/blackgui/editors/serverform.ui b/src/blackgui/editors/serverform.ui index 5b8be779b..60215ae9b 100644 --- a/src/blackgui/editors/serverform.ui +++ b/src/blackgui/editors/serverform.ui @@ -231,16 +231,48 @@ - - - 32 - - - QLineEdit::Password - - - password - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 32 + + + QLineEdit::Password + + + password + + + + + + + unhide password + + + + + + + :/diagona/icons/diagona/icons/question-button.png:/diagona/icons/diagona/icons/question-button.png + + + + @@ -327,9 +359,20 @@ - le_RealName tw_ServerForm + le_Name + le_Description + cbp_Ecosystem + cb_ServerType + le_Address + le_Port + le_RealName + le_NetworkId + le_Password + tb_Unhide - + + +