fix: introduce new DesktopFile class

KeyFile::saveToFile not guaranteed section order, which is not the right
behavior of desktop file. XDG requires the first section of desktop file
always to be "Desktop Entry".

So I write a new DesktopFile class, which override the saveToFile method
of KeyFile, to make it work.

close linuxdeepin/developer-center#3807

Signed-off-by: black-desk <me@black-desk.cn>
This commit is contained in:
Chen Linxuan
2023-03-07 10:52:06 +08:00
committed by deepin-bot[bot]
parent abf322377e
commit accc9c2aac
9 changed files with 127 additions and 47 deletions

View File

@ -343,7 +343,7 @@ bool StartManager::doLaunchAppWithOptions(QString desktopFile, uint32_t timestam
}
if (options.find("path") != options.end()) {
info.getKeyFile()->setKey(MainSection, KeyPath, options["path"].toString().toStdString());
info.getDesktopFile()->setKey(MainSection, KeyPath, options["path"].toString().toStdString());
}
if (options.find("desktop-override-exec") != options.end()) {
@ -433,7 +433,7 @@ bool StartManager::launch(DesktopInfo *info, QString cmdLine, uint32_t timestamp
exeArgs.insert(0, SETTING->getDefaultTerminalExec());
}
std::string workingDir = info->getKeyFile()->getStr(MainSection, KeyPath);
std::string workingDir = info->getDesktopFile()->getStr(MainSection, KeyPath);
if (workingDir.empty()) {
workingDir = BaseDir::homeDir();
}