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
39 changes: 11 additions & 28 deletions src/dde-lock/lockframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,6 @@ LockFrame::LockFrame(SessionBaseModel *const model, QWidget *parent)
m_enablePowerOffKey = true;
});
}

//待机时由锁屏提供假黑屏,唤醒时显示正常界面
model->setIsBlackMode(isSleep);
model->setVisible(true);

if (!isSleep) {
//待机唤醒后检查是否需要密码,若不需要密码直接隐藏锁定界面
if (!isSleepLock()) {
qDebug() << "sleep-lock is off, prepare unlock";
// 待机唤醒的一瞬间,会延迟收到DBusLogin1Manager::PrepareForSleep(true), 进而最终传入到dde-session的locked状态也是延迟的
// dde-session 延迟收到locked后会重新发送锁定信号,导致这里unlock后又被重新lock
// 设置一个100ms的延时,等待dde-session的locked状态和dde-lock的locked状态完全同步后再进行隐藏锁屏的动作
model->setIsBlackMode(true);
QTimer::singleShot(100, this, [this, model](){
model->setIsBlackMode(false);
hide();
});
}
}
} );

connect(model, &SessionBaseModel::authFinished, this, [this](bool success) {
Expand Down Expand Up @@ -263,16 +244,18 @@ void LockFrame::shutdownInhibit(const SessionBaseModel::PowerAction action, bool
m_warningContent->setPowerAction(action);
}
m_warningContent->resize(size());
setContent(m_warningContent);

//多屏状态下,当前界面显示内容时才显示提示界面
if (old_visible) {
setContentVisible(true);
m_lockContent->hide();
//检查是有阻塞
if (const bool inhibit = m_warningContent->beforeInvokeAction(needConfirm)) {
setContent(m_warningContent);

//多屏状态下,当前界面显示内容时才显示提示界面
if (old_visible) {
m_lockContent->hide();
setContentVisible(true);
}
} else {
m_warningContent->doAccecpShutdownInhibit();
}

//检查是否允许关机
m_warningContent->beforeInvokeAction(needConfirm);
}

void LockFrame::cancelShutdownInhibit(bool hideFrame)
Expand Down
25 changes: 24 additions & 1 deletion src/dde-lock/lockworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,35 @@ void LockWorker::initConnections()
/* org.freedesktop.login1.Manager */
connect(m_login1Inter, &DBusLogin1Manager::PrepareForSleep, this, [ = ](bool isSleep) {
qInfo() << "DBusLogin1Manager::PrepareForSleep:" << isSleep;

const auto sleepLock = isSleepLock();
if (isSleep) {
endAuthentication(m_account, AT_All);
destroyAuthentication(m_account);
} else {
createAuthentication(m_model->currentUser()->name());
// 非黑屏mode
m_model->setIsBlackMode(false);

// 如果待机唤醒后需要密码则创建验证
if(m_login1SessionSelf->active() && sleepLock)
createAuthentication(m_model->currentUser()->name());
}
if (!m_model->visible() && sleepLock) {
m_model->setIsBlackMode(isSleep);
m_model->setVisible(true);
}

if (!isSleep && !sleepLock) {
// 待机唤醒后检查是否需要密码,若不需要密码直接隐藏锁定界面
// 待机唤醒的一瞬间,会延迟收到DBusLogin1Manager::PrepareForSleep(true), 进而最终传入到dde-session的locked状态也是延迟的
// dde-session 延迟收到locked后会重新发送锁定信号,导致这里unlock后又被重新lock
// 设置一个100ms的延时,等待dde-session的locked状态和dde-lock的locked状态完全同步后再进行隐藏锁屏的动作
QTimer::singleShot(100, this, [this]() {
m_model->setVisible(false);
m_model->setCurrentModeState(SessionBaseModel::PasswordMode);
});
}

emit m_model->prepareForSleep(isSleep);
});

Expand Down
4 changes: 4 additions & 0 deletions src/widgets/fullscreenbackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ void FullscreenBackground::setContentVisible(bool visible)

void FullscreenBackground::setContent(QWidget *const w)
{
if (m_content) {
m_content->setVisible(false);
}

m_content = w;
m_content->setParent(this);
m_content->move(0, 0);
Expand Down
13 changes: 7 additions & 6 deletions src/widgets/warningcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void WarningContent::doAccecpShutdownInhibit()
emit m_model->cancelShutdownInhibit(false);
}

void WarningContent::beforeInvokeAction(bool needConfirm)
bool WarningContent::beforeInvokeAction(bool needConfirm)
{
const QList<InhibitWarnView::InhibitorData> inhibitors = listInhibitors(m_powerAction);
const QList<std::shared_ptr<User>> &loginUsers = m_model->loginedUserList();
Expand Down Expand Up @@ -178,7 +178,7 @@ void WarningContent::beforeInvokeAction(bool needConfirm)
tr("To close the program, click Cancel, and then close the program."));
break;
default:
return;
return true;
}

// 如果有阻止关机、重启、待机或休眠的进程,则不允许手动强制执行
Expand Down Expand Up @@ -209,7 +209,7 @@ void WarningContent::beforeInvokeAction(bool needConfirm)
connect(view, &InhibitWarnView::cancelled, this, &WarningContent::doCancelShutdownInhibit);
connect(view, &InhibitWarnView::actionInvoked, this, &WarningContent::doAccecpShutdownInhibit);

return;
return true;
}

if (loginUsers.length() > 1 && (m_powerAction == SessionBaseModel::PowerAction::RequireShutdown || m_powerAction == SessionBaseModel::PowerAction::RequireRestart)) {
Expand Down Expand Up @@ -239,7 +239,7 @@ void WarningContent::beforeInvokeAction(bool needConfirm)
connect(view, &MultiUsersWarningView::cancelled, this, &WarningContent::doCancelShutdownInhibit);
connect(view, &MultiUsersWarningView::actionInvoked, this, &WarningContent::doAccecpShutdownInhibit);

return;
return true;
}

if (needConfirm && (m_powerAction == SessionBaseModel::PowerAction::RequireShutdown ||
Expand All @@ -266,10 +266,11 @@ void WarningContent::beforeInvokeAction(bool needConfirm)
connect(view, &InhibitWarnView::cancelled, this, &WarningContent::doCancelShutdownInhibit);
connect(view, &InhibitWarnView::actionInvoked, this, &WarningContent::doAccecpShutdownInhibit);

return;
return true;
}

doAccecpShutdownInhibit();
//doAccecpShutdownInhibit();
return false;
}

void WarningContent::setPowerAction(const SessionBaseModel::PowerAction action)
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/warningcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ class WarningContent : public SessionBaseWindow
public:
explicit WarningContent(SessionBaseModel *const model, const SessionBaseModel::PowerAction action, QWidget *parent = nullptr);
~WarningContent() override;
void beforeInvokeAction(bool needConfirm);
bool beforeInvokeAction(bool needConfirm);
void setPowerAction(const SessionBaseModel::PowerAction action);
void doAccecpShutdownInhibit();

protected:
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
QList<InhibitWarnView::InhibitorData> listInhibitors(const SessionBaseModel::PowerAction action);
void doCancelShutdownInhibit();
void doAccecpShutdownInhibit();

private:
SessionBaseModel *m_model;
Expand Down
Loading