diff --git a/src/common/dbus/updateassistant.cpp b/src/common/dbus/updateassistant.cpp new file mode 100644 index 00000000..d4c0cba9 --- /dev/null +++ b/src/common/dbus/updateassistant.cpp @@ -0,0 +1,63 @@ +// // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later +#include "updateassistant.h" + +UpdateAssistant::UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) + , d_ptr(new UpdateAssistantPrivate) +{ + QDBusConnection::systemBus().connect("org.deepin.upgradedelivery", "/org/deepin/upgradedelivery", "org.freedesktop.DBus.Properties", "PropertiesChanged", this, SLOT(onPropertyChanged(QString, QVariantMap, QStringList))); +} + +UpdateAssistant::~UpdateAssistant() +{ +} + +void UpdateAssistant::onPropertyChanged(const QString& interfaceName, + const QVariantMap& changedProperties, + const QStringList& invalidatedProperties) +{ + if (interfaceName != staticInterfaceName()) + return; + + if (changedProperties.contains("UploadLimitSpeed")) { + Q_EMIT UploadLimitSpeedChanged(uploadLimitSpeed()); + } + if (changedProperties.contains("DownloadLimitSpeed")) { + Q_EMIT DownloadLimitSpeedChanged(downloadLimitSpeed()); + } + + return; +} + +void UpdateAssistant::CallQueued(const QString &callName, const QList &args) +{ + if (d_ptr->m_waittingCalls.contains(callName)) { + d_ptr->m_waittingCalls[callName] = args; + return; + } + if (d_ptr->m_processingCalls.contains(callName)) { + d_ptr->m_waittingCalls.insert(callName, args); + } else { + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCallWithArgumentList(callName, args)); + connect(watcher, &QDBusPendingCallWatcher::finished, this, &UpdateAssistant::onPendingCallFinished); + d_ptr->m_processingCalls.insert(callName, watcher); + } +} + +void UpdateAssistant::onPendingCallFinished(QDBusPendingCallWatcher *w) +{ + if (!w) + return; + w->deleteLater(); + const auto callName = d_ptr->m_processingCalls.key(w); + Q_ASSERT(!callName.isEmpty()); + if (callName.isEmpty()) + return; + d_ptr->m_processingCalls.remove(callName); + if (!d_ptr->m_waittingCalls.contains(callName)) + return; + const auto args = d_ptr->m_waittingCalls.take(callName); + CallQueued(callName, args); +} \ No newline at end of file diff --git a/src/common/dbus/updateassistant.h b/src/common/dbus/updateassistant.h new file mode 100644 index 00000000..f404af31 --- /dev/null +++ b/src/common/dbus/updateassistant.h @@ -0,0 +1,84 @@ +// // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later +#ifndef UPDATEASSISTANT_H +#define UPDATEASSISTANT_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class UpdateAssistantPrivate +{ +public: + UpdateAssistantPrivate() = default; + +public: + QMap m_processingCalls; + QMap> m_waittingCalls; +}; + +/* + * Proxy class for interface org.deepin.updateassistant + */ +class UpdateAssistant: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.deepin.upgradedelivery"; } + +public: + UpdateAssistant(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + ~UpdateAssistant(); + + Q_PROPERTY(QString UploadLimitSpeed READ uploadLimitSpeed NOTIFY UploadLimitSpeedChanged) + inline QString uploadLimitSpeed() const + { return qvariant_cast(internalPropGet("UploadLimitSpeed")); } + + Q_PROPERTY(QString DownloadLimitSpeed READ downloadLimitSpeed NOTIFY DownloadLimitSpeedChanged) + inline QString downloadLimitSpeed() const + { return qvariant_cast(internalPropGet("DownloadLimitSpeed")); } + +public Q_SLOTS: // METHODS + + inline QDBusPendingReply SetUploadRateLimit(int speed) + { + QList argumentList; + argumentList << QVariant::fromValue(speed); + return asyncCallWithArgumentList(QStringLiteral("SetUploadRateLimit"), argumentList); + } + + inline QDBusPendingReply SetDownloadRateLimit(int speed) + { + QList argumentList; + argumentList << QVariant::fromValue(speed); + return asyncCallWithArgumentList(QStringLiteral("SetDownloadRateLimit"), argumentList); + } + +Q_SIGNALS: // SIGNALS + // begin property changed signals + void propertyChanged(const QString &propertyName, const QVariant &value); + void UploadLimitSpeedChanged(const QString & speed) const; + void DownloadLimitSpeedChanged(const QString & speed) const; + +public Q_SLOTS: + void CallQueued(const QString &callName, const QList &args); + +private Q_SLOTS: + void onPendingCallFinished(QDBusPendingCallWatcher *w); + void onPropertyChanged(const QString& interfaceName, + const QVariantMap& changedProperties, + const QStringList& invalidatedProperties); + +private: + UpdateAssistantPrivate *d_ptr; +}; + +#endif // UPDATEASSISTANT_H diff --git a/src/common/dbus/updatedbusproxy.cpp b/src/common/dbus/updatedbusproxy.cpp index c6cd74f6..436b6ba1 100644 --- a/src/common/dbus/updatedbusproxy.cpp +++ b/src/common/dbus/updatedbusproxy.cpp @@ -207,6 +207,16 @@ QString UpdateDBusProxy::updateStatus() return qvariant_cast(m_managerInter->property("UpdateStatus")); } +bool UpdateDBusProxy::p2PUpdateEnable() +{ + return qvariant_cast(m_managerInter->property("P2PUpdateEnable")); +} + +bool UpdateDBusProxy::p2PUpdateSupport() +{ + return qvariant_cast(m_managerInter->property("P2PUpdateSupport")); +} + bool UpdateDBusProxy::immutableAutoRecovery() { return qvariant_cast(m_managerInter->property("ImmutableAutoRecovery")); @@ -387,6 +397,36 @@ QDBusPendingReply UpdateDBusProxy::GetUpdateLogs(int updateType) return m_managerInter->asyncCallWithArgumentList(QStringLiteral("GetUpdateLogs"), argumentList); } +QDBusPendingReply UpdateDBusProxy::SetUpgradeDeliveryEnable(bool enable) +{ + qCDebug(logCommon) << "Setting upgrade delivery enable :" << enable; + QList argumentList; + argumentList << QVariant::fromValue(enable); + return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetP2PUpdateEnable"), argumentList); +} + +QDBusPendingReply UpdateDBusProxy::SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit) +{ + qCDebug(logCommon) << "Setting upgrade delivery download speed limit : " << downloadLimit; + QList argumentList; + argumentList << QVariant::fromValue(downloadLimit); + return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryDownloadSpeedLimit"), argumentList); +} + +QDBusPendingReply UpdateDBusProxy::SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit) +{ + qCDebug(logCommon) << "Setting upgrade delivery upload speed limit : " << uploadLimit; + QList argumentList; + argumentList << QVariant::fromValue(uploadLimit); + return m_updateInter->asyncCallWithArgumentList(QStringLiteral("SetDeliveryUploadSpeedLimit"), argumentList); +} + +QDBusPendingReply UpdateDBusProxy::ClearUpgradeDeliveryCache() +{ + qCDebug(logCommon) << "Clearing upgrade delivery cache"; + return m_updateInter->asyncCall(QStringLiteral("CleanTransmissionFiles")); +} + QDBusPendingReply UpdateDBusProxy::SetIdleDownloadConfig(const QString& config) { qCDebug(logCommon) << "Setting idle download config:" << config; diff --git a/src/common/dbus/updatedbusproxy.h b/src/common/dbus/updatedbusproxy.h index 8c15215d..32263948 100644 --- a/src/common/dbus/updatedbusproxy.h +++ b/src/common/dbus/updatedbusproxy.h @@ -70,6 +70,12 @@ class UpdateDBusProxy : public QObject Q_PROPERTY(bool ImmutableAutoRecovery READ immutableAutoRecovery NOTIFY ImmutableAutoRecoveryChanged) bool immutableAutoRecovery(); + Q_PROPERTY(bool P2PUpdateEnable READ p2PUpdateEnable NOTIFY P2PUpdateEnableChanged) + bool p2PUpdateEnable(); + + Q_PROPERTY(bool P2PUpdateSupport READ p2PUpdateSupport NOTIFY P2PUpdateSupportChanged) + bool p2PUpdateSupport(); + QString hardwareId(); quint64 checkUpdateMode(); @@ -103,6 +109,10 @@ class UpdateDBusProxy : public QObject QDBusPendingReply SetDownloadSpeedLimit(const QString &config); QDBusPendingReply QueryAllSizeWithSource(int updateType); QDBusPendingReply GetUpdateLogs(int updateType); + QDBusPendingReply SetUpgradeDeliveryEnable(bool enable); + QDBusPendingReply SetUpgradeDeliveryDownloadSpeedLimit(const QString& downloadLimit); + QDBusPendingReply SetUpgradeDeliveryUploadSpeedLimit(const QString& uploadLimit); + QDBusPendingReply ClearUpgradeDeliveryCache(); QDBusPendingReply SetIdleDownloadConfig(const QString &config); QDBusPendingReply PrepareDistUpgradePartly(int updateMode); QDBusPendingReply fixError(const QString &errorType); @@ -137,6 +147,7 @@ class UpdateDBusProxy : public QObject void AutoInstallUpdatesChanged(bool value) const; void AutoInstallUpdateTypeChanged(qulonglong value) const; void MirrorSourceChanged(const QString &value) const; + void UpgradeDeliveryEnabledChanged(bool value) const; void AutoCheckUpdatesChanged(bool value) const; void ClassifiedUpdatablePackagesChanged(LastoreUpdatePackagesInfo value) const; @@ -146,6 +157,8 @@ class UpdateDBusProxy : public QObject void UpdateModeChanged(qulonglong value) const; void UpdateStatusChanged(QString value) const; void ImmutableAutoRecoveryChanged(bool value) const; + void P2PUpdateEnableChanged(bool value) const; + void P2PUpdateSupportChanged(bool value) const; void managerInterServiceValidChanged(bool value) const; // Power diff --git a/src/dcc-update-plugin/operation/updatedatastructs.h b/src/dcc-update-plugin/operation/updatedatastructs.h index abd00dca..d82ad99c 100644 --- a/src/dcc-update-plugin/operation/updatedatastructs.h +++ b/src/dcc-update-plugin/operation/updatedatastructs.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2011 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2011-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -65,12 +65,14 @@ struct IdleDownloadConfig { struct DownloadSpeedLimitConfig { bool downloadSpeedLimitEnabled = false; QString limitSpeed = "10240"; + bool isOnlineSpeedLimit = false; QString toJson() const { QJsonObject obj; obj.insert("DownloadSpeedLimitEnabled", downloadSpeedLimitEnabled); obj.insert("LimitSpeed", limitSpeed); + obj.insert("IsOnlineSpeedLimit", isOnlineSpeedLimit); QJsonDocument doc; doc.setObject(obj); return doc.toJson(); @@ -89,11 +91,130 @@ struct DownloadSpeedLimitConfig { QJsonObject obj = doc.object(); config.downloadSpeedLimitEnabled = obj.contains("DownloadSpeedLimitEnabled") ? obj.value("DownloadSpeedLimitEnabled").toBool() : false; config.limitSpeed = obj.contains("LimitSpeed") ? obj.value("LimitSpeed").toString() : "10240"; + config.isOnlineSpeedLimit = obj.contains("IsOnlineSpeedLimit") ? obj.value("IsOnlineSpeedLimit").toBool() : false; return config; } }; +/** + * @brief 通过lastore修改upgrade服务限速配置的数据结构 + */ +struct LastoreUpgradeSpeedLimitConfig { + bool speedLimitEnabled = false; + QString limitSpeed = "10240"; + bool isOnlineSpeedLimit = false; + + QString toJson() const + { + QJsonObject obj; + obj.insert("SpeedLimitEnabled", speedLimitEnabled); + obj.insert("LimitSpeed", limitSpeed); + obj.insert("IsOnlineSpeedLimit", isOnlineSpeedLimit); + QJsonDocument doc; + doc.setObject(obj); + return doc.toJson(); + } + + static LastoreUpgradeSpeedLimitConfig fromJson(const QByteArray& configStr) + { + LastoreUpgradeSpeedLimitConfig config; + QJsonParseError jsonParseError; + const QJsonDocument doc = QJsonDocument::fromJson(configStr, &jsonParseError); + if (jsonParseError.error != QJsonParseError::NoError || doc.isEmpty()) { + qWarning() << "Parse download speed limit config failed: " << jsonParseError.errorString(); + return config; + } + + QJsonObject obj = doc.object(); + config.speedLimitEnabled = obj.contains("SpeedLimitEnabled") ? obj.value("SpeedLimitEnabled").toBool() : false; + config.limitSpeed = obj.contains("LimitSpeed") ? obj.value("LimitSpeed").toString() : "10240"; + config.isOnlineSpeedLimit = obj.contains("IsOnlineSpeedLimit") ? obj.value("IsOnlineSpeedLimit").toBool() : false; + + return config; + } +}; + +/** + * @brief 传递优化upgrade服务上传下载限速配置 + */ +struct UpgradeSpeedLimitConfig { + int currentRate = 102400; + int limitRate = 102400; + int limitType = 0; // 限速类型 + int rateType = 0; // 速率类型 + int speed = 10240; // 速度值 + QDateTime startTime; // 开始时间 + QDateTime endTime; // 结束时间 + + bool ifInOnlineLimit() const { + if (limitType != 3) { + return false; + } + + if (!startTime.isValid() || !endTime.isValid()) { + return false; + } + + QDateTime currentTime = QDateTime::currentDateTime(); + return currentTime >= startTime && currentTime <= endTime; + } + + bool shouldLimitRate() const { + if (ifInOnlineLimit()) { + return true; + } + return limitType == 1; + } + + QString toJson() const + { + QJsonObject obj; + obj.insert("CurrentRate", currentRate); + obj.insert("LimitRate", limitRate); + obj.insert("LimitType", limitType); + obj.insert("RateType", rateType); + obj.insert("Speed", speed); + obj.insert("StartTime", startTime.toString(Qt::ISODate)); + obj.insert("EndTime", endTime.toString(Qt::ISODate)); + + QJsonDocument doc; + doc.setObject(obj); + return doc.toJson(); + } + + static UpgradeSpeedLimitConfig fromJson(const QByteArray& configStr) + { + UpgradeSpeedLimitConfig config; + QJsonParseError jsonParseError; + const QJsonDocument doc = QJsonDocument::fromJson(configStr, &jsonParseError); + + if (jsonParseError.error != QJsonParseError::NoError || doc.isEmpty()) { + // qCWarning(logDccUpdatePlugin) << "Parse upgrade speed limit config failed: " << jsonParseError.errorString(); + return config; + } + + QJsonObject obj = doc.object(); + config.currentRate = obj.contains("CurrentRate") ? obj.value("CurrentRate").toInt() : 10240; + config.limitRate = obj.contains("LimitRate") ? obj.value("LimitRate").toInt() : 10240; + config.limitType = obj.contains("LimitType") ? obj.value("LimitType").toInt() : 0; + config.rateType = obj.contains("RateType") ? obj.value("RateType").toInt() : 0; + config.speed = obj.contains("Speed") ? obj.value("Speed").toInt() : 10240; + + if (obj.contains("StartTime") && obj.value("StartTime").isString()) { + QString startTimeStr = obj.value("StartTime").toString(); + config.startTime = QDateTime::fromString(startTimeStr, Qt::ISODate); + } + + if (obj.contains("EndTime") && obj.value("EndTime").isString()) { + QString endTimeStr = obj.value("EndTime").toString(); + config.endTime = QDateTime::fromString(endTimeStr, Qt::ISODate); + } + + return config; + } +}; + struct LastoreDaemonUpdateStatus { UpdatesStatus backupStatus = UpdatesStatus::Default; UpdateErrorType backupError = UpdateErrorType::NoError; diff --git a/src/dcc-update-plugin/operation/updatelistmodel.cpp b/src/dcc-update-plugin/operation/updatelistmodel.cpp index b5fbdc7a..bd040b99 100644 --- a/src/dcc-update-plugin/operation/updatelistmodel.cpp +++ b/src/dcc-update-plugin/operation/updatelistmodel.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd. // SPDX-License-Identifier: GPL-3.0-or-later #include "updatelistmodel.h" #include diff --git a/src/dcc-update-plugin/operation/updatelistmodel.h b/src/dcc-update-plugin/operation/updatelistmodel.h index 1d26b8b3..51d3c9f5 100644 --- a/src/dcc-update-plugin/operation/updatelistmodel.h +++ b/src/dcc-update-plugin/operation/updatelistmodel.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd. // SPDX-License-Identifier: GPL-3.0-or-later #ifndef UPDATELISTMODEL_H #define UPDATELISTMODEL_H diff --git a/src/dcc-update-plugin/operation/updatemodel.cpp b/src/dcc-update-plugin/operation/updatemodel.cpp index 861e12de..8a1a538b 100644 --- a/src/dcc-update-plugin/operation/updatemodel.cpp +++ b/src/dcc-update-plugin/operation/updatemodel.cpp @@ -1113,6 +1113,11 @@ bool UpdateModel::downloadSpeedLimitEnabled() const return DownloadSpeedLimitConfig::fromJson(m_speedLimitConfig).downloadSpeedLimitEnabled; } +bool UpdateModel::downloadIsOnlineSpeedLimit() const +{ + return DownloadSpeedLimitConfig::fromJson(m_speedLimitConfig).isOnlineSpeedLimit; +} + QString UpdateModel::downloadSpeedLimitSize() const { return DownloadSpeedLimitConfig::fromJson(m_speedLimitConfig).limitSpeed; @@ -1133,6 +1138,95 @@ void UpdateModel::setSpeedLimitConfig(const QByteArray& config) Q_EMIT downloadSpeedLimitConfigChanged(); } +void UpdateModel::setUpgradeDownloadSpeedLimitConfig(const QByteArray& config) +{ + qCInfo(logDccUpdatePlugin) << "setUpgradeDownloadSpeedLimitConfig" << config; + // if (m_upgradeDownloadSpeedLimitConfig == config) + // return; + + m_upgradeDownloadSpeedLimitConfig = config; + Q_EMIT upgradeDownloadSpeedLimitConfigChanged(); +} + +QString UpdateModel::upgradeDownloadSpeedCurrentRate() const +{ + qCInfo(logDccUpdatePlugin) << "upgradeDownloadSpeedCurrentRate " << UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig).currentRate; + return QString::number(UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig).currentRate / 1024); +} + +QString UpdateModel::upgradeDownloadSpeedLimitRate() const +{ + qCInfo(logDccUpdatePlugin) << "upgradeDownloadSpeedCurrentRate " << UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig).currentRate; + return QString::number(UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig).limitRate / 1024); +} + +bool UpdateModel::upgradeDownloadSpeedEnable() const +{ + qCInfo(logDccUpdatePlugin) << "xiongbo111 upgradeDownloadSpeedCurrentRate " << m_upgradeDownloadSpeedLimitConfig; + return UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig).shouldLimitRate(); +} + +bool UpdateModel::upgradeDownloadSpeedIsOnline() const +{ + return UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig).ifInOnlineLimit(); +} + +UpgradeSpeedLimitConfig UpdateModel::upgradeDownloadSpeedLimitConfig() const +{ + return UpgradeSpeedLimitConfig::fromJson(m_upgradeDownloadSpeedLimitConfig); +} + +void UpdateModel::setUpgradeUploadSpeedLimitConfig(const QByteArray& config) +{ + m_upgradeUploadSpeedLimitConfig = config; + Q_EMIT upgradeUploadSpeedLimitConfigChanged(); +} + +QString UpdateModel::upgradeUploadSpeedCurrentRate() const +{ + return QString::number(UpgradeSpeedLimitConfig::fromJson(m_upgradeUploadSpeedLimitConfig).currentRate / 1024); +} + +QString UpdateModel::upgradeUploadSpeedLimitRate() const +{ + return QString::number(UpgradeSpeedLimitConfig::fromJson(m_upgradeUploadSpeedLimitConfig).limitRate / 1024); +} + +bool UpdateModel::upgradeUploadSpeedEnable() const +{ + return UpgradeSpeedLimitConfig::fromJson(m_upgradeUploadSpeedLimitConfig).shouldLimitRate(); +} + +bool UpdateModel::upgradeUploadSpeedIsOnline() const +{ + return UpgradeSpeedLimitConfig::fromJson(m_upgradeUploadSpeedLimitConfig).ifInOnlineLimit(); +} + +UpgradeSpeedLimitConfig UpdateModel::upgradeUploadSpeedLimitConfig() const +{ + return UpgradeSpeedLimitConfig::fromJson(m_upgradeUploadSpeedLimitConfig); +} + +bool UpdateModel::upgradeDeliveryEnable() const +{ + return m_isUpgradeDeliveryEnable; +} + +void UpdateModel::setUpgradeDeliveryEnable(bool enable) +{ + m_isUpgradeDeliveryEnable = enable; + Q_EMIT upgradeDeliveryEnableChanged(); +} + +void UpdateModel::refreshUpgradeDeliveryEnable(bool enable) +{ + m_isUpgradeDeliveryEnable = enable; + if (enable) { + Q_EMIT upgradeDownloadSpeedLimitConfigChanged(); + Q_EMIT upgradeUploadSpeedLimitConfigChanged(); + } +} + void UpdateModel::setAutoDownloadUpdates(bool autoDownloadUpdates) { qCDebug(logDccUpdatePlugin) << "Set auto download updates:" << autoDownloadUpdates; diff --git a/src/dcc-update-plugin/operation/updatemodel.h b/src/dcc-update-plugin/operation/updatemodel.h index 6a5d8f4a..52c9997c 100644 --- a/src/dcc-update-plugin/operation/updatemodel.h +++ b/src/dcc-update-plugin/operation/updatemodel.h @@ -73,6 +73,7 @@ class UpdateModel : public QObject Q_PROPERTY(bool thirdPartyUpdate READ thirdPartyUpdate NOTIFY updateModeChanged FINAL) Q_PROPERTY(bool updateModeDisabled READ updateModeDisabled NOTIFY updateModeChanged FINAL) Q_PROPERTY(bool downloadSpeedLimitEnabled READ downloadSpeedLimitEnabled NOTIFY downloadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(bool downloadIsOnlineSpeedLimit READ downloadIsOnlineSpeedLimit NOTIFY downloadIsOnlineSpeedLimitChanged FINAL) Q_PROPERTY(QString downloadSpeedLimitSize READ downloadSpeedLimitSize NOTIFY downloadSpeedLimitConfigChanged FINAL) Q_PROPERTY(bool autoDownloadUpdates READ autoDownloadUpdates WRITE setAutoDownloadUpdates NOTIFY autoDownloadUpdatesChanged FINAL) Q_PROPERTY(bool idleDownloadEnabled READ idleDownloadEnabled NOTIFY idleDownloadConfigChanged FINAL) @@ -82,7 +83,13 @@ class UpdateModel : public QObject Q_PROPERTY(bool autoCleanCache READ autoCleanCache WRITE setAutoCleanCache NOTIFY autoCleanCacheChanged FINAL) Q_PROPERTY(bool smartMirrorSwitch READ smartMirrorSwitch WRITE setSmartMirrorSwitch NOTIFY smartMirrorSwitchChanged FINAL) Q_PROPERTY(TestingChannelStatus testingChannelStatus READ testingChannelStatus WRITE setTestingChannelStatus NOTIFY testingChannelStatusChanged FINAL) - + Q_PROPERTY(QString upgradeDownloadSpeedCurrentRate READ upgradeDownloadSpeedCurrentRate NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(QString upgradeDownloadSpeedLimitRate READ upgradeDownloadSpeedLimitRate NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(bool upgradeDownloadSpeedEnable READ upgradeDownloadSpeedEnable NOTIFY upgradeDownloadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(QString upgradeUploadSpeedCurrentRate READ upgradeUploadSpeedCurrentRate NOTIFY upgradeUploadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(QString upgradeUploadSpeedLimitRate READ upgradeUploadSpeedLimitRate NOTIFY upgradeUploadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(bool upgradeUploadSpeedEnable READ upgradeUploadSpeedEnable NOTIFY upgradeUploadSpeedLimitConfigChanged FINAL) + Q_PROPERTY(bool upgradeDeliveryEnable READ upgradeDeliveryEnable NOTIFY upgradeDeliveryEnableChanged FINAL) Q_PROPERTY(UpdateHistoryModel *historyModel READ historyModel NOTIFY historyModelChanged FINAL) @@ -262,10 +269,28 @@ class UpdateModel : public QObject void setUpdateItemEnabled(); bool downloadSpeedLimitEnabled() const; + bool downloadIsOnlineSpeedLimit() const; QString downloadSpeedLimitSize() const; DownloadSpeedLimitConfig speedLimitConfig() const; void setSpeedLimitConfig(const QByteArray &config); + void setUpgradeDownloadSpeedLimitConfig(const QByteArray& config); + QString upgradeDownloadSpeedCurrentRate() const; + QString upgradeDownloadSpeedLimitRate() const; + bool upgradeDownloadSpeedEnable() const; + bool upgradeDownloadSpeedIsOnline() const; + UpgradeSpeedLimitConfig upgradeDownloadSpeedLimitConfig() const; + void setUpgradeUploadSpeedLimitConfig(const QByteArray& config); + QString upgradeUploadSpeedCurrentRate() const; + QString upgradeUploadSpeedLimitRate() const; + bool upgradeUploadSpeedEnable() const; + bool upgradeUploadSpeedIsOnline() const; + UpgradeSpeedLimitConfig upgradeUploadSpeedLimitConfig() const; + bool upgradeDeliveryEnable() const; + + void setUpgradeDeliveryEnable(bool enable); + void refreshUpgradeDeliveryEnable(bool enable); + bool autoDownloadUpdates() const { return m_autoDownloadUpdates; } void setAutoDownloadUpdates(bool autoDownloadUpdates); @@ -383,7 +408,11 @@ public slots: void securityUpdateEnabledChanged(bool enable); void thirdPartyUpdateEnabledChanged(bool enable); void updateModeChanged(quint64 updateMode); + void upgradeDeliveryEnableChanged(); void downloadSpeedLimitConfigChanged(); + void downloadIsOnlineSpeedLimitChanged(); + void upgradeDownloadSpeedLimitConfigChanged(); + void upgradeUploadSpeedLimitConfigChanged(); void autoDownloadUpdatesChanged(bool autoDownloadUpdates); void idleDownloadConfigChanged(); void updateNotifyChanged(const bool notify); @@ -457,6 +486,9 @@ public slots: bool m_thirdPartyUpdateEnabled; quint64 m_updateMode; QByteArray m_speedLimitConfig; + bool m_isUpgradeDeliveryEnable; + QByteArray m_upgradeDownloadSpeedLimitConfig; + QByteArray m_upgradeUploadSpeedLimitConfig; bool m_autoDownloadUpdates; IdleDownloadConfig m_idleDownloadConfig; bool m_updateNotify; diff --git a/src/dcc-update-plugin/operation/updatework.cpp b/src/dcc-update-plugin/operation/updatework.cpp index 9b350cf7..c67fa354 100644 --- a/src/dcc-update-plugin/operation/updatework.cpp +++ b/src/dcc-update-plugin/operation/updatework.cpp @@ -29,7 +29,6 @@ #include Q_DECLARE_LOGGING_CATEGORY(logDccUpdatePlugin) - using namespace DCC_NAMESPACE; const QString TestingChannel = "testing Channel"; @@ -129,6 +128,7 @@ UpdateWorker::UpdateWorker(UpdateModel* model, QObject* parent) , m_backupJob(nullptr) , m_installPackageJob(nullptr) , m_removePackageJob(nullptr) + , m_updateAssistant(nullptr) { qCDebug(logDccUpdatePlugin) << "Initializing UpdateWorker"; qRegisterMetaType("UpdatesStatus"); @@ -209,6 +209,15 @@ void UpdateWorker::initConnect() // m_model->setP2PUpdateEnabled(DConfigWatcher::instance()->getValue(DConfigWatcher::update, configName).toBool()); } }); + + m_updateAssistant = new UpdateAssistant("org.deepin.upgradedelivery", "/org/deepin/upgradedelivery", QDBusConnection::systemBus(), this); + connect(m_updateInter, &UpdateDBusProxy::AutoDownloadUpdatesChanged, m_model, &UpdateModel::setAutoDownloadUpdates); + connect(m_updateInter, &UpdateDBusProxy::MirrorSourceChanged, m_model, &UpdateModel::setDefaultMirror); + QDBusConnection::systemBus().connect("org.deepin.upgradedelivery", + "/org/deepin/upgradedelivery", + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + m_model, SLOT(onUpdatePropertiesChanged(QString, QVariantMap, QStringList))); } void UpdateWorker::activate() @@ -221,6 +230,7 @@ void UpdateWorker::activate() updateSystemVersion(); refreshLastTimeAndCheckCircle(); initTestingChannel(); + refreshUpgradeDeliveryInfo(); m_model->setIsPrivateUpdate(DConfigHelper::instance()->getConfig("org.deepin.dde.lastore", "org.deepin.dde.lastore", "","intranet-update", false).toString() == "true"); m_model->setUpdateMode(m_updateInter->updateMode()); @@ -905,6 +915,7 @@ void UpdateWorker::setDownloadSpeedLimitEnabled(bool enable) qCDebug(logDccUpdatePlugin) << "Set download speed limit enabled:" << enable; auto config = m_model->speedLimitConfig(); config.downloadSpeedLimitEnabled = enable; + config.isOnlineSpeedLimit = false; // dbus返回需要1s,导致界面更新慢,这里直接先更新model m_model->setSpeedLimitConfig(config.toJson().toUtf8()); setDownloadSpeedLimitConfig(config.toJson()); @@ -915,6 +926,7 @@ void UpdateWorker::setDownloadSpeedLimitSize(const QString& size) qCDebug(logDccUpdatePlugin) << "set download speed limit size" << size; auto config = m_model->speedLimitConfig(); config.limitSpeed = size; + config.isOnlineSpeedLimit = false; setDownloadSpeedLimitConfig(config.toJson()); } @@ -1271,6 +1283,14 @@ void UpdateWorker::initTestingChannel() }); } +void UpdateWorker::refreshUpgradeDeliveryInfo() +{ + qCDebug(logDccUpdatePlugin) << "Refresh upgrade delivery info"; + m_model->setUpgradeDownloadSpeedLimitConfig(m_updateAssistant->downloadLimitSpeed().toUtf8()); + m_model->setUpgradeUploadSpeedLimitConfig(m_updateAssistant->uploadLimitSpeed().toUtf8()); + m_model->setUpgradeDeliveryEnable(m_updateInter->p2pUpdateEnable()); +} + void UpdateWorker::checkTestingChannelStatus() { // Leave page @@ -1706,3 +1726,94 @@ void UpdateWorker::onRemovePackageStatusChanged(const QString& value) } } +//更新传递总开关 +void UpdateWorker::setUpgradeDeliveryEnabled(bool enabled) +{ + if (enabled == m_model->upgradeDeliveryEnable()) { + return; + } + + qCDebug(logDccUpdatePlugin) << "Set update assistant service, enabled: " << enabled; + auto func_set_success = [=](bool enabled) { + qCDebug(logDccUpdatePlugin) << "Set update assistant service succeed, enabled " << enabled; + if (m_updateAssistant && m_model) { + m_model->setUpgradeDownloadSpeedLimitConfig(m_updateAssistant->downloadLimitSpeed().toUtf8()); + m_model->setUpgradeUploadSpeedLimitConfig(m_updateAssistant->uploadLimitSpeed().toUtf8()); + m_model->setUpgradeDeliveryEnable(enabled); + } + }; + auto watcher = new QDBusPendingCallWatcher(m_updateInter->SetUpgradeDeliveryEnable(enabled), this); + connect(watcher, &QDBusPendingCallWatcher::finished, [this, watcher, enabled, func_set_success] { + watcher->deleteLater(); + if (watcher->isError()) { + qCWarning(logDccUpdatePlugin) << "Set update assistant service failed, enabled " << enabled << " error: " << watcher->error().message(); + m_model->setUpgradeDeliveryEnable(!enabled); + return; + } + func_set_success(enabled); + }); +} + +//设置更新传递下载限速 +void UpdateWorker::setUpgradeDeliveryDownloadLimitSpeed(const QString& speed, bool enable) +{ + LastoreUpgradeSpeedLimitConfig downloadSpeedLimitConfig; + downloadSpeedLimitConfig.isOnlineSpeedLimit = false; + downloadSpeedLimitConfig.speedLimitEnabled = enable; + downloadSpeedLimitConfig.limitSpeed = speed; + qCInfo(logDccUpdatePlugin) << "Set upgrade download speed limit: " << downloadSpeedLimitConfig.toJson(); + auto watcher = new QDBusPendingCallWatcher(m_updateInter->SetUpgradeDeliveryDownloadSpeedLimit(downloadSpeedLimitConfig.toJson()), this); + connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, this] { + watcher->deleteLater(); + if (watcher->isError()) { + qCWarning(logDccUpdatePlugin) << "Set upgrade download speed limit config error: " << watcher->error().message(); + getUpgradeDeliveryDownloadLimitSpeed(); + } + }); +} + +//设置更新传递上传限速 +void UpdateWorker::setUpgradeDeliveryUploadLimitSpeed(const QString& speed, bool enable) +{ + LastoreUpgradeSpeedLimitConfig uploadSpeedLimitConfig; + uploadSpeedLimitConfig.isOnlineSpeedLimit = false; + uploadSpeedLimitConfig.speedLimitEnabled = enable; + uploadSpeedLimitConfig.limitSpeed = speed; + qCInfo(logDccUpdatePlugin) << "Set upgrade upload speed limit: " << uploadSpeedLimitConfig.toJson(); + auto watcher = new QDBusPendingCallWatcher(m_updateInter->SetUpgradeDeliveryUploadSpeedLimit(uploadSpeedLimitConfig.toJson()), this); + connect(watcher, &QDBusPendingCallWatcher::finished, [watcher, this] { + watcher->deleteLater(); + if (watcher->isError()) { + qCWarning(logDccUpdatePlugin) << "Set upgrade upload speed limit config error: " << watcher->error().message(); + getUpgradeDeliveryUploadLimitSpeed(); + } + }); +} + +void UpdateWorker::getUpgradeDeliveryDownloadLimitSpeed() +{ + if (m_updateAssistant && m_model) { + m_model->setUpgradeDownloadSpeedLimitConfig(m_updateAssistant->downloadLimitSpeed().toUtf8()); + } +} + +void UpdateWorker::getUpgradeDeliveryUploadLimitSpeed() +{ + if (m_updateAssistant && m_model) { + m_model->setUpgradeUploadSpeedLimitConfig(m_updateAssistant->uploadLimitSpeed().toUtf8()); + } +} + +void UpdateWorker::cleanUpgradeDeliveryCache() +{ + qCDebug(logDccUpdatePlugin) << "Clean update assistant cache succeed"; + auto watcher = new QDBusPendingCallWatcher(m_updateInter->ClearUpgradeDeliveryCache(), this); + connect(watcher, &QDBusPendingCallWatcher::finished, [this, watcher] { + watcher->deleteLater(); + if (watcher->isError()) { + qCWarning(logDccUpdatePlugin) << "Clean update assistant cache failed"; + return; + } + }); +} + diff --git a/src/dcc-update-plugin/operation/updatework.h b/src/dcc-update-plugin/operation/updatework.h index 376e4cc5..35c623ee 100644 --- a/src/dcc-update-plugin/operation/updatework.h +++ b/src/dcc-update-plugin/operation/updatework.h @@ -10,6 +10,7 @@ #include "common/common/logwatcherhelper.h" #include "common/dbus/updatedbusproxy.h" #include "common/dbus/updatejobdbusproxy.h" +#include "common/dbus/updateassistant.h" #include #include @@ -73,7 +74,13 @@ class UpdateWorker : public QObject Q_INVOKABLE void setIdleDownloadEnabled(bool enable); Q_INVOKABLE void setIdleDownloadBeginTime(QString time); Q_INVOKABLE void setIdleDownloadEndTime(QString time); - void setIdleDownloadConfig(const IdleDownloadConfig& config); + Q_INVOKABLE void setUpgradeDeliveryEnabled(bool enabled); + Q_INVOKABLE void setUpgradeDeliveryDownloadLimitSpeed(const QString& speed, bool enable); + Q_INVOKABLE void setUpgradeDeliveryUploadLimitSpeed(const QString& speed, bool enable); + Q_INVOKABLE void getUpgradeDeliveryDownloadLimitSpeed(); + Q_INVOKABLE void getUpgradeDeliveryUploadLimitSpeed(); + Q_INVOKABLE void cleanUpgradeDeliveryCache(); + Q_INVOKABLE void setIdleDownloadConfig(const IdleDownloadConfig& config); QString adjustTimeFunc(const QString& start, const QString& end, bool returnEndTime); // 更新设置-更新提醒 @@ -101,6 +108,7 @@ class UpdateWorker : public QObject void setInstallPackageJob(const QString& jobPath); void setRemovePackageJob(const QString& jobPath); QString getServiceUrlByRegion(); + void refreshUpgradeDeliveryInfo(); Q_INVOKABLE bool openUrl(const QString& url); Q_INVOKABLE void onRequestRetry(int type, int updateTypes); @@ -133,6 +141,7 @@ public Q_SLOTS: Dtk::Core::DConfig *m_lastoreDConfig; UpdateModel* m_model; UpdateDBusProxy *m_updateInter; + UpdateAssistant* m_updateAssistant; QTimer *m_lastoreHeartBeatTimer; // lastore-daemon 心跳信号,防止lastore-daemon自动退出 LogWatcherHelper *m_logWatcherHelper; diff --git a/src/dcc-update-plugin/operation/utils.h b/src/dcc-update-plugin/operation/utils.h index 44ad9696..65e7448d 100644 --- a/src/dcc-update-plugin/operation/utils.h +++ b/src/dcc-update-plugin/operation/utils.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2011 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2011-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/src/dcc-update-plugin/qml/UpdateControl.qml b/src/dcc-update-plugin/qml/UpdateControl.qml index c2c4ee6d..156336e4 100644 --- a/src/dcc-update-plugin/qml/UpdateControl.qml +++ b/src/dcc-update-plugin/qml/UpdateControl.qml @@ -118,115 +118,14 @@ ColumnLayout { Repeater { model: btnActions - delegate: Loader { - id: buttonLoader + delegate: D.Button { Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + text: modelData + font: D.DTK.fontManager.t6 visible: modelData.length !== 0 && !initAnimation.visible enabled: updatelistModel.model.isUpdateEnable - - Connections { - target: dccData.model() - function onIsPrivateUpdateChanged() { - updateButtonType() - } - function onIsUpdateDisabledChanged() { - updateButtonType() - } - function onShowCheckUpdateChanged() { - updateButtonType() - } - } - - Component.onCompleted: { - updateButtonType() - } - - function updateButtonType() { - var model = dccData.model() - if (!model) { - console.log("Model not ready yet") - return - } - if (index === 1) { - buttonLoader.sourceComponent = normalButtonComponent - } else if (model.isPrivateUpdate && - !model.isUpdateDisabled && - !model.showCheckUpdate && - model.preInstallListModel.anyVisible) { - buttonLoader.sourceComponent = dropdownButtonComponent - } else { - // 默认使用普通按钮 - buttonLoader.sourceComponent = normalButtonComponent - } - } - - Component { - id: normalButtonComponent - D.Button { - text: modelData - font: D.DTK.fontManager.t6 - onClicked: { - rootLayout.btnClicked(index, updateListModels.getAllUpdateType()) - } - } - } - - Component { - id: dropdownButtonComponent - Item { - implicitWidth: button.implicitWidth - implicitHeight: button.implicitHeight - - enum InstallType { - Now, - Shutdown - } - - property int curType: DropdownButton.InstallType.Now - - signal requestUpdateNow() - signal requestUpdateShutdown() - - D.Button { - id: button - text: qsTr("Install") - - Menu { - id: contextMenu - - MenuItem { - text: qsTr("Install Now") - onClicked: { - dccData.work().setShutdownAndUpgrade(false) - dccData.work().doUpgrade(updateListModels.getAllUpdateType(), true) - } - } - - MenuItem { - text: qsTr("Install Shutdown") - onClicked: { - dccData.work().setShutdownAndUpgrade(true) - } - } - } - - // 点击按钮显示菜单 - onClicked: { - contextMenu.open() - } - } - - // 连接内部信号到外部 - Connections { - target: parent - function onRequestUpdateNow() { - rootLayout.btnClicked(index, 0) - } - function onRequestUpdateShutdown() { - rootLayout.btnClicked(index, 1) - } - } - } + onClicked: { + rootLayout.btnClicked(index, updateListModels.getAllUpdateType()) } } } diff --git a/src/dcc-update-plugin/qml/UpdateMain.qml b/src/dcc-update-plugin/qml/UpdateMain.qml index b1b975f1..c4db54ea 100644 --- a/src/dcc-update-plugin/qml/UpdateMain.qml +++ b/src/dcc-update-plugin/qml/UpdateMain.qml @@ -292,7 +292,7 @@ DccObject { updateListModels: dccData.model().preInstallListModel updateTitle: qsTr("Update download completed") btnActions: dccData.model().isPrivateUpdate ? [ - qsTr("Install updates"), + qsTr("Install Now"), qsTr("Check Again") ] : [qsTr("Install updates")] updateTips: { @@ -306,8 +306,12 @@ DccObject { onBtnClicked: function(index, updateType) { if (index === 0) { - updateSelectDialog.updateType = updateType - updateSelectDialog.show() + if (dccData.model().isPrivateUpdate) { + dccData.work().doUpgrade(updateListModels.getAllUpdateType(), true) + } else { + updateSelectDialog.updateType = updateType + updateSelectDialog.show() + } } else if (index === 1) { dccData.work().reCheckWithUi(); } @@ -400,7 +404,7 @@ DccObject { description: qsTr("Configure Update settings、Security Updates、Auto Download Updates and Updates Notification") icon: "update_set" weight: 120 - visible: dccData.model().systemActivation && !dccData.model().isPrivateUpdate + visible: dccData.model().systemActivation UpdateSetting {} } diff --git a/src/dcc-update-plugin/qml/UpdateSetting.qml b/src/dcc-update-plugin/qml/UpdateSetting.qml index 2f6ac976..8652379d 100644 --- a/src/dcc-update-plugin/qml/UpdateSetting.qml +++ b/src/dcc-update-plugin/qml/UpdateSetting.qml @@ -161,10 +161,221 @@ DccObject { } } + DccObject { + name: "upgradeDeliveryGrp" + parentName: "advancedSettingGroup" + weight: 40 + pageType: DccObject.Item + page: DccGroupView { + height: implicitHeight + 10 + spacing: 0 + } + + DccObject { + name: "upgradeDeliverySwitch" + parentName: "upgradeDeliveryGrp" + displayName: qsTr("Upgrade Delivery") + weight: 10 + enabled: !dccData.model().updateProhibited + pageType: DccObject.Editor + page: D.Switch { + id: upgradeDeliverySwitch + checked: dccData.model().upgradeDeliveryEnable + onCheckedChanged: { + dccData.work().setUpgradeDeliveryEnabled(checked) + } + Connections { + target: dccData.model() + function onUpgradeDeliveryEnableChanged() { + upgradeDeliverySwitch.checked = dccData.model().upgradeDeliveryEnable + } + } + } + } + + DccObject { + name: "upgradeDeliveryDownloadLimitSetting" + parentName: "upgradeDeliveryGrp" + displayName: qsTr("Upgrade Delivery Download Limit Setting") + visible: dccData.model().upgradeDeliveryEnable + weight: 20 + enabled: !dccData.model().upgradeDownloadSpeedIsOnline + pageType: DccObject.Item + property bool isInitializing: true + page: RowLayout { + D.CheckBox { + id: limitCheckBox + Layout.leftMargin: 14 + Layout.fillWidth: true + text: dccObj.displayName + checked: dccData.model().upgradeDownloadSpeedEnable + Connections { + target: dccData.model() + function onUpgradeDownloadSpeedLimitConfigChanged() { + limitCheckBox.checked = dccData.model().upgradeDownloadSpeedEnable + } + } + onCheckedChanged: { + if (dccObj.isInitializing) { + dccObj.isInitializing = false + return + } + if (limitCheckBox.checked) { + dccData.work().setUpgradeDeliveryDownloadLimitSpeed(lineEdit.text, limitCheckBox.checked) + } else { + dccData.work().setUpgradeDeliveryDownloadLimitSpeed("102400", limitCheckBox.checked) + } + } + } + + RowLayout { + spacing: 10 + Layout.topMargin: 5 + Layout.bottomMargin: 5 + Layout.rightMargin: 10 + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + D.LineEdit { + id: lineEdit + maximumLength: 5 + validator: RegularExpressionValidator { regularExpression: /^\d*$/ } + alertText: qsTr("Only numbers between 1-99999 are allowed") + alertDuration: 3000 + clearButton.active: lineEdit.activeFocus && (text.length !== 0) + text: dccData.model().upgradeDownloadSpeedCurrentRate + + onTextChanged: { + // 如果输入不为空且数字为0的情况,需要弹出提示且阻止继续输入 + if (lineEdit.text.length !== 0 && lineEdit.text[0] === "0") { + lineEdit.text = "" + lineEdit.showAlert = true + } else if (lineEdit.showAlert) { + lineEdit.showAlert = false + } + } + onEditingFinished: { + if (lineEdit.text.length === 0) { + lineEdit.text = dccData.model().upgradeDownloadSpeedLimitSize + return + } + dccData.work().setUpgradeDeliveryDownloadLimitSpeed(lineEdit.text, limitCheckBox.checked) + } + Keys.onPressed: { + if (event.key === Qt.Key_Return) { + lineEdit.forceActiveFocus(false); + } + } + Connections { + target: dccData.model() + function onUpgradeDownloadSpeedLimitConfigChanged() { + lineEdit.text = dccData.model().upgradeDownloadSpeedCurrentRate + } + } + } + + D.Label { + text: "KB/S" + } + } + } + } + + DccObject { + name: "upgradeDeliveryUploadLimitSetting" + parentName: "upgradeDeliveryGrp" + displayName: qsTr("Upgrade Delivery Upload Limit Setting") + visible: dccData.model().upgradeDeliveryEnable + weight: 20 + enabled: !dccData.model().upgradeUploadSpeedIsOnline + pageType: DccObject.Item + property bool isInitializing: true + page: RowLayout { + D.CheckBox { + id: limitCheckBox + Layout.leftMargin: 14 + Layout.fillWidth: true + text: dccObj.displayName + checked: dccData.model().upgradeUploadSpeedEnable + Connections { + target: dccData.model() + function onUpgradeUploadSpeedLimitConfigChanged() { + limitCheckBox.checked = dccData.model().upgradeUploadSpeedEnable + } + } + onCheckedChanged: { + console.log("xiongbo111") + if (dccObj.isInitializing) { + console.log("xiongbo222") + dccObj.isInitializing = false + return + } + console.log("xiongbo333") + if (limitCheckBox.checked) { + console.log("xiongbo444") + dccData.work().setUpgradeDeliveryUploadLimitSpeed(lineEdit.text, limitCheckBox.checked) + } else { + console.log("xiongbo555") + dccData.work().setUpgradeDeliveryUploadLimitSpeed("102400", limitCheckBox.checked) + } + } + } + + RowLayout { + spacing: 10 + Layout.topMargin: 5 + Layout.bottomMargin: 5 + Layout.rightMargin: 10 + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + D.LineEdit { + id: lineEdit + maximumLength: 5 + validator: RegularExpressionValidator { regularExpression: /^\d*$/ } + alertText: qsTr("Only numbers between 1-99999 are allowed") + alertDuration: 3000 + clearButton.active: lineEdit.activeFocus && (text.length !== 0) + text: dccData.model().upgradeUploadSpeedCurrentRate + + onTextChanged: { + // 如果输入不为空且数字为0的情况,需要弹出提示且阻止继续输入 + if (lineEdit.text.length !== 0 && lineEdit.text[0] === "0") { + lineEdit.text = "" + lineEdit.showAlert = true + } else if (lineEdit.showAlert) { + lineEdit.showAlert = false + } + } + onEditingFinished: { + if (lineEdit.text.length === 0) { + lineEdit.text = dccData.model().upgradeUploadSpeedLimitSize + return + } + dccData.work().setUpgradeDeliveryUploadLimitSpeed(lineEdit.text, limitCheckBox.checked) + } + Keys.onPressed: { + if (event.key === Qt.Key_Return) { + lineEdit.forceActiveFocus(false); + } + } + Connections { + target: dccData.model() + function onUpgradeUploadSpeedLimitConfigChanged() { + lineEdit.text = dccData.model().upgradeUploadSpeedCurrentRate + } + } + } + + D.Label { + text: "KB/S" + } + } + } + } + } + DccObject { name: "downloadLimitGrp" parentName: "advancedSettingGroup" weight: 40 + enabled: !dccData.model().downloadIsOnlineSpeedLimit pageType: DccObject.Item page: DccGroupView { height: implicitHeight + 10 @@ -179,7 +390,7 @@ DccObject { enabled: !dccData.model().updateProhibited pageType: DccObject.Editor page: D.Switch { - checked: dccData.model().downloadSpeedLimitEnabled + checked: dccData.model().downloadSpeedLimitEnabled || dccData.model().downloadIsOnlineSpeedLimit onCheckedChanged: { dccData.work().setDownloadSpeedLimitEnabled(checked) } @@ -238,6 +449,7 @@ DccObject { name: "autoDownloadGrp" parentName: "advancedSettingGroup" weight: 50 + visible: !dccData.model().isPrivateUpdate pageType: DccObject.Item page: DccGroupView { height: implicitHeight + 10 @@ -263,7 +475,7 @@ DccObject { name: "limitSetting" parentName: "autoDownloadGrp" displayName: qsTr("Download when Inactive") - visible: dccData.model().autoDownloadUpdates + visible: dccData.model().autoDownloadUpdates && !dccData.model().isPrivateUpdate weight: 20 enabled: !dccData.model().updateProhibited && !dccData.model().updateModeDisabled pageType: DccObject.Item @@ -346,6 +558,7 @@ DccObject { displayName: qsTr("Updates Notification") weight: 10 pageType: DccObject.Editor + visible: !dccData.model().isPrivateUpdate enabled: !dccData.model().updateProhibited && !dccData.model().updateModeDisabled page: D.Switch { checked: dccData.model().updateNotify @@ -360,6 +573,7 @@ DccObject { parentName: "advancedSettingGrp" displayName: qsTr("Clear Package Cache") weight: 20 + visible: !dccData.model().isPrivateUpdate pageType: DccObject.Editor page: D.Switch { checked: dccData.model().autoCleanCache @@ -374,6 +588,7 @@ DccObject { parentName: "advancedSettingGrp" displayName: qsTr("Update History") weight: 40 + visible: !dccData.model().isPrivateUpdate backgroundType: DccObject.Normal pageType: DccObject.Editor page: D.Button { @@ -403,7 +618,7 @@ DccObject { DccObject { name: "mirrorSettingGrp" parentName: "advancedSettingGroup" - visible: dccData.model().isCommunitySystem() + visible: dccData.model().isCommunitySystem() && !dccData.model().isPrivateUpdate weight: 70 pageType: DccObject.Item page: DccGroupView { diff --git a/src/dcc-update-plugin/translations/update_zh_CN.ts b/src/dcc-update-plugin/translations/update_zh_CN.ts index 7caeb278..e87eea2e 100644 --- a/src/dcc-update-plugin/translations/update_zh_CN.ts +++ b/src/dcc-update-plugin/translations/update_zh_CN.ts @@ -47,18 +47,6 @@ View Update Log 查看更新日志 - - Install - 更新 - - - Install Now - 立即更新 - - - Install Shutdown - 关机后更新 - UpdateHistoryDialog @@ -261,6 +249,10 @@ Install updates 安装更新 + + Install Now + 立即更新 + Check Again 重新检查更新 @@ -430,6 +422,18 @@ Delivers updates for additional repository sources 提供额外添加的仓库源更新内容 + + Upgrade Delivery + 更新传递 + + + Upgrade Delivery Download Limit Setting + 更新传递-下载限速 + + + Upgrade Delivery Upload Limit Setting + 更新传递-上传限速 + Limit Speed 下载限速 diff --git a/src/dcc-update-plugin/translations/update_zh_HK.ts b/src/dcc-update-plugin/translations/update_zh_HK.ts index 7d9e3fba..037d968c 100644 --- a/src/dcc-update-plugin/translations/update_zh_HK.ts +++ b/src/dcc-update-plugin/translations/update_zh_HK.ts @@ -47,18 +47,6 @@ View Update Log 查看更新日誌 - - Install - 更新 - - - Install Now - 立即更新 - - - Install Shutdown - 關機後更新 - UpdateHistoryDialog @@ -261,6 +249,10 @@ Install updates 安裝更新 + + Install Now + 立即更新 + Check Again 重新檢查更新 @@ -430,6 +422,18 @@ Delivers updates for additional repository sources 提供額外添加的倉庫源更新內容 + + Upgrade Delivery + 更新傳遞 + + + Upgrade Delivery Download Limit Setting + 更新傳遞-下載限速 + + + Upgrade Delivery Upload Limit Setting + 更新傳遞-上傳限速 + Limit Speed 下載限速 diff --git a/src/dcc-update-plugin/translations/update_zh_TW.ts b/src/dcc-update-plugin/translations/update_zh_TW.ts index 14066691..238dedee 100644 --- a/src/dcc-update-plugin/translations/update_zh_TW.ts +++ b/src/dcc-update-plugin/translations/update_zh_TW.ts @@ -47,18 +47,6 @@ View Update Log 檢視更新日誌 - - Install - 更新 - - - Install Now - 立即更新 - - - Install Shutdown - 關機後更新 - UpdateHistoryDialog @@ -261,6 +249,10 @@ Install updates 安裝更新 + + Install Now + 立即更新 + Check Again 重新檢查更新 @@ -430,6 +422,18 @@ Delivers updates for additional repository sources 提供額外新增的倉庫源更新內容 + + Upgrade Delivery + 更新傳遞 + + + Upgrade Delivery Download Limit Setting + 更新傳遞-下載限速 + + + Upgrade Delivery Upload Limit Setting + 更新傳遞-上傳限速 + Limit Speed 下載限速 diff --git a/src/private-lastore-tray/tipswidget.cpp b/src/private-lastore-tray/tipswidget.cpp index dee99773..68a4a63e 100644 --- a/src/private-lastore-tray/tipswidget.cpp +++ b/src/private-lastore-tray/tipswidget.cpp @@ -91,7 +91,6 @@ bool TipsWidget::checkRegularlyUpdate() void TipsWidget::onUpdatePropertiesChanged(const QString& interfaceName, const QVariantMap& changedProperties, const QStringList& invalidatedProperties) { Q_UNUSED(invalidatedProperties) - qCInfo(dockUpdatePlugin) << "xiongbo111 onUpdatePropertiesChanged " << interfaceName << " changedProperties " << changedProperties; if (interfaceName == "org.deepin.dde.Lastore1.Job") { if (changedProperties.contains("Speed")) {