Skip to content

Commit f8771f0

Browse files
committed
feat: add battery check before system updates
1. Added battery status check in UpdateWorker before starting upgrades 2. Show notification if battery is not plugged in 3. Added new signal startDoUpgrade to properly handle dialog closing 4. Updated translations for new battery check message 5. Modified update dialog to close only after upgrade starts This change prevents system updates when running on battery to avoid potential issues from power loss during update process. The dialog now closes at the right time after the upgrade begins rather than immediately when clicking the button. feat: 在系统更新前添加电池检查 1. 在UpdateWorker中添加升级前的电池状态检查 2. 如果未插入电源则显示通知 3. 添加新的startDoUpgrade信号以正确处理对话框关闭 4. 更新电池检查消息的翻译 5. 修改更新对话框只在升级开始后关闭 此更改可防止在电池供电时进行系统更新,以避免更新过程中断电可能导致的问 题。对话框现在会在升级开始后而不是点击按钮时立即关闭。 pms: Bug-320697
1 parent 951a335 commit f8771f0

34 files changed

Lines changed: 225 additions & 54 deletions

src/dcc-update-plugin/operation/updatework.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,13 @@ void UpdateWorker::setDownloadJob(const QString& jobPath)
666666

667667
void UpdateWorker::doUpgrade(int updateTypes, bool doBackup)
668668
{
669+
if (!m_model->batterIsOK()) {
670+
notifyInfo(tr("Update"), tr("Please plug in and then install updates."));
671+
return;
672+
}
673+
674+
emit startDoUpgrade();
675+
669676
qCInfo(DCC_UPDATE_WORKER) << "Do upgrade, update types:" << updateTypes << ", whether do backup:" << doBackup;
670677
cleanLaStoreJob(m_distUpgradeJob);
671678
cleanLaStoreJob(m_backupJob);
@@ -700,6 +707,11 @@ void UpdateWorker::reStart()
700707

701708
void UpdateWorker::modalUpgrade(bool rebootAfterUpgrade)
702709
{
710+
if (!m_model->batterIsOK()) {
711+
notifyInfo(tr("Update"), tr("Please plug in and then install updates."));
712+
return;
713+
}
714+
703715
qCInfo(DCC_UPDATE_WORKER) << "request modal upgrade, reboot after upgrade:" << rebootAfterUpgrade;
704716
if (rebootAfterUpgrade) {
705717
m_updateInter->UpdateAndReboot();

src/dcc-update-plugin/operation/updatework.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public Q_SLOTS:
125125
Q_SIGNALS:
126126
void systemActivationChanged(bool systemActivation);
127127
void requestCloseTestingChannel();
128+
void startDoUpgrade();
128129

129130
private:
130131
Dtk::Core::DConfig *m_lastoreDConfig;

src/dcc-update-plugin/qml/updateMain.qml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ DccObject {
293293
visible: false
294294
onSilentBtnClicked: {
295295
dccData.work().doUpgrade(updateType, true)
296-
close()
297296
}
298297
onUpgradeRebootBtnClicked: {
299298
dccData.work().modalUpgrade(true)
@@ -302,6 +301,13 @@ DccObject {
302301
dccData.work().modalUpgrade(false)
303302
}
304303
}
304+
305+
Connections {
306+
target: dccData.work()
307+
function onStartDoUpgrade() {
308+
updateSelectDialog.close()
309+
}
310+
}
305311
}
306312
}
307313

src/dcc-update-plugin/translations/update_ar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@
412412
<source>Update</source>
413413
<translation type="unfinished"></translation>
414414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
415419
</context>
416420
<context>
417421
<name>update</name>

src/dcc-update-plugin/translations/update_az.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@
412412
<source>Update</source>
413413
<translation type="unfinished"></translation>
414414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
415419
</context>
416420
<context>
417421
<name>update</name>

src/dcc-update-plugin/translations/update_bo.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@
412412
<source>Update</source>
413413
<translation type="unfinished"></translation>
414414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
415419
</context>
416420
<context>
417421
<name>update</name>

src/dcc-update-plugin/translations/update_ca.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="ca">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="ca">
24
<context>
35
<name>CheckUpdate</name>
46
<message>
@@ -410,6 +412,10 @@
410412
<source>Update</source>
411413
<translation>Actualitza</translation>
412414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
413419
</context>
414420
<context>
415421
<name>update</name>
@@ -525,4 +531,4 @@
525531
<translation>La capacitat de la bateria és inferior al 60%. Per obtenir actualitzacions correctes, endolleu el dispositiu.</translation>
526532
</message>
527533
</context>
528-
</TS>
534+
</TS>

src/dcc-update-plugin/translations/update_de_DE.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="de_DE">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="de_DE">
24
<context>
35
<name>CheckUpdate</name>
46
<message>
@@ -25,7 +27,7 @@
2527
<name>UpdateControl</name>
2628
<message>
2729
<source>View Update Log</source>
28-
<translation type="unfinished"/>
30+
<translation type="unfinished"></translation>
2931
</message>
3032
</context>
3133
<context>
@@ -75,22 +77,22 @@
7577
</message>
7678
<message>
7779
<source>Version:</source>
78-
<translation type="unfinished"/>
80+
<translation type="unfinished"></translation>
7981
</message>
8082
</context>
8183
<context>
8284
<name>UpdateLogDialog</name>
8385
<message>
8486
<source>Update Log</source>
85-
<translation type="unfinished"/>
87+
<translation type="unfinished"></translation>
8688
</message>
8789
<message>
8890
<source>Close</source>
89-
<translation type="unfinished"/>
91+
<translation type="unfinished"></translation>
9092
</message>
9193
<message>
9294
<source>Export to desktop</source>
93-
<translation type="unfinished"/>
95+
<translation type="unfinished"></translation>
9496
</message>
9597
</context>
9698
<context>
@@ -247,26 +249,26 @@
247249
</message>
248250
<message>
249251
<source>The system has enabled auto recovery function and does not support updates. If you have any questions, please contact the enterprise administrator</source>
250-
<translation type="unfinished"/>
252+
<translation type="unfinished"></translation>
251253
</message>
252254
</context>
253255
<context>
254256
<name>UpdateSelectDialog</name>
255257
<message>
256258
<source>The updates have been already downloaded. What do you want to do?</source>
257-
<translation type="unfinished"/>
259+
<translation type="unfinished"></translation>
258260
</message>
259261
<message>
260262
<source>Silent Installation</source>
261-
<translation type="unfinished"/>
263+
<translation type="unfinished"></translation>
262264
</message>
263265
<message>
264266
<source>Update and Reboot</source>
265-
<translation type="unfinished"/>
267+
<translation type="unfinished"></translation>
266268
</message>
267269
<message>
268270
<source>Update and Shut Down</source>
269-
<translation type="unfinished"/>
271+
<translation type="unfinished"></translation>
270272
</message>
271273
</context>
272274
<context>
@@ -369,11 +371,11 @@
369371
</message>
370372
<message>
371373
<source>Collapse</source>
372-
<translation type="unfinished"/>
374+
<translation type="unfinished">Einfahren</translation>
373375
</message>
374376
<message>
375377
<source>Only numbers between 1-99999 are allowed</source>
376-
<translation type="unfinished"/>
378+
<translation type="unfinished"></translation>
377379
</message>
378380
</context>
379381
<context>
@@ -400,16 +402,20 @@
400402
</message>
401403
<message>
402404
<source>Log export failed, please try again</source>
403-
<translation type="unfinished"/>
405+
<translation type="unfinished"></translation>
404406
</message>
405407
<message>
406408
<source>The log has been exported to the desktop</source>
407-
<translation type="unfinished"/>
409+
<translation type="unfinished"></translation>
408410
</message>
409411
<message>
410412
<source>Update</source>
411413
<translation>Aktualisieren</translation>
412414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
413419
</context>
414420
<context>
415421
<name>update</name>
@@ -525,4 +531,4 @@
525531
<translation>Der Akku ist unter 60%. Um die Aktualisierung erfolgreich durchführen zu können schließen Sie bitte den Rechner ans Stromnetz an.</translation>
526532
</message>
527533
</context>
528-
</TS>
534+
</TS>

src/dcc-update-plugin/translations/update_en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@
412412
<source>Update</source>
413413
<translation type="unfinished"></translation>
414414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
415419
</context>
416420
<context>
417421
<name>update</name>

src/dcc-update-plugin/translations/update_en_US.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@
412412
<source>Update</source>
413413
<translation type="unfinished"></translation>
414414
</message>
415+
<message>
416+
<source>Please plug in and then install updates.</source>
417+
<translation type="unfinished"></translation>
418+
</message>
415419
</context>
416420
<context>
417421
<name>update</name>

0 commit comments

Comments
 (0)