Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Description:gsetting配置控制是否显示屏保 RootCause:Null Solution:
- Loading branch information
zhangwencong
committed
Jul 20, 2020
1 parent
f9f052e
commit 189c582
Showing
8 changed files
with
67 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "screensavercontrol.h" | ||
|
||
#include <QDebug> | ||
#include <QProcess> | ||
#include <QDBusConnection> | ||
#include <QDBusMessage> | ||
#include <dgiosettings.h> | ||
|
||
#define DESKTOP_CAN_SCREENSAVER "DESKTOP_CAN_SCREENSAVER" | ||
|
||
bool needShowScreensaver() | ||
{ | ||
//1 判断环境变量 | ||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); | ||
if ((env.contains(DESKTOP_CAN_SCREENSAVER) && env.value(DESKTOP_CAN_SCREENSAVER).startsWith("N"))) | ||
{ | ||
qDebug() << "System environment variables do not support screen savers"; | ||
return false; | ||
} | ||
|
||
#ifndef DISABLE_SCREENSAVER | ||
//2 判断是否安装屏保程序 | ||
QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "ListActivatableNames"); | ||
QDBusMessage response = QDBusConnection::sessionBus().call(msg); | ||
if(response.type() == QDBusMessage::ReplyMessage | ||
&& response.arguments().takeFirst().toList().contains("com.deepin.ScreenSaver")){ | ||
qDebug() << "com.deepin.ScreenSaver is ok"; | ||
}else { | ||
qDebug() << "The screen saver is uninstalled"; | ||
return false; | ||
} | ||
#endif | ||
|
||
//3 Gsetting 判断屏保是否可用... | ||
DGioSettings desktopSettings("com.deepin.dde.filemanager.desktop", "/com/deepin/dde/filemanager/desktop/"); | ||
if (desktopSettings.keys().contains("show-screen-saver") && false == desktopSettings.value("show-screen-saver").toBool()) { | ||
qDebug() << "Gsetting show-screen-saver is false"; | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef SCREENSAVERCONTROL_H | ||
#define SCREENSAVERCONTROL_H | ||
|
||
|
||
bool needShowScreensaver(); | ||
|
||
#endif // SCREENSAVERCONTROL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters