Skip to content

Commit bff4c6d

Browse files
committed
fix(keyboard): resolve layout name disappearing after deletion
Batch collect layout descriptions before updating model to avoid transient empty state during async DBus calls. 批量收集布局描述后再更新模型,避免异步DBus调用期间的空状态。 Also show done button when in editing mode to prevent user getting stuck. 同时修复编辑模式下完成按钮消失的问题。 Log: 修复删除键盘布局后名称消失及完成按钮不显示的问题 PMS: BUG-356121 Influence: 键盘布局编辑功能现在正常工作,删除布局后名称正确显示,编辑模式下始终可以退出编辑。
1 parent 7223c00 commit bff4c6d

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

src/dcc-fcitx5configtool/keyboard-layout/operation/keyboardwork.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
1+
//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
//SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -492,23 +492,47 @@ void KeyboardWorker::onLocalListsFinished(QDBusPendingCallWatcher *watch)
492492

493493
void KeyboardWorker::onUserLayout(const QStringList &list)
494494
{
495-
m_model->cleanUserLayout();
496495
m_model->getUserLayoutList() = list;
496+
m_pendingLayouts.clear();
497+
m_pendingLayoutCount = list.size();
498+
m_batchId++;
499+
500+
if (list.isEmpty()) {
501+
m_model->cleanUserLayout();
502+
return;
503+
}
497504

498505
for (const QString &data : list) {
499506
QDBusPendingCallWatcher *layoutResult = new QDBusPendingCallWatcher(m_keyboardDBusProxy->GetLayoutDesc(data), this);
500507
layoutResult->setProperty("id", data);
508+
layoutResult->setProperty("batchId", m_batchId);
501509
connect(layoutResult, &QDBusPendingCallWatcher::finished, this, &KeyboardWorker::onUserLayoutFinished);
502510
}
503511
}
504512

505513
void KeyboardWorker::onUserLayoutFinished(QDBusPendingCallWatcher *watch)
506514
{
507-
QDBusPendingReply<QString> reply = *watch;
515+
if (watch->property("batchId").toULongLong() != m_batchId) {
516+
watch->deleteLater();
517+
return;
518+
}
508519

509-
m_model->addUserLayout(watch->property("id").toString(), reply.value());
520+
QDBusPendingReply<QString> reply = *watch;
521+
if (!reply.isError()) {
522+
m_pendingLayouts.insert(watch->property("id").toString(), reply.value());
523+
} else {
524+
qWarning() << "GetLayoutDesc failed for" << watch->property("id").toString()
525+
<< ":" << reply.error().message();
526+
}
510527

511528
watch->deleteLater();
529+
530+
if (--m_pendingLayoutCount == 0) {
531+
m_model->cleanUserLayout();
532+
for (auto it = m_pendingLayouts.constBegin(); it != m_pendingLayouts.constEnd(); ++it) {
533+
m_model->addUserLayout(it.key(), it.value());
534+
}
535+
}
512536
}
513537

514538
void KeyboardWorker::onCurrentLayout(const QString &value)

src/dcc-fcitx5configtool/keyboard-layout/operation/keyboardwork.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
1+
//SPDX-FileCopyrightText: 2018 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
//SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -121,6 +121,9 @@ public Q_SLOTS:
121121
KeyboardDBusProxy *m_keyboardDBusProxy;
122122
ShortcutModel *m_shortcutModel = nullptr;
123123
QTranslator *m_translatorLanguage;
124+
QMap<QString, QString> m_pendingLayouts;
125+
int m_pendingLayoutCount = 0;
126+
quint64 m_batchId = 0;
124127
Dtk::Core::DConfig *m_inputDevCfg;
125128
};
126129
}

src/dcc-fcitx5configtool/qml/KeyboardLayoutModule.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DccObject {
2525
D.Button {
2626
id: button
2727
checkable: true
28-
visible: dccData.keyboardController.layoutCount > 1
28+
visible: dccData.keyboardController.layoutCount > 1 || keyboardLayoutTitle.isEditing
2929
checked: keyboardLayoutTitle.isEditing
3030
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
3131
Layout.rightMargin: 10

0 commit comments

Comments
 (0)