Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lighter-greeter/lightergreeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void LighterGreeter::initUI()
m_userCbx->setMinimumWidth(300);
m_passwordEdit->setMinimumWidth(300);
m_passwordEdit->setContextMenuPolicy(Qt::NoContextMenu);
m_passwordEdit->setSecureInputEnabled(true);
m_passwordEdit->lineEdit()->setAlignment(Qt::AlignCenter);
m_passwordEdit->setClearButtonEnabled(false);
m_passwordEdit->setEchoMode(QLineEdit::Password);
Expand Down
1 change: 1 addition & 0 deletions src/session-widgets/auth_password.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void AuthPassword::initUI()

m_lineEdit->setClearButtonEnabled(false);
m_lineEdit->setEchoMode(QLineEdit::Password);
m_lineEdit->setSecureInputEnabled(true);
m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu);
m_lineEdit->setFocusPolicy(Qt::StrongFocus);
m_lineEdit->lineEdit()->setAlignment(Qt::AlignCenter);
Expand Down
1 change: 1 addition & 0 deletions src/session-widgets/auth_single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void AuthSingle::initUI()

m_lineEdit->setClearButtonEnabled(false);
m_lineEdit->setEchoMode(QLineEdit::Password);
m_lineEdit->setSecureInputEnabled(true);
m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu);
m_lineEdit->setFocusPolicy(Qt::StrongFocus);
m_lineEdit->lineEdit()->setAlignment(Qt::AlignCenter);
Expand Down
1 change: 1 addition & 0 deletions src/session-widgets/auth_ukey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void AuthUKey::initUI()

m_lineEdit->setClearButtonEnabled(false);
m_lineEdit->setEchoMode(QLineEdit::Password);
m_lineEdit->setSecureInputEnabled(true);
m_lineEdit->setContextMenuPolicy(Qt::NoContextMenu);
m_lineEdit->setFocusPolicy(Qt::StrongFocus);
m_lineEdit->lineEdit()->setAlignment(Qt::AlignCenter);
Expand Down
28 changes: 24 additions & 4 deletions src/widgets/dlineeditex.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -8,9 +8,10 @@

#include <QGuiApplication>
#include <QPainter>
#include <QPropertyAnimation>

Check warning on line 11 in src/widgets/dlineeditex.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPropertyAnimation> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QVariantAnimation>

Check warning on line 12 in src/widgets/dlineeditex.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVariantAnimation> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QKeyEvent>

Check warning on line 13 in src/widgets/dlineeditex.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeyEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QKeySequence>

Check warning on line 14 in src/widgets/dlineeditex.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeySequence> not found. Please note: Cppcheck does not need standard library headers to get proper results.

LoadSlider::LoadSlider(QWidget *parent)
: QWidget(parent)
Expand Down Expand Up @@ -39,6 +40,7 @@
, m_loadSlider(new LoadSlider(this))
, m_animation(new QPropertyAnimation(m_loadSlider, "pos", m_loadSlider))
, m_enableTableKeyEvent(false)
, m_secureInputEnabled(false)
{
setObjectName(QStringLiteral("DLineEditEx"));
setAccessibleName(QStringLiteral("DLineEditEx"));
Expand Down Expand Up @@ -128,6 +130,14 @@
m_enableTableKeyEvent = enable;
}

void DLineEditEx::setSecureInputEnabled(bool enable)
{
if (m_secureInputEnabled == enable)
return;

m_secureInputEnabled = enable;
}

/**
* @brief 重写 QLineEdit paintEvent 函数,实现当文本设置居中后,holderText 仍然显示的需求
*
Expand Down Expand Up @@ -170,10 +180,20 @@
&& event->type() == QEvent::InputMethodQuery) {
return true;
} else if ((watched == this || watched == this->lineEdit())
&& event->type() == QEvent::KeyPress
&& m_enableTableKeyEvent) {
&& event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Tab

if (m_secureInputEnabled
&& (keyEvent->matches(QKeySequence::Cut)
|| keyEvent->matches(QKeySequence::Copy)
|| keyEvent->matches(QKeySequence::Paste)
|| keyEvent->matches(QKeySequence::Undo)
|| keyEvent->matches(QKeySequence::Redo))) {
return true;
}

if (m_enableTableKeyEvent
&& keyEvent->key() == Qt::Key_Tab
&& keyEvent->modifiers() == Qt::NoModifier
&& !this->text().isEmpty()) {
emit this->returnPressed();
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/dlineeditex.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2019 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -37,6 +37,7 @@ public slots:
void startAnimation();
void stopAnimation();
void setEnableTableKeyEvent(bool enable);
void setSecureInputEnabled(bool enable);

protected:
void paintEvent(QPaintEvent *event) override;
Expand All @@ -50,6 +51,7 @@ public slots:
LoadSlider *m_loadSlider;
QPropertyAnimation *m_animation;
bool m_enableTableKeyEvent;
bool m_secureInputEnabled;
};

#endif // DLINEEDITEX_H
Loading