fix: get wrong prefix of desktop name
We can only get 'org' by baseName() if the desktop file named org.gnome.Chess.desktop. It should be completeBaseName(). Log:
This commit is contained in:
parent
39c50de56f
commit
95ca87eebc
@ -64,7 +64,7 @@ void AlRecorder::markLaunched(const QString &filePath)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
info.setFile(filePath);
|
info.setFile(filePath);
|
||||||
QString name = info.baseName();
|
QString name = info.completeBaseName();
|
||||||
for (auto li = sri.value().launchedMap.begin(); li != sri.value().launchedMap.end(); li++) {
|
for (auto li = sri.value().launchedMap.begin(); li != sri.value().launchedMap.end(); li++) {
|
||||||
// 查找同名且未启动过的应用
|
// 查找同名且未启动过的应用
|
||||||
if (li.key() == name && !li.value()) {
|
if (li.key() == name && !li.value()) {
|
||||||
@ -91,7 +91,7 @@ void AlRecorder::uninstallHints(const QStringList &desktopFiles)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
QFileInfo info(desktop);
|
QFileInfo info(desktop);
|
||||||
sri.value().uninstallMap[info.baseName()] = true;
|
sri.value().uninstallMap[info.completeBaseName()] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ void AlRecorder::onDFChanged(const QString &filePath, uint32_t op)
|
|||||||
{
|
{
|
||||||
QFileInfo info(filePath);
|
QFileInfo info(filePath);
|
||||||
QString dirPath = info.absolutePath() + "/";
|
QString dirPath = info.absolutePath() + "/";
|
||||||
QString name = info.baseName();
|
QString name = info.completeBaseName();
|
||||||
subRecorder &sub = subRecoders[dirPath];
|
subRecorder &sub = subRecoders[dirPath];
|
||||||
QMap<QString, bool> &launchedMap = sub.launchedMap;
|
QMap<QString, bool> &launchedMap = sub.launchedMap;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ void Dock::undockEntry(Entry *entry, bool moveToEnd)
|
|||||||
m_entries->removeLastRecent();
|
m_entries->removeLastRecent();
|
||||||
if (desktopFile.contains(scratchDir) && entry->getCurrentWindowInfo()) {
|
if (desktopFile.contains(scratchDir) && entry->getCurrentWindowInfo()) {
|
||||||
QFileInfo info(desktopFile);
|
QFileInfo info(desktopFile);
|
||||||
QString baseName = info.baseName();
|
QString baseName = info.completeBaseName();
|
||||||
if (baseName.startsWith(windowHashPrefix)) {
|
if (baseName.startsWith(windowHashPrefix)) {
|
||||||
// desktop base starts with w:
|
// desktop base starts with w:
|
||||||
// 由于有 Pid 识别方法在,在这里不能用 m.identifyWindow 再次识别
|
// 由于有 Pid 识别方法在,在这里不能用 m.identifyWindow 再次识别
|
||||||
|
@ -42,7 +42,7 @@ ProcessInfo::ProcessInfo(int pid)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
QFileInfo info(firstArg.c_str());
|
QFileInfo info(firstArg.c_str());
|
||||||
if (info.baseName() == firstArg.c_str())
|
if (info.completeBaseName() == firstArg.c_str())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!QDir::isAbsolutePath(firstArg.c_str()))
|
if (!QDir::isAbsolutePath(firstArg.c_str()))
|
||||||
|
@ -277,7 +277,7 @@ AppInfo *WindowIdentify::identifyWindowByCmdlineTurboBooster(Dock *_dock, Window
|
|||||||
} else if (QString(cmdline[0].c_str()).contains("/applications/")) {
|
} else if (QString(cmdline[0].c_str()).contains("/applications/")) {
|
||||||
QFileInfo fileInfo(cmdline[0].c_str());
|
QFileInfo fileInfo(cmdline[0].c_str());
|
||||||
QString path = fileInfo.path();
|
QString path = fileInfo.path();
|
||||||
QString base = fileInfo.baseName();
|
QString base = fileInfo.completeBaseName();
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
QStringList files = dir.entryList(QDir::Files);
|
QStringList files = dir.entryList(QDir::Files);
|
||||||
for (auto f : files) {
|
for (auto f : files) {
|
||||||
@ -310,14 +310,14 @@ AppInfo *WindowIdentify::identifyWindowByCmdlineXWalk(Dock *_dock, WindowInfoX *
|
|||||||
|
|
||||||
QString exe = process->getExe().c_str();
|
QString exe = process->getExe().c_str();
|
||||||
QFileInfo file(exe);
|
QFileInfo file(exe);
|
||||||
QString exeBase = file.baseName();
|
QString exeBase = file.completeBaseName();
|
||||||
auto args = process->getArgs();
|
auto args = process->getArgs();
|
||||||
if (exe != "xwalk" || args.size() == 0)
|
if (exe != "xwalk" || args.size() == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
QString lastArg = args[args.size() - 1].c_str();
|
QString lastArg = args[args.size() - 1].c_str();
|
||||||
file.setFile(lastArg);
|
file.setFile(lastArg);
|
||||||
if (file.baseName() == "manifest.json") {
|
if (file.completeBaseName() == "manifest.json") {
|
||||||
auto strs = lastArg.split("/");
|
auto strs = lastArg.split("/");
|
||||||
if (strs.size() > 3 && strs[strs.size() - 2].size() > 0) { // appId为 strs倒数第二个字符串
|
if (strs.size() > 3 && strs[strs.size() - 2].size() > 0) { // appId为 strs倒数第二个字符串
|
||||||
ret = new AppInfo(strs[strs.size() - 2]);
|
ret = new AppInfo(strs[strs.size() - 2]);
|
||||||
@ -516,7 +516,7 @@ AppInfo *WindowIdentify::fixAutostartAppInfo(QString fileName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isAutoStart ? new AppInfo(file.baseName()) : nullptr;
|
return isAutoStart ? new AppInfo(file.completeBaseName()) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WindowIdentify::getAndroidUengineId(XWindow winId)
|
int32_t WindowIdentify::getAndroidUengineId(XWindow winId)
|
||||||
|
@ -915,7 +915,7 @@ AppType Launcher::getAppType(DesktopInfo &info, const Item &item)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
fileInfo.setFile(parts[0].c_str());
|
fileInfo.setFile(parts[0].c_str());
|
||||||
if (flatpakBin != fileInfo.baseName())
|
if (flatpakBin != fileInfo.completeBaseName())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ty = AppType::Flatpak;
|
ty = AppType::Flatpak;
|
||||||
@ -937,7 +937,7 @@ AppType Launcher::getAppType(DesktopInfo &info, const Item &item)
|
|||||||
// 判断是否为CrossOver
|
// 判断是否为CrossOver
|
||||||
do {
|
do {
|
||||||
fileInfo.setFile(info.getExecutable().c_str());
|
fileInfo.setFile(info.getExecutable().c_str());
|
||||||
QString execBase(fileInfo.baseName());
|
QString execBase(fileInfo.completeBaseName());
|
||||||
if (execBase.contains("CrossOver") && (execBase.contains("crossover") || execBase.contains("cxuninstall"))) {
|
if (execBase.contains("CrossOver") && (execBase.contains("crossover") || execBase.contains("cxuninstall"))) {
|
||||||
ty = AppType::CrossOver;
|
ty = AppType::CrossOver;
|
||||||
goto end;
|
goto end;
|
||||||
@ -1183,7 +1183,7 @@ bool Launcher::isDeepinCustomDesktopFile(QString fileName)
|
|||||||
{
|
{
|
||||||
QFileInfo fileInfo(fileName);
|
QFileInfo fileInfo(fileName);
|
||||||
return fileInfo.dir() == QDir::homePath() + ".local/share/applications"
|
return fileInfo.dir() == QDir::homePath() + ".local/share/applications"
|
||||||
&& fileInfo.baseName().startsWith("deepin-custom-");
|
&& fileInfo.completeBaseName().startsWith("deepin-custom-");
|
||||||
}
|
}
|
||||||
|
|
||||||
Item Launcher::NewItemWithDesktopInfo(DesktopInfo &info)
|
Item Launcher::NewItemWithDesktopInfo(DesktopInfo &info)
|
||||||
|
@ -93,7 +93,7 @@ bool StartManager::isAutostart(const QString &desktop)
|
|||||||
|
|
||||||
QFileInfo file(desktop);
|
QFileInfo file(desktop);
|
||||||
for (auto autostartDir : BaseDir::autoStartDirs()) {
|
for (auto autostartDir : BaseDir::autoStartDirs()) {
|
||||||
std::string filePath = autostartDir + file.baseName().toStdString();
|
std::string filePath = autostartDir + file.completeBaseName().toStdString();
|
||||||
QDir dir(autostartDir.c_str());
|
QDir dir(autostartDir.c_str());
|
||||||
if (dir.exists(file.fileName())) {
|
if (dir.exists(file.fileName())) {
|
||||||
DesktopInfo info(desktop.toStdString());
|
DesktopInfo info(desktop.toStdString());
|
||||||
@ -191,7 +191,7 @@ void StartManager::onAutoStartupPathChange(const QString &path)
|
|||||||
dir.setNameFilters({ "*.desktop" });
|
dir.setNameFilters({ "*.desktop" });
|
||||||
for (const auto &entry : dir.entryInfoList()) {
|
for (const auto &entry : dir.entryInfoList()) {
|
||||||
const QString &desktopPath = entry.absoluteFilePath();
|
const QString &desktopPath = entry.absoluteFilePath();
|
||||||
if (desktopPath.contains(info.baseName())) {
|
if (desktopPath.contains(info.completeBaseName())) {
|
||||||
desktopFullPath = desktopPath;
|
desktopFullPath = desktopPath;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ void StartManager::onAutoStartupPathChange(const QString &path)
|
|||||||
KeyFile kf;
|
KeyFile kf;
|
||||||
kf.loadFile(autostartDesktopPath.toStdString());
|
kf.loadFile(autostartDesktopPath.toStdString());
|
||||||
kf.setKey(MainSection, KeyXDeepinCreatedBy.toStdString(), AMServiceName.toStdString());
|
kf.setKey(MainSection, KeyXDeepinCreatedBy.toStdString(), AMServiceName.toStdString());
|
||||||
kf.setKey(MainSection, KeyXDeepinAppID.toStdString(), info.baseName().toStdString());
|
kf.setKey(MainSection, KeyXDeepinAppID.toStdString(), info.completeBaseName().toStdString());
|
||||||
kf.setBool(MainSection, KeyHidden, "false");
|
kf.setBool(MainSection, KeyHidden, "false");
|
||||||
kf.saveToFile(autostartDesktopPath.toStdString());
|
kf.saveToFile(autostartDesktopPath.toStdString());
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ void StartManager::onAutoStartupPathChange(const QString &path)
|
|||||||
dir.setNameFilters({ "*.desktop" });
|
dir.setNameFilters({ "*.desktop" });
|
||||||
for (const auto &entry : dir.entryInfoList()) {
|
for (const auto &entry : dir.entryInfoList()) {
|
||||||
const QString &desktopPath = entry.absoluteFilePath();
|
const QString &desktopPath = entry.absoluteFilePath();
|
||||||
if (desktopPath.contains(info.baseName())) {
|
if (desktopPath.contains(info.completeBaseName())) {
|
||||||
desktopFullPath = desktopPath;
|
desktopFullPath = desktopPath;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ bool StartManager::setAutostart(const QString &desktop, const bool value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QDir autostartDir(BaseDir::userAutoStartDir().c_str());
|
QDir autostartDir(BaseDir::userAutoStartDir().c_str());
|
||||||
const QString &appId = fileInfo.baseName();
|
const QString &appId = fileInfo.completeBaseName();
|
||||||
|
|
||||||
if (value && isAutostart(desktop)) {
|
if (value && isAutostart(desktop)) {
|
||||||
qWarning() << "invalid path or item is already in the autostart list.";
|
qWarning() << "invalid path or item is already in the autostart list.";
|
||||||
@ -624,7 +624,7 @@ QMap<QString, QString> StartManager::getDesktopToAutostartMap()
|
|||||||
dir.setNameFilters({ "*.desktop" });
|
dir.setNameFilters({ "*.desktop" });
|
||||||
for (const auto &entry : dir.entryInfoList()) {
|
for (const auto &entry : dir.entryInfoList()) {
|
||||||
const QString &desktopPath = entry.absoluteFilePath();
|
const QString &desktopPath = entry.absoluteFilePath();
|
||||||
if (desktopPath.contains(fileInfo.baseName()) &&
|
if (desktopPath.contains(fileInfo.completeBaseName()) &&
|
||||||
m_desktopDirToAutostartDirMap.find(desktopPath) == m_desktopDirToAutostartDirMap.end()) {
|
m_desktopDirToAutostartDirMap.find(desktopPath) == m_desktopDirToAutostartDirMap.end()) {
|
||||||
m_desktopDirToAutostartDirMap.insert(desktopPath, entry.absoluteFilePath());
|
m_desktopDirToAutostartDirMap.insert(desktopPath, entry.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user