|
@@ -18,6 +18,25 @@ LineEditButton::LineEditButton(FluentIconBase *ficon, QWidget *parent) : QToolBu
|
|
FluentStyleSheet::apply("LINE_EDIT", this);
|
|
FluentStyleSheet::apply("LINE_EDIT", this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void LineEditButton::setIcon(FluentIconBase *ficon)
|
|
|
|
+{
|
|
|
|
+ m_ficon.reset(ficon);
|
|
|
|
+ update();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+FluentIconBase *LineEditButton::ficon() const
|
|
|
|
+{
|
|
|
|
+ return m_ficon.data();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+QIcon LineEditButton::icon() const
|
|
|
|
+{
|
|
|
|
+ if (!m_ficon) {
|
|
|
|
+ return QIcon();
|
|
|
|
+ }
|
|
|
|
+ return m_ficon->icon();
|
|
|
|
+}
|
|
|
|
+
|
|
void LineEditButton::paintEvent(QPaintEvent *event)
|
|
void LineEditButton::paintEvent(QPaintEvent *event)
|
|
{
|
|
{
|
|
QToolButton::paintEvent(event);
|
|
QToolButton::paintEvent(event);
|
|
@@ -162,11 +181,12 @@ void SearchLineEdit::search()
|
|
|
|
|
|
PasswordLineEdit::PasswordLineEdit(QWidget *parent) : LineEdit(parent)
|
|
PasswordLineEdit::PasswordLineEdit(QWidget *parent) : LineEdit(parent)
|
|
{
|
|
{
|
|
- m_echoButton = new LineEditButton(NEWFLICON(FluentIcon, VIEW), this);
|
|
|
|
|
|
+ m_echoButton = new LineEditButton(NEWFLICON(FluentIcon, HIDE), this);
|
|
QHBoxLayout *hLayout = hBoxLayout();
|
|
QHBoxLayout *hLayout = hBoxLayout();
|
|
hLayout->addWidget(m_echoButton, 0, Qt::AlignRight);
|
|
hLayout->addWidget(m_echoButton, 0, Qt::AlignRight);
|
|
setIsClearButtonEnabled(true);
|
|
setIsClearButtonEnabled(true);
|
|
setTextMargins(0, 0, 59, 0);
|
|
setTextMargins(0, 0, 59, 0);
|
|
|
|
+ setEchoMode(QLineEdit::Password);
|
|
|
|
|
|
connect(m_echoButton, &LineEditButton::clicked, this, &PasswordLineEdit::switchEchoMode);
|
|
connect(m_echoButton, &LineEditButton::clicked, this, &PasswordLineEdit::switchEchoMode);
|
|
connect(clearButton(), &LineEditButton::clicked, this, &PasswordLineEdit::clearSignal);
|
|
connect(clearButton(), &LineEditButton::clicked, this, &PasswordLineEdit::clearSignal);
|
|
@@ -175,6 +195,7 @@ PasswordLineEdit::PasswordLineEdit(QWidget *parent) : LineEdit(parent)
|
|
void PasswordLineEdit::switchEchoMode()
|
|
void PasswordLineEdit::switchEchoMode()
|
|
{
|
|
{
|
|
setEchoMode(echoMode() == QLineEdit::Normal ? QLineEdit::Password : QLineEdit::Normal);
|
|
setEchoMode(echoMode() == QLineEdit::Normal ? QLineEdit::Password : QLineEdit::Normal);
|
|
|
|
+ m_echoButton->setIcon(echoMode() == QLineEdit::Normal ? NEWFLICON(FluentIcon, VIEW) : NEWFLICON(FluentIcon, HIDE));
|
|
emit echoModeChanged();
|
|
emit echoModeChanged();
|
|
}
|
|
}
|
|
|
|
|