feat: 修复启动器获取新安装应用数据异常的问题
修复启动器获取新安装应用数据异常的问题 Log: Task: https://pms.uniontech.com/task-view-143305.html Influence: 启动器正常获取新安装应用 Change-Id: I556b6725348813cc1674f00273cb9e34f96283a2
This commit is contained in:
parent
765365d364
commit
a74c02d4c5
@ -77,25 +77,22 @@ void AlRecorder::markLaunched(const QString &filePath)
|
|||||||
QFileInfo info;
|
QFileInfo info;
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
for (auto sri = subRecoders.begin(); sri != subRecoders.end(); sri++) {
|
for (auto sri = subRecoders.begin(); sri != subRecoders.end(); sri++) {
|
||||||
if (!filePath.contains(sri.key()))
|
if (!filePath.startsWith(sri.key()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
info.setFile(filePath);
|
info.setFile(filePath);
|
||||||
QString name = info.baseName();
|
QString name = info.baseName();
|
||||||
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()) {
|
||||||
li.value() = true;
|
li.value() = true;
|
||||||
goto end;
|
Q_EMIT launched(filePath);
|
||||||
|
|
||||||
|
// 记录启动状态
|
||||||
|
saveStatusFile(info.absolutePath() + "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据filePath匹配到唯一应用
|
|
||||||
end:
|
|
||||||
if (info.isDir()) {
|
|
||||||
saveStatusFile(info.absolutePath() + "/");
|
|
||||||
Q_EMIT launched(filePath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -154,7 +151,7 @@ void AlRecorder::initSubRecoder(const QString &dirPath)
|
|||||||
// 读取App状态记录
|
// 读取App状态记录
|
||||||
QMap<QString, bool> launchedApp;
|
QMap<QString, bool> launchedApp;
|
||||||
QFile file(statusFile);
|
QFile file(statusFile);
|
||||||
if (file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
if (file.exists() && file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||||
while (!file.atEnd()){
|
while (!file.atEnd()){
|
||||||
QString line(file.readLine());
|
QString line(file.readLine());
|
||||||
QStringList strs = line.split(",");
|
QStringList strs = line.split(",");
|
||||||
@ -166,6 +163,7 @@ void AlRecorder::initSubRecoder(const QString &dirPath)
|
|||||||
else
|
else
|
||||||
launchedApp[strs[0]] = false;
|
launchedApp[strs[0]] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
} else {
|
} else {
|
||||||
// 读取app desktop
|
// 读取app desktop
|
||||||
|
@ -28,13 +28,14 @@
|
|||||||
|
|
||||||
class DFWatcher;
|
class DFWatcher;
|
||||||
|
|
||||||
// 记录应用状态信息
|
// 记录当前用户应用状态信息
|
||||||
class AlRecorder: public QObject
|
class AlRecorder: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("D-Bus Interface", "org.deepin.daemon.AlRecorder1")
|
Q_CLASSINFO("D-Bus Interface", "org.deepin.daemon.AlRecorder1")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// 各个应用目录中应用的启动记录
|
||||||
struct subRecorder {
|
struct subRecorder {
|
||||||
QString statusFile; // 应用目录状态文件
|
QString statusFile; // 应用目录状态文件
|
||||||
QMap<QString, bool> launchedMap; // 应用启动记录
|
QMap<QString, bool> launchedMap; // 应用启动记录
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
DBusAdaptorRecorder::DBusAdaptorRecorder(QObject *parent)
|
DBusAdaptorRecorder::DBusAdaptorRecorder(QObject *parent)
|
||||||
: QDBusAbstractAdaptor(parent)
|
: QDBusAbstractAdaptor(parent)
|
||||||
{
|
{
|
||||||
// constructor
|
|
||||||
setAutoRelaySignals(true);
|
setAutoRelaySignals(true);
|
||||||
if (QMetaType::type("UnlaunchedAppMap") == QMetaType::UnknownType)
|
if (QMetaType::type("UnlaunchedAppMap") == QMetaType::UnknownType)
|
||||||
registerUnLaunchedAppMapMetaType();
|
registerUnLaunchedAppMapMetaType();
|
||||||
@ -18,7 +17,6 @@ DBusAdaptorRecorder::DBusAdaptorRecorder(QObject *parent)
|
|||||||
|
|
||||||
DBusAdaptorRecorder::~DBusAdaptorRecorder()
|
DBusAdaptorRecorder::~DBusAdaptorRecorder()
|
||||||
{
|
{
|
||||||
// destructor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AlRecorder *DBusAdaptorRecorder::parent() const
|
AlRecorder *DBusAdaptorRecorder::parent() const
|
||||||
|
@ -178,8 +178,12 @@ QStringList Launcher::getAllNewInstalledApps()
|
|||||||
newApps = reply;
|
newApps = reply;
|
||||||
|
|
||||||
for (auto iter = newApps.begin(); iter != newApps.end(); iter++) {
|
for (auto iter = newApps.begin(); iter != newApps.end(); iter++) {
|
||||||
if (iter.value().size() > 0) {
|
for (QString name : iter.value()) {
|
||||||
ret << iter.value();
|
QString path = iter.key() + name + ".desktop";
|
||||||
|
Item item = getItemByPath(path);
|
||||||
|
if (item.isValid()) {
|
||||||
|
ret << item.info.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user