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
11 changes: 11 additions & 0 deletions configs/org.deepin.dde.session-shell.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@
"description[zh_CN]": "0:启用。1:禁用。2:隐藏",
"permissions": "readwrite",
"visibility": "private"
},
"systemReboot": {
"value": 0,
"serial": 0,
"flags": [],
"name": "system reboot",
"name[zh_CN]": "系统重启",
"description": "0:Enabled。1:Disabled。2:Hidden",
"description[zh_CN]": "0:启用。1:禁用。2:隐藏",
"permissions": "readwrite",
"visibility": "private"
}
}
}
8 changes: 7 additions & 1 deletion src/widgets/shutdownwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ShutdownWidget::ShutdownWidget(QWidget *parent)
onEnable("systemSuspend", enableState(DConfigWatcher::instance()->getStatus("systemSuspend")));
onEnable("systemHibernate", enableState(DConfigWatcher::instance()->getStatus("systemHibernate")));
onEnable("systemLock", enableState(DConfigWatcher::instance()->getStatus("systemLock")));
onEnable("systemReboot", enableState(DConfigWatcher::instance()->getStatus("systemReboot")));

std::function<void (QVariant)> function = std::bind(&ShutdownWidget::onOtherPageChanged, this, std::placeholders::_1);
int index = m_frameDataBind->registerFunction("ShutdownWidget", function);
Expand All @@ -50,6 +51,7 @@ ShutdownWidget::~ShutdownWidget()
DConfigWatcher::instance()->erase("systemSuspend");
DConfigWatcher::instance()->erase("systemHibernate");
DConfigWatcher::instance()->erase("systemShutdown");
DConfigWatcher::instance()->erase("systemReboot");
}

void ShutdownWidget::initConnect()
Expand Down Expand Up @@ -129,6 +131,9 @@ void ShutdownWidget::onEnable(const QString &key, bool enable)
m_requireHibernateButton->setCheckable(enable);
} else if ("systemLock" == key) {
m_requireLockButton->setDisabled(!enable);
} else if ("systemReboot" == key) {
m_requireRestartButton->setDisabled(!enable);
m_requireRestartButton->setCheckable(enable);
}
}

Expand Down Expand Up @@ -209,6 +214,7 @@ void ShutdownWidget::initUI()
m_requireRestartButton->setAccessibleName("RequireRestartButton");
m_requireRestartButton->setAutoExclusive(true);
updateTr(m_requireRestartButton, "Reboot");
DConfigWatcher::instance()->bind("systemReboot", m_requireRestartButton);

m_requireSuspendButton = new RoundItemButton(tr("Suspend"), this);
m_requireSuspendButton->setFocusPolicy(Qt::NoFocus);
Expand Down Expand Up @@ -456,7 +462,7 @@ void ShutdownWidget::recoveryLayout()
//关机或重启确认前会隐藏所有按钮,取消重启或关机后隐藏界面时重置按钮可见状态
//同时需要判断切换用户按钮是否允许可见
m_requireShutdownButton->setVisible(true && (DConfigWatcher::instance()->getStatus("systemShutdown") != Status_Hidden));
m_requireRestartButton->setVisible(true);
m_requireRestartButton->setVisible(DConfigWatcher::instance()->getStatus("systemReboot") != Status_Hidden);
enableHibernateBtn(m_model->hasSwap());
enableSleepBtn(m_model->canSleep());
m_requireLockButton->setVisible(true && (DConfigWatcher::instance()->getStatus("systemLock") != Status_Hidden));
Expand Down