mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 控制中心设置的电源选项任务栏未生效 (#779)
任务栏电源配置原来管理gsetting配置替换成dconfig配置 Log: 修复控制中心设置的电源选项任务栏未生效的问题 Bug: https://github.com/linuxdeepin/developer-center/issues/3768 Influence: 任务栏电池信息显示
This commit is contained in:
parent
16ca6eaee9
commit
4ebedb53d2
46
configs/org.deepin.dde.dock.power.json
Normal file
46
configs/org.deepin.dde.dock.power.json
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"magic": "dsg.config.meta",
|
||||||
|
"version": "1.0",
|
||||||
|
"contents": {
|
||||||
|
"control": {
|
||||||
|
"value": false,
|
||||||
|
"serial": 0,
|
||||||
|
"flags": [],
|
||||||
|
"name": "contorl",
|
||||||
|
"name[zh_CN]": "控制",
|
||||||
|
"description": "阻止鼠标事件",
|
||||||
|
"permissions": "readwrite",
|
||||||
|
"visibility": "private"
|
||||||
|
},
|
||||||
|
"enable": {
|
||||||
|
"value": true,
|
||||||
|
"serial": 0,
|
||||||
|
"flags": [],
|
||||||
|
"name": "enable",
|
||||||
|
"name[zh_CN]": "使能",
|
||||||
|
"description": "使能电源管理模块。",
|
||||||
|
"permissions": "readwrite",
|
||||||
|
"visibility": "private"
|
||||||
|
},
|
||||||
|
"showtimetofull":{
|
||||||
|
"value": true,
|
||||||
|
"serial": 0,
|
||||||
|
"flags": [],
|
||||||
|
"name": "showtimetofull",
|
||||||
|
"name[zh_CN]": "显示完整时间",
|
||||||
|
"description": "是否显示电池使用时间/剩余充电时间。",
|
||||||
|
"permissions": "readwrite",
|
||||||
|
"visibility": "public"
|
||||||
|
},
|
||||||
|
"menu-enable":{
|
||||||
|
"value": true,
|
||||||
|
"serial": 0,
|
||||||
|
"flags": [],
|
||||||
|
"name": "menu-enable",
|
||||||
|
"name[zh_CN]": "使能菜单",
|
||||||
|
"description": "使能菜单。",
|
||||||
|
"permissions": "readwrite",
|
||||||
|
"visibility": "private"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,16 +14,13 @@
|
|||||||
|
|
||||||
#include <DFontSizeManager>
|
#include <DFontSizeManager>
|
||||||
#include <DDBusSender>
|
#include <DDBusSender>
|
||||||
|
#include <DConfig>
|
||||||
|
|
||||||
#define PLUGIN_STATE_KEY "enable"
|
#define PLUGIN_STATE_KEY "enable"
|
||||||
#define DELAYTIME (20 * 1000)
|
#define DELAYTIME (20 * 1000)
|
||||||
|
|
||||||
|
DCORE_USE_NAMESPACE
|
||||||
using namespace Dock;
|
using namespace Dock;
|
||||||
static QGSettings *GSettingsByApp()
|
|
||||||
{
|
|
||||||
static QGSettings settings("com.deepin.dde.dock.module.power");
|
|
||||||
return &settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
PowerPlugin::PowerPlugin(QObject *parent)
|
PowerPlugin::PowerPlugin(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@ -33,6 +30,7 @@ PowerPlugin::PowerPlugin(QObject *parent)
|
|||||||
, m_tipsLabel(new TipsWidget)
|
, m_tipsLabel(new TipsWidget)
|
||||||
, m_systemPowerInter(nullptr)
|
, m_systemPowerInter(nullptr)
|
||||||
, m_powerInter(nullptr)
|
, m_powerInter(nullptr)
|
||||||
|
, m_dconfig(new DConfig(QString("org.deepin.dde.dock.power"), QString()))
|
||||||
, m_preChargeTimer(new QTimer(this))
|
, m_preChargeTimer(new QTimer(this))
|
||||||
, m_quickPanel(nullptr)
|
, m_quickPanel(nullptr)
|
||||||
{
|
{
|
||||||
@ -185,7 +183,7 @@ void PowerPlugin::loadPlugin()
|
|||||||
m_systemPowerInter = new SystemPowerInter("org.deepin.dde.Power1", "/org/deepin/dde/Power1", QDBusConnection::systemBus(), this);
|
m_systemPowerInter = new SystemPowerInter("org.deepin.dde.Power1", "/org/deepin/dde/Power1", QDBusConnection::systemBus(), this);
|
||||||
m_systemPowerInter->setSync(true);
|
m_systemPowerInter->setSync(true);
|
||||||
|
|
||||||
connect(GSettingsByApp(), &QGSettings::changed, this, &PowerPlugin::onGSettingsChanged);
|
connect(m_dconfig, &DConfig::valueChanged, this, &PowerPlugin::onGSettingsChanged);
|
||||||
connect(m_systemPowerInter, &SystemPowerInter::BatteryStatusChanged, [&](uint value) {
|
connect(m_systemPowerInter, &SystemPowerInter::BatteryStatusChanged, [&](uint value) {
|
||||||
if (value == BatteryState::CHARGING)
|
if (value == BatteryState::CHARGING)
|
||||||
m_preChargeTimer->start();
|
m_preChargeTimer->start();
|
||||||
@ -207,10 +205,8 @@ void PowerPlugin::onGSettingsChanged(const QString &key)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GSettingsByApp()->keys().contains("showtimetofull")) {
|
if (m_dconfig->isValid())
|
||||||
const bool isEnable = GSettingsByApp()->keys().contains("showtimetofull") && GSettingsByApp()->get("showtimetofull").toBool();
|
m_showTimeToFull = m_dconfig->value("showtimetofull").toBool();
|
||||||
m_showTimeToFull = isEnable && GSettingsByApp()->get("showtimetofull").toBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshTipsData();
|
refreshTipsData();
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
using SystemPowerInter = org::deepin::dde::Power1;
|
using SystemPowerInter = org::deepin::dde::Power1;
|
||||||
|
|
||||||
|
DCORE_BEGIN_NAMESPACE
|
||||||
|
class DConfig;
|
||||||
|
DCORE_END_NAMESPACE
|
||||||
|
|
||||||
namespace Dock {
|
namespace Dock {
|
||||||
class TipsWidget;
|
class TipsWidget;
|
||||||
}
|
}
|
||||||
@ -61,6 +66,7 @@ private:
|
|||||||
|
|
||||||
SystemPowerInter *m_systemPowerInter;
|
SystemPowerInter *m_systemPowerInter;
|
||||||
DBusPower *m_powerInter;
|
DBusPower *m_powerInter;
|
||||||
|
Dtk::Core::DConfig *m_dconfig; // 配置
|
||||||
QTimer *m_preChargeTimer;
|
QTimer *m_preChargeTimer;
|
||||||
QWidget *m_quickPanel;
|
QWidget *m_quickPanel;
|
||||||
QLabel *m_imageLabel;
|
QLabel *m_imageLabel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user