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
38 changes: 1 addition & 37 deletions src/session-widgets/lockcontent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ void LockContent::init(SessionBaseModel *model)
}

DConfigHelper::instance()->bind(this, SHOW_MEDIA_WIDGET, &LockContent::OnDConfigPropertyChanged);

QString kbLayout = getCurrentKBLayout();
if (!kbLayout.isEmpty() && !kbLayout.toLower().startsWith("us")) {
m_originalKBLayout = kbLayout;
qCInfo(DDE_SHELL) << "Original keyboard layout:" << m_originalKBLayout;
// 如果键盘布局有特殊设置,则切换到英文键盘布局,认证成功后恢复
setKBLayout("us");
}
}

void LockContent::initUI()
Expand Down Expand Up @@ -196,13 +188,8 @@ void LockContent::initConnections()
connect(m_model, &SessionBaseModel::userListChanged, this, &LockContent::onUserListChanged);
connect(m_model, &SessionBaseModel::userListLoginedChanged, this, &LockContent::onUserListChanged);
connect(m_model, &SessionBaseModel::authFinished, this, [this](bool successful) {
if (successful) {
if (successful)
setVisible(false);
if (!m_originalKBLayout.isEmpty()) {
// 切换回原来的键盘布局
setKBLayout(m_originalKBLayout);
}
}
restoreMode();
});
connect(m_model, &SessionBaseModel::MFAFlagChanged, this, [this](const bool isMFA) {
Expand Down Expand Up @@ -1027,26 +1014,3 @@ void LockContent::showShutdown()
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ShutDownMode);
m_model->setVisible(true);
}

QString LockContent::getCurrentKBLayout() const
{
QProcess p;
p.start("/usr/bin/setxkbmap", {"-query"});
p.waitForFinished();

const QString output = QString::fromUtf8(p.readAllStandardOutput());
for (const QString &line : output.split('\n')) {
if (line.startsWith("layout:")) {
QString layout = line.section(':', 1).trimmed();
return layout;
}
}

return {};
}

void LockContent::setKBLayout(const QString &layout)
{
qCDebug(DDE_SHELL) << "Set keyboard layout: " << layout;
QProcess::execute("/usr/bin/setxkbmap", { layout});
}
4 changes: 0 additions & 4 deletions src/session-widgets/lockcontent.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ public slots:
void initFMAWidget();
void initUserListWidget();
void enableSystemShortcut(const QStringList &shortcuts, bool enabled, bool isPersistent);
QString getCurrentKBLayout() const;
void setKBLayout(const QString &layout);

protected:
SessionBaseModel *m_model = nullptr;
Expand Down Expand Up @@ -136,8 +134,6 @@ public slots:
bool m_MPRISEnable = false;
bool m_showMediaWidget = false;
bool m_hasResetPasswordDialog = false;

QString m_originalKBLayout;
};

#endif // LOCKCONTENT_H
Loading