Skip to content

Commit 7e785c3

Browse files
committed
fix: use dynamic integer range from fcitx5 config properties
Pass IntMax/IntMin properties for Integer type options to QML SpinBox, enable editable input and set fixed width to prevent layout stretching. 将Integer类型选项的IntMax/IntMin属性传递到QML SpinBox,启用可编辑输入并设置固定宽度防止布局拉伸。 Log: SpinBox支持动态整数范围和可编辑输入 PMS: BUG-357563 Influence: Integer类型配置项的SpinBox现在使用fcitx5配置中定义的实际范围,支持手动输入数值。
1 parent 8272d56 commit 7e785c3

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/dcc-fcitx5configtool/operation/fcitx5configproxy.cpp

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

@@ -219,6 +219,13 @@ QVariantList Fcitx5ConfigProxy::globalConfigOptions(const QString &type, bool al
219219
}
220220
++iterator;
221221
}
222+
if (option.type() == "Integer") {
223+
bool ok = false;
224+
int maxVal = properties.contains("IntMax") ? properties["IntMax"].toInt(&ok) : 9999;
225+
item["intMax"] = ok ? maxVal : 9999;
226+
int minVal = properties.contains("IntMin") ? properties["IntMin"].toInt(&ok) : 0;
227+
item["intMin"] = ok ? minVal : 0;
228+
}
222229
}
223230
list.append(item);
224231
}

src/dcc-fcitx5configtool/qml/DetailConfigItem.qml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ DccObject {
112112
Component {
113113
id: integerComponent
114114
D.SpinBox {
115-
width: 55
116-
implicitWidth: 55
115+
editable: true
116+
width: 75
117+
implicitWidth: 75
118+
from: modelData.intMin !== undefined ? modelData.intMin : 0
119+
to: modelData.intMax !== undefined ? modelData.intMax : 9999
117120
value: parseInt(modelData.value)
118121
onValueChanged: {
119122
dccData.fcitx5ConfigProxy.setValue(

0 commit comments

Comments
 (0)