mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-05-30 22:01:41 +00:00

1. taskmanager used to identify which entry should map to window in x11 environmrnt, listen to xevent in anohter thread, and handle those event when window create, destory, changed. use some way to identify which entry(desktopfile) should mapped to changed window. in wayland, connected plsamawindow signal(window created destoried. 2. use taskmanager instead of dbus in old dock code log: as title
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "appinfo.h"
|
|
#include "common.h"
|
|
|
|
#include <QDebug>
|
|
#include <QString>
|
|
#include <QCryptographicHash>
|
|
|
|
AppInfo::AppInfo(DesktopInfo &info)
|
|
: m_isValid(true)
|
|
{
|
|
init(info);
|
|
}
|
|
|
|
AppInfo::AppInfo(const QString &_fileName)
|
|
: m_isValid(true)
|
|
{
|
|
DesktopInfo info(_fileName);
|
|
init(info);
|
|
}
|
|
|
|
void AppInfo::init(DesktopInfo &info)
|
|
{
|
|
if (!info.isValidDesktop()) {
|
|
m_isValid = false;
|
|
return;
|
|
}
|
|
|
|
QString xDeepinVendor = info.getDesktopFile()->value(MainSection + "/X-Deepin-Vendor").toString();
|
|
if (xDeepinVendor == "deepin") {
|
|
m_name = info.getGenericName();
|
|
if (m_name.isEmpty()) {
|
|
m_name = info.getName();
|
|
}
|
|
} else {
|
|
m_name = info.getName();
|
|
}
|
|
|
|
m_innerId = genInnerIdWithDesktopInfo(info);
|
|
m_fileName = info.getDesktopFilePath();
|
|
m_id = info.getId();
|
|
m_icon = info.getIcon();
|
|
for (const auto & action : info.getActions()) {
|
|
m_actions.push_back(action);
|
|
}
|
|
}
|
|
|
|
QString AppInfo::genInnerIdWithDesktopInfo(DesktopInfo &info)
|
|
{
|
|
QString cmdline = info.getCommandLine();
|
|
QByteArray encryText = QCryptographicHash::hash(QString(cmdline).toLatin1(), QCryptographicHash::Md5);
|
|
QString innerId = desktopHashPrefix + encryText.toHex();
|
|
qInfo() << "app: " << info.getId() << " generate innerId: " << innerId;
|
|
return innerId;
|
|
}
|