Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions applets/dde-apps/amappitemmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "amappitemmodel.h"
#include "amappitem.h"
#include "appgroupmanager.h"
#include "appitemmodel.h"
#include "objectmanager1interface.h"

Check warning on line 8 in applets/dde-apps/amappitemmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "objectmanager1interface.h" not found.

#include <DUtil>

Check warning on line 10 in applets/dde-apps/amappitemmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DUtil> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtConcurrent>
#include <QDBusPendingCallWatcher>

Check warning on line 11 in applets/dde-apps/amappitemmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusPendingCallWatcher> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusPendingReply>

Check warning on line 12 in applets/dde-apps/amappitemmodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusPendingReply> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Q_LOGGING_CATEGORY(appsLog, "org.deepin.dde.shell.dde-apps.amappitemmodel")

namespace apps
{
AMAppItemModel::AMAppItemModel(QObject *parent)
: AppItemModel(parent)
, m_manager(new ObjectManager("org.desktopspec.ApplicationManager1", "/org/desktopspec/ApplicationManager1", QDBusConnection::sessionBus()))
, m_manager(new ObjectManager("org.desktopspec.ApplicationManager1", "/org/desktopspec/ApplicationManager1", QDBusConnection::sessionBus(), this))
, m_ready(false)
{
qRegisterMetaType<ObjectInterfaceMap>();
Expand Down Expand Up @@ -50,18 +50,24 @@
removeRow(res.first().row());
});

// load static desktop info from am
auto future = QtConcurrent::run([this]() {
auto apps = m_manager->GetManagedObjects().value();

// load static desktop info from am asynchronously
auto reply = m_manager->GetManagedObjects();
auto *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher]() {
watcher->deleteLater();
QDBusPendingReply<ObjectMap> reply = *watcher;
if (reply.isError()) {
qCWarning(appsLog()) << "Failed to get managed objects:" << reply.error().message();
return;
}
auto apps = reply.value();
for (auto app = apps.cbegin(); app != apps.cend(); app++) {
auto path = app.key();
if (!path.path().isEmpty()) {
auto c = new AMAppItem(path, app.value());
appendRow(c);
}
}

setProperty("ready", true);
qCDebug(appsLog) << "AMAppItemModel is now ready with apps counts:" << rowCount();
});
Expand Down
7 changes: 6 additions & 1 deletion applets/dde-apps/appgroupmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -240,6 +240,11 @@ QVariantList AppGroupManager::fromListOfStringList(const QList<QStringList> & li
// On AM model changed, add newly installed apps to group (if any) and remove apps that are no longer exists.
void AppGroupManager::onReferenceModelChanged()
{
if (!m_referenceModel) {
qWarning() << "referenceModel has been destroyed, skip updating";
return;
}

// Avoid remove all existing records when first time (AM model is not ready).
if (m_referenceModel->rowCount() == 0) {
qDebug() << "referenceModel not ready, wait for next time";
Expand Down
5 changes: 3 additions & 2 deletions applets/dde-apps/appgroupmanager.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QHash>

Check warning on line 7 in applets/dde-apps/appgroupmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QHash> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QObject>

Check warning on line 8 in applets/dde-apps/appgroupmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointer>

Check warning on line 9 in applets/dde-apps/appgroupmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DConfig>

Check warning on line 10 in applets/dde-apps/appgroupmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DConfig> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 11 in applets/dde-apps/appgroupmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQmlEngine>

Check warning on line 12 in applets/dde-apps/appgroupmanager.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQmlEngine> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QStandardItemModel>

Expand Down Expand Up @@ -82,7 +83,7 @@

private:
bool m_appGroupInitialized;
AMAppItemModel * m_referenceModel;
QPointer<AMAppItemModel> m_referenceModel;
QTimer* m_dumpTimer;
Dtk::Core::DConfig *m_config;
};
Expand Down
Loading