fix: 修复安装应用失败问题
优化新应用安装/启动后,AM发送消息通知dde-launcher的逻辑 Log: Influence: 安装应用/启动应用时,启动器功能正常 Bug: https://pms.uniontech.com/bug-view-150623.html Change-Id: Icebea449ccd5ad9eac39cf5d527e87813910b356
This commit is contained in:
		@ -24,6 +24,7 @@
 | 
			
		||||
#include <QtDBus/QtDBus>
 | 
			
		||||
#include <QtCore/QList>
 | 
			
		||||
#include <QDBusMetaType>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
struct LauncherItemInfo {
 | 
			
		||||
    QString path;
 | 
			
		||||
@ -34,6 +35,14 @@ struct LauncherItemInfo {
 | 
			
		||||
    qint64 timeInstalled;
 | 
			
		||||
    QStringList keywords;
 | 
			
		||||
    bool operator!=(const LauncherItemInfo &versionInfo);
 | 
			
		||||
 | 
			
		||||
    friend QDebug operator<<(QDebug argument, const LauncherItemInfo &info)
 | 
			
		||||
    {
 | 
			
		||||
        argument << info.path << info.name << info.id;
 | 
			
		||||
        argument << info.icon << info.categoryId << info.timeInstalled << info.keywords;
 | 
			
		||||
 | 
			
		||||
        return argument;
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(LauncherItemInfo)
 | 
			
		||||
 | 
			
		||||
@ -63,24 +63,7 @@ Launcher::Launcher(QObject *parent)
 | 
			
		||||
    loadNameMap();
 | 
			
		||||
    initItems();
 | 
			
		||||
 | 
			
		||||
    // 关联org.deepin.daemon.DFWatcher1接口事件Event
 | 
			
		||||
    QDBusConnection::sessionBus().connect("org.deepin.daemon.DFWatcher1",
 | 
			
		||||
                                          "/org/deepin/daemon/DFWatcher1",
 | 
			
		||||
                                          "org.deepin.daemon.DFWatcher1",
 | 
			
		||||
                                          "Event", "",      // TODO 修正事件参数
 | 
			
		||||
                                          this, SLOT(handleFSWatcherEvents(QDBusMessage)));
 | 
			
		||||
 | 
			
		||||
    // 关联org.deepin.daemon.LRecorder1接口事件Launched
 | 
			
		||||
    QDBusConnection::sessionBus().connect("org.deepin.daemon.AlRecorder1",
 | 
			
		||||
                                          "/org/deepin/daemon/AlRecorder1",
 | 
			
		||||
                                          "org.deepin.daemon.AlRecorder1",
 | 
			
		||||
                                          "Launched", "sa",
 | 
			
		||||
                                          this, SLOT([&](QDBusMessage msg) {
 | 
			
		||||
                                              QString path = msg.arguments().at(0).toString();
 | 
			
		||||
                                              Item item = getItemByPath(path);
 | 
			
		||||
                                              if (item.isValid())
 | 
			
		||||
                                              Q_EMIT newAppLaunched(item.id);
 | 
			
		||||
                                          }));
 | 
			
		||||
    initConnection();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Launcher::~Launcher()
 | 
			
		||||
@ -440,7 +423,7 @@ void Launcher::handleFSWatcherEvents(QDBusMessage msg)
 | 
			
		||||
    } else if (filePath == applicationsFile) {  // 应用信息文件变化
 | 
			
		||||
        loadPkgCategoryMap();
 | 
			
		||||
    } else if (filePath.endsWith(".desktop")){  // desktop文件变化
 | 
			
		||||
        checkDesktopFile(filePath);
 | 
			
		||||
        onCheckDesktopFile(filePath);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -521,8 +504,10 @@ void Launcher::loadPkgCategoryMap()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Launcher::checkDesktopFile(QString filePath)
 | 
			
		||||
void Launcher::onCheckDesktopFile(const QString &filePath, int type)
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(type);
 | 
			
		||||
 | 
			
		||||
    QString appId = getAppIdByFilePath(filePath, appDirs);
 | 
			
		||||
    if (appId.isEmpty())
 | 
			
		||||
        return;
 | 
			
		||||
@ -563,6 +548,31 @@ void Launcher::checkDesktopFile(QString filePath)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Launcher::onNewAppLaunched(const QString &filePath)
 | 
			
		||||
{
 | 
			
		||||
    Item item = getItemByPath(filePath);
 | 
			
		||||
 | 
			
		||||
    if (item.isValid())
 | 
			
		||||
        Q_EMIT newAppLaunched(item.info.id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Launcher::initConnection()
 | 
			
		||||
{
 | 
			
		||||
    QDBusConnection::sessionBus().connect("org.deepin.daemon.DFWatcher1",
 | 
			
		||||
                                          "/org/deepin/daemon/DFWatcher1",
 | 
			
		||||
                                          "org.deepin.daemon.DFWatcher1",
 | 
			
		||||
                                          "Event",
 | 
			
		||||
                                          this,
 | 
			
		||||
                                          SLOT(onCheckDesktopFile(const QString &, int)));
 | 
			
		||||
 | 
			
		||||
    QDBusConnection::sessionBus().connect("org.deepin.daemon.AlRecorder1",
 | 
			
		||||
                                          "/org/deepin/daemon/AlRecorder1",
 | 
			
		||||
                                          "org.deepin.daemon.AlRecorder1",
 | 
			
		||||
                                          "Launched",
 | 
			
		||||
                                          this,
 | 
			
		||||
                                          SLOT(onNewAppLaunched(const QString &)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Launcher::handleAppHiddenChanged 响应DConfig中隐藏应用配置变化
 | 
			
		||||
 */
 | 
			
		||||
@ -673,7 +683,7 @@ void Launcher::initItems()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Launcher::addItem(Item item)
 | 
			
		||||
void Launcher::addItem(Item &item)
 | 
			
		||||
{
 | 
			
		||||
    if (!item.isValid())
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
@ -119,19 +119,21 @@ Q_SIGNALS:
 | 
			
		||||
private Q_SLOTS:
 | 
			
		||||
    void handleFSWatcherEvents(QDBusMessage msg);
 | 
			
		||||
    void onAppSuffixNameChanged(bool hidden);
 | 
			
		||||
    void onCheckDesktopFile(const QString &filePath, int type = 0);
 | 
			
		||||
    void onNewAppLaunched(const QString &filePath);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void initConnection();
 | 
			
		||||
    void initSettings();
 | 
			
		||||
    void loadDesktopPkgMap();
 | 
			
		||||
    void loadPkgCategoryMap();
 | 
			
		||||
    void checkDesktopFile(QString filePath);
 | 
			
		||||
    void handleAppHiddenChanged();
 | 
			
		||||
    void loadNameMap();
 | 
			
		||||
    void initItems();
 | 
			
		||||
    QString getAppIdByFilePath(QString filePath, QStringList dirs);
 | 
			
		||||
    bool isDeepinCustomDesktopFile(QString fileName);
 | 
			
		||||
    Item NewItemWithDesktopInfo(DesktopInfo &info);
 | 
			
		||||
    void addItem(Item item);
 | 
			
		||||
    void addItem(Item &item);
 | 
			
		||||
    Categorytype queryCategoryId(const Item *item);
 | 
			
		||||
    Categorytype getXCategory(const Item *item);
 | 
			
		||||
    QString queryPkgName(const QString &itemID, const QString &itemPath);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user