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); + } } }