Skip to content

Commit 8c7d2c9

Browse files
committed
feat: add modal update
- Users can choose whether to perform modal updates - Update the logo of deepin pms: TASK-377199
1 parent 2f5623b commit 8c7d2c9

44 files changed

Lines changed: 1071 additions & 115 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/common/commondefine.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,10 @@ const static QString LockService = QStringLiteral("org.deepin.dde.LockService1")
3636
const static QString LockPath = QStringLiteral("/org/deepin/dde/LockService1");
3737
const static QString LockInterface = QStringLiteral("org.deepin.dde.LockService1");
3838

39+
// shutdownFront1
40+
const static QString ShutdownFront1Service = QStringLiteral("org.deepin.dde.ShutdownFront1");
41+
const static QString ShutdownFront1Path = QStringLiteral("/org/deepin/dde/ShutdownFront1");
42+
const static QString ShutdownFront1Interface = QStringLiteral("org.deepin.dde.ShutdownFront1");
43+
3944
const static QString PropertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties");
4045
const static QString PropertiesChanged = QStringLiteral("PropertiesChanged");

src/common/dbus/updatedbusproxy.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ UpdateDBusProxy::UpdateDBusProxy(QObject *parent)
3333
this))
3434
, m_lockServiceInter(new DDBusInterface(
3535
LockService, LockPath, LockInterface, QDBusConnection::systemBus(), this))
36+
, m_shutdownFrontInter(new DDBusInterface(
37+
ShutdownFront1Service, ShutdownFront1Path, ShutdownFront1Interface, QDBusConnection::sessionBus(), this))
3638
, m_interWatcher(new QDBusServiceWatcher(UpdaterService, QDBusConnection::systemBus()))
3739

3840
{
@@ -416,4 +418,17 @@ void UpdateDBusProxy::SetEnable(bool enable)
416418
QString UpdateDBusProxy::CurrentUser()
417419
{
418420
return QDBusPendingReply<QString>(m_lockServiceInter->asyncCall(QStringLiteral("CurrentUser")));
421+
}
422+
423+
void UpdateDBusProxy::Restart()
424+
{
425+
m_shutdownFrontInter->asyncCall(QStringLiteral("Restart"));
426+
}
427+
void UpdateDBusProxy::UpdateAndReboot()
428+
{
429+
m_shutdownFrontInter->asyncCall(QStringLiteral("UpdateAndReboot"));
430+
}
431+
void UpdateDBusProxy::UpdateAndShutdown()
432+
{
433+
m_shutdownFrontInter->asyncCall(QStringLiteral("UpdateAndShutdown"));
419434
}

src/common/dbus/updatedbusproxy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ class UpdateDBusProxy : public QObject
121121

122122
// lockService
123123
QString CurrentUser();
124+
125+
// shutdownFront
126+
void Restart();
127+
void UpdateAndReboot();
128+
void UpdateAndShutdown();
124129
signals:
125130
// updater
126131
void UpdateNotifyChanged(bool value) const;
@@ -156,6 +161,7 @@ class UpdateDBusProxy : public QObject
156161
DDBusInterface *m_smartMirrorInter;
157162
DDBusInterface *m_login1Inter;
158163
DDBusInterface *m_lockServiceInter;
164+
DDBusInterface *m_shutdownFrontInter;
159165

160166
QDBusServiceWatcher *m_interWatcher;
161167
};

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -682,12 +682,18 @@ void UpdateWorker::doUpgrade(int updateTypes, bool doBackup)
682682

683683
void UpdateWorker::reStart()
684684
{
685-
DDBusSender()
686-
.service("com.deepin.dde.shutdownFront")
687-
.interface("com.deepin.dde.shutdownFront")
688-
.path("/com/deepin/dde/shutdownFront")
689-
.method("Restart")
690-
.call();
685+
qCInfo(DCC_UPDATE_WORKER) << "request restart";
686+
m_updateInter->Restart();
687+
}
688+
689+
void UpdateWorker::modalUpgrade(bool rebootAfterUpgrade)
690+
{
691+
qCInfo(DCC_UPDATE_WORKER) << "request modal upgrade, reboot after upgrade:" << rebootAfterUpgrade;
692+
if (rebootAfterUpgrade) {
693+
m_updateInter->UpdateAndReboot();
694+
} else {
695+
m_updateInter->UpdateAndShutdown();
696+
}
691697
}
692698

693699
void UpdateWorker::setBackupJob(const QString& jobPath)
@@ -1404,7 +1410,7 @@ void UpdateWorker::onBackupStatusChanged(const QString &value)
14041410
m_model->setLastError(BackupFailed, analyzeJobErrorMessage(description, BackupFailed));
14051411
m_model->setBackupFailedTips(m_model->errorToText(m_model->lastError(BackupFailed)));
14061412
} else if (value == "end") {
1407-
deleteJob(m_downloadJob);
1413+
deleteJob(m_backupJob);
14081414
}
14091415
}
14101416

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class UpdateWorker : public QObject
5252
// 备份并安装更新
5353
Q_INVOKABLE void doUpgrade(int updateTypes, bool doBackup);
5454
Q_INVOKABLE void reStart();
55+
Q_INVOKABLE void modalUpgrade(bool rebootAfterUpgrade = true);
5556
void setBackupJob(const QString& jobPath);
5657
void setDistUpgradeJob(const QString& jobPath);
5758
void updateSystemVersion();
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
import QtQuick 2.15
4+
import QtQuick.Layouts 1.15
5+
import QtQuick.Controls 2.5
6+
7+
import org.deepin.dtk 1.0 as D
8+
import org.deepin.dtk.style as DS
9+
import org.deepin.dcc 1.0
10+
11+
D.DialogWindow {
12+
id: root
13+
width: 360
14+
height: 130
15+
icon: "preferences-system"
16+
modality: Qt.WindowModal
17+
18+
signal silentBtnClicked()
19+
signal upgradeRebootBtnClicked()
20+
signal upgradeShutdownBtnClicked()
21+
22+
ColumnLayout {
23+
anchors.fill: parent
24+
Label {
25+
Layout.alignment: Qt.AlignHCenter
26+
wrapMode: Text.WordWrap
27+
text: qsTr("The updates have been already downloaded. What do you want to do?")
28+
}
29+
30+
Item {
31+
Layout.fillHeight: true
32+
}
33+
34+
RowLayout {
35+
Layout.fillWidth: true
36+
Layout.bottomMargin: 0
37+
spacing: 10
38+
39+
D.Button {
40+
text: qsTr("Silent Installation")
41+
Layout.fillWidth: true
42+
onClicked: {
43+
root.silentBtnClicked()
44+
}
45+
}
46+
47+
D.Button {
48+
text: qsTr("Update and Reboot")
49+
Layout.fillWidth: true
50+
onClicked: {
51+
root.upgradeRebootBtnClicked()
52+
}
53+
}
54+
55+
D.Button {
56+
text: qsTr("Update and Shut Down")
57+
textColor: D.Palette {
58+
normal {
59+
common: D.DTK.makeColor(D.Color.Highlight)
60+
}
61+
normalDark: normal
62+
}
63+
Layout.fillWidth: true
64+
onClicked: {
65+
root.upgradeShutdownBtnClicked()
66+
}
67+
}
68+
}
69+
}
70+
}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,24 @@ DccObject {
238238
updateListEnable: !dccData.model().upgradeWaiting
239239

240240
onBtnClicked: function(index, updateType) {
241-
dccData.work().doUpgrade(updateType, true)
241+
updateSelectDialog.updateType = updateType
242+
updateSelectDialog.show()
243+
}
244+
245+
UpdateSelectDialog {
246+
id: updateSelectDialog
247+
property var updateType: 0
248+
palette: parent.palette
249+
visible: false
250+
onSilentBtnClicked: {
251+
dccData.work().doUpgrade(updateType, true)
252+
}
253+
onUpgradeRebootBtnClicked: {
254+
dccData.work().modalUpgrade(true)
255+
}
256+
onUpgradeShutdownBtnClicked: {
257+
dccData.work().modalUpgrade(false)
258+
}
242259
}
243260
}
244261
}

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@
226226
<translation type="unfinished"></translation>
227227
</message>
228228
</context>
229+
<context>
230+
<name>UpdateSelectDialog</name>
231+
<message>
232+
<source>The updates have been already downloaded. What do you want to do?</source>
233+
<translation type="unfinished"></translation>
234+
</message>
235+
<message>
236+
<source>Silent Installation</source>
237+
<translation type="unfinished"></translation>
238+
</message>
239+
<message>
240+
<source>Update and Reboot</source>
241+
<translation type="unfinished"></translation>
242+
</message>
243+
<message>
244+
<source>Update and Shut Down</source>
245+
<translation type="unfinished"></translation>
246+
</message>
247+
</context>
229248
<context>
230249
<name>UpdateSetting</name>
231250
<message>
@@ -324,6 +343,14 @@
324343
<source>Forum users at level 2 and above can join the beta test to receive the latest updates.</source>
325344
<translation type="unfinished"></translation>
326345
</message>
346+
<message>
347+
<source>Collapse</source>
348+
<translation type="unfinished">قم بطي ذلك</translation>
349+
</message>
350+
<message>
351+
<source>Only numbers between 1-99999 are allowed</source>
352+
<translation type="unfinished"></translation>
353+
</message>
327354
</context>
328355
<context>
329356
<name>UpdateWorker</name>

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@
226226
<translation type="unfinished"></translation>
227227
</message>
228228
</context>
229+
<context>
230+
<name>UpdateSelectDialog</name>
231+
<message>
232+
<source>The updates have been already downloaded. What do you want to do?</source>
233+
<translation type="unfinished"></translation>
234+
</message>
235+
<message>
236+
<source>Silent Installation</source>
237+
<translation type="unfinished"></translation>
238+
</message>
239+
<message>
240+
<source>Update and Reboot</source>
241+
<translation type="unfinished"></translation>
242+
</message>
243+
<message>
244+
<source>Update and Shut Down</source>
245+
<translation type="unfinished"></translation>
246+
</message>
247+
</context>
229248
<context>
230249
<name>UpdateSetting</name>
231250
<message>
@@ -324,6 +343,14 @@
324343
<source>Forum users at level 2 and above can join the beta test to receive the latest updates.</source>
325344
<translation type="unfinished"></translation>
326345
</message>
346+
<message>
347+
<source>Collapse</source>
348+
<translation type="unfinished"></translation>
349+
</message>
350+
<message>
351+
<source>Only numbers between 1-99999 are allowed</source>
352+
<translation type="unfinished"></translation>
353+
</message>
327354
</context>
328355
<context>
329356
<name>UpdateWorker</name>

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,25 @@
226226
<translation type="unfinished"></translation>
227227
</message>
228228
</context>
229+
<context>
230+
<name>UpdateSelectDialog</name>
231+
<message>
232+
<source>The updates have been already downloaded. What do you want to do?</source>
233+
<translation type="unfinished"></translation>
234+
</message>
235+
<message>
236+
<source>Silent Installation</source>
237+
<translation type="unfinished"></translation>
238+
</message>
239+
<message>
240+
<source>Update and Reboot</source>
241+
<translation type="unfinished"></translation>
242+
</message>
243+
<message>
244+
<source>Update and Shut Down</source>
245+
<translation type="unfinished"></translation>
246+
</message>
247+
</context>
229248
<context>
230249
<name>UpdateSetting</name>
231250
<message>
@@ -324,6 +343,14 @@
324343
<source>Forum users at level 2 and above can join the beta test to receive the latest updates.</source>
325344
<translation type="unfinished"></translation>
326345
</message>
346+
<message>
347+
<source>Collapse</source>
348+
<translation type="unfinished"></translation>
349+
</message>
350+
<message>
351+
<source>Only numbers between 1-99999 are allowed</source>
352+
<translation type="unfinished"></translation>
353+
</message>
327354
</context>
328355
<context>
329356
<name>UpdateWorker</name>

0 commit comments

Comments
 (0)