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:
ComixHe
2023-08-23 17:20:47 +08:00
committed by Comix
parent 2bdb9e99ee
commit 9f2a8b6798
8 changed files with 108 additions and 18 deletions

View File

@ -25,7 +25,9 @@ void registerComplexDbusType()
int main(int argc, char *argv[])
{
#ifdef PROFILING_MODE
auto start = std::chrono::high_resolution_clock::now();
#endif
QCoreApplication app{argc, argv};
auto &bus = ApplicationManager1DBus::instance();
@ -36,24 +38,25 @@ int main(int argc, char *argv[])
registerComplexDbusType();
ApplicationManager1Service AMService{std::make_unique<CGroupsIdentifier>(), AMBus};
QList<DesktopFile> fileList{};
auto desktopFileDirs = getXDGDataDirs();
const auto &desktopFileDirs = getDesktopFileDirs();
applyIteratively(QList<QDir>(desktopFileDirs.begin(), desktopFileDirs.end()), [&AMService](const QFileInfo &info) -> bool {
applyIteratively(QList<QDir>(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [&AMService](const QFileInfo &info) -> bool {
DesktopErrorCode err{DesktopErrorCode::NoError};
auto ret = DesktopFile::searchDesktopFileByPath(info.absoluteFilePath(), err);
if (!ret.has_value()) {
qWarning() << "failed to search File:" << err;
return false;
}
AMService.addApplication(std::move(ret).value());
if (!AMService.addApplication(std::move(ret).value())) {
qWarning() << "add Application failed:" << ret->sourcePath() << "skip...";
}
return false; // means to apply this function to the rest of the files
});
#ifdef PROFILING_MODE
auto end = std::chrono::high_resolution_clock::now();
qCInfo(DDEAMProf) << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms";
return
#ifdef PROFILING_MODE
QCoreApplication::exec();
return 0;
#else
0;
return QCoreApplication::exec();
#endif
}