Skip to content

Commit

Permalink
fix(DPasswordEditAnimated): alert visible control
Browse files Browse the repository at this point in the history
remember visible of alert widget before the main widget hide,
restore visible of alert widget if the show event of main event

Change-Id: Ib504a9f7ec72aaa0ebcc68344e3c17751ece57c8
  • Loading branch information
listenerri committed Oct 24, 2018
1 parent cd8578f commit eb55642
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/widgets/dpasswdeditanimated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void DPasswdEditAnimatedPrivate::init()
m_submitEnable = true;
m_loadAnimEnable = true;
m_isLoading = false;
m_alterBeforeHide = false;

m_keyboard->setObjectName("KeyboardButton");
m_passwdEdit->setObjectName("PasswdEdit");
Expand Down Expand Up @@ -393,6 +394,36 @@ bool DPasswdEditAnimated::eventFilter(QObject *watched, QEvent *event)
return false;
}

/*!
* \reimp
*/
void DPasswdEditAnimated::showEvent(QShowEvent *event)
{
D_D(DPasswdEditAnimated);

// show alert message if it is visible when widget is hidden
if (d->m_alterBeforeHide) {
showAlert(d->m_invalidMessage->text());
}

QFrame::showEvent(event);
}

/*!
* \reimp
*/
void DPasswdEditAnimated::hideEvent(QHideEvent *event)
{
D_D(DPasswdEditAnimated);

// remember alert visible before hide
d->m_alterBeforeHide = alert();

hideAlert();

QFrame::hideEvent(event);
}

/**
* \~chinese \brief 显示警告信息。
*
Expand All @@ -410,6 +441,11 @@ void DPasswdEditAnimated::showAlert(const QString &message)
d->m_passwdEdit->selectAll();
d->m_passwdEdit->setFocus();

if (isVisible() == false) {
d->m_alterBeforeHide = true;
return;
}

if (!d->m_invalidTip->isVisible()) {
// focus BUG
//d->m_invalidTip->setContent(d->m_invalidMessage);
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/dpasswdeditanimated.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public Q_SLOTS:

protected:
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;

protected:
D_PRIVATE_SLOT(void _q_resetCapslockState())
Expand Down
1 change: 1 addition & 0 deletions src/widgets/private/dpasswdeditanimated_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Q_SLOTS:
bool m_submitEnable;
bool m_loadAnimEnable;
bool m_isLoading;
bool m_alterBeforeHide;

const int LoadSliderWidth = 40;
};
Expand Down

0 comments on commit eb55642

Please sign in to comment.