fix:bug#132979 【用户反馈】【锁屏】系统不操作等待5分钟必进入锁屏(锁屏同步新的逻辑,跟随屏保设置
This commit is contained in:
parent
81fe730f0f
commit
2f63fea759
|
@ -33,16 +33,13 @@
|
|||
|
||||
BackThread::BackThread(QObject *parent) : QObject(parent)
|
||||
{
|
||||
cmdConnWifi = new QProcess(this);
|
||||
connect(cmdConnWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
|
||||
connect(cmdConnWifi , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
|
||||
cmdConnWifi->start("bash");
|
||||
cmdConnWifi->waitForStarted();
|
||||
}
|
||||
|
||||
BackThread::~BackThread()
|
||||
{
|
||||
cmdConnWifi->close();
|
||||
if (cmdConnWifi) {
|
||||
cmdConnWifi->close();
|
||||
}
|
||||
}
|
||||
|
||||
//get the connection state of wired and wireles network
|
||||
|
@ -278,7 +275,13 @@ void BackThread::execConnWifiPWD(QString connName, QString password)
|
|||
void BackThread::execConnWifi(QString connName)
|
||||
{
|
||||
//disConnLanOrWifi("wifi");
|
||||
|
||||
if (!cmdConnWifi) {
|
||||
cmdConnWifi = new QProcess(this);
|
||||
connect(cmdConnWifi , SIGNAL(readyReadStandardOutput()) , this , SLOT(on_readoutput()));
|
||||
connect(cmdConnWifi , SIGNAL(readyReadStandardError()) , this , SLOT(on_readerror()));
|
||||
cmdConnWifi->start("bash");
|
||||
cmdConnWifi->waitForStarted();
|
||||
}
|
||||
QString cmdStr = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection up \"" + connName.replace("\"","\\\"") + "\"\n";
|
||||
cmdConnWifi->write(cmdStr.toUtf8().data());
|
||||
}
|
||||
|
|
|
@ -71,15 +71,25 @@
|
|||
<description>Wait idle delay to lock</description>
|
||||
</key>
|
||||
<key name="idle-lock" type="i">
|
||||
<default>5</default>
|
||||
<default>-1</default>
|
||||
<summary>idle lock to lock</summary>
|
||||
<description>Display the lock screen</description>
|
||||
</key>
|
||||
<key name="lock-timeout" type="i">
|
||||
<default>10</default>
|
||||
<summary>screensaver with lock timeout</summary>
|
||||
<description>Display the screensaver with lock's timeout</description>
|
||||
</key>
|
||||
<key name="sleep-activation-enabled" type="b">
|
||||
<default>true</default>
|
||||
<summary>Lock when sleep</summary>
|
||||
<description>Set this to TRUE to lock the screen when the system goes sleep.</description>
|
||||
</key>
|
||||
<key name="close-activation-enabled" type="b">
|
||||
<default>true</default>
|
||||
<summary>Lock when close screen</summary>
|
||||
<description>Set this to TRUE to lock the screen when the screen goes close.</description>
|
||||
</key>
|
||||
<key name="mode" enum="org.ukui.screensaver.Mode">
|
||||
<default>'default-ukui'</default>
|
||||
<summary>Screensaver theme selection mode</summary>
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
ukui-screensaver (3.1.1.34update1-ok8) yangtze; urgency=medium
|
||||
|
||||
* BUG号:132979 【用户反馈】【锁屏】系统不操作等待5分钟必进入锁屏(锁屏同步新的逻辑,跟随屏保设置)
|
||||
* 需求号:无
|
||||
* 其他修改说明:无
|
||||
|
||||
-- Yang Min <yangmin@kylinos.cn> Thu, 11 Aug 2022 10:08:54 +0800
|
||||
|
||||
ukui-screensaver (3.1.1.34update1-ok7.1) yangtze; urgency=medium
|
||||
|
||||
* BUG号: 129308 【网络】输入密码界面点击网络连接,网络图标显示错误,显示的是未连接状态
|
||||
|
|
|
@ -5,3 +5,7 @@ set -e
|
|||
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas/
|
||||
|
||||
if [ -x /usr/share/kylin-system-updater/kylin-reboot-required ]; then
|
||||
#执行请求重启提示
|
||||
/usr/share/kylin-system-updater/kylin-reboot-required
|
||||
fi
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#define XSCREENSAVER_DIRNAME "/usr/lib/xscreensaver"
|
||||
#define KEY_IDLE_DELAY "idleDelay"
|
||||
#define KEY_IDLE_LOCK "idleLock"
|
||||
#define KEY_LOCK_TIMEOUT "lockTimeout"
|
||||
|
||||
Configuration* Configuration::instance_ = nullptr;
|
||||
|
||||
|
@ -52,13 +53,13 @@ Configuration::Configuration(QObject *parent) : QObject(parent)
|
|||
/* Initiailization */
|
||||
mode = gsettings->get(KEY_MODE).toString();
|
||||
themes = gsettings->get(KEY_THEMES).toStringList();
|
||||
idleDelay = gsettings->get(
|
||||
KEY_IDLE_DELAY).toInt();
|
||||
idleDelay = gsettings->get(KEY_IDLE_DELAY).toInt();
|
||||
lockEnabled = gsettings->get(KEY_LOCK_ENABLED).toBool();
|
||||
idleLock = gsettings->get(KEY_IDLE_LOCK).toInt();
|
||||
imageSwitchInterval = gsettings->get(KEY_IMAGE_SWITCH_INTERVAL).toInt();
|
||||
imageTSEffect = gsettings->get(KEY_IMAGE_TRANSITION_EFFECT).toInt();
|
||||
background = gsettings->get(KEY_BACKGROUND).toString();
|
||||
m_nLockTimeout = gsettings->get(KEY_LOCK_TIMEOUT).toInt();
|
||||
|
||||
qDebug() << mode << themes;
|
||||
qDebug() << imageSwitchInterval << imageTSEffect;
|
||||
|
@ -119,6 +120,8 @@ void Configuration::onConfigurationChanged(QString key)
|
|||
imageTSEffect = gsettings->get(KEY_IMAGE_TRANSITION_EFFECT).toInt();
|
||||
else if(key == KEY_IMAGE_SWITCH_INTERVAL)
|
||||
imageSwitchInterval = gsettings->get(KEY_IMAGE_SWITCH_INTERVAL).toInt();
|
||||
else if (key == KEY_LOCK_TIMEOUT)
|
||||
m_nLockTimeout = gsettings->get(KEY_LOCK_TIMEOUT).toInt();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -206,12 +209,22 @@ QString Configuration::getBackground()
|
|||
return "/usr/share/backgrounds/1-openkylin.jpg";
|
||||
}
|
||||
|
||||
int Configuration::xscreensaverActivatedWhenIdle()
|
||||
{
|
||||
return idleDelay;
|
||||
}
|
||||
|
||||
bool Configuration::lockWhenXScreensaverActivated()
|
||||
{
|
||||
return lockEnabled;
|
||||
}
|
||||
|
||||
int Configuration::idlelock()
|
||||
{
|
||||
return idleLock;
|
||||
}
|
||||
|
||||
int Configuration::idledelay()
|
||||
{
|
||||
return idleDelay;
|
||||
}
|
||||
|
||||
int Configuration::locktimeout()
|
||||
{
|
||||
return m_nLockTimeout;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,10 @@ public:
|
|||
ScreenSaver *getScreensaver();
|
||||
static Configuration *instance(QObject *parent = nullptr);
|
||||
QString getBackground();
|
||||
int xscreensaverActivatedWhenIdle();
|
||||
bool lockWhenXScreensaverActivated();
|
||||
int idlelock();
|
||||
int idledelay();
|
||||
int locktimeout();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConfigurationChanged(QString key);
|
||||
|
@ -56,11 +58,12 @@ private:
|
|||
QString background;
|
||||
bool idleActivationEnabled;
|
||||
bool lockEnabled;
|
||||
int idleDelay;
|
||||
int idleLock;
|
||||
int idleDelay = -1;
|
||||
int idleLock = -1;
|
||||
int imageTSEffect;
|
||||
int imageSwitchInterval;
|
||||
static Configuration *instance_;
|
||||
int m_nLockTimeout = -1;
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_H
|
||||
|
|
|
@ -76,10 +76,6 @@ extern void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool qual
|
|||
QT_END_NAMESPACE
|
||||
|
||||
#define BLUR_RADIUS 300
|
||||
#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver"
|
||||
#define KEY_IDLE_DELAY "idleDelay"
|
||||
#define KEY_IDLE_LOCK "idleLock"
|
||||
#define KEY_IDLE_LOCK_ENABLED "idleLockEnabled"
|
||||
|
||||
QPixmap scaledPixmap(int width, int height, QString url)
|
||||
{
|
||||
|
@ -236,33 +232,17 @@ FullBackgroundWidget::FullBackgroundWidget(QWidget *parent)
|
|||
SS_DBUS_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
connect(interfaceScreensaver, SIGNAL(SessionIdle()),
|
||||
this, SLOT(showScreensaver()));
|
||||
connect(interfaceScreensaver, SIGNAL(SecondRunParam(QString)),
|
||||
this, SLOT(onSecondRunParam(QString)));
|
||||
// 闲置不会主动锁住
|
||||
// QDBusInterface *interfaceLock = new QDBusInterface(
|
||||
// SS_DBUS_SERVICE,
|
||||
// SS_DBUS_PATH,
|
||||
// SS_DBUS_INTERFACE,
|
||||
// QDBusConnection::sessionBus());
|
||||
|
||||
settings_delay = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
connect(settings_delay, &QGSettings::changed,
|
||||
this, &FullBackgroundWidget::onConfigurationDelayChanged);
|
||||
idleDelay = settings_delay->get("idle-delay").toInt();
|
||||
qDebug()<<"idleDelay="<<idleDelay;
|
||||
settings_lock = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
connect(settings_lock, &QGSettings::changed,
|
||||
this, &FullBackgroundWidget::onConfigurationLockChanged);
|
||||
idleLock = settings_lock->get("idle-lock").toInt();
|
||||
|
||||
// lockEnabled_Key = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
// connect(lockEnabled_Key, &QGSettings::changed,
|
||||
// this, &FullBackgroundWidget::lockEnabledChanged);
|
||||
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
|
||||
// qDebug()<<lockEnabled;
|
||||
|
||||
QDBusInterface *interfaceLock = new QDBusInterface(
|
||||
SS_DBUS_SERVICE,
|
||||
SS_DBUS_PATH,
|
||||
SS_DBUS_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
connect(interfaceLock, SIGNAL(SessionLockIdle()),
|
||||
this, SLOT(showLock()));
|
||||
// connect(interfaceLock, SIGNAL(SessionLockIdle()),
|
||||
// this, SLOT(showLock()));
|
||||
#ifdef USE_INTEL
|
||||
QDBusConnection::systemBus().connect("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", "PropertiesChanged",
|
||||
this, SLOT(propertiesChangedSlot(QString, QMap<QString, QVariant>, QStringList)));
|
||||
|
@ -325,27 +305,6 @@ void FullBackgroundWidget::laterActivate()
|
|||
lockWidget->setFocus();
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onConfigurationDelayChanged(QString key)
|
||||
{
|
||||
if(key == KEY_IDLE_DELAY){
|
||||
idleDelay = settings_delay->get("idle-delay").toInt();
|
||||
}
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onConfigurationLockChanged(QString key)
|
||||
{
|
||||
if(key == KEY_IDLE_LOCK){
|
||||
idleLock = settings_lock->get("idle-lock").toInt();
|
||||
}
|
||||
}
|
||||
|
||||
//void FullBackgroundWidget::lockEnabledChanged(QString key)
|
||||
//{
|
||||
// if(key == KEY_IDLE_LOCK_ENABLED){
|
||||
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
|
||||
// }
|
||||
//}
|
||||
|
||||
void FullBackgroundWidget::setLockState()
|
||||
{
|
||||
if(lockState == true)
|
||||
|
@ -393,6 +352,12 @@ void FullBackgroundWidget::killWindow()
|
|||
void FullBackgroundWidget::setIsStartup(bool val)
|
||||
{
|
||||
isStartup = val;
|
||||
Q_EMIT StartupModeChanged(isStartup);
|
||||
}
|
||||
|
||||
bool FullBackgroundWidget::IsStartupMode()
|
||||
{
|
||||
return isStartup;
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::paintEvent(QPaintEvent *event)
|
||||
|
@ -436,7 +401,8 @@ void FullBackgroundWidget::paintEvent(QPaintEvent *event)
|
|||
void FullBackgroundWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
qDebug() << "FullBackgroundWidget::closeEvent";
|
||||
|
||||
if (isStartup)
|
||||
setIsStartup(false);
|
||||
#ifdef USE_INTEL
|
||||
//蓝牙连接后 唤醒信号会有延迟 以防退出时未收到信号导致kwin compositor未resume
|
||||
QDBusInterface *interface = new QDBusInterface("org.ukui.KWin",
|
||||
|
@ -705,6 +671,18 @@ void FullBackgroundWidget::showLockWidget()
|
|||
repaint();
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onSecondRunParam(QString strParam)
|
||||
{
|
||||
qDebug()<<"onSecondRunParam:"<<strParam;
|
||||
if (strParam == "SessionIdle") {
|
||||
showScreensaver();
|
||||
} else if (strParam == "SleepLock") {
|
||||
showLock();
|
||||
} else if (strParam == "CloseLock") {
|
||||
showLock();
|
||||
}
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::showScreensaver()
|
||||
{
|
||||
if(screenStatus & SCREEN_SAVER){
|
||||
|
@ -747,10 +725,13 @@ void FullBackgroundWidget::showScreensaver()
|
|||
lockWidget->stopAuth();
|
||||
lockWidget->hide();
|
||||
}
|
||||
// 延迟启动锁屏
|
||||
delayLockScreen();
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::clearScreensavers()
|
||||
{
|
||||
stopDelayLockScreen();
|
||||
#ifdef USE_INTEL
|
||||
screenStatus = /*(ScreenStatus)(screenStatus & ~SCREEN_SAVER)*/SCREEN_LOCK;
|
||||
#else
|
||||
|
@ -785,7 +766,7 @@ int FullBackgroundWidget::onSessionStatusChanged(uint status)
|
|||
}
|
||||
qDebug() << "onSessionStatusChanged - screenStatus: " << screenStatus;
|
||||
|
||||
if(!configuration->xscreensaverActivatedWhenIdle())
|
||||
if(configuration->idledelay() == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -812,28 +793,42 @@ int FullBackgroundWidget::onSessionStatusChanged(uint status)
|
|||
showLockWidget();
|
||||
showScreensaver();
|
||||
#else
|
||||
if(configuration->xscreensaverActivatedWhenIdle() != -1 && configuration->lockWhenXScreensaverActivated())
|
||||
{
|
||||
//显示锁屏和屏保
|
||||
showLockWidget();
|
||||
showScreensaver();
|
||||
}
|
||||
else if(configuration->xscreensaverActivatedWhenIdle() != -1)
|
||||
{
|
||||
if( idleDelay == idleLock && idleLock != -1){
|
||||
//显示锁屏和屏保
|
||||
showLockWidget();
|
||||
showScreensaver();
|
||||
}else{
|
||||
//只显示屏保
|
||||
showScreensaver();
|
||||
}
|
||||
}
|
||||
//显示屏保
|
||||
showScreensaver();
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::delayLockScreen()
|
||||
{
|
||||
if (!m_timerLock) {
|
||||
m_timerLock = new QTimer(this);
|
||||
connect(m_timerLock, &QTimer::timeout, this, &FullBackgroundWidget::onLockScreenTimeout);
|
||||
}
|
||||
qDebug()<<"LockTimeout:"<<configuration->locktimeout();
|
||||
if (configuration->locktimeout() != -1) {
|
||||
stopDelayLockScreen();
|
||||
m_timerLock->start(configuration->locktimeout()*1000);
|
||||
}
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::stopDelayLockScreen()
|
||||
{
|
||||
if (m_timerLock && m_timerLock->isActive()) {
|
||||
m_timerLock->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onLockScreenTimeout()
|
||||
{
|
||||
qDebug()<<"onLockScreenTimeout:"<<configuration->lockWhenXScreensaverActivated();
|
||||
if (configuration->lockWhenXScreensaverActivated()) {
|
||||
showLock();
|
||||
}
|
||||
m_timerLock->stop();
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onBlankScreensaver()
|
||||
{
|
||||
showLockWidget();
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
void onBlankScreensaver();
|
||||
void closeScreensaver();
|
||||
void setIsStartup(bool val);
|
||||
bool IsStartupMode();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onCursorMoved(const QPoint &pos);
|
||||
|
@ -62,6 +63,7 @@ public Q_SLOTS:
|
|||
void showLockWidget();
|
||||
void showLock();
|
||||
void showScreensaver();
|
||||
void onSecondRunParam(QString strParam);
|
||||
int onSessionStatusChanged(uint status);
|
||||
void inhibit();
|
||||
void uninhibit();
|
||||
|
@ -69,6 +71,10 @@ public Q_SLOTS:
|
|||
void propertiesChangedSlot(QString, QMap<QString, QVariant>, QStringList);
|
||||
void onShowBlackBackGround();
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void StartupModeChanged(bool isStartup);
|
||||
|
||||
private:
|
||||
void init();
|
||||
void clearScreensavers();
|
||||
|
@ -77,6 +83,8 @@ private:
|
|||
QPixmap getPaddingPixmap(QPixmap pixmap, int width, int height);
|
||||
// void checkNumLock();
|
||||
// int numberMatch(const QString &key);
|
||||
void delayLockScreen();
|
||||
void stopDelayLockScreen();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onScreenCountChanged(int);
|
||||
|
@ -92,9 +100,7 @@ private Q_SLOTS:
|
|||
void killWindow();
|
||||
void laterInhibit(bool val);
|
||||
void laterStartAuth();
|
||||
void onConfigurationDelayChanged(QString key);
|
||||
void onConfigurationLockChanged(QString key);
|
||||
// void lockEnabledChanged(QString key);
|
||||
void onLockScreenTimeout();
|
||||
|
||||
private:
|
||||
QDBusInterface *smInterface;
|
||||
|
@ -117,15 +123,12 @@ private:
|
|||
bool isPassed;
|
||||
bool m_delay;
|
||||
int isBlank;
|
||||
QGSettings *settings_delay;
|
||||
QGSettings *settings_lock;
|
||||
QGSettings *lockEnabled_Key;
|
||||
QProcess *process = nullptr;
|
||||
int idleDelay;
|
||||
int idleLock;
|
||||
bool lockEnabled;
|
||||
bool isStartup = false;
|
||||
QFuture<void> future;
|
||||
|
||||
QTimer *m_timerLock = nullptr;
|
||||
};
|
||||
|
||||
#endif // FULLBACKGROUNDWIDGET_H
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <unistd.h>
|
||||
#include <QDBusPendingReply>
|
||||
#include <QGSettings>
|
||||
#include <QDBusReply>
|
||||
#include <signal.h>
|
||||
#include <QFileInfo>
|
||||
#include <unistd.h>
|
||||
|
@ -32,7 +33,6 @@
|
|||
Interface::Interface(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_timerCount(0),
|
||||
settings(nullptr),
|
||||
m_timer(nullptr)
|
||||
{
|
||||
lockState = false;
|
||||
|
@ -56,8 +56,6 @@ Interface::Interface(QObject *parent)
|
|||
[=](int exitCode, QProcess::ExitStatus exitStatus){
|
||||
emitLockState(false);
|
||||
});
|
||||
|
||||
settings = new QGSettings("org.ukui.screensaver","",this);
|
||||
|
||||
QDBusInterface *iface = new QDBusInterface("org.freedesktop.login1",
|
||||
"/org/freedesktop/login1",
|
||||
|
@ -65,8 +63,43 @@ Interface::Interface(QObject *parent)
|
|||
QDBusConnection::systemBus(),
|
||||
this);
|
||||
connect(iface, SIGNAL(PrepareForSleep(bool)), this, SLOT(onPrepareForSleep(bool)));
|
||||
inhibit();
|
||||
|
||||
// 监听一些会话状态
|
||||
m_sessionWatcher = new SessionWatcher(this);
|
||||
connect(m_sessionWatcher, &SessionWatcher::sessionIdle,
|
||||
this, &Interface::onSessionIdleReceived);
|
||||
// connect(m_sessionWatcher, &SessionWatcher::sessionLockIdle,
|
||||
// this, &Interface::Lock);
|
||||
connect(m_sessionWatcher, &SessionWatcher::sessionIdle,
|
||||
this, [=](){
|
||||
QDBusMessage message;
|
||||
message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
SS_DBUS_INTERFACE,
|
||||
"SecondRunParam");
|
||||
message<<"SessionIdle";
|
||||
QDBusConnection::sessionBus().send(message);
|
||||
});
|
||||
// connect(m_sessionWatcher, &SessionWatcher::sessionLockIdle,
|
||||
// this, [=](){
|
||||
// QDBusMessage message;
|
||||
// message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
// SS_DBUS_INTERFACE,
|
||||
// "SessionLockIdle");
|
||||
// QDBusConnection::sessionBus().send(message);
|
||||
// });
|
||||
connect(m_sessionWatcher, &SessionWatcher::sessionIdleExit,
|
||||
this, &Interface::onSessionIdleExit);
|
||||
connect(m_sessionWatcher, &SessionWatcher::lidStateChanged,
|
||||
this, &Interface::onLidStateChaned);
|
||||
|
||||
// 监听关屏信号
|
||||
QDBusConnection::sessionBus().connect(QString(),
|
||||
"/",
|
||||
"ukui.power.manager",
|
||||
"TurnOffDisplay",
|
||||
this,
|
||||
SLOT(onScreenClosed(bool)));
|
||||
inhibit();
|
||||
}
|
||||
|
||||
bool Interface::GetSlpState()
|
||||
|
@ -113,8 +146,9 @@ void Interface::UnLock()
|
|||
|
||||
void Interface::Lock()
|
||||
{
|
||||
if(process.state() != QProcess::NotRunning)
|
||||
if(process.state() != QProcess::NotRunning) {
|
||||
return ;
|
||||
}
|
||||
qDebug() << "Lock requested";
|
||||
lockState = false;
|
||||
QString cmd = QString("/usr/bin/ukui-screensaver-dialog --lock");
|
||||
|
@ -126,6 +160,11 @@ void Interface::Lock()
|
|||
|
||||
void Interface::onSessionIdleReceived()
|
||||
{
|
||||
qDebug()<<"onSessionIdleReceived--------";
|
||||
if (!checkStatus(SESSION_STATUS_SCREENSAVER)) {
|
||||
qDebug()<<"m_nStatus:"<<m_nStatus<<" can't do screensaver!";
|
||||
return ;
|
||||
}
|
||||
if(process.state() != QProcess::NotRunning)
|
||||
return ;
|
||||
|
||||
|
@ -139,8 +178,15 @@ void Interface::onSessionIdleReceived()
|
|||
|
||||
void Interface::onShowBlankScreensaver()
|
||||
{
|
||||
if(process.state() != QProcess::NotRunning)
|
||||
if(process.state() != QProcess::NotRunning) {
|
||||
QDBusMessage message;
|
||||
message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
SS_DBUS_INTERFACE,
|
||||
"SecondRunParam");
|
||||
message<<"SleepLock";
|
||||
QDBusConnection::sessionBus().send(message);
|
||||
return ;
|
||||
}
|
||||
|
||||
qDebug() << "lock and show screensaver";
|
||||
lockState = false;
|
||||
|
@ -229,13 +275,15 @@ bool Interface::checkScreenDialogRunning()
|
|||
|
||||
void Interface::onPrepareForSleep(bool sleep)
|
||||
{
|
||||
qDebug()<<"onPrepareForSleep:"<<sleep<<"--------";
|
||||
if(sleep)
|
||||
{
|
||||
if (checkScreenDialogRunning()) {
|
||||
if (!checkStatus(SESSION_STATUS_SLEEPED)) {
|
||||
uninhibit();
|
||||
return;
|
||||
}
|
||||
if(!settings->get("sleep-activation-enabled").toBool()){
|
||||
|
||||
if (checkScreenDialogRunning()) {
|
||||
uninhibit();
|
||||
return;
|
||||
}
|
||||
|
@ -252,7 +300,7 @@ void Interface::onPrepareForSleep(bool sleep)
|
|||
|
||||
this->onShowBlankScreensaver();
|
||||
|
||||
if(!m_timer){
|
||||
if(!m_timer){
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, &QTimer::timeout, this, [&]{
|
||||
m_timerCount+=1;
|
||||
|
@ -268,10 +316,48 @@ void Interface::onPrepareForSleep(bool sleep)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_nStatus &= ~SESSION_STATUS_SLEEPED;
|
||||
inhibit();
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::onSessionIdleExit()
|
||||
{
|
||||
qDebug()<<"onSessionIdleExit--------";
|
||||
m_nStatus &= ~SESSION_STATUS_SCREENSAVER;
|
||||
m_nStatus &= ~SESSION_STATUS_SCREENCLOSE;
|
||||
}
|
||||
|
||||
void Interface::onScreenClosed(bool state)
|
||||
{
|
||||
qDebug()<<"onScreenClosed:"<<state<<"------";
|
||||
if (state) {
|
||||
if (!checkStatus(SESSION_STATUS_SCREENCLOSE)) {
|
||||
qDebug()<<"m_nStatus:"<<m_nStatus<<" can't do screenclose lock!";
|
||||
return ;
|
||||
}
|
||||
if(process.state() != QProcess::NotRunning) {
|
||||
QDBusMessage message;
|
||||
message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
SS_DBUS_INTERFACE,
|
||||
"SecondRunParam");
|
||||
message<<"CloseLock";
|
||||
QDBusConnection::sessionBus().send(message);
|
||||
return ;
|
||||
}
|
||||
Lock();
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::onLidStateChaned(bool isClosed)
|
||||
{
|
||||
if (!isClosed) {
|
||||
if (m_sessionWatcher->isLidCloseWithBlank()) {
|
||||
m_nStatus &= ~SESSION_STATUS_SCREENCLOSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::ShowScreensaver()
|
||||
{
|
||||
if(process.state() != QProcess::NotRunning)
|
||||
|
@ -315,3 +401,54 @@ void Interface::uninhibit()
|
|||
|
||||
m_inhibitFileDescriptor = QDBusUnixFileDescriptor();
|
||||
}
|
||||
|
||||
bool Interface::checkStatus(int nStatus)
|
||||
{
|
||||
if (!m_sessionWatcher) {
|
||||
return false;
|
||||
}
|
||||
switch (nStatus) {
|
||||
case SESSION_STATUS_SLEEPED:
|
||||
{
|
||||
m_nStatus |= nStatus;
|
||||
if (!m_sessionWatcher->isSleepActivationEnable()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SESSION_STATUS_SCREENCLOSE:
|
||||
{
|
||||
m_nStatus |= nStatus;
|
||||
if ((m_nStatus&SESSION_STATUS_SLEEPED) || !m_sessionWatcher->isCloseActivationEnable()) {
|
||||
return false;
|
||||
}
|
||||
if (((m_sessionWatcher->closeActivationDelay() == m_sessionWatcher->sleepActivationDelay())
|
||||
&& m_sessionWatcher->sleepActivationDelay() != -1) && !m_sessionWatcher->isSleepActivationEnable()) {
|
||||
qDebug()<<"Sleep same with Close and Sleep disable!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SESSION_STATUS_SCREENSAVER:
|
||||
{
|
||||
m_nStatus |= nStatus;
|
||||
if ((m_nStatus&SESSION_STATUS_SLEEPED) || (m_nStatus&SESSION_STATUS_SCREENCLOSE)) {
|
||||
return false;
|
||||
}
|
||||
if (((m_sessionWatcher->idledelay()*60 == m_sessionWatcher->sleepActivationDelay())
|
||||
&& m_sessionWatcher->sleepActivationDelay() != -1) && !m_sessionWatcher->isSleepActivationEnable()) {
|
||||
qDebug()<<"Sleep same with idle and Sleep disable!";
|
||||
return false;
|
||||
}
|
||||
if (((m_sessionWatcher->idledelay()*60 == m_sessionWatcher->closeActivationDelay())
|
||||
&& m_sessionWatcher->closeActivationDelay() != -1) && !m_sessionWatcher->isCloseActivationEnable()) {
|
||||
qDebug()<<"Close same with idle and Close disable!";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QDBusUnixFileDescriptor>
|
||||
#include "types.h"
|
||||
#include "logind.h"
|
||||
#include "sessionwatcher.h"
|
||||
|
||||
class QGSettings;
|
||||
class Interface : public QObject, protected QDBusContext
|
||||
|
@ -34,10 +35,13 @@ class Interface : public QObject, protected QDBusContext
|
|||
Q_CLASSINFO("D-Bus Interface", SS_DBUS_SERVICE)
|
||||
|
||||
public:
|
||||
enum {
|
||||
SESSION_STATUS_SCREENSAVER = 1, // 屏保
|
||||
SESSION_STATUS_SCREENCLOSE = 2, // 关屏
|
||||
SESSION_STATUS_SLEEPED = 4, // 休眠/睡眠
|
||||
};
|
||||
explicit Interface(QObject *parent = nullptr);
|
||||
LogindIntegration *m_logind;
|
||||
Q_SIGNALS:
|
||||
void SessionIdle();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
|
@ -55,18 +59,25 @@ public Q_SLOTS:
|
|||
void onNameLost(const QString&);
|
||||
void onPrepareForSleep(bool sleep);
|
||||
bool checkScreenDialogRunning();
|
||||
|
||||
void onSessionIdleExit();
|
||||
void onScreenClosed(bool state);
|
||||
void onLidStateChaned(bool isClosed);
|
||||
|
||||
private:
|
||||
bool checkExistChild();
|
||||
void inhibit();
|
||||
void uninhibit();
|
||||
void emitLockState(bool);
|
||||
bool checkStatus(int nStatus);
|
||||
|
||||
private:
|
||||
bool lockState;
|
||||
bool slpState;
|
||||
void emitLockState(bool);
|
||||
int m_timerCount;
|
||||
QGSettings *settings;
|
||||
SessionWatcher *m_sessionWatcher = nullptr;
|
||||
QTimer *m_timer;
|
||||
QDBusUnixFileDescriptor m_inhibitFileDescriptor;
|
||||
int m_nStatus = 0; // 当前状态
|
||||
|
||||
private:
|
||||
QProcess process;
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
</signal>
|
||||
<signal name="unlock">
|
||||
</signal>
|
||||
<signal name="SecondRunParam">
|
||||
<arg name="param" type="s" />
|
||||
</signal>
|
||||
<method name="Lock">
|
||||
</method>
|
||||
<method name="ShowScreensaver">
|
||||
|
|
|
@ -357,10 +357,18 @@ pam_modutil_read(int fd, char *buffer, int count)
|
|||
|
||||
void get_tally(uid_t uid, int *tfile, struct tallylog *tally)
|
||||
{
|
||||
char filename[50]={0};
|
||||
sprintf(filename,"%s","/tmp/.tallylog");
|
||||
char filename[50]={0};
|
||||
sprintf(filename,"/tmp/.tallylog.d/.%d",uid);
|
||||
fprintf(stderr,"new_filename = :%s \n",filename);
|
||||
void *void_tally = tally;
|
||||
|
||||
void *void_tally = tally;
|
||||
if ((*tfile = open(filename, O_RDONLY)) == -1){
|
||||
if(uid >= 0) {
|
||||
fprintf(stderr, "lseek tallylog failed,Re-open the new file, uid = %d \n",uid);
|
||||
sprintf(filename,"/tmp/.tallylog");
|
||||
fprintf(stderr,"old_filename = :%s \n",filename);
|
||||
}
|
||||
}
|
||||
if ((*tfile = open(filename, O_RDONLY)) == -1){
|
||||
fprintf(stderr, "open tallylog failed \n");
|
||||
return ;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <QDBusInterface>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QDBusReply>
|
||||
#include "types.h"
|
||||
|
||||
#define GSETTINGS_SCHEMA_SCREENSAVER "org.ukui.screensaver"
|
||||
|
@ -28,6 +29,12 @@
|
|||
#define KEY_IDLE_LOCK_ENABLED "idleLockEnabled"
|
||||
#define TIME_TYPE_SCHEMA "org.ukui.control-center.panel.plugins"
|
||||
|
||||
#define POWER_TYPE_SCHENA "org.ukui.power-manager"
|
||||
#define FREEDESKTOP_UPOWER "org.freedesktop.DBus.Properties"
|
||||
#define UPOWER_PATH "/org/freedesktop/UPower"
|
||||
#define UPOWER_SERVICE "org.freedesktop.UPower"
|
||||
#define UPOWER_DISPLAY_PATH "/org/freedesktop/UPower/devices/DisplayDevice"
|
||||
|
||||
SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
|
||||
{
|
||||
sessionPath = qgetenv("XDG_SESSION_PATH");
|
||||
|
@ -36,7 +43,7 @@ SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
|
|||
SM_DBUS_SERVICE,
|
||||
SM_DBUS_PATH,
|
||||
SM_DBUS_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
QDBusConnection::sessionBus(), this);
|
||||
|
||||
connect(interface, SIGNAL(StatusChanged(unsigned int)),
|
||||
this, SLOT(onStatusChanged(unsigned int)));
|
||||
|
@ -45,19 +52,53 @@ SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
|
|||
DM_DBUS_SERVICE,
|
||||
DM_DBUS_PATH,
|
||||
DM_DBUS_INTERFACE,
|
||||
QDBusConnection::systemBus());
|
||||
QDBusConnection::systemBus(), this);
|
||||
connect(displayManagerInterface, SIGNAL(SessionRemoved(QDBusObjectPath)),
|
||||
this, SLOT(onSessionRemoved(QDBusObjectPath)));
|
||||
|
||||
settings_delay = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
connect(settings_delay, &QGSettings::changed,
|
||||
this, &SessionWatcher::onConfigurationDelayChanged);
|
||||
idleDelay = settings_delay->get("idle-delay").toInt();
|
||||
QStringList keysScreenSaver;
|
||||
if(QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_SCREENSAVER)){
|
||||
m_ssSettings = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
connect(m_ssSettings, &QGSettings::changed,
|
||||
this, &SessionWatcher::onSSConfigChanged);
|
||||
// 重置锁屏时间(不处理超时锁屏220620)
|
||||
keysScreenSaver = m_ssSettings->keys();
|
||||
if (keysScreenSaver.contains(KEY_IDLE_LOCK)) {
|
||||
m_ssSettings->set("idle-lock", -1);
|
||||
}
|
||||
idleDelay = m_ssSettings->get("idle-delay").toInt();
|
||||
idleLock = m_ssSettings->get("idle-lock").toInt();
|
||||
}
|
||||
|
||||
settings_lock = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
connect(settings_lock, &QGSettings::changed,
|
||||
this, &SessionWatcher::onConfigurationLockChanged);
|
||||
idleLock = settings_lock->get("idle-lock").toInt();
|
||||
// for PowerManager
|
||||
// 同步旧的电源管理唤醒是否需密码配置
|
||||
FILE *fp = NULL;
|
||||
fp = popen("xset s 0 0", "r");
|
||||
fclose(fp);
|
||||
|
||||
if(QGSettings::isSchemaInstalled(POWER_TYPE_SCHENA)){
|
||||
m_pmSettings = new QGSettings(POWER_TYPE_SCHENA,"", this);
|
||||
QStringList keys = m_pmSettings->keys();
|
||||
if (keys.contains("lockSuspend")) {
|
||||
bool ret = m_pmSettings->get("lockSuspend").toBool();
|
||||
if(ret){
|
||||
m_pmSettings->set("lock-suspend",false);
|
||||
}
|
||||
}
|
||||
if (keys.contains("lockHibernate")) {
|
||||
bool ret = m_pmSettings->get("lockHibernate").toBool();
|
||||
if(ret){
|
||||
m_pmSettings->set("lock-hibernate",false);
|
||||
}
|
||||
}
|
||||
if (keys.contains("lockBlankScreen") && keysScreenSaver.contains("closeActivationEnabled")) {
|
||||
bool oldValue = m_pmSettings->get("lockBlankScreen").toBool();
|
||||
if(!oldValue && m_ssSettings){
|
||||
m_ssSettings->set("close-activation-enabled", oldValue);
|
||||
m_pmSettings->set("lock-blank-screen", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString userName = getenv("USER");
|
||||
QString configPath;
|
||||
|
@ -77,29 +118,17 @@ SessionWatcher::SessionWatcher(QObject *parent) : QObject(parent)
|
|||
connect(timegsettings, &QGSettings::changed,
|
||||
this, &SessionWatcher::onConfigurationTimeTpChanged);
|
||||
|
||||
// activationEnabled_Key = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
// connect(activationEnabled_Key, &QGSettings::changed,
|
||||
// this, &SessionWatcher::activationEnabledChanged);
|
||||
// idleActivationEnabled = activationEnabled_Key->get("idle-activation-enabled").toBool();
|
||||
|
||||
// lockEnabled_Key = new QGSettings(GSETTINGS_SCHEMA_SCREENSAVER, "", this);
|
||||
// connect(lockEnabled_Key, &QGSettings::changed,
|
||||
// this, &SessionWatcher::lockEnabledChanged);
|
||||
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
|
||||
// qDebug()<<lockEnabled;
|
||||
}
|
||||
|
||||
void SessionWatcher::onConfigurationDelayChanged(QString key)
|
||||
{
|
||||
if(key == KEY_IDLE_DELAY){
|
||||
idleDelay = settings_delay->get("idle-delay").toInt();
|
||||
}
|
||||
// 监听合盖信号
|
||||
QDBusConnection::systemBus().connect(
|
||||
UPOWER_SERVICE, UPOWER_PATH, FREEDESKTOP_UPOWER, "PropertiesChanged", this, SLOT(onLidWatcherMessage(void)));
|
||||
}
|
||||
|
||||
void SessionWatcher::onConfigurationLockChanged(QString key)
|
||||
void SessionWatcher::onSSConfigChanged(QString strKey)
|
||||
{
|
||||
if(key == KEY_IDLE_LOCK){
|
||||
idleLock = settings_lock->get("idle-lock").toInt();
|
||||
if(strKey == KEY_IDLE_DELAY){
|
||||
idleDelay = m_ssSettings->get("idle-delay").toInt();
|
||||
} else if (strKey == KEY_IDLE_LOCK){
|
||||
idleLock = m_ssSettings->get("idle-lock").toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,25 +148,13 @@ void SessionWatcher::onConfigurationTimeTpChanged(QString key)
|
|||
|
||||
void SessionWatcher::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
if (!configSettings)
|
||||
return;
|
||||
configSettings->beginGroup("Greeter");
|
||||
configSettings->setValue(key, value);
|
||||
configSettings->endGroup();
|
||||
}
|
||||
|
||||
//void SessionWatcher::activationEnabledChanged(QString key)
|
||||
//{
|
||||
// if(key == KEY_IDLE_ACTIVATION_ENABLED){
|
||||
// idleActivationEnabled = activationEnabled_Key->get("idle-activation-enabled").toBool();
|
||||
// }
|
||||
//}
|
||||
|
||||
//void SessionWatcher::lockEnabledChanged(QString key)
|
||||
//{
|
||||
// if(key == KEY_IDLE_LOCK_ENABLED){
|
||||
// lockEnabled = lockEnabled_Key->get("idle-lock-enabled").toBool();
|
||||
// }
|
||||
//}
|
||||
|
||||
void SessionWatcher::onStatusChanged(unsigned int status)
|
||||
{
|
||||
if(status == SESSION_IDLE) {
|
||||
|
@ -179,6 +196,7 @@ void SessionWatcher::onStatusChanged(unsigned int status)
|
|||
if(m_timer2 && m_timer2->isActive()){
|
||||
m_timer2->stop();
|
||||
}
|
||||
Q_EMIT sessionIdleExit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,3 +206,94 @@ void SessionWatcher::onSessionRemoved(const QDBusObjectPath &objectPath)
|
|||
if(objectPath.path() == sessionPath)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
bool SessionWatcher::isSleepActivationEnable()
|
||||
{
|
||||
if (!m_ssSettings)
|
||||
return false;
|
||||
QStringList settingsKeys = m_ssSettings->keys();
|
||||
if (settingsKeys.contains("sleepActivationEnabled")) {
|
||||
return m_ssSettings->get("sleep-activation-enabled").toBool();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SessionWatcher::isCloseActivationEnable()
|
||||
{
|
||||
if (!m_ssSettings)
|
||||
return false;
|
||||
QStringList settingsKeys = m_ssSettings->keys();
|
||||
if (settingsKeys.contains("closeActivationEnabled")) {
|
||||
return m_ssSettings->get("close-activation-enabled").toBool();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SessionWatcher::isLockEnable()
|
||||
{
|
||||
if (!m_ssSettings)
|
||||
return false;
|
||||
QStringList settingsKeys = m_ssSettings->keys();
|
||||
if (settingsKeys.contains("lockEnabled")) {
|
||||
return m_ssSettings->get("lock-enabled").toBool();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int SessionWatcher::sleepActivationDelay()
|
||||
{
|
||||
if (!m_pmSettings)
|
||||
return -1;
|
||||
QStringList settingsKeys = m_pmSettings->keys();
|
||||
if (settingsKeys.contains("sleepComputerAc")) {
|
||||
return m_pmSettings->get("sleep-computer-ac").toInt();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int SessionWatcher::closeActivationDelay()
|
||||
{
|
||||
if (!m_pmSettings)
|
||||
return -1;
|
||||
QStringList settingsKeys = m_pmSettings->keys();
|
||||
if (settingsKeys.contains("sleepDisplayAc")) {
|
||||
return m_pmSettings->get("sleep-display-ac").toInt();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int SessionWatcher::idledelay()
|
||||
{
|
||||
return idleDelay;
|
||||
}
|
||||
|
||||
bool SessionWatcher::isLidCloseWithBlank()
|
||||
{
|
||||
if (!m_pmSettings)
|
||||
return false;
|
||||
QStringList settingsKeys = m_pmSettings->keys();
|
||||
if (settingsKeys.contains("buttonLidAc")) {
|
||||
QString strAction = m_pmSettings->get("button-lid-ac").toString();
|
||||
return (strAction == "blank");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SessionWatcher::onLidWatcherMessage(void)
|
||||
{
|
||||
QDBusInterface iface(UPOWER_SERVICE, UPOWER_PATH, FREEDESKTOP_UPOWER, QDBusConnection::systemBus());
|
||||
QDBusReply<QVariant> reply = iface.call("Get", "org.freedesktop.UPower", "LidIsClosed");
|
||||
if (reply.isValid()) {
|
||||
m_lidState = reply.value().toBool();
|
||||
Q_EMIT lidStateChanged(m_lidState);
|
||||
qDebug() << "lid state:" << m_lidState;
|
||||
} else {
|
||||
qDebug() << "Failed to get lid closed event!";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,32 +31,38 @@ class SessionWatcher : public QObject
|
|||
public:
|
||||
explicit SessionWatcher(QObject *parent = nullptr);
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
bool isSleepActivationEnable();
|
||||
bool isCloseActivationEnable();
|
||||
bool isLockEnable();
|
||||
int sleepActivationDelay();
|
||||
int closeActivationDelay();
|
||||
int idledelay();
|
||||
bool isLidCloseWithBlank(); // 合盖关屏
|
||||
|
||||
Q_SIGNALS:
|
||||
void sessionIdle();
|
||||
void sessionLockIdle();
|
||||
void sessionIdleExit();
|
||||
void lidStateChanged(bool isClosed);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onStatusChanged(unsigned int status);
|
||||
void onSessionRemoved(const QDBusObjectPath &objectPath);
|
||||
void onConfigurationDelayChanged(QString key);
|
||||
void onConfigurationLockChanged(QString key);
|
||||
void onConfigurationTimeTpChanged(QString key);
|
||||
// void activationEnabledChanged(QString key);
|
||||
// void lockEnabledChanged(QString key);
|
||||
void onSSConfigChanged(QString strKey);
|
||||
void onLidWatcherMessage(void);
|
||||
|
||||
private:
|
||||
QString sessionPath;
|
||||
QGSettings *settings_delay;
|
||||
QGSettings *settings_lock;
|
||||
QGSettings *activationEnabled_Key;
|
||||
QGSettings *lockEnabled_Key;
|
||||
QGSettings *timegsettings;
|
||||
QSettings *configSettings;
|
||||
bool idleActivationEnabled;
|
||||
bool lockEnabled;
|
||||
int idleDelay;
|
||||
int idleLock;
|
||||
QGSettings *timegsettings = nullptr;
|
||||
QSettings *configSettings = nullptr;
|
||||
QGSettings *m_ssSettings = nullptr;
|
||||
QGSettings *m_pmSettings = nullptr;
|
||||
int idleDelay = -1;
|
||||
int idleLock = -1;
|
||||
QTimer *m_timer = nullptr;
|
||||
QTimer *m_timer2 = nullptr;
|
||||
bool m_lidState = false;
|
||||
};
|
||||
|
||||
#endif // SESSIONWATCHER_H
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <QGSettings>
|
||||
|
||||
#include "interface.h"
|
||||
#include "sessionwatcher.h"
|
||||
#include "screensaveradaptor.h"
|
||||
#include "types.h"
|
||||
|
||||
|
@ -31,8 +30,6 @@
|
|||
#include <stdio.h>
|
||||
#include <ukui-log4qt.h>
|
||||
|
||||
#define POWER_TYPE_SCHENA "org.ukui.power-manager"
|
||||
|
||||
void sig_chld(int /*signo*/)
|
||||
{
|
||||
pid_t pid;
|
||||
|
@ -65,31 +62,6 @@ int main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FILE *fp;
|
||||
|
||||
// for PowerManager
|
||||
fp = popen("xset s 0 0", "r");
|
||||
fclose(fp);
|
||||
// Q_UNUSED(fp)
|
||||
|
||||
QGSettings *powerSettings;
|
||||
if(QGSettings::isSchemaInstalled(POWER_TYPE_SCHENA)){
|
||||
powerSettings = new QGSettings(POWER_TYPE_SCHENA,"",NULL);
|
||||
QStringList keys = powerSettings->keys();
|
||||
if (keys.contains("lockSuspend")) {
|
||||
bool ret = powerSettings->get("lockSuspend").toBool();
|
||||
if(ret){
|
||||
powerSettings->set("lock-suspend",false);
|
||||
}
|
||||
}
|
||||
if (keys.contains("lockHibernate")) {
|
||||
bool ret = powerSettings->get("lockHibernate").toBool();
|
||||
if(ret){
|
||||
powerSettings->set("lock-hibernate",false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 注册DBus
|
||||
Interface *interface = new Interface();
|
||||
ScreenSaverAdaptor adaptor(interface);
|
||||
|
@ -107,41 +79,6 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
qDebug() << service.baseService();
|
||||
|
||||
// 发送DBus信号
|
||||
SessionWatcher *watcher = new SessionWatcher;
|
||||
QObject::connect(watcher, &SessionWatcher::sessionIdle,
|
||||
interface, &Interface::onSessionIdleReceived);
|
||||
|
||||
QObject::connect(watcher, &SessionWatcher::sessionLockIdle,
|
||||
interface, &Interface::Lock);
|
||||
|
||||
QObject::connect(watcher, &SessionWatcher::sessionIdle,
|
||||
&a, [&]{
|
||||
QDBusMessage message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
SS_DBUS_INTERFACE,
|
||||
"SessionIdle");
|
||||
service.send(message);
|
||||
//qDebug()<<"message="<<message;
|
||||
});
|
||||
|
||||
QObject::connect(watcher, &SessionWatcher::sessionLockIdle,
|
||||
&a, [&]{
|
||||
QDBusMessage message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
SS_DBUS_INTERFACE,
|
||||
"SessionLockIdle");
|
||||
service.send(message);
|
||||
qDebug()<<"message="<<message;
|
||||
});
|
||||
|
||||
// QTimer *timer = new QTimer;
|
||||
// QObject::connect(timer, &QTimer::timeout, &a, [&]{
|
||||
// QDBusMessage message = QDBusMessage::createSignal(SS_DBUS_PATH,
|
||||
// SS_DBUS_INTERFACE,
|
||||
// "SessionLockIdle");
|
||||
// service.send(message);
|
||||
// });
|
||||
// timer->start(3000);
|
||||
|
||||
QObject::connect(checkInterface, SIGNAL(NameLost(QString)),
|
||||
interface, SLOT(onNameLost(QString)));
|
||||
|
||||
|
|
|
@ -218,8 +218,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
if(parser.isSet(lstOption))
|
||||
{
|
||||
window->setIsStartup(true);
|
||||
window->lock();
|
||||
window->setIsStartup(true);
|
||||
}
|
||||
|
||||
if(parser.isSet(sessionIdleOption))
|
||||
|
|
Loading…
Reference in New Issue