mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat: shutdown plugin support hibernate
https://github.com/linuxdeepin/internal-discussion/issues/820 Change-Id: Ifa3b35ba6bab8677b5246cd9ecf2279877966891
This commit is contained in:
parent
e2a791eb4a
commit
60b5d9e0c2
Notes:
gerrit
2019-01-15 16:16:05 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+1: 流年匆忙 <justforlxz@gmail.com> Verified+1: liuwen123 <liuwen@linuxdeepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Tue, 15 Jan 2019 16:16:04 +0800 Reviewed-on: https://cr.deepin.io/41327 Project: dde/dde-dock Branch: refs/heads/master
@ -127,6 +127,14 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey)
|
||||
suspend["isActive"] = true;
|
||||
items.push_back(suspend);
|
||||
|
||||
if (checkSwap()) {
|
||||
QMap<QString, QVariant> hibernate;
|
||||
hibernate["itemId"] = "Hibernate";
|
||||
hibernate["itemText"] = tr("Hibernate");
|
||||
hibernate["isActive"] = true;
|
||||
items.push_back(hibernate);
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> lock;
|
||||
lock["itemId"] = "Lock";
|
||||
lock["itemText"] = tr("Lock");
|
||||
@ -222,3 +230,17 @@ void ShutdownPlugin::loadPlugin()
|
||||
m_proxyInter->itemAdded(this, pluginName());
|
||||
displayModeChanged(displayMode());
|
||||
}
|
||||
|
||||
bool ShutdownPlugin::checkSwap()
|
||||
{
|
||||
QFile file("/proc/swaps");
|
||||
if (file.open(QIODevice::Text | QIODevice::ReadOnly)) {
|
||||
const QString &body = file.readAll();
|
||||
file.close();
|
||||
QRegularExpression re("\\spartition\\s");
|
||||
QRegularExpressionMatch match = re.match(body);
|
||||
return match.hasMatch();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
void loadPlugin();
|
||||
bool checkSwap();
|
||||
|
||||
private:
|
||||
bool m_pluginLoaded;
|
||||
|
Loading…
x
Reference in New Issue
Block a user