commit
8628f076fc
|
@ -23,6 +23,7 @@ typedef enum _LOCK_CMD_ID_e
|
|||
LOCK_CMD_ID_GET_USERINFO_LIST = 0,
|
||||
LOCK_CMD_ID_USERINFO_CHANGED,
|
||||
LOCK_CMD_ID_SET_USER,
|
||||
LOCK_CMD_ID_SWITCH_TO_USER,
|
||||
LOCK_CMD_ID_GET_DEFAULT_AUTH_USER,
|
||||
LOCK_CMD_ID_GET_CURRENT_USER,
|
||||
LOCK_CMD_ID_CURRENT_USER_CHANGED,
|
||||
|
|
|
@ -566,6 +566,9 @@ int DbusUpperInterface::SetInformation(QString strJson)
|
|||
case LOCK_CMD_ID_SET_USER:
|
||||
nRet = SetCurrentUser(rootObj);
|
||||
break;
|
||||
case LOCK_CMD_ID_SWITCH_TO_USER:
|
||||
nRet = switchToUser(rootObj);
|
||||
break;
|
||||
case LOCK_CMD_ID_SET_SESSION:
|
||||
nRet = SetCurrentSession(rootObj);
|
||||
break;
|
||||
|
@ -881,39 +884,6 @@ int DbusUpperInterface::SetCurrentUser(const QJsonObject &objInfo)
|
|||
m_lightDmHelper->setSession(strSession);
|
||||
}
|
||||
}
|
||||
{
|
||||
QString strSwitchSeatPath = "";
|
||||
QString strDesUserName = strUserName;
|
||||
QString strCurUserName = SwitchUserUtils::GetCurUserName();
|
||||
if (strCurUserName.isEmpty()) {
|
||||
qDebug()<<"GetCurUserName failed!";
|
||||
nRet = 1;
|
||||
} else {
|
||||
UserDisplayIfInfo curUdii = SwitchUserUtils::GetUserUDII(strCurUserName);
|
||||
UserDisplayIfInfo desUdii = {""};
|
||||
if (!strDesUserName.isEmpty()) {
|
||||
desUdii = SwitchUserUtils::GetUserUDII(strDesUserName);
|
||||
if (desUdii.strUserName.isEmpty()) {
|
||||
desUdii.strUserName = strDesUserName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!curUdii.strSeatPath.isEmpty()) {
|
||||
strSwitchSeatPath = curUdii.strSeatPath;
|
||||
}
|
||||
if (!desUdii.strSeatPath.isEmpty()) {
|
||||
strSwitchSeatPath = desUdii.strSeatPath;
|
||||
}
|
||||
|
||||
if (strSwitchSeatPath.isEmpty()) {
|
||||
qWarning()<<"switch user: switch seat path invalid!";
|
||||
nRet = 1;
|
||||
} else {
|
||||
nRet = SwitchUserUtils::SwitchToUserSession(strSwitchSeatPath, desUdii);
|
||||
qDebug()<<"Switch user result:"<<nRet;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nRet >= 0) {
|
||||
|
@ -925,6 +895,46 @@ int DbusUpperInterface::SetCurrentUser(const QJsonObject &objInfo)
|
|||
return nRet;
|
||||
}
|
||||
|
||||
int DbusUpperInterface::switchToUser(const QJsonObject &objInfo)
|
||||
{
|
||||
int nRet = -1;
|
||||
QString strUserName = objInfo.value("Content").toString();
|
||||
if (!strUserName.isEmpty()) {
|
||||
QString strSwitchSeatPath = "";
|
||||
QString strDesUserName = strUserName;
|
||||
QString strCurUserName = SwitchUserUtils::GetCurUserName();
|
||||
if (strCurUserName.isEmpty()) {
|
||||
qDebug()<<"GetCurUserName failed!";
|
||||
nRet = 1;
|
||||
} else {
|
||||
UserDisplayIfInfo curUdii = SwitchUserUtils::GetUserUDII(strCurUserName);
|
||||
UserDisplayIfInfo desUdii = {""};
|
||||
if (!strDesUserName.isEmpty()) {
|
||||
desUdii = SwitchUserUtils::GetUserUDII(strDesUserName);
|
||||
if (desUdii.strUserName.isEmpty()) {
|
||||
desUdii.strUserName = strDesUserName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!curUdii.strSeatPath.isEmpty()) {
|
||||
strSwitchSeatPath = curUdii.strSeatPath;
|
||||
}
|
||||
if (!desUdii.strSeatPath.isEmpty()) {
|
||||
strSwitchSeatPath = desUdii.strSeatPath;
|
||||
}
|
||||
|
||||
if (strSwitchSeatPath.isEmpty()) {
|
||||
qWarning()<<"switch user: switch seat path invalid!";
|
||||
nRet = 1;
|
||||
} else {
|
||||
nRet = SwitchUserUtils::SwitchToUserSession(strSwitchSeatPath, desUdii);
|
||||
qDebug()<<"Switch user result:"<<nRet;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
||||
void DbusUpperInterface::onUsersInfoChanged()
|
||||
{
|
||||
QJsonObject retObj;
|
||||
|
|
|
@ -219,6 +219,8 @@ private:
|
|||
|
||||
int SetCurrentUser(const QJsonObject &objInfo);
|
||||
|
||||
int switchToUser(const QJsonObject &objInfo);
|
||||
|
||||
QJsonArray GenerateSessionInfoList();
|
||||
|
||||
QString GetCurrentSession();
|
||||
|
|
|
@ -295,6 +295,7 @@ int SwitchUserUtils::SwitchToUserSession(QString seatPath, UserDisplayIfInfo &to
|
|||
// }
|
||||
// return 1;
|
||||
// }
|
||||
return 4;
|
||||
} else {
|
||||
// QDBusMessage result = ifaceDM.call("SwitchToGreeter");
|
||||
// if(result.type() == QDBusMessage::ErrorMessage) {
|
||||
|
@ -302,6 +303,7 @@ int SwitchUserUtils::SwitchToUserSession(QString seatPath, UserDisplayIfInfo &to
|
|||
// return -2;
|
||||
// }
|
||||
// return 2;
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1350,6 +1350,21 @@ bool BackendDbusHelper::setCurrentUser(QString strUserName)
|
|||
return true;
|
||||
}
|
||||
|
||||
int BackendDbusHelper::switchToUser(QString strUserName)
|
||||
{
|
||||
QJsonObject jsonCmd;
|
||||
jsonCmd["CmdId"] = LOCK_CMD_ID_SWITCH_TO_USER;
|
||||
jsonCmd["Content"] = strUserName;
|
||||
QDBusPendingReply<int> reply = SetInformation(QString(QJsonDocument(jsonCmd).toJson()));
|
||||
reply.waitForFinished();
|
||||
if (reply.isError()) {
|
||||
qWarning() << "switchToUser error: " << reply.error().message();
|
||||
return -1;
|
||||
} else {
|
||||
return reply.value();
|
||||
}
|
||||
}
|
||||
|
||||
bool BackendDbusHelper::usdExternalDoAction(int actionType)
|
||||
{
|
||||
QJsonObject jsonCmd;
|
||||
|
|
|
@ -134,6 +134,7 @@ public Q_SLOTS:
|
|||
void onUpdateInformation(const QString &strJson);
|
||||
|
||||
bool setCurrentUser(QString strUserName);
|
||||
int switchToUser(QString strUserName);
|
||||
bool setCurrentSession(QString strSession);
|
||||
bool lockStateChanged(bool isVisible);
|
||||
void startSession();
|
||||
|
|
|
@ -317,6 +317,7 @@ Q_SIGNALS:
|
|||
|
||||
///
|
||||
void setCurrentUser(QString strUserName);
|
||||
int switchToUser(QString strUserName);
|
||||
void setCurrentSession(QString strSession);
|
||||
void startSession();
|
||||
void pamAuthenticate(QString strUserName);
|
||||
|
|
|
@ -72,6 +72,7 @@ void LockDialogPerformer::initConnections()
|
|||
connect(m_bdHelper, &BackendDbusHelper::usdMediaKeysConfChanged, m_modelLockDialog, &LockDialogModel::onUsdMediaKeysChanged);
|
||||
///通过信号直接调用槽
|
||||
connect(m_modelLockDialog, &LockDialogModel::setCurrentUser, m_bdHelper, &BackendDbusHelper::setCurrentUser);
|
||||
connect(m_modelLockDialog, &LockDialogModel::switchToUser, m_bdHelper, &BackendDbusHelper::switchToUser);
|
||||
connect(m_modelLockDialog, &LockDialogModel::setCurrentSession, m_bdHelper, &BackendDbusHelper::setCurrentSession);
|
||||
connect(m_modelLockDialog, &LockDialogModel::startSession, m_bdHelper, &BackendDbusHelper::startSession);
|
||||
connect(m_modelLockDialog, &LockDialogModel::pamAuthenticate, m_bdHelper, &BackendDbusHelper::pamAuthenticate);
|
||||
|
|
|
@ -1002,6 +1002,14 @@ void AuthDialog::startAuth()
|
|||
|
||||
void AuthDialog::stopAuth()
|
||||
{
|
||||
if(m_loginOpts)
|
||||
{
|
||||
if(m_bioTimer && m_bioTimer->isActive())
|
||||
m_bioTimer->stop();
|
||||
m_loginOpts->stopAuth();
|
||||
|
||||
m_loginOpts->hide();
|
||||
}
|
||||
clearMessage();
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ void FullBackgroundWidget::onShowLock(bool isStartup)
|
|||
Q_EMIT m_modelLockDialog->setCurrentUser(m_modelLockDialog->defaultUserName());
|
||||
Q_EMIT m_modelLockDialog->lockStateChanged(true);
|
||||
if(m_lockWidget)
|
||||
m_lockWidget->show();
|
||||
m_lockWidget->show();
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onShowSessionIdle()
|
||||
|
@ -271,8 +271,8 @@ void FullBackgroundWidget::onShowSessionIdle()
|
|||
|
||||
void FullBackgroundWidget::onShowLockScreensaver()
|
||||
{
|
||||
show();
|
||||
Q_EMIT m_modelLockDialog->lockStateChanged(true);
|
||||
onShowLock(false);
|
||||
onShowScreensaver();
|
||||
}
|
||||
|
||||
void FullBackgroundWidget::onShowScreensaver()
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "VirtualKeyboard/src/virtualkeyboardwidget.h"
|
||||
#include "blockwidget.h"
|
||||
#include "pluginsloader.h"
|
||||
#include "global_utils.h"
|
||||
|
||||
#define BLUR_RADIUS 300
|
||||
#define RIGHT_MARGIN 24
|
||||
|
@ -302,6 +303,7 @@ void LockWidget::initConnections()
|
|||
connect(m_modelLockDialog, &LockDialogModel::usersInfoChanged, this, &LockWidget::onUsersInfoChanged);
|
||||
connect(m_modelLockDialog, &LockDialogModel::currentUserChanged, this, &LockWidget::onCurUserChanged);
|
||||
connect(m_modelLockDialog, &LockDialogModel::currentSessionChanged, this, &LockWidget::onSessionChanged);
|
||||
connect(m_modelLockDialog, &LockDialogModel::sessionActiveChanged, this, &LockWidget::onSessionActiveChanged);
|
||||
if (authDialog) {
|
||||
connect(authDialog, SIGNAL(authSucceed(QString)), this, SIGNAL(authSucceed(QString)));
|
||||
connect(authDialog, &AuthDialog::userChangedByManual,
|
||||
|
@ -324,7 +326,9 @@ void LockWidget::initUserWidget()
|
|||
m_userListWidget->setMaxHeight(height()/2);
|
||||
m_userListWidget->updateWidgetSize();
|
||||
m_userListWidget->hide();
|
||||
connect(m_userListWidget, &UserListWidget::userSelected, m_modelLockDialog, &LockDialogModel::setCurrentUser);
|
||||
connect(m_userListWidget, &UserListWidget::userSelected, m_modelLockDialog, [=](QString strUserName){
|
||||
SwitchToUser(strUserName);
|
||||
});
|
||||
m_userListWidget->clearFocus();
|
||||
m_userListWidget->move(width() - m_userListWidget->width() - RIGHT_MARGIN,
|
||||
height()- BOTTOM_MARGIN*scale - buttonListWidget->height() - buttonListWidget->spacing()*scale - m_userListWidget->height());
|
||||
|
@ -662,7 +666,11 @@ void LockWidget::onCurUserChanged(const QString &strUserName)
|
|||
void LockWidget::onUserChangedByManual(const QString &userName)
|
||||
{
|
||||
if (m_modelLockDialog && m_modelLockDialog->findUserByName(userName)) {
|
||||
Q_EMIT m_modelLockDialog->setCurrentUser(userName);
|
||||
if (isCurUserSelf(userName)) {
|
||||
Q_EMIT m_modelLockDialog->setCurrentUser(userName);
|
||||
} else {
|
||||
SwitchToUser(userName);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
@ -934,8 +942,9 @@ void LockWidget::onCancelBtnClicked()
|
|||
|
||||
void LockWidget::onCustomRequestAccount(QString account)
|
||||
{
|
||||
if(m_modelLockDialog)
|
||||
Q_EMIT m_modelLockDialog->setCurrentUser(account);
|
||||
if(m_modelLockDialog) {
|
||||
SwitchToUser(account);
|
||||
}
|
||||
}
|
||||
|
||||
void LockWidget::onGetCustomPluginMsg(QString strMsg)
|
||||
|
@ -977,3 +986,52 @@ void LockWidget::startAuth()
|
|||
authDialog->startAuth();
|
||||
}
|
||||
}
|
||||
|
||||
void LockWidget::onSessionActiveChanged(bool isActive)
|
||||
{
|
||||
if (isActive) {
|
||||
if (m_timerChkActive && m_timerChkActive->isActive()) {
|
||||
m_timerChkActive->stop();
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
update();
|
||||
}
|
||||
}
|
||||
// if(authDialog) {
|
||||
// authDialog->stopAuth();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void LockWidget::SwitchToUser(QString strUserName)
|
||||
{
|
||||
if(m_modelLockDialog) {
|
||||
int nSwitchRet = Q_EMIT m_modelLockDialog->switchToUser(strUserName);
|
||||
if (nSwitchRet != 0) {
|
||||
Q_EMIT m_modelLockDialog->setCurrentUser(strUserName);
|
||||
} else {
|
||||
// if(authDialog) {
|
||||
// authDialog->stopAuth();
|
||||
// }
|
||||
if (!isCurUserSelf(strUserName) && !isHidden()) {
|
||||
this->hide();
|
||||
update();
|
||||
if (!m_timerChkActive) {
|
||||
m_timerChkActive = new QTimer(this);
|
||||
m_timerChkActive->setInterval(10*1000);
|
||||
connect(m_timerChkActive, &QTimer::timeout, this, [&,this](){
|
||||
if (this->isHidden()) {
|
||||
this->show();
|
||||
}
|
||||
m_timerChkActive->stop();
|
||||
});
|
||||
} else {
|
||||
if (m_timerChkActive->isActive()) {
|
||||
m_timerChkActive->stop();
|
||||
}
|
||||
}
|
||||
m_timerChkActive->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ private:
|
|||
|
||||
void updateBottomButton();
|
||||
|
||||
void SwitchToUser(QString strUserName);
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* @brief item选中状态改变
|
||||
|
@ -115,6 +117,8 @@ private Q_SLOTS:
|
|||
*/
|
||||
void onGetCustomPluginMsg(QString strMsg);
|
||||
|
||||
void onSessionActiveChanged(bool isActive);
|
||||
|
||||
Q_SIGNALS:
|
||||
void authSucceed(QString strUserName);
|
||||
|
||||
|
@ -137,6 +141,7 @@ private:
|
|||
UserInfo m_curUserInfo;
|
||||
|
||||
AuthDialog *authDialog = nullptr;
|
||||
QTimer *m_timerChkActive = nullptr;
|
||||
|
||||
// usd快捷键键值
|
||||
QString m_areaScreenShot;
|
||||
|
|
Loading…
Reference in New Issue