!88 登录界面字体更改未生效 登录界面的时间显示格式不正确

Merge pull request !88 from liudunfa/openkylin/nile
This commit is contained in:
杨敏 2024-06-07 06:48:52 +00:00 committed by openkylin-cibot
parent 0899b5b444
commit 3235d04626
2 changed files with 272 additions and 0 deletions

271
debian/patches/0036-88.patch vendored Normal file
View File

@ -0,0 +1,271 @@
From: =?utf-8?b?5p2o5pWP?= <yangmin@kylinos.cn>
Date: Fri, 7 Jun 2024 06:48:52 +0000
Subject: =?utf-8?b?ITg4IOeZu+W9leeVjOmdouWtl+S9k+abtOaUueacqueUn+aViCDnmbs=?=
=?utf-8?b?5b2V55WM6Z2i55qE5pe26Ze05pi+56S65qC85byP5LiN5q2j56GuIE1lcmdlIHB1?=
=?utf-8?b?bGwgcmVxdWVzdCAhODggZnJvbSBsaXVkdW5mYS9vcGVua3lsaW4vbmlsZQ==?=
---
src/common/utils.cpp | 32 ++++++++++++++++++++++++++++++++
src/common/utils.h | 4 ++++
src/dbusifs/sessionhelper.cpp | 19 +++++++++++--------
src/lock-dialog/languagesetting.cpp | 4 ++--
src/lock-dialog/lockdialogmodel.h | 2 ++
src/lock-dialog/lockdialogperformer.cpp | 1 +
src/widgets/authdialog.cpp | 3 +++
src/widgets/iconedit.cpp | 8 ++++++++
src/widgets/iconedit.h | 1 +
src/widgets/lockwidget.cpp | 6 ++++++
src/widgets/timewidget.cpp | 5 ++++-
11 files changed, 74 insertions(+), 11 deletions(-)
diff --git a/src/common/utils.cpp b/src/common/utils.cpp
index e96e3d4..22ddf60 100644
--- a/src/common/utils.cpp
+++ b/src/common/utils.cpp
@@ -34,6 +34,7 @@
#include <QTextStream>
#include <QtX11Extras/QX11Info>
#include <X11/XKBlib.h>
+#include <QSettings>
#define DRM_DIR "/sys/class/leds/"
@@ -149,3 +150,34 @@ double getDefaultFontSize()
}
return defaultFontSize;
}
+
+double getUserFontSize(QString userName)
+{
+ getDefaultFontSize();
+ QString configPath;
+ configPath = QString("/var/lib/lightdm-data/%1/ukui-greeter.conf").arg(userName);
+ QFile configFile(configPath);
+ double fontSize;
+ if (configFile.exists()) {
+ QSettings settings(configPath, QSettings::IniFormat);
+ settings.beginGroup("Greeter");
+ fontSize = settings.value("fontSize").toDouble();
+ } else {
+ fontSize = getDefaultFontSize();
+ }
+ return fontSize - getDefaultFontSize();
+}
+
+QString getUserThemeColor(QString userName)
+{
+ QString configPath;
+ configPath = QString("/var/lib/lightdm-data/%1/ukui-greeter.conf").arg(userName);
+ QFile configFile(configPath);
+ QString themeColor = "daybreakBlue";
+ if (configFile.exists()) {
+ QSettings settings(configPath, QSettings::IniFormat);
+ settings.beginGroup("Greeter");
+ themeColor = settings.value("themeColor").toString();
+ }
+ return themeColor;
+}
diff --git a/src/common/utils.h b/src/common/utils.h
index 54dba3c..e2cd0a5 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -40,4 +40,8 @@ bool ispicture(QString filepath);
double getDefaultFontSize();
+double getUserFontSize(QString userName);
+
+QString getUserThemeColor(QString userName);
+
#endif // UTILS_H
diff --git a/src/dbusifs/sessionhelper.cpp b/src/dbusifs/sessionhelper.cpp
index d8fa70f..ccbb7d1 100644
--- a/src/dbusifs/sessionhelper.cpp
+++ b/src/dbusifs/sessionhelper.cpp
@@ -124,7 +124,7 @@ bool SessionHelper::doAction(const QString &powerManagerfunc)
up_to_time = new QTimer();
up_to_time->setSingleShot(true);
- qDebug() << "playShutdownMusic(powerManagerfunc) = " << playShutdownMusic(powerManagerfunc);
+// qDebug() << "playShutdownMusic(powerManagerfunc) = " << playShutdownMusic(powerManagerfunc);
if (!playShutdownMusic(powerManagerfunc)) {
doPowerManager(powerManagerfunc);
@@ -197,21 +197,24 @@ bool SessionHelper::playShutdownMusic(const QString &powerManagerfunc)
// otherwise run ukui-session-tools --suspend with segmente error.
// because they will be delate at the end of the playShutdownMusic().
bool play_music = false;
+ QDBusMessage msg;
GSettingsHelper *gsettingsHelper = new GSettingsHelper(this);
if (powerManagerfunc == "Reboot" || powerManagerfunc == "PowerOff") {
play_music = gsettingsHelper->GetSessionConf(KEY_SESSION_POWEROFF_MUSIC).toBool();
} else if (powerManagerfunc == "Logout") {
play_music = gsettingsHelper->GetSessionConf(KEY_SESSION_LOGOUT_MUSIC).toBool();
- } else {
- return false;
- }
-
- QDBusMessage msg;
- if (powerManagerfunc == "SwitchUser") {
- msg = m_sessionInterface->call("emitPrepareForSwitchuser");
+ msg = m_sessionInterface->call("emitStartLogout");
if (!msg.errorName().isEmpty()) {
qWarning() << "Dbus error: " << msg;
}
+ } else {
+ if (powerManagerfunc == "SwitchUser") {
+ msg = m_sessionInterface->call("emitPrepareForSwitchuser");
+ if (!msg.errorName().isEmpty()) {
+ qWarning() << "Dbus error: " << msg;
+ }
+ }
+ return false;
}
if (play_music) {
diff --git a/src/lock-dialog/languagesetting.cpp b/src/lock-dialog/languagesetting.cpp
index d504a50..95131e5 100644
--- a/src/lock-dialog/languagesetting.cpp
+++ b/src/lock-dialog/languagesetting.cpp
@@ -55,7 +55,7 @@ void LanguageSetting::onLanguageChanged(QString languageCode)
if (languageCode.startsWith("zh_CN")) { /*这里写的有问题忘记之前为什么写了会导致繁体也会加载zh_CN*/
qmFile = QString(WORKING_DIRECTORY "/i18n_qm/%1.qm").arg("zh_CN");
setenv("LANGUAGE", "zh_CN", 1);
- // setenv("LANG","zh_CN",1);
+ setenv("LANG","zh_CN",1);
setlocale(LC_ALL, "zh_CN.utf8");
QLocale lang("zh_CN");
/*这里设置一个QLocale的默认值用来影响插件的语言。插件加载翻译文件时不使用QLocale::system().name()来获取语言,
@@ -64,7 +64,7 @@ void LanguageSetting::onLanguageChanged(QString languageCode)
} else {
qmFile = QString(WORKING_DIRECTORY "/i18n_qm/%1.qm").arg(languageCode);
setenv("LANGUAGE", languageCode.toLatin1().data(), 1);
- // setenv("LANG",languageCode.toLatin1().data(),1);
+ setenv("LANG",languageCode.toLatin1().data(),1);
setlocale(LC_ALL, "");
QLocale lang(languageCode);
/*这里设置一个QLocale的默认值用来影响插件的语言。插件加载翻译文件时不使用QLocale::system().name()来获取语言,
diff --git a/src/lock-dialog/lockdialogmodel.h b/src/lock-dialog/lockdialogmodel.h
index 8df7680..df32779 100644
--- a/src/lock-dialog/lockdialogmodel.h
+++ b/src/lock-dialog/lockdialogmodel.h
@@ -537,6 +537,8 @@ Q_SIGNALS:
void fontChanged(QString font);
+ void setUserThemeColor(QString keyStr, QVariant themeColor);
+
private:
QString getXScreensaverPath(const QString &theme);
diff --git a/src/lock-dialog/lockdialogperformer.cpp b/src/lock-dialog/lockdialogperformer.cpp
index 00effee..0ab512d 100644
--- a/src/lock-dialog/lockdialogperformer.cpp
+++ b/src/lock-dialog/lockdialogperformer.cpp
@@ -171,6 +171,7 @@ void LockDialogPerformer::initConnections()
connect(m_modelLockDialog, &LockDialogModel::lockStateChanged, m_bdHelper, &BackendDbusHelper::lockStateChanged);
connect(m_modelLockDialog, &LockDialogModel::getPublicEncrypt, m_bdHelper, &BackendDbusHelper::getPublicEncrypt);
connect(m_modelLockDialog, &LockDialogModel::sendPassword, m_bdHelper, &BackendDbusHelper::sendPassword);
+ connect(m_modelLockDialog, &LockDialogModel::setUserThemeColor, m_bdHelper, &BackendDbusHelper::setThemeStyleConf);
}
void LockDialogPerformer::initData()
diff --git a/src/widgets/authdialog.cpp b/src/widgets/authdialog.cpp
index 30cbfcc..e0e9eba 100644
--- a/src/widgets/authdialog.cpp
+++ b/src/widgets/authdialog.cpp
@@ -263,6 +263,9 @@ void AuthDialog::updateAuthFontSize(double fontSize)
if (m_labelQRCodeMsg) {
m_labelQRCodeMsg->setFontSize((14 + fontSize) * m_ptToPx);
}
+ if (m_passwordEdit) {
+ m_passwordEdit->setFontSize((16 + fontSize) * m_ptToPx);
+ }
}
void AuthDialog::initTipWidget()
diff --git a/src/widgets/iconedit.cpp b/src/widgets/iconedit.cpp
index 9e82ad4..78bdc1d 100644
--- a/src/widgets/iconedit.cpp
+++ b/src/widgets/iconedit.cpp
@@ -27,6 +27,7 @@
#include <QDir>
#include <QDebug>
#include <QTimer>
+#include <QApplication>
#include "commonfunc.h"
#include "utils.h"
@@ -282,6 +283,13 @@ void IconEdit::updateUI()
m_capsIcon->setPixmap(QIcon::fromTheme("ukui-capslock-symbolic").pixmap(QSize(16, 16)));
}
+void IconEdit::setFontSize(double fontSize)
+{
+ QFont font = qApp->font();
+ font.setPointSize(fontSize);
+ m_edit->setFont(font);
+}
+
void IconEdit::updatePixmap()
{
m_iconButton->setEnabled(true);
diff --git a/src/widgets/iconedit.h b/src/widgets/iconedit.h
index efc2fd0..363d5ea 100644
--- a/src/widgets/iconedit.h
+++ b/src/widgets/iconedit.h
@@ -49,6 +49,7 @@ public:
void startWaiting();
void stopWaiting();
void updateUI();
+ void setFontSize(double fontSize);
protected:
void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
diff --git a/src/widgets/lockwidget.cpp b/src/widgets/lockwidget.cpp
index 9214ef6..9d8791e 100644
--- a/src/widgets/lockwidget.cpp
+++ b/src/widgets/lockwidget.cpp
@@ -56,6 +56,7 @@
#include "../lock-dialog/languagesetting.h"
#include "../lock-dialog/rootWindowBackground.h"
#include "configuration.h"
+#include "utils.h"
#define BLUR_RADIUS 300
#define RIGHT_MARGIN 24
@@ -727,6 +728,10 @@ void LockWidget::onCurUserChanged(const QString &strUserName)
}
if (authDialog)
authDialog->onCurUserChanged(m_curUserInfo);
+ m_curFontSize = getUserFontSize(strUserName);
+ updateFontSize();
+ QVariant curUserThemeColor = getUserThemeColor(strUserName);
+ Q_EMIT m_modelLockDialog->setUserThemeColor("themeColor", curUserThemeColor);
// 登录后绘制桌面背景而不是登录背景
QString backgroundPath = m_curUserInfo->backGround();
QFile backgroundPathFile(backgroundPath);
@@ -1293,6 +1298,7 @@ void LockWidget::onFontChanged(QString font)
void LockWidget::onFontSizeChanged(double fontSize)
{
m_curFontSize = fontSize;
+ updateFontSize();
}
void LockWidget::SwitchToUser(QString strUserName)
diff --git a/src/widgets/timewidget.cpp b/src/widgets/timewidget.cpp
index bee908f..08abf0a 100644
--- a/src/widgets/timewidget.cpp
+++ b/src/widgets/timewidget.cpp
@@ -102,7 +102,10 @@ void TimeWidget::updateTimeFontSize(double fontSize)
QString TimeWidget::getLongFormatDate(int type)
{
- kdk_logn_dateinfo *dateInfo = kdk_system_login_lock_dateinfo(getenv("USER"));
+ char* userName;
+ QByteArray ba = m_modelLockDialog->currentUserName().toLatin1();
+ userName = ba.data();
+ kdk_logn_dateinfo *dateInfo = kdk_system_login_lock_dateinfo(userName);
if (type == DATE)
{
QString date = dateInfo->date;

View File

@ -33,3 +33,4 @@
0033-85-fixbug.patch
0034-86.patch
0035-87-fixbug.patch
0036-88.patch