feat: add property "LastLaunchedTime"
1. reactor some utils implementation. 2. remove constexpr before `decltype(auto)` due to GCC bug. refer: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102229 Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
@ -52,12 +52,19 @@ QSharedPointer<ApplicationService> ApplicationService::createApplicationService(
|
||||
objectPath = QString{DDEApplicationManager1ObjectPath} + "/" + QUuid::createUuid().toString(QUuid::Id128);
|
||||
}
|
||||
|
||||
DesktopFileGuard guard{app->desktopFileSource()};
|
||||
|
||||
if (!guard.try_open()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sourceStream.setDevice(app->desktopFileSource().sourceFile());
|
||||
std::unique_ptr<DesktopEntry> entry{std::make_unique<DesktopEntry>()};
|
||||
auto error = entry->parse(sourceStream);
|
||||
|
||||
if (error != DesktopErrorCode::NoError) {
|
||||
if (error != DesktopErrorCode::EntryKeyInvalid) {
|
||||
qWarning() << "parse failed:" << error;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -65,6 +72,7 @@ QSharedPointer<ApplicationService> ApplicationService::createApplicationService(
|
||||
if (auto val = entry->value(DesktopFileEntryKey, "Hidden"); val.has_value()) {
|
||||
bool ok{false};
|
||||
if (auto hidden = val.value().toBoolean(ok); ok and hidden) {
|
||||
qWarning() << "invalid hidden value:" << *val.value().find(defaultKeyStr);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -333,6 +341,11 @@ QString ApplicationService::id() const noexcept
|
||||
return m_desktopSource.desktopId();
|
||||
}
|
||||
|
||||
qulonglong ApplicationService::lastLaunchedTime() const noexcept
|
||||
{
|
||||
return m_lastLaunch;
|
||||
}
|
||||
|
||||
IconMap ApplicationService::icons() const
|
||||
{
|
||||
if (m_Icons) {
|
||||
|
Reference in New Issue
Block a user