Skip to content

Commit

Permalink
fix(DPasswdEditAnimated): modify parent for tip widget
Browse files Browse the repository at this point in the history
Change-Id: I95fb48a76029031d658092030793d972ae014aa7
  • Loading branch information
haruyukilxz authored and justforlxz committed Nov 22, 2018
1 parent 251418b commit b9edc9d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/widgets/dpasswdeditanimated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ void DPasswdEditAnimatedPrivate::init()
m_caps = new DLabel;
m_eye = new DImageButton;
m_submit = new DImageButton;
m_invalidTip = new DArrowRectangle(DArrowRectangle::ArrowTop, q);
m_invalidTip = new DArrowRectangle(DArrowRectangle::ArrowTop, DArrowRectangle::FloatWidget);
m_invalidMessage = new DLabel(m_invalidTip);
m_invalidTip->setContent(m_invalidMessage);
m_invalidTip->setMargin(10);

m_loadSlider = new LoadSlider(q);
m_loadSlider->hide();
Expand Down Expand Up @@ -250,6 +252,8 @@ DPasswdEditAnimated::DPasswdEditAnimated(QWidget *parent) : QFrame(parent),
D_D(DPasswdEditAnimated);

d->init();

d->m_invalidTip->setParent(parent);
}

/**
Expand Down Expand Up @@ -437,6 +441,7 @@ void DPasswdEditAnimated::showAlert(const QString &message)
d->_q_hideLoadSlider();

d->m_invalidMessage->setText(message);
d->m_invalidMessage->adjustSize();

d->m_passwdEdit->selectAll();
d->m_passwdEdit->setFocus();
Expand All @@ -448,8 +453,9 @@ void DPasswdEditAnimated::showAlert(const QString &message)

if (!d->m_invalidTip->isVisible()) {
// focus BUG
//d->m_invalidTip->setContent(d->m_invalidMessage);
//d->m_invalidTip->adjustSize();
// d->m_invalidTip->setContent(d->m_invalidMessage);
// d->m_invalidTip->adjustSize();
d->m_invalidTip->setContent(d->m_invalidMessage);

updateAlertPosition();

Expand Down Expand Up @@ -491,12 +497,13 @@ void DPasswdEditAnimated::updateAlertPosition()
{
D_D(DPasswdEditAnimated);

const QString &message = d->m_invalidMessage->text();
QPoint pos = mapToParent(rect().bottomLeft());
const int messageHalfWidth = d->m_invalidMessage->width() / 2;
d->m_invalidTip->move(pos.x() + messageHalfWidth + 10, pos.y() + 5);

QPoint pos = mapToGlobal(rect().bottomLeft());
QFontMetrics fm((QFont()));
d->m_invalidTip->setGeometry(pos.x(), pos.y() + 5, fm.width(message) + 20, fm.height() + 20);
d->m_invalidMessage->move(10, 15);
const QPoint messagePos = d->m_invalidMessage->pos();
const int h = d->m_invalidTip->height() - d->m_invalidMessage->height() - 10;
d->m_invalidMessage->move(messagePos.x(), h / 2);

d->m_invalidTip->setArrowX(20);
d->m_invalidMessage->show();
Expand Down

0 comments on commit b9edc9d

Please sign in to comment.