Skip to content

Commit f19d7d2

Browse files
committed
chore: avoid show confirm uninstall dialog when have preuninstall hook
存在卸载前钩子时,不显示卸载提示对话框,由卸载钩子来显示. PMS: BUG-322365 Log:
1 parent 0dd62d3 commit f19d7d2

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

desktopintegration.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,20 @@ void DesktopIntegration::setAutoStart(const QString &desktopId, bool on)
197197
return AppMgr::setAutoStart(desktopId, on);
198198
}
199199

200+
bool DesktopIntegration::shouldSkipConfirmUninstallDialog(const QString &desktopId) const
201+
{
202+
bool result = false;
203+
const QString & fullPath = AppInfo::fullPathByDesktopId(desktopId);
204+
if (fullPath.isEmpty()) return result;
205+
206+
DDesktopEntry entry(fullPath);
207+
if (!entry.stringValue("X-Deepin-PreUninstall").isEmpty()) {
208+
result = true;
209+
}
210+
211+
return result;
212+
}
213+
200214
void DesktopIntegration::uninstallApp(const QString &desktopId)
201215
{
202216
const QString & fullPath = AppInfo::fullPathByDesktopId(desktopId);

desktopintegration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class DesktopIntegration : public QObject
6464
Q_INVOKABLE void removeFromDesktop(const QString & desktopId);
6565
Q_INVOKABLE bool isAutoStart(const QString & desktopId) const;
6666
Q_INVOKABLE void setAutoStart(const QString & desktopId, bool on = true);
67+
Q_INVOKABLE bool shouldSkipConfirmUninstallDialog(const QString & desktopId) const;
6768
Q_INVOKABLE void uninstallApp(const QString & desktopId);
6869
qreal opacity() const;
6970

qml/AppItemMenu.qml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,20 @@ Loader {
132132
enabled: !root.desktopId.startsWith("internal/folders/") && !DesktopIntegration.appIsCompulsoryForDesktop(root.desktopId)
133133
text: qsTr("Uninstall")
134134
onTriggered: {
135-
if(LauncherController.currentFrame !== "FullscreenFrame"){
135+
if (LauncherController.currentFrame !== "FullscreenFrame") {
136136
LauncherController.setAvoidHide(true)
137137
LauncherController.visible = false
138-
}else{
138+
} else {
139139
LauncherController.setAvoidHide(false)
140140
}
141-
confirmUninstallDlg.appName = root.display
142-
confirmUninstallDlg.appId = root.desktopId
143-
confirmUninstallDlg.icon = root.iconName
144-
confirmUninstallDlg.show()
141+
if (!DesktopIntegration.shouldSkipConfirmUninstallDialog(root.desktopId)) {
142+
confirmUninstallDlg.appName = root.display
143+
confirmUninstallDlg.appId = root.desktopId
144+
confirmUninstallDlg.icon = root.iconName
145+
confirmUninstallDlg.show()
146+
} else {
147+
DesktopIntegration.uninstallApp(root.desktopId)
148+
}
145149
}
146150
}
147151

0 commit comments

Comments
 (0)