Skip to content
Merged
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
37 changes: 17 additions & 20 deletions desktopintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
#include <appinfo.h>
#include <appmgr.h>

#include <xdgactivation.h>

Check warning on line 18 in desktopintegration.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <AppStreamQt/pool.h>

#include "appwiz.h"

Check warning on line 20 in desktopintegration.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "appwiz.h" not found.
#include "ddedock.h"

Check warning on line 21 in desktopintegration.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "ddedock.h" not found.
#include "appearance.h"

Check warning on line 22 in desktopintegration.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "appearance.h" not found.

DCORE_USE_NAMESPACE

Expand Down Expand Up @@ -91,38 +89,22 @@
{
if (m_compulsoryAppIdList.contains(desktopId)) return true;

#ifdef NO_APPSTREAM_QT
Q_UNUSED(desktopId)
#else
const QString currentDE(DesktopIntegration::currentDE());

AppStream::Pool pool;
// qDebug() << pool.flags() << currentDE;
pool.load();

const AppStream::ComponentBox components = pool.componentsByLaunchable(AppStream::Launchable::KindDesktopId, desktopId);
const AppStream::ComponentBox components = m_appStreamPool.componentsByLaunchable(AppStream::Launchable::KindDesktopId, desktopId);
for (const AppStream::Component & component : components) {
return component.compulsoryForDesktops().contains(currentDE);
}
#endif

return false;
}

bool DesktopIntegration::appIsDummyPackage(const QString &desktopId)
{
#ifdef NO_APPSTREAM_QT
Q_UNUSED(desktopId)
#else
AppStream::Pool pool;
// qDebug() << pool.flags();
pool.load();

const AppStream::ComponentBox components = pool.componentsByLaunchable(AppStream::Launchable::KindDesktopId, desktopId);
const AppStream::ComponentBox components = m_appStreamPool.componentsByLaunchable(AppStream::Launchable::KindDesktopId, desktopId);
for (const AppStream::Component & component : components) {
return component.customValue("DDE::is_dummy_package") == "true";
}
#endif

return false;
}
Expand Down Expand Up @@ -232,12 +214,22 @@

DesktopIntegration::DesktopIntegration(QObject *parent)
: QObject(parent)
, m_appStreamPool(this)
, m_appWizIntegration(new AppWiz(this))
, m_dockIntegration(new DdeDock(this))
, m_appearanceIntegration(new Appearance(this))
, m_iconScaleFactor(1.0)
{
qCDebug(logDesktopIntegration) << "Initializing DesktopIntegration";
m_appStreamPool.addFlags(AppStream::Pool::FlagMonitor);
if (!m_appStreamPool.load()) {
qCWarning(logDesktopIntegration) << "Failed to load AppStream metadata:" << m_appStreamPool.lastError();
}
connect(&m_appStreamPool, &AppStream::Pool::changed, this, [this] {
++m_dummyPackagesRevision;
Q_EMIT dummyPackagesChanged();
});

QScopedPointer<DConfig> dconfig(DConfig::create("org.deepin.dde.shell", "org.deepin.ds.launchpad"));
Q_ASSERT_X(dconfig->isValid(), "DConfig", "DConfig file is missing or invalid");
// TODO:
Expand Down Expand Up @@ -268,6 +260,11 @@
connect(m_appearanceIntegration, &Appearance::opacityChanged, this, &DesktopIntegration::opacityChanged);
}

uint DesktopIntegration::dummyPackagesRevision() const
{
return m_dummyPackagesRevision;
}

double DesktopIntegration::scaleFactor() const
{
return m_appearanceIntegration->scaleFactor();
Expand Down
8 changes: 7 additions & 1 deletion desktopintegration.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>
#include <QRect>

Check warning on line 8 in desktopintegration.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 9 in desktopintegration.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QStandardPaths> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtQml/qqml.h>

Check warning on line 10 in desktopintegration.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtQml/qqml.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <AppStreamQt/pool.h>

Check warning on line 11 in desktopintegration.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

class AppWiz;
class DdeDock;
Expand All @@ -23,6 +24,7 @@
Q_PROPERTY(qreal opacity READ opacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(double scaleFactor READ scaleFactor NOTIFY scaleFactorChanged FINAL)
Q_PROPERTY(qreal iconScaleFactor READ iconScaleFactor WRITE setIconScaleFactor NOTIFY iconScaleFactorChanged FINAL)
Q_PROPERTY(uint dummyPackagesRevision READ dummyPackagesRevision NOTIFY dummyPackagesChanged FINAL)

QML_NAMED_ELEMENT(DesktopIntegration)
QML_SINGLETON
Expand Down Expand Up @@ -57,6 +59,7 @@
QRect dockGeometry() const;
uint dockSpacing() const;
QString backgroundUrl() const;
uint dummyPackagesRevision() const;

Q_INVOKABLE bool isDockedApp(const QString & desktopId) const;
Q_INVOKABLE void sendToDock(const QString & desktopId);
Expand All @@ -81,11 +84,14 @@
void opacityChanged();
void scaleFactorChanged();
void iconScaleFactorChanged();
void dummyPackagesChanged();

private:
explicit DesktopIntegration(QObject * parent = nullptr);

QStringList m_compulsoryAppIdList;
AppStream::Pool m_appStreamPool;
uint m_dummyPackagesRevision = 0;
AppWiz * m_appWizIntegration;
DdeDock * m_dockIntegration;
Appearance * m_appearanceIntegration;
Expand Down
4 changes: 3 additions & 1 deletion qml/Helper.qml
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 @@ -41,6 +41,8 @@ QtObject {
}

function generateDragMimeData(desktopId, dockOnly = false) {
// Re-evaluate this binding when monitored AppStream metadata changes.
DesktopIntegration.dummyPackagesRevision
// In some cases an app is not allowed to be pinned onto dock via drag-n-drop;
// We only insert the MIME data for dde-dock in those allowed cases.
let mime = {}
Expand Down
Loading