From 2f6e7239b85e431719482a231b2a9ed5699f9cbb Mon Sep 17 00:00:00 2001 From: chenhongtao Date: Tue, 31 Oct 2023 16:23:30 +0800 Subject: [PATCH] chore: supportbalance performance Log: --- src/plugin-power/operation/powerdbusproxy.cpp | 5 + src/plugin-power/operation/powerdbusproxy.h | 3 + src/plugin-power/operation/powermodel.cpp | 9 + src/plugin-power/operation/powermodel.h | 3 + src/plugin-power/operation/powerworker.cpp | 6 + src/plugin-power/operation/powerworker.h | 1 + src/plugin-power/window/generalmodule.cpp | 89 ++++- translations/dde-control-center_en.ts | 315 ++++++++---------- translations/dde-control-center_zh_CN.ts | 30 +- 9 files changed, 264 insertions(+), 197 deletions(-) diff --git a/src/plugin-power/operation/powerdbusproxy.cpp b/src/plugin-power/operation/powerdbusproxy.cpp index 0511466001..901d63e16f 100644 --- a/src/plugin-power/operation/powerdbusproxy.cpp +++ b/src/plugin-power/operation/powerdbusproxy.cpp @@ -183,6 +183,11 @@ bool PowerDBusProxy::isHighPerformanceSupported() return qvariant_cast(m_powerInter->property("IsHighPerformanceSupported")); } +bool PowerDBusProxy::isBalancePerformanceSupported() +{ + return qvariant_cast(m_sysPowerInter->property("IsBalancePerformanceSupported")); +} + int PowerDBusProxy::linePowerScreenBlackDelay() { return qvariant_cast(m_powerInter->property("LinePowerScreenBlackDelay")); diff --git a/src/plugin-power/operation/powerdbusproxy.h b/src/plugin-power/operation/powerdbusproxy.h index 418820be25..8cf2e8390a 100644 --- a/src/plugin-power/operation/powerdbusproxy.h +++ b/src/plugin-power/operation/powerdbusproxy.h @@ -51,6 +51,8 @@ class PowerDBusProxy : public QObject void setBatteryLidClosedAction(int value); Q_PROPERTY(bool IsHighPerformanceSupported READ isHighPerformanceSupported NOTIFY IsHighPerformanceSupportedChanged) bool isHighPerformanceSupported(); + Q_PROPERTY(bool IsBalancePerformanceSupported READ isBalancePerformanceSupported NOTIFY IsBalancePerformanceSupportedChanged) + bool isBalancePerformanceSupported(); Q_PROPERTY(int LinePowerScreenBlackDelay READ linePowerScreenBlackDelay WRITE setLinePowerScreenBlackDelay NOTIFY LinePowerScreenBlackDelayChanged) int linePowerScreenBlackDelay(); void setLinePowerScreenBlackDelay(int value); @@ -116,6 +118,7 @@ class PowerDBusProxy : public QObject void BatteryLockDelayChanged(int value) const; void LinePowerLockDelayChanged(int value) const; void IsHighPerformanceSupportedChanged(bool value) const; + void IsBalancePerformanceSupportedChanged(bool value) const; void LinePowerPressPowerBtnActionChanged(int value) const; void LinePowerLidClosedActionChanged(int value) const; void BatteryPressPowerBtnActionChanged(int value) const; diff --git a/src/plugin-power/operation/powermodel.cpp b/src/plugin-power/operation/powermodel.cpp index 90c270aee4..5338c92abd 100644 --- a/src/plugin-power/operation/powermodel.cpp +++ b/src/plugin-power/operation/powermodel.cpp @@ -40,6 +40,7 @@ PowerModel::PowerModel(QObject *parent) , m_isShutdown(false) , m_powerPlan("") , m_isHighPerformanceSupported(false) + , m_isBalancePerformanceSupported(false) { } @@ -321,6 +322,14 @@ void PowerModel::setHighPerformanceSupported(bool isHighSupport) Q_EMIT highPerformaceSupportChanged(isHighSupport); } +void PowerModel::setBalancePerformanceSupported(bool isBalancePerformanceSupported) +{ + if (m_isBalancePerformanceSupported == isBalancePerformanceSupported) + return; + m_isBalancePerformanceSupported = isBalancePerformanceSupported; + Q_EMIT highPerformaceSupportChanged(isBalancePerformanceSupported); +} + void PowerModel::setSuspend(bool suspend) { if (suspend == m_isSuspend) diff --git a/src/plugin-power/operation/powermodel.h b/src/plugin-power/operation/powermodel.h index 8b29b4c239..fd390734e4 100644 --- a/src/plugin-power/operation/powermodel.h +++ b/src/plugin-power/operation/powermodel.h @@ -123,6 +123,8 @@ class PowerModel : public QObject inline bool isHighPerformanceSupported() const { return m_isHighPerformanceSupported; } void setHighPerformanceSupported(bool isHighSupport); + inline bool isBalancePerformanceSupported() const { return m_isBalancePerformanceSupported; } + void setBalancePerformanceSupported(bool isBalancePerformanceSupported); // ---- inline bool isNoPasswdLogin() const { return m_noPasswdLogin; } @@ -211,6 +213,7 @@ class PowerModel : public QObject QString m_powerPlan; bool m_isHighPerformanceSupported; + bool m_isBalancePerformanceSupported; // Account bool m_noPasswdLogin; diff --git a/src/plugin-power/operation/powerworker.cpp b/src/plugin-power/operation/powerworker.cpp index f2b8cb403b..937e1a6b93 100644 --- a/src/plugin-power/operation/powerworker.cpp +++ b/src/plugin-power/operation/powerworker.cpp @@ -85,6 +85,7 @@ void PowerWorker::active() m_powerModel->setNoPasswdLogin(m_powerDBusProxy->noPasswdLogin()); setHighPerformanceSupported(m_powerDBusProxy->isHighPerformanceSupported()); + setBalancePerformanceSupported(m_powerDBusProxy->isBalancePerformanceSupported()); setScreenBlackDelayToModelOnPower(m_powerDBusProxy->linePowerScreenBlackDelay()); setSleepDelayToModelOnPower(m_powerDBusProxy->linePowerSleepDelay()); @@ -204,6 +205,11 @@ void PowerWorker::setHighPerformanceSupported(bool state) m_powerModel->setHighPerformanceSupported(state); } +void PowerWorker::setBalancePerformanceSupported(bool state) +{ + m_powerModel->setBalancePerformanceSupported(state); +} + void PowerWorker::setPowerSavingModeAutoWhenQuantifyLow(bool bLowBatteryAutoIntoSaveEnergyMode) { m_powerDBusProxy->setPowerSavingModeAutoWhenBatteryLow(bLowBatteryAutoIntoSaveEnergyMode); diff --git a/src/plugin-power/operation/powerworker.h b/src/plugin-power/operation/powerworker.h index 8627a836f0..446fc633eb 100644 --- a/src/plugin-power/operation/powerworker.h +++ b/src/plugin-power/operation/powerworker.h @@ -35,6 +35,7 @@ public Q_SLOTS: void setResponseBatteryLockScreenDelay(const int delay); void setResponsePowerLockScreenDelay(const int delay); void setHighPerformanceSupported(bool state); + void setBalancePerformanceSupported(bool state); //------------sp2 add----------------------- void setPowerSavingModeAutoWhenQuantifyLow(bool bLowBatteryAutoIntoSaveEnergyMode); void setPowerSavingModeAuto(bool bAutoIntoSaveEnergyMode); diff --git a/src/plugin-power/window/generalmodule.cpp b/src/plugin-power/window/generalmodule.cpp index f15badd816..e13b5e5ffc 100644 --- a/src/plugin-power/window/generalmodule.cpp +++ b/src/plugin-power/window/generalmodule.cpp @@ -18,20 +18,38 @@ #include #include -#define BALANCE "balance" // 平衡模式 -#define PERFORMANCE "performance" // 高性能模式 -#define POWERSAVE "powersave" // 节能模式 +#define BALANCE "balance" // 平衡模式 +#define PERFORMANCE "performance" // 高性能模式 +#define BALANCEPERFORMANCE "balance_performance" // 高性能模式 +#define POWERSAVE "powersave" // 节能模式 using namespace DCC_NAMESPACE; DGUI_USE_NAMESPACE DWIDGET_USE_NAMESPACE +static QString get_translate(const QString &type) +{ + if (type == BALANCE) { + return QObject::tr("Auto adjust CPU operating frequency based on CPU load condition"); + } + if (type == BALANCEPERFORMANCE) { + return QObject::tr( + "Aggressively adjust CPU operating frequency based on CPU load condition"); + } + if (type == PERFORMANCE) { + return QObject::tr("Be good to imporving performance, but power consumption and heat " + "generation will increase"); + } + return QObject::tr("CPU always works under low frequency, will reduce power consumption"); +} + GeneralModule::GeneralModule(PowerModel *model, PowerWorker *work, QObject *parent) : PageModule("general", tr("General"), DIconTheme::findQIcon("dcc_general_purpose"), parent) , m_model(model) , m_work(work) { m_powerPlanMap.insert(BALANCE, tr("Balanced")); + m_powerPlanMap.insert(BALANCEPERFORMANCE, tr("Balance Performance")); m_powerPlanMap.insert(PERFORMANCE, tr("High Performance")); m_powerPlanMap.insert(POWERSAVE, tr("Power Saver")); @@ -77,8 +95,15 @@ void GeneralModule::initUI() QMap::iterator iter; for (iter = m_powerPlanMap.begin(); iter != m_powerPlanMap.end(); ++iter) { DStandardItem *powerPlanItem = new DStandardItem(iter.value()); + DStandardItem *powerPlanItemTip = new DStandardItem(::get_translate(iter.key())); + powerPlanItemTip->setEnabled(false); + powerPlanItemTip->setEditable(false); + powerPlanItemTip->setBackgroundRole(DPalette::Window); + powerPlanItemTip->setTextColorRole(DPalette::TextTips); + powerPlanItemTip->setSizeHint(QSize(-1, 20)); powerPlanItem->setData(iter.key(), PowerPlanRole); m_powerPlanModel->appendRow(powerPlanItem); + m_powerPlanModel->appendRow(powerPlanItemTip); } //  性能设置 @@ -94,7 +119,7 @@ void GeneralModule::initUI() powerplanListview->setModel(m_powerPlanModel); powerplanListview->setEditTriggers(QAbstractItemView::NoEditTriggers); powerplanListview->setBackgroundType( - DStyledItemDelegate::BackgroundType::ClipCornerBackground); + DStyledItemDelegate::BackgroundType::RoundedBackground); powerplanListview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); powerplanListview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); powerplanListview->setSelectionMode(QAbstractItemView::NoSelection); @@ -104,10 +129,10 @@ void GeneralModule::initUI() int row_count = m_powerPlanModel->rowCount(); if (!isSupport) { int cur_place = powerplanListview->currentIndex().row(); - for (int i = 0; i < row_count; ++i) { + for (int i = 0; i < row_count; i += 2) { QStandardItem *items = m_powerPlanModel->item(i, 0); if (items->data(PowerPlanRole).toString() == PERFORMANCE) { - m_powerPlanModel->removeRow(i); + m_powerPlanModel->removeRows(i, 2); if (cur_place == i || cur_place < 0) { powerplanListview->clicked(m_powerPlanModel->index(0, 0)); @@ -117,7 +142,7 @@ void GeneralModule::initUI() } } else { bool findHighPerform = false; - for (int i = 0; i < row_count; ++i) { + for (int i = 0; i < row_count; i += 2) { QStandardItem *items = m_powerPlanModel->item(i, 0); if (items->data(PowerPlanRole).toString() == PERFORMANCE) { findHighPerform = true; @@ -128,12 +153,55 @@ void GeneralModule::initUI() DStandardItem *powerPlanItem = new DStandardItem(m_powerPlanMap.value(PERFORMANCE)); powerPlanItem->setData(PERFORMANCE, PowerPlanRole); - m_powerPlanModel->insertRow(1, powerPlanItem); + if (row_count == 6) { + DStandardItem *powerPlanItemTip = + new DStandardItem(::get_translate(PERFORMANCE)); + m_powerPlanModel->insertRow(4, { powerPlanItem, powerPlanItemTip }); + } else { + DStandardItem *powerPlanItemTip = + new DStandardItem(::get_translate(PERFORMANCE)); + m_powerPlanModel->insertRow(2, { powerPlanItem, powerPlanItemTip }); + } } } }; onHighPerformanceSupportChanged(m_model->isHighPerformanceSupported()); + auto onBalancePerformanceSupportedChanged = [this, powerplanListview]( + const bool isSupport) { + int row_count = m_powerPlanModel->rowCount(); + if (!isSupport) { + int cur_place = powerplanListview->currentIndex().row(); + for (int i = 0; i < row_count; i += 2) { + QStandardItem *items = m_powerPlanModel->item(i, 0); + if (items->data(PowerPlanRole).toString() == BALANCEPERFORMANCE) { + m_powerPlanModel->removeRows(i, 2); + if (cur_place == i || cur_place < 0) { + powerplanListview->clicked(m_powerPlanModel->index(0, 0)); + } + break; + } + } + } else { + bool findBalancePerform = false; + for (int i = 0; i < row_count; i += 2) { + QStandardItem *items = m_powerPlanModel->item(i, 0); + if (items->data(PowerPlanRole).toString() == BALANCEPERFORMANCE) { + findBalancePerform = true; + break; + } + } + if (!findBalancePerform) { + DStandardItem *powerPlanItem = + new DStandardItem(m_powerPlanMap.value(BALANCEPERFORMANCE)); + powerPlanItem->setData(PERFORMANCE, PowerPlanRole); + DStandardItem *powerPlanItemTip = + new DStandardItem(::get_translate(BALANCEPERFORMANCE)); + m_powerPlanModel->insertRow(2, { powerPlanItem, powerPlanItemTip }); + } + } + }; + onBalancePerformanceSupportedChanged(m_model->isBalancePerformanceSupported()); connect(powerplanListview, &DListView::clicked, this, @@ -150,7 +218,7 @@ void GeneralModule::initUI() auto onCurPowerPlanChanged = [this](const QString &curPowerPlan) { int row_count = m_powerPlanModel->rowCount(); - for (int i = 0; i < row_count; ++i) { + for (int i = 0; i < row_count; i += 2) { QStandardItem *items = m_powerPlanModel->item(i, 0); if (items->data(PowerPlanRole).toString() == curPowerPlan) { items->setCheckState(Qt::Checked); @@ -220,7 +288,8 @@ void GeneralModule::initUI() sldLowerBrightness->slider()->setPageStep(10); sldLowerBrightness->slider()->setType(DCCSlider::Vernier); sldLowerBrightness->slider()->setTickPosition(QSlider::NoTicks); - sldLowerBrightness->slider()->setValue(m_model->powerSavingModeAutoBatteryPercentage() / 10); + sldLowerBrightness->slider()->setValue( + m_model->powerSavingModeAutoBatteryPercentage() / 10); sldLowerBrightness->setValueLiteral( QString("%1%").arg(m_model->powerSavingModeAutoBatteryPercentage())); diff --git a/translations/dde-control-center_en.ts b/translations/dde-control-center_en.ts index 57cbc2a2a4..a99cd3e551 100644 --- a/translations/dde-control-center_en.ts +++ b/translations/dde-control-center_en.ts @@ -1012,6 +1012,53 @@ + + dccV23::CustomRegionFormatDialog + + Custom format + + + + First day of week + + + + Short date + + + + Long date + + + + Short time + + + + Long time + + + + Currency symbol + + + + Numbers + + + + Paper + + + + Cancel + + + + Save + + + dccV23::DetailInfoItem @@ -1577,6 +1624,57 @@ + + dccV23::RegionFormatDialog + + Region format + + + + Default format + + + + First of day + + + + Short date + + + + Long date + + + + Short time + + + + Long time + + + + Currency symbol + + + + Numbers + + + + Paper + + + + Cancel + + + + Save + + + dccV23::RemoveUserDialog @@ -2083,16 +2181,12 @@ DatetimeModule - Date and Time + Time and Format DatetimeWorker - - Authentication is required to set the system timezone - - Authentication is required to change NTP server @@ -2420,29 +2514,6 @@ UnionTech Software is committed to research and improve the security, accuracy a - - FormatShowGrid - - Date - - - - Time - - - - Date and Time - - - - Number - - - - Currency - - - GeneralModule @@ -2453,6 +2524,10 @@ UnionTech Software is committed to research and improve the security, accuracy a Balanced + + Balance Performance + + High Performance @@ -2837,6 +2912,22 @@ UnionTech Software is committed to research and improve the security, accuracy a Error occurred when reading the configuration files of password rules! + + Auto adjust CPU operating frequency based on CPU load condition + + + + Aggressively adjust CPU operating frequency based on CPU load condition + + + + Be good to imporving performance, but power consumption and heat generation will increase + + + + CPU always works under low frequency, will reduce power consumption + + Activated @@ -2887,203 +2978,69 @@ UnionTech Software is committed to research and improve the security, accuracy a - RegionAndFormatModule - - Region and Format - - - - Monday - - - - monday - - - - April 5, 2020 - - - - April 5, 2020, Sunday - - - - Sunday, April 5, 2020 - - - - 2020/4/5 - - - - 2020-4-5 - - + RegionModule - 2020.4.5 + Region - 2020/04/05 + Country region - 2020-04-05 + Region format - 2020.04.05 + Provide localized services based on your country or region. - 20/4/5 + Country/region - 20-4-5 + Set the date and time format according to language and region options. - 20.4.5 + Languange and region - 9:40:07 + First day of week - 09:40:07 + Short date - 9:40 + Long date - 09:40 + Short time - Tuesday + Long time - Wednesday - - - - Thursday - - - - Friday - - - - Saturday - - - - Sunday - - - - Regional Setting - - - - * The setting of region will influence the formats of date, time, number and some other formats, it will be enabled on the next time of login - - - - Locale Show - - - - Time - - - - time - - - - Date - - - - 24-hour Time - - - - Short Time - - - - Long Time - - - - Weeks - - - - First Day of Week - - - - Short Date - - - - Long Date - - - - - RegionDialog - - Cancel - - - - Confirm - - - - Regional Setting - - - - Search - - - - - RegionFormatShowPage - - Default Format - - - - Date - - - - Time + Currency symbol - Date And Time + Numbers - Number + Paper - Currency + custom format diff --git a/translations/dde-control-center_zh_CN.ts b/translations/dde-control-center_zh_CN.ts index 28449231f2..5beef56731 100644 --- a/translations/dde-control-center_zh_CN.ts +++ b/translations/dde-control-center_zh_CN.ts @@ -1,6 +1,4 @@ - - - + AdapterModule @@ -2187,10 +2185,6 @@ DatetimeWorker - - Authentication is required to set the system timezone - 设置系统时区需要认证 - Authentication is required to change NTP server 修改时间服务器需要认证 @@ -2268,7 +2262,7 @@ In order to better use of face recognition, please pay attention to the followin "Biometric authentication" is a function for user identity authentication provided by UnionTech Software Technology Co., Ltd. Through "biometric authentication", the biometric data collected will be compared with that stored in the device, and the user identity will be verified based on the comparison result. -Please be noted that UnionTech Software will not collect or access your biometric information, which will be stored on your local device. Please only enable the biometric authentication in your personal device and use your own biometric information for related operations, and promptly disable or delete other people's biometric information on that device, otherwise you will bear the risk arising therefrom. +Please be noted that UnionTech Software will not collect or access your biometric information, which will be stored on your local device. Please only enable the biometric authentication in your personal device and use your own biometric information for related operations, and promptly disable or delete other people's biometric information on that device, otherwise you will bear the risk arising therefrom. UnionTech Software is committed to research and improve the security, accuracy and stability of biometric authentication. However, due to environmental, equipment, technical and other factors and risk control, there is no guarantee that you will pass the biometric authentication temporarily. Therefore, please do not take biometric authentication as the only way to log in to UnionTech OS. If you have any questions or suggestions when using the biometric authentication, you can give feedback through "Service and Support" in the UnionTech OS. “生物认证”是统信软件技术有限公司提供的一种对用户进行身份认证的功能。通过“生物认证”,将采集的生物识别数据与存储在设备本地的生物识别数据进行比对,并根据比对结果来验证用户身份。 @@ -2542,6 +2536,10 @@ UnionTech Software is committed to research and improve the security, accuracy a Balanced 平衡模式 + + Balance Performance + 性能模式 + High Performance 高性能模式 @@ -2926,6 +2924,22 @@ UnionTech Software is committed to research and improve the security, accuracy a Error occurred when reading the configuration files of password rules! 密码规则配置文件读取错误 + + Auto adjust CPU operating frequency based on CPU load condition + 根据负载情况自动调整运行频率 + + + Aggressively adjust CPU operating frequency based on CPU load condition + 根据负载情况积极调整运行频率 + + + Be good to imporving performance, but power consumption and heat generation will increase + 有利于增加性能,会显著提升功耗和发热 + + + CPU always works under low frequency, will reduce power consumption + 始终低频率运行,可降低功耗 + Activated 已激活