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
10 changes: 10 additions & 0 deletions configs/org.deepin.dde.lightdm-deepin-greeter.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@
"permissions": "readwrite",
"visibility": "private"
},
"systemVersionText":{
"value": "",
"serial": 0,
"flags": ["global"],
"name": "SystemVersionText",
"name[zh_CN]": "自定义系统版本信息",
"description[zh_CN]": "登录/锁屏界面左下角logo右侧显示的系统版本及类型信息;为空时显示系统默认的版本号+系统类型,不为空时显示配置的文本内容。",
"permissions": "readwrite",
"visibility": "private"
},
"designatedLoginPlugin":{
"value": "",
"serial": 0,
Expand Down
10 changes: 10 additions & 0 deletions configs/org.deepin.dde.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@
"permissions": "readwrite",
"visibility": "private"
},
"systemVersionText":{
"value": "",
"serial": 0,
"flags": ["global"],
"name": "SystemVersionText",
"name[zh_CN]": "自定义系统版本信息",
"description[zh_CN]": "登录/锁屏界面左下角logo右侧显示的系统版本及类型信息;为空时显示系统默认的版本号+系统类型,不为空时显示配置的文本内容。",
"permissions": "readwrite",
"visibility": "private"
},
"delayInhibitIgnoreList":{
"value": [],
"serial": 0,
Expand Down
10 changes: 10 additions & 0 deletions configs/snipe/org.deepin.dde.lightdm-deepin-greeter.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@
"permissions": "readwrite",
"visibility": "private"
},
"systemVersionText":{
"value": "",
"serial": 0,
"flags": ["global"],
"name": "SystemVersionText",
"name[zh_CN]": "自定义系统版本信息",
"description[zh_CN]": "登录/锁屏界面左下角logo右侧显示的系统版本及类型信息;为空时显示系统默认的版本号+系统类型,不为空时显示配置的文本内容。",
"permissions": "readwrite",
"visibility": "private"
},
"designatedLoginPlugin":{
"value": "",
"serial": 0,
Expand Down
20 changes: 20 additions & 0 deletions configs/snipe/org.deepin.dde.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@
"permissions": "readwrite",
"visibility": "private"
},
"systemVersionText":{
"value": "",
"serial": 0,
"flags": ["global"],
"name": "SystemVersionText",
"name[zh_CN]": "自定义系统版本信息",
"description[zh_CN]": "登录/锁屏界面左下角logo右侧显示的系统版本及类型信息;为空时显示系统默认的版本号+系统类型,不为空时显示配置的文本内容。",
"permissions": "readwrite",
"visibility": "private"
},
"delayInhibitIgnoreList":{
"value": [],
"serial": 0,
Expand Down Expand Up @@ -281,6 +291,16 @@
"description": "是否长按小眼睛显示密码,true-鼠按长按小眼睛才显示密码,false-鼠标点击一下就一直显示密码",
"permissions": "readwrite",
"visibility": "private"
},
"enableShutdownBlackWidget":{
"value": true,
"serial": 0,
"flags": ["global"],
"name": "enableShutdownBlackWidget",
"name[zh_CN]": "是否打开关机、重启黑屏界面",
"description": "是否打开关机、重启黑屏界面;false:不开,true:开启。默认值为true;",
"permissions": "readwrite",
"visibility": "private"
}
}
}
1 change: 1 addition & 0 deletions src/global_util/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const QString SHOW_MEDIA_WIDGET = "showMediaWidget";

// 系统版本显示配置
const QString SHOW_SYSTEM_VERSION = QStringLiteral("showSystemVersion");
const QString SYSTEM_VERSION_TEXT = QStringLiteral("systemVersionText");
// 第三方logo相关配置
const QString CUSTOM_LOGO_PATH = QStringLiteral("customLogoPath");
const QString CUSTOM_LOGO_POS = QStringLiteral("customLogoPos");
Expand Down
14 changes: 11 additions & 3 deletions src/widgets/logowidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -81,13 +81,14 @@ void LogoWidget::initUI()
return;
}

m_logoVersionLabel->setText(getVersion());
updateVersionText(DConfigHelper::instance()->getConfig(SYSTEM_VERSION_TEXT, "").toString());
logoLayout->addWidget(m_logoVersionLabel);

updateStyle(":/skin/login.qss", m_logoVersionLabel);
m_logoVersionLabel->setVisible(DConfigHelper::instance()->getConfig(SHOW_SYSTEM_VERSION, true).toBool());

DConfigHelper::instance()->bind(this, SHOW_SYSTEM_VERSION, &LogoWidget::onDConfigPropertyChanged);
DConfigHelper::instance()->bind(this, SYSTEM_VERSION_TEXT, &LogoWidget::onDConfigPropertyChanged);
DConfigHelper::instance()->bind(this, CUSTOM_LOGO_PATH, &LogoWidget::onDConfigPropertyChanged);
DConfigHelper::instance()->bind(this, CUSTOM_LOGO_POS, &LogoWidget::onDConfigPropertyChanged);
}
Expand All @@ -112,6 +113,11 @@ QString LogoWidget::getVersion()
return version;
}

void LogoWidget::updateVersionText(const QString &customText)
{
m_logoVersionLabel->setText(customText.isEmpty() ? getVersion() : customText);
}

/**
* @brief LogoWidget::updateLocale
* 将翻译文件与用户选择的语言对应
Expand All @@ -123,7 +129,7 @@ void LogoWidget::updateLocale(const QString &locale)
if(DSysInfo::UosEdition::UosEducation == DSysInfo::uosEditionType()) { //教育版登录界面不要显示系统版本号(和Logo冲突)
return;
}
m_logoVersionLabel->setText(getVersion());
updateVersionText(DConfigHelper::instance()->getConfig(SYSTEM_VERSION_TEXT, "").toString());
}

void LogoWidget::resizeEvent(QResizeEvent *event)
Expand All @@ -149,6 +155,8 @@ void LogoWidget::onDConfigPropertyChanged(const QString &key, const QVariant &va

if (key == SHOW_SYSTEM_VERSION) {
obj->m_logoVersionLabel->setVisible(value.toBool());
} else if (key == SYSTEM_VERSION_TEXT) {
obj->updateVersionText(value.toString());
} else if (key == CUSTOM_LOGO_PATH) {
obj->loadCustomLogo();
obj->updateCustomLogoPos();
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/logowidget.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -21,6 +21,7 @@ class LogoWidget : public QFrame

void updateLocale(const QString &locale);
static void onDConfigPropertyChanged(const QString &key, const QVariant &value, QObject* objPtr);
void updateVersionText(const QString &customText);

protected:
void resizeEvent(QResizeEvent *event) override;
Expand Down
37 changes: 36 additions & 1 deletion tests/dde-lock/ut_logowidget.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "logowidget.h"

Check warning on line 5 in tests/dde-lock/ut_logowidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "logowidget.h" not found.
#include "constants.h"

Check warning on line 6 in tests/dde-lock/ut_logowidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.

#include <gtest/gtest.h>

Check warning on line 8 in tests/dde-lock/ut_logowidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <gtest/gtest.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DSysInfo>

Check warning on line 9 in tests/dde-lock/ut_logowidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 10 in tests/dde-lock/ut_logowidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

DCORE_USE_NAMESPACE
using namespace DDESESSIONCC;

class UT_LogWidget : public testing::Test
{
Expand All @@ -29,3 +35,32 @@
{
logoWidget->updateLocale("en_US.UTF-8");
}

TEST_F(UT_LogWidget, versionText)
{
// 教育版不显示系统版本信息
if (DSysInfo::UosEdition::UosEducation == DSysInfo::uosEditionType()) {
GTEST_SKIP() << "Education edition does not show system version";
}

QLabel *versionLabel = logoWidget->findChild<QLabel *>("LogoVersion");
ASSERT_NE(versionLabel, nullptr);

const QString defaultText = versionLabel->text();
EXPECT_FALSE(defaultText.isEmpty());

// 配置项不为空时,显示配置的文本内容
logoWidget->updateVersionText("25 专效版");
EXPECT_EQ(versionLabel->text(), QString("25 专效版"));

// 配置项为空时,回退到系统默认的版本号+系统类型
logoWidget->updateVersionText("");
EXPECT_EQ(versionLabel->text(), defaultText);

// dconfig 变更回调
LogoWidget::onDConfigPropertyChanged(SYSTEM_VERSION_TEXT, "26 专效版", logoWidget);
EXPECT_EQ(versionLabel->text(), QString("26 专效版"));

LogoWidget::onDConfigPropertyChanged(SYSTEM_VERSION_TEXT, "", logoWidget);
EXPECT_EQ(versionLabel->text(), defaultText);
}
Loading