fix: relink to autostart when dekstopFile has been changed
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
b2b5c23a2b
commit
7d94a8b71d
@ -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()
|
||||
|
@ -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.";
|
||||
|
@ -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
|
||||
|
@ -556,6 +556,28 @@ bool operator!=(const DesktopEntry &lhs, const DesktopEntry &rhs)
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
bool operator==(const DesktopFile &lhs, const DesktopFile &rhs)
|
||||
{
|
||||
if (lhs.m_desktopId != rhs.m_desktopId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.sourcePath() != rhs.sourcePath()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.m_ctime != rhs.m_ctime or lhs.m_mtime != rhs.m_mtime) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const DesktopFile &lhs, const DesktopFile &rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const DesktopEntry::Value &v)
|
||||
{
|
||||
QDebugStateSaver saver{debug};
|
||||
|
@ -50,6 +50,9 @@ struct DesktopFile
|
||||
[[nodiscard]] bool modified(qint64 time) const noexcept;
|
||||
[[nodiscard]] qint64 createTime() const noexcept { return m_ctime; }
|
||||
|
||||
friend bool operator==(const DesktopFile &lhs, const DesktopFile &rhs);
|
||||
friend bool operator!=(const DesktopFile &lhs, const DesktopFile &rhs);
|
||||
|
||||
static std::optional<DesktopFile> searchDesktopFileById(const QString &appId, DesktopErrorCode &err) noexcept;
|
||||
static std::optional<DesktopFile> searchDesktopFileByPath(const QString &desktopFilePath, DesktopErrorCode &err) noexcept;
|
||||
static std::optional<DesktopFile> createTemporaryDesktopFile(const QString &temporaryFile) noexcept;
|
||||
@ -157,4 +160,8 @@ bool operator==(const DesktopEntry &lhs, const DesktopEntry &rhs);
|
||||
|
||||
bool operator!=(const DesktopEntry &lhs, const DesktopEntry &rhs);
|
||||
|
||||
bool operator==(const DesktopFile &lhs, const DesktopFile &rhs);
|
||||
|
||||
bool operator!=(const DesktopFile &lhs, const DesktopFile &rhs);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user