diff --git a/src/session-widgets/lockcontent.cpp b/src/session-widgets/lockcontent.cpp index 074398de..0548bef4 100644 --- a/src/session-widgets/lockcontent.cpp +++ b/src/session-widgets/lockcontent.cpp @@ -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() @@ -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) { @@ -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}); -} diff --git a/src/session-widgets/lockcontent.h b/src/session-widgets/lockcontent.h index 404780eb..5dadaf58 100644 --- a/src/session-widgets/lockcontent.h +++ b/src/session-widgets/lockcontent.h @@ -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; @@ -136,8 +134,6 @@ public slots: bool m_MPRISEnable = false; bool m_showMediaWidget = false; bool m_hasResetPasswordDialog = false; - - QString m_originalKBLayout; }; #endif // LOCKCONTENT_H