Merge pull request !82 from 杨敏/openkylin/nile
This commit is contained in:
杨敏 2024-05-30 13:02:43 +00:00 committed by openkylin-cibot
parent 892f1d7e3b
commit e419b93f31
2 changed files with 432 additions and 0 deletions

431
debian/patches/0030-82-fixbug.patch vendored Normal file
View File

@ -0,0 +1,431 @@
From: =?utf-8?b?5p2o5pWP?= <yangmin@kylinos.cn>
Date: Thu, 30 May 2024 13:02:43 +0000
Subject: =?utf-8?q?!82_fixbug_Merge_pull_request_!82_from_=E6=9D=A8?=
=?utf-8?q?=E6=95=8F/openkylin/nile?=
---
src/VirtualKeyboard/src/kbtitle.cpp | 47 ++++++++++++++++-------------------
src/assets/authdialog.qss | 14 +++++------
src/dbusifs/sessionhelper.cpp | 6 ++---
src/lock-dialog/backenddbushelper.cpp | 8 ++----
src/widgets/authdialog.cpp | 41 +++++++++++++++++-------------
src/widgets/authdialog.h | 4 +++
src/widgets/batterywidget.cpp | 2 +-
src/widgets/blockwidget.cpp | 6 ++---
src/widgets/powerlistwidget.cpp | 5 ++--
src/widgets/sessionlistwidget.cpp | 8 +++---
src/widgets/userlistwidget.cpp | 8 +++---
11 files changed, 76 insertions(+), 73 deletions(-)
diff --git a/src/VirtualKeyboard/src/kbtitle.cpp b/src/VirtualKeyboard/src/kbtitle.cpp
index 733caf3..ac30430 100644
--- a/src/VirtualKeyboard/src/kbtitle.cpp
+++ b/src/VirtualKeyboard/src/kbtitle.cpp
@@ -14,33 +14,30 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
-**/
+ **/
#include "kbtitle.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "commondef.h"
#include <QDebug>
-KBTitle::KBTitle(QWidget *parent/* = nullptr*/)
- : QWidget(parent)
+KBTitle::KBTitle(QWidget *parent /* = nullptr*/) : QWidget(parent)
{
- setAttribute(Qt::WA_TranslucentBackground);//背景透明
+ setAttribute(Qt::WA_TranslucentBackground); //背景透明
initUI();
initConnections();
}
-KBTitle::~KBTitle()
-{
-
-}
+KBTitle::~KBTitle() {}
void KBTitle::initUI()
{
setFixedHeight(KEYBOARD_TITLE_DEFAULT_HEIGHT);
- QString strBtnStyle = "QPushButton{ text-align:center; color: rgb(255, 255, 255, 255); border: none; border-radius: 4px; outline: none;}"
- "QPushButton:hover{ background-color: rgb(255,255,255,15%); }"
- "QPushButton::pressed { background-color: rgba(255,255,255,40%); }"
- "QPushButton::checked { background-color: rgba(255,255,255,40%); }";
+ QString strBtnStyle = "QPushButton{ text-align:center; color: rgba(255, 255, 255, 255); border: none; "
+ "border-radius: 4px; outline: none;}"
+ "QPushButton:hover{ background-color: rgba(255,255,255,15%); }"
+ "QPushButton::pressed { background-color: rgba(255,255,255,40%); }"
+ "QPushButton::checked { background-color: rgba(255,255,255,40%); }";
m_btnFloat = new QPushButton(this);
m_btnFloat->setFlat(true);
@@ -74,7 +71,7 @@ void KBTitle::initConnections()
void KBTitle::onBtnClicked()
{
QObject *obj = sender();
- QPushButton *btn = static_cast<QPushButton*>(obj);
+ QPushButton *btn = static_cast<QPushButton *>(obj);
QString objName = btn->objectName();
int lastUnderline = objName.lastIndexOf('_');
int start = strlen("btn_");
@@ -94,25 +91,25 @@ void KBTitle::onBtnClicked()
Q_EMIT btnClicked(keyName);
}
-void KBTitle::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical/* = false*/, bool floatStatus)
+void KBTitle::adjustGeometry(double lfWidthScale, double lfHeightScale, bool isVertical /* = false*/, bool floatStatus)
{
- setFixedHeight(KEYBOARD_TITLE_DEFAULT_HEIGHT*lfHeightScale);
- QMap<QPushButton*, QRect>::iterator itGeometry = m_mapSubGeometrys.begin();
- for (; itGeometry != m_mapSubGeometrys.end(); itGeometry ++) {
+ setFixedHeight(KEYBOARD_TITLE_DEFAULT_HEIGHT * lfHeightScale);
+ QMap<QPushButton *, QRect>::iterator itGeometry = m_mapSubGeometrys.begin();
+ for (; itGeometry != m_mapSubGeometrys.end(); itGeometry++) {
QPushButton *button = itGeometry.key();
if (button) {
QRect oldGeometry = itGeometry.value();
QRect newGeometry = oldGeometry;
if (floatStatus) {
- newGeometry.setX(oldGeometry.x()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
- newGeometry.setY(oldGeometry.y()*lfHeightScale);
- newGeometry.setWidth(oldGeometry.width()*lfWidthScale*KEYBOARD_FLOAT_PERCENTAGE);
- newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
+ newGeometry.setX(oldGeometry.x() * lfWidthScale * KEYBOARD_FLOAT_PERCENTAGE);
+ newGeometry.setY(oldGeometry.y() * lfHeightScale);
+ newGeometry.setWidth(oldGeometry.width() * lfWidthScale * KEYBOARD_FLOAT_PERCENTAGE);
+ newGeometry.setHeight(oldGeometry.height() * lfHeightScale);
} else {
- newGeometry.setX(oldGeometry.x()*lfWidthScale);
- newGeometry.setY(oldGeometry.y()*lfHeightScale);
- newGeometry.setWidth(oldGeometry.width()*lfWidthScale);
- newGeometry.setHeight(oldGeometry.height()*lfHeightScale);
+ newGeometry.setX(oldGeometry.x() * lfWidthScale);
+ newGeometry.setY(oldGeometry.y() * lfHeightScale);
+ newGeometry.setWidth(oldGeometry.width() * lfWidthScale);
+ newGeometry.setHeight(oldGeometry.height() * lfHeightScale);
}
button->setGeometry(newGeometry);
}
diff --git a/src/assets/authdialog.qss b/src/assets/authdialog.qss
index a45e1c3..895ec8f 100644
--- a/src/assets/authdialog.qss
+++ b/src/assets/authdialog.qss
@@ -1,12 +1,12 @@
QPushButton{
text-align:center;
- color: rgb(255, 255, 255, 255);
+ color: rgba(255, 255, 255, 255);
border: none;
border-radius: 4px;
outline: none;
}
QPushButton::hover{
- background-color: rgb(255,255,255,15%);
+ background-color: rgba(255,255,255,15%);
}
QPushButton::pressed {
background-color: rgba(255,255,255,40%);
@@ -119,7 +119,7 @@ QLineEdit::focus{
/* 切换用户 */
QMenu{
- background-color: rgb(255,255,255,15%);
+ background-color: rgba(255,255,255,15%);
color: white;
border-radius: 4px;
width:250px;
@@ -139,11 +139,11 @@ QMenu::item
QMenu::item:selected {
border-radius: 4px;
- background-color:rgb(255,255,255,40%);
+ background-color:rgba(255,255,255,40%);
}
QMenu::item:pressed {
border-radius: 4px;
- background-color: rgb(255,255,255,40%);
+ background-color: rgba(255,255,255,40%);
}
/* 虚拟键盘开启按钮、用户切换按钮 */
@@ -151,7 +151,7 @@ QMenu::item:pressed {
border-radius: 4px;
}
#btnKeyboard::hover, #btnSwitchUser::hover,#btnPowerManager::hover {
- background-color: rgb(255, 255, 255, 15%);
+ background-color: rgba(255, 255, 255, 15%);
}
#btnKeyboard::pressed, #btnSwitchUser::pressed,#btnPowerManager::pressed{
background: rgba(255,255,255,40%);
@@ -163,7 +163,7 @@ QMenu::item:pressed {
QComboBox{
background: rgba(255, 255, 255, 20);
- border: 1px solid rgb(255, 255, 255, 30);
+ border: 1px solid rgba(255, 255, 255, 30);
font-size:18px;
color: white;
combobox-popup: 0; /* 配合setMaxVisibleItems设置下拉框显示的条数超过的滚动显示 */
diff --git a/src/dbusifs/sessionhelper.cpp b/src/dbusifs/sessionhelper.cpp
index f5229ae..d8fa70f 100644
--- a/src/dbusifs/sessionhelper.cpp
+++ b/src/dbusifs/sessionhelper.cpp
@@ -165,8 +165,8 @@ QStringList SessionHelper::getLockCheckStatus(QString type)
QVector<InhibitInfo::InhibitorInfo> resVec;
- if (m_sessionInterface->isValid()) {
- qDebug() << "create interface success";
+ if (!m_sessionInterface->isValid()) {
+ qDebug() << "session interface invalid!";
}
QDBusMessage result = m_sessionInterface->call("ListInhibitor", QVariant(type));
@@ -186,7 +186,7 @@ QStringList SessionHelper::getLockCheckStatus(QString type)
lockCheckList.append(iter->icon);
lockCheckList.append(iter->name);
}
- qDebug() << "lockCheckList = " << lockCheckList;
+ // qDebug() << "lockCheckList = " << lockCheckList;
return lockCheckList;
}
diff --git a/src/lock-dialog/backenddbushelper.cpp b/src/lock-dialog/backenddbushelper.cpp
index fed4bfa..fff34c3 100644
--- a/src/lock-dialog/backenddbushelper.cpp
+++ b/src/lock-dialog/backenddbushelper.cpp
@@ -219,8 +219,7 @@ QStringList BackendDbusHelper::getSleepLockcheck()
if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) {
int nCmdId = objRes.value("CmdId").toInt(-1);
int nRet = objRes.value("Ret").toInt(-1);
- QJsonArray jsonArray = objRes.value("Content").toArray();
- if (nCmdId != LOCK_CMD_ID_SESSION_GET_SLEEP_LOCKCHECK || nRet != 0 || jsonArray.isEmpty()) {
+ if (nCmdId != LOCK_CMD_ID_SESSION_GET_SLEEP_LOCKCHECK || nRet != 0) {
qInfo() << "getSleepLockcheck Failed!!";
} else {
listArgs = ParseSleepLockcheck(objRes);
@@ -1210,7 +1209,6 @@ QStringList BackendDbusHelper::ParseSleepLockcheck(const QJsonObject &objRes)
QStringList sleepLockcheck;
QJsonArray jsonArray = objRes.value("Content").toArray();
if (jsonArray.isEmpty()) {
- qInfo() << "ParseSleepLockcheck Failed!!";
return sleepLockcheck;
} else {
for (auto jsonValue : jsonArray) {
@@ -1227,7 +1225,6 @@ QStringList BackendDbusHelper::ParseShutdownLockcheck(const QJsonObject &objRes)
QStringList shutdownLockcheck;
QJsonArray jsonArray = objRes.value("Content").toArray();
if (jsonArray.isEmpty()) {
- qInfo() << "ParseShutdownLockcheck Failed!!";
return shutdownLockcheck;
} else {
for (auto jsonValue : jsonArray) {
@@ -1650,8 +1647,7 @@ QStringList BackendDbusHelper::getShutdownLockcheck()
if (objRes.contains("CmdId") && objRes.contains("Ret") && objRes.contains("Content")) {
int nCmdId = objRes.value("CmdId").toInt(-1);
int nRet = objRes.value("Ret").toInt(-1);
- QJsonArray jsonArray = objRes.value("Content").toArray();
- if (nCmdId != LOCK_CMD_ID_SESSION_GET_SHUTDOWN_LOCKCHECK || nRet != 0 || jsonArray.isEmpty()) {
+ if (nCmdId != LOCK_CMD_ID_SESSION_GET_SHUTDOWN_LOCKCHECK || nRet != 0) {
qInfo() << "getShutdownLockcheck Failed!!";
} else {
listArgs = ParseShutdownLockcheck(objRes);
diff --git a/src/widgets/authdialog.cpp b/src/widgets/authdialog.cpp
index cfface1..30cbfcc 100644
--- a/src/widgets/authdialog.cpp
+++ b/src/widgets/authdialog.cpp
@@ -294,7 +294,7 @@ void AuthDialog::initHeaderWidget()
m_fRetryButton->setFocusPolicy(Qt::NoFocus);
m_fRetryButton->setStyleSheet(
QString("QPushButton{border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);}"
- "QPushButton::hover{background-color: rgb(255,255,255,30%);}"
+ "QPushButton::hover{background-color: rgba(255,255,255,30%);}"
"QPushButton::pressed {background-color: rgba(255,255,255,40%);}")
.arg((int)(77 * scale)));
@@ -321,7 +321,7 @@ void AuthDialog::initHeaderWidget()
m_labelQRCodeTip->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(QSize(22, 22)));
m_labelQRCodeTip->show();
m_labelQRCodeMsg = new KLabel();
- m_labelQRCodeMsg->setStyleSheet("QLabel{background-color:rgba(255,255,255,0);color:rgb(255,0,0)}");
+ m_labelQRCodeMsg->setStyleSheet("QLabel{background-color:rgba(255,255,255,0);color:rgba(255,0,0)}");
m_labelQRCodeMsg->hide();
layoutQRCode->addWidget(m_labelQRCodeMsg, 0, Qt::AlignHCenter);
headerLayout->addWidget(m_labelQRCode);
@@ -440,7 +440,7 @@ void AuthDialog::updateUI()
m_fRetryButton->setStyleSheet(
QString("QPushButton{border-radius: %1px; border:0px solid white;background-color: rgba(255,255,255,10%);}"
- "QPushButton::hover{background-color: rgb(255,255,255,30%);}"
+ "QPushButton::hover{background-color: rgba(255,255,255,30%);}"
"QPushButton::pressed {background-color: rgba(255,255,255,40%);}")
.arg((int)(77 * scale)));
m_fRetryButton->setFixedSize(154 * scale, 154 * scale);
@@ -1059,20 +1059,27 @@ void AuthDialog::onRespond(const QString &strRes)
void AuthDialog::startAuth()
{
if (!m_curUserInfo->name().isEmpty()) {
- m_bRecvPrompt = false;
- m_bHasUnacknowledgedMsg = false;
- // 用户认证
- if (m_curUserInfo->name() == "*guest") { // 游客登录
- qDebug() << "guest login";
- m_passwordEdit->show();
- m_passwordEdit->setPrompt(tr("login"));
- } else if (m_curUserInfo->name() == "*login") { // 手动输入用户名
- Q_EMIT m_modelLockDialog->pamAuthenticate("");
- } else {
- qDebug() << "login: " << m_curUserInfo->name();
- Q_EMIT m_modelLockDialog->pamAuthenticate(m_curUserInfo->name());
- m_passwordEdit->clear();
- m_passwordEdit->readOnly(true);
+ qint64 lnDiffTime = qAbs(m_lastPamAuthTime.msecsTo(QDateTime::currentDateTime()));
+ if (lnDiffTime >= 1000 || m_strLastPamAuthName != m_curUserInfo->name()) {
+ m_lastPamAuthTime = QDateTime::currentDateTime();
+ m_bRecvPrompt = false;
+ m_bHasUnacknowledgedMsg = false;
+ // 用户认证
+ if (m_curUserInfo->name() == "*guest") { // 游客登录
+ qDebug() << "guest login";
+ m_passwordEdit->show();
+ m_passwordEdit->setPrompt(tr("login"));
+ m_strLastPamAuthName = "*guest";
+ } else if (m_curUserInfo->name() == "*login") { // 手动输入用户名
+ Q_EMIT m_modelLockDialog->pamAuthenticate("");
+ m_strLastPamAuthName = "*login";
+ } else {
+ qDebug() << "login: " << m_curUserInfo->name();
+ Q_EMIT m_modelLockDialog->pamAuthenticate(m_curUserInfo->name());
+ m_passwordEdit->clear();
+ m_passwordEdit->readOnly(true);
+ m_strLastPamAuthName = m_curUserInfo->name();
+ }
}
}
}
diff --git a/src/widgets/authdialog.h b/src/widgets/authdialog.h
index 5f16dc9..fbba479 100644
--- a/src/widgets/authdialog.h
+++ b/src/widgets/authdialog.h
@@ -26,6 +26,7 @@
#include "biodefines.h"
#include "loginoptionswidget.h"
#include "pluginsloader.h"
+#include <QDateTime>
class QLabel;
class KLabel;
@@ -278,5 +279,8 @@ private:
double m_curFontSize;
double m_ptToPx = 1.0;
+
+ QString m_strLastPamAuthName = "";
+ QDateTime m_lastPamAuthTime;
};
#endif // AUTHDIALOG_H
diff --git a/src/widgets/batterywidget.cpp b/src/widgets/batterywidget.cpp
index 7be01db..d5eacde 100644
--- a/src/widgets/batterywidget.cpp
+++ b/src/widgets/batterywidget.cpp
@@ -47,7 +47,7 @@ void BatteryWidget::initUi()
mIconBtn = new QPushButton(this);
mIconBtn->setFixedSize(48, 32);
mIconBtn->setStyleSheet("QPushButton{\
- color: rgb(255, 255, 255, 255);\
+ color: rgba(255, 255, 255, 255);\
border: none;\
border-radius: 4px;\
outline: none;\
diff --git a/src/widgets/blockwidget.cpp b/src/widgets/blockwidget.cpp
index 36c225d..a0b3d8b 100644
--- a/src/widgets/blockwidget.cpp
+++ b/src/widgets/blockwidget.cpp
@@ -163,11 +163,11 @@ void BlockWidget::setWarning(QStringList list, int type)
m_listView->verticalScrollMode();
m_listView->setStyleSheet(
- "QListView#applist{font:10pt;color:white;background-color: rgb(255,255,255,80);border-style: outset;border-width: 0px;border-radius: 6px;}\
+ "QListView#applist{font:10pt;color:white;background-color: rgba(255,255,255,80);border-style: outset;border-width: 0px;border-radius: 6px;}\
QListView#applist::item{height:48px;margin-top:2px;border-radius: 6px;}\
- QListView#applist::item::selected {background-color: rgb(255,255,255,80);border: 1px solid #296CD9;\
+ QListView#applist::item::selected {background-color: rgba(255,255,255,80);border: 1px solid #296CD9;\
height:48px;margin-top:2px;border-radius: 6px;}\
- QListView#applist::item::hover {background-color: rgb(255,255,255,80);height:48px;margin-top:2px;border-radius: 6px;}");
+ QListView#applist::item::hover {background-color: rgba(255,255,255,80);height:48px;margin-top:2px;border-radius: 6px;}");
sysFont.setPointSize((10 + m_curFontSize) * m_ptToPx);
m_listView->setFont(sysFont);
diff --git a/src/widgets/powerlistwidget.cpp b/src/widgets/powerlistwidget.cpp
index 2dc29d5..341f667 100644
--- a/src/widgets/powerlistwidget.cpp
+++ b/src/widgets/powerlistwidget.cpp
@@ -152,7 +152,7 @@ void PowerListWidget::onUpdateListInfo()
this->clear();
for (int i = 0; i < sizeof(powerBtnList) / sizeof(powerBtnList[0]); i++) {
- qDebug() << powerBtnList[i].m_strName << powerBtnList[i].setFuncName << powerBtnList[i].m_show_flag;
+ // qDebug() << powerBtnList[i].m_strName << powerBtnList[i].setFuncName << powerBtnList[i].m_show_flag;
if (!powerBtnList[i].m_show_flag)
continue;
@@ -173,7 +173,6 @@ void PowerListWidget::onUpdateListInfo()
void PowerListWidget::onListItemClicked(QListWidgetItem *item)
{
- qWarning() << __FUNCTION__ << __LINE__;
QWidget *widget = itemWidget(item);
PowerItemWidget *currentItem = qobject_cast<PowerItemWidget *>(widget);
for (int i = 0; i < sizeof(powerBtnList) / sizeof(powerBtnList[0]); i++) {
@@ -196,7 +195,7 @@ void PowerListWidget::onListItemClicked(QListWidgetItem *item)
break;
}
}
- qWarning() << __LINE__ << "=================" << powerBtnList[i].setFuncName << __FUNCTION__;
+ // qWarning() << __LINE__ << "=================" << powerBtnList[i].setFuncName << __FUNCTION__;
if (powerBtnList[i].setFuncName == "LockScreen") {
Q_EMIT lockScreenClicked();
} else if (powerBtnList[i].setFuncName == "Suspend") {
diff --git a/src/widgets/sessionlistwidget.cpp b/src/widgets/sessionlistwidget.cpp
index 6427745..d5e457d 100644
--- a/src/widgets/sessionlistwidget.cpp
+++ b/src/widgets/sessionlistwidget.cpp
@@ -29,10 +29,10 @@ SessionListWidget::SessionListWidget(LockDialogModel *model, QWidget *parent)
void SessionListWidget::initUI()
{
QString userListStyle
- = "QListWidget{ background-color: rgb(255,255,255,15%); border-radius: 8px; padding: 5px 5px 5px 5px;}"
- "QListWidget::item{background:rgb(255,255,255,0%);height:40px; border-radius:4px}"
- "QListWidget::item:hover{color:#333333; background-color:rgb(255,255,255,20%)}"
- "QListWidget::item::selected{border-radius: 4px;background-color:rgb(255,255,255,40%);}";
+ = "QListWidget{ background-color: rgba(255,255,255,15%); border-radius: 8px; padding: 5px 5px 5px 5px;}"
+ "QListWidget::item{background:rgba(255,255,255,0%);height:40px; border-radius:4px}"
+ "QListWidget::item:hover{color:#333333; background-color:rgba(255,255,255,20%)}"
+ "QListWidget::item::selected{border-radius: 4px;background-color:rgba(255,255,255,40%);}";
setStyleSheet(userListStyle);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
verticalScrollBar()->setProperty("drawScrollBarGroove", false);
diff --git a/src/widgets/userlistwidget.cpp b/src/widgets/userlistwidget.cpp
index 2e23356..2a3ce87 100644
--- a/src/widgets/userlistwidget.cpp
+++ b/src/widgets/userlistwidget.cpp
@@ -29,10 +29,10 @@ UserListWidget::UserListWidget(LockDialogModel *model, QWidget *parent) : MyList
void UserListWidget::initUI()
{
QString userListStyle
- = "QListWidget{ background-color: rgb(255,255,255,15%); border-radius: 8px; padding: 5px 5px 5px 5px;}"
- "QListWidget::item{background:rgb(255,255,255,0%);height:40px; border-radius:4px}"
- "QListWidget::item:hover{color:#333333; background-color:rgb(255,255,255,20%)}"
- "QListWidget::item::selected{border-radius: 4px;background-color:rgb(255,255,255,40%);}";
+ = "QListWidget{ background-color: rgba(255,255,255,15%); border-radius: 8px; padding: 5px 5px 5px 5px;}"
+ "QListWidget::item{background:rgba(255,255,255,0%);height:40px; border-radius:4px}"
+ "QListWidget::item:hover{color:#333333; background-color:rgba(255,255,255,20%)}"
+ "QListWidget::item::selected{border-radius: 4px;background-color:rgba(255,255,255,40%);}";
setStyleSheet(userListStyle);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
verticalScrollBar()->setProperty("drawScrollBarGroove", false);

View File

@ -27,3 +27,4 @@
0027-Translated-using-Weblate-Uyghur.patch
0028-Translated-using-Weblate-Chinese-Simplified.patch
0029-81-format-codes.patch
0030-82-fixbug.patch