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