From 26fdfeb5bc561c45b987e9af532d1138567bcab6 Mon Sep 17 00:00:00 2001 From: xionglinlin Date: Fri, 23 May 2025 13:56:43 +0800 Subject: [PATCH] fix: update system update icon and speed limit input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Replaced system update icon with a new design using blue gradient and simplified shape 2. Added input validation for download speed limit setting 3. Implemented real-time model update for speed limit configuration 4. Added key handling for Enter key in speed limit input field 5. Improved user feedback with alert messages for invalid inputs fix: 更新系统更新图标和速度限制输入 1. 使用蓝色渐变和简化形状重新设计了系统更新图标 2. 为下载速度限制设置添加了输入验证 3. 实现了速度限制配置的实时模型更新 4. 为速度限制输入字段添加了回车键处理 5. 通过无效输入的警报消息改进了用户反馈 pms: Bug-313015 pms: Bug-313021 pms: Bug-313027 pms: Bug-313043 pms: Bug-314877 --- .../operation/qrc/icons/dcc_system_update.svg | 54 ++++++------------- .../operation/updatework.cpp | 3 ++ src/dcc-update-plugin/qml/UpdateSetting.qml | 37 ++++++++++--- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/dcc-update-plugin/operation/qrc/icons/dcc_system_update.svg b/src/dcc-update-plugin/operation/qrc/icons/dcc_system_update.svg index e2c70a400..8944ce90c 100644 --- a/src/dcc-update-plugin/operation/qrc/icons/dcc_system_update.svg +++ b/src/dcc-update-plugin/operation/qrc/icons/dcc_system_update.svg @@ -1,49 +1,25 @@ - icon/更新/系统 + update-48px - - - - - - - - - - - - - - - - + + + - - - - - - - + + + + + - - - - - - - - - - - - - - + + + + + + - \ No newline at end of file diff --git a/src/dcc-update-plugin/operation/updatework.cpp b/src/dcc-update-plugin/operation/updatework.cpp index f72d7e1ea..34250f1ff 100644 --- a/src/dcc-update-plugin/operation/updatework.cpp +++ b/src/dcc-update-plugin/operation/updatework.cpp @@ -783,11 +783,14 @@ void UpdateWorker::setDownloadSpeedLimitEnabled(bool enable) { auto config = m_model->speedLimitConfig(); config.downloadSpeedLimitEnabled = enable; + // dbus返回需要1s,导致界面更新慢,这里直接先更新model + m_model->setSpeedLimitConfig(config.toJson().toUtf8()); setDownloadSpeedLimitConfig(config.toJson()); } void UpdateWorker::setDownloadSpeedLimitSize(const QString& size) { + qCDebug(DCC_UPDATE_WORKER) << "set download speed limit size" << size; auto config = m_model->speedLimitConfig(); config.limitSpeed = size; setDownloadSpeedLimitConfig(config.toJson()); diff --git a/src/dcc-update-plugin/qml/UpdateSetting.qml b/src/dcc-update-plugin/qml/UpdateSetting.qml index 40875db1c..b0703bf88 100644 --- a/src/dcc-update-plugin/qml/UpdateSetting.qml +++ b/src/dcc-update-plugin/qml/UpdateSetting.qml @@ -116,7 +116,6 @@ DccObject { Layout.fillWidth: true } D.ToolButton { - visible: !advancedSetting.showDetails textColor: D.Palette { normal { common: D.DTK.makeColor(D.Color.Highlight) @@ -127,9 +126,9 @@ DccObject { } hoveredDark: hovered } - text: qsTr("Expand") + text: advancedSetting.showDetails ? qsTr("Collapse") : qsTr("Expand") onClicked: { - advancedSetting.showDetails = true + advancedSetting.showDetails = !advancedSetting.showDetails } background: Item {} } @@ -178,12 +177,38 @@ DccObject { pageType: DccObject.Editor page: RowLayout { D.LineEdit { - width: Math.max(implicitWidth, editInputMinWidth) - text: dccData.model().downloadSpeedLimitSize + id: lineEdit font.pixelSize: 14 + maximumLength: 5 + validator: RegularExpressionValidator { regularExpression: /^\d*$/ } + alertText: qsTr("Only numbers between 1-99999 are allowed") + alertDuration: 3000 + + text: dccData.model().downloadSpeedLimitSize + onTextChanged: { + // 如果输入不为空且数字为0的情况,需要弹出提示且阻止继续输入 + if (lineEdit.text.length !== 0 && lineEdit.text[0] === "0") { + lineEdit.text = "" + lineEdit.showAlert = true + } else if (lineEdit.showAlert) { + lineEdit.showAlert = false + } + } onEditingFinished: { - dccData.work().setDownloadSpeedLimitSize(text) + if (lineEdit.showAlert) { + return + } + if (lineEdit.text.length === 0) { + lineEdit.text = dccData.model().downloadSpeedLimitSize + return + } + dccData.work().setDownloadSpeedLimitSize(lineEdit.text) + } + Keys.onPressed: { + if (event.key === Qt.Key_Return) { + lineEdit.forceActiveFocus(false); + } } }