Skip to content

Commit

Permalink
fix: repeated warning when fetch GetAllItemInfos
Browse files Browse the repository at this point in the history
  The interface has removed in AM.
  Only fetch once and use async way.
  • Loading branch information
18202781743 committed Nov 16, 2023
1 parent 069b40a commit 3c8895a
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions dde-osd/src/notification/notifysettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ NotifySettings::NotifySettings(QObject *parent)
qDebug()<<"System configuration fetch failed!";
}
m_initTimer->start(1000);
m_initTimer->setSingleShot(true);
m_systemSetting = new QGSettings(schemaKey.toLocal8Bit(), schemaPath.toLocal8Bit(), this);

connect(m_initTimer, &QTimer::timeout, this, &NotifySettings::initAllSettings);
Expand All @@ -51,37 +52,45 @@ NotifySettings::NotifySettings(QObject *parent)

void NotifySettings::initAllSettings()
{
LauncherItemInfoList itemInfoList = m_launcherInter->GetAllItemInfos();
if (!itemInfoList.isEmpty()) {
m_initTimer->stop();
}

QStringList appList = m_systemSetting->get("app-list").toStringList();
QStringList launcherList;

foreach(const LauncherItemInfo &item, itemInfoList) {
launcherList << item.id;
DDesktopEntry desktopInfo(item.path);
if (IgnoreList.contains(item.id) || desktopInfo.rawValue("X-Created-By") == "Deepin WINE Team") {
continue;
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(m_launcherInter->GetAllItemInfos());
QObject::connect(watcher, &QDBusPendingCallWatcher::finished,
this, [this](QDBusPendingCallWatcher *call) {
QDBusPendingReply<LauncherItemInfoList> reply = *call;
if (reply.isError()) {
qWarning() << "Falied to fetch GetAllItemInfos" << reply.error();
} else {
LauncherItemInfoList itemInfoList = reply.value();

QStringList appList = m_systemSetting->get("app-list").toStringList();
QStringList launcherList;

foreach(const LauncherItemInfo &item, itemInfoList) {
launcherList << item.id;
DDesktopEntry desktopInfo(item.path);
if (IgnoreList.contains(item.id) || desktopInfo.rawValue("X-Created-By") == "Deepin WINE Team") {
continue;
}

if (appList.contains(item.id)) {
// 修改系统语言后需要更新翻译
QGSettings itemSetting(appSchemaKey.toLocal8Bit(), appSchemaPath.arg(item.id).toLocal8Bit(), this);
itemSetting.set("app-name", item.name);
continue;
}
appList.append(item.id);
m_systemSetting->set("app-list", appList);
appAdded(item);
}

for (const QString &app : appList) {
if (!launcherList.contains(app)) {
appRemoved(app);
}
}
}

if (appList.contains(item.id)) {
// 修改系统语言后需要更新翻译
QGSettings itemSetting(appSchemaKey.toLocal8Bit(), appSchemaPath.arg(item.id).toLocal8Bit(), this);
itemSetting.set("app-name", item.name);
continue;
}
appList.append(item.id);
m_systemSetting->set("app-list", appList);
appAdded(item);
}

for (const QString &app : appList) {
if (!launcherList.contains(app)) {
appRemoved(app);
}
}
call->deleteLater();
});
}

void NotifySettings::setAppSetting(const QString &id, const NotifySettings::AppConfigurationItem &item, const QVariant &var)
Expand Down

0 comments on commit 3c8895a

Please sign in to comment.