Skip to content

Commit

Permalink
fix: black circle in PasswordEdit
Browse files Browse the repository at this point in the history
set the size of black circle to 6 pixel by changing the font,
set the letter spacing to 200 under PercentageSpacing type.

Issue: linuxdeepin/developer-center#7335
  • Loading branch information
wangfei committed Mar 5, 2024
1 parent e2ffdc6 commit 0cb8055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/widgets/dlineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ bool DLineEdit::eventFilter(QObject *watched, QEvent *event)
event->accept();
pLineEdit->setFocus();
return true;
} else if (event->type() == QEvent::Paint) {
d->lineEdit->echoMode() == QLineEdit::Password ?
d->lineEdit->setFont(d->passwordFont) : d->lineEdit->setFont(font());
}

// if (d->frame)
Expand Down Expand Up @@ -714,6 +717,10 @@ void DLineEditPrivate::init()
q->setFocusProxy(lineEdit); // fix DlineEdit setFocut but lineEdit can not edit(without focus rect)
q->setFocusPolicy(lineEdit->focusPolicy());

passwordFont = lineEdit->font();
passwordFont.setPixelSize(6);
passwordFont.setLetterSpacing(passwordFont.letterSpacingType(), 200);

control = new DAlertControl(lineEdit, q);
q->connect(control, &DAlertControl::alertChanged, q, &DLineEdit::alertChanged);

Expand Down
1 change: 1 addition & 0 deletions src/widgets/private/dlineedit_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class DLineEditPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate
bool bSpeechToText = true;
bool bTextToSpeech = true;
bool bTextToTranslate = true;
QFont passwordFont;
};

DWIDGET_END_NAMESPACE
Expand Down

0 comments on commit 0cb8055

Please sign in to comment.