Skip to content

Commit 717c7d1

Browse files
sync: from linuxdeepin/dde-session-shell
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#46
1 parent 9bfe3b0 commit 717c7d1

6 files changed

Lines changed: 30 additions & 42 deletions

File tree

plugins/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ if (DISABLE_DSS_SNIPE)
44
endif()
55
# add_subdirectory(examples)
66
# add_subdirectory(assist_login)
7-
# add_subdirectory("login-gesture")

src/dde-lock/lockframe.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ bool LockFrame::event(QEvent *event)
171171
}
172172

173173
if (keyValue != "") {
174+
#ifdef ENABLE_DSS_SNIPE
175+
// v25 dde-daemon接受小驼峰命名的name
176+
emit sendKeyValue(qtifyName(keyValue));
177+
#else
174178
emit sendKeyValue(keyValue);
179+
#endif
175180
}
176181
}
177182
return FullScreenBackground::event(event);

src/global_util/public_func.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,21 @@ bool isSleepLock()
356356
return value.toBool();
357357
}
358358
#endif
359+
360+
QString qtifyName(const QString &name) {
361+
bool next_cap = false;
362+
QString result;
363+
364+
for (auto it = name.cbegin(); it != name.cend(); ++it) {
365+
if (*it == '-') {
366+
next_cap = true;
367+
} else if (next_cap) {
368+
result.append(it->toUpper());
369+
next_cap = false;
370+
} else {
371+
result.append(*it);
372+
}
373+
}
374+
375+
return result;
376+
}

src/global_util/public_func.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,10 @@ void configWebEngine();
8282
bool isSleepLock();
8383
#endif
8484

85+
/**
86+
* @brief convert 'some-key' to 'someKey'.
87+
*/
88+
89+
QString qtifyName(const QString &name);
90+
8591
#endif // PUBLIC_FUNC_H

src/session-widgets/lockcontent.cpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ void LockContent::init(SessionBaseModel *model)
113113
}
114114

115115
DConfigHelper::instance()->bind(this, SHOW_MEDIA_WIDGET, &LockContent::OnDConfigPropertyChanged);
116-
117-
QString kbLayout = getCurrentKBLayout();
118-
if (!kbLayout.isEmpty() && !kbLayout.toLower().startsWith("us")) {
119-
m_originalKBLayout = kbLayout;
120-
qCInfo(DDE_SHELL) << "Original keyboard layout:" << m_originalKBLayout;
121-
// 如果键盘布局有特殊设置,则切换到英文键盘布局,认证成功后恢复
122-
setKBLayout("us");
123-
}
124116
}
125117

126118
void LockContent::initUI()
@@ -196,13 +188,8 @@ void LockContent::initConnections()
196188
connect(m_model, &SessionBaseModel::userListChanged, this, &LockContent::onUserListChanged);
197189
connect(m_model, &SessionBaseModel::userListLoginedChanged, this, &LockContent::onUserListChanged);
198190
connect(m_model, &SessionBaseModel::authFinished, this, [this](bool successful) {
199-
if (successful) {
191+
if (successful)
200192
setVisible(false);
201-
if (!m_originalKBLayout.isEmpty()) {
202-
// 切换回原来的键盘布局
203-
setKBLayout(m_originalKBLayout);
204-
}
205-
}
206193
restoreMode();
207194
});
208195
connect(m_model, &SessionBaseModel::MFAFlagChanged, this, [this](const bool isMFA) {
@@ -1027,26 +1014,3 @@ void LockContent::showShutdown()
10271014
m_model->setCurrentModeState(SessionBaseModel::ModeStatus::ShutDownMode);
10281015
m_model->setVisible(true);
10291016
}
1030-
1031-
QString LockContent::getCurrentKBLayout() const
1032-
{
1033-
QProcess p;
1034-
p.start("/usr/bin/setxkbmap", {"-query"});
1035-
p.waitForFinished();
1036-
1037-
const QString output = QString::fromUtf8(p.readAllStandardOutput());
1038-
for (const QString &line : output.split('\n')) {
1039-
if (line.startsWith("layout:")) {
1040-
QString layout = line.section(':', 1).trimmed();
1041-
return layout;
1042-
}
1043-
}
1044-
1045-
return {};
1046-
}
1047-
1048-
void LockContent::setKBLayout(const QString &layout)
1049-
{
1050-
qCDebug(DDE_SHELL) << "Set keyboard layout: " << layout;
1051-
QProcess::execute("/usr/bin/setxkbmap", { layout});
1052-
}

src/session-widgets/lockcontent.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ public slots:
102102
void initFMAWidget();
103103
void initUserListWidget();
104104
void enableSystemShortcut(const QStringList &shortcuts, bool enabled, bool isPersistent);
105-
QString getCurrentKBLayout() const;
106-
void setKBLayout(const QString &layout);
107105

108106
protected:
109107
SessionBaseModel *m_model = nullptr;
@@ -136,8 +134,6 @@ public slots:
136134
bool m_MPRISEnable = false;
137135
bool m_showMediaWidget = false;
138136
bool m_hasResetPasswordDialog = false;
139-
140-
QString m_originalKBLayout;
141137
};
142138

143139
#endif // LOCKCONTENT_H

0 commit comments

Comments
 (0)