fix: relink to autostart when dekstopFile has been changed

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2023-09-15 14:44:27 +08:00
committed by Comix
parent b2b5c23a2b
commit 7d94a8b71d
5 changed files with 38 additions and 4 deletions

View File

@ -386,9 +386,14 @@ void ApplicationManager1Service::updateApplication(const QSharedPointer<Applicat
if (destApp->m_entry != newEntry) {
destApp->resetEntry(newEntry);
destApp->m_desktopSource = std::move(desktopFile);
destApp->detachAllInstance();
}
if (destApp->m_desktopSource != desktopFile and destApp->isAutoStart()) {
destApp->setAutoStart(false);
destApp->m_desktopSource = std::move(desktopFile);
destApp->setAutoStart(true);
}
}
void ApplicationManager1Service::ReloadApplications()

View File

@ -421,12 +421,12 @@ qulonglong ApplicationService::lastLaunchedTime() const noexcept
return m_lastLaunch;
}
bool ApplicationService::autostartCheck(const QString &linkPath) noexcept
bool ApplicationService::autostartCheck(const QString &linkPath) const noexcept
{
QFileInfo info{linkPath};
if (info.exists()) {
if (info.isSymbolicLink()) {
if (info.isSymbolicLink() and info.symLinkTarget() == m_desktopSource.sourcePath()) {
return true;
}
qWarning() << "same name desktop file exists:" << linkPath << "but this may not created by AM.";

View File

@ -146,7 +146,7 @@ private:
const QLocale &locale = getUserLocale()) const noexcept;
void updateAfterLaunch(bool isLaunch) noexcept;
static bool shouldBeShown(const std::unique_ptr<DesktopEntry> &entry) noexcept;
static bool autostartCheck(const QString &linkPath) noexcept;
[[nodiscard]] bool autostartCheck(const QString &linkPath) const noexcept;
};
#endif