diff --git a/desktopintegration.cpp b/desktopintegration.cpp index 58512494..e2315879 100644 --- a/desktopintegration.cpp +++ b/desktopintegration.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include #include #include #include @@ -64,6 +66,13 @@ QString DesktopIntegration::environmentVariable(const QString &env) return qEnvironmentVariable(env.toStdString().c_str()); } +bool DesktopIntegration::isDciIcon(const QString &iconName) +{ + QByteArray themeName = Dtk::Gui::DGuiApplicationHelper::instance()->applicationTheme()->iconThemeName(); + QString dciFile = Dtk::Gui::DIconTheme::findDciIconFile(iconName, QString::fromLatin1(themeName)); + return !dciFile.isEmpty(); +} + double DesktopIntegration::disableScale(const QString &desktopId) { return AppMgr::disableScale(desktopId); diff --git a/desktopintegration.h b/desktopintegration.h index 33543a8a..790aec03 100644 --- a/desktopintegration.h +++ b/desktopintegration.h @@ -51,6 +51,7 @@ class DesktopIntegration : public QObject Q_INVOKABLE static void setDisableScale(const QString & desktopId, double disableScale); Q_INVOKABLE static void showFolder(enum QStandardPaths::StandardLocation location); Q_INVOKABLE static void showUrl(const QString & url); + Q_INVOKABLE static bool isDciIcon(const QString &iconName); Q_INVOKABLE bool appIsCompulsoryForDesktop(const QString & desktopId); Q_INVOKABLE bool appIsDummyPackage(const QString & desktopId); // TODO: async get wallpaper? diff --git a/qml/IconItemDelegate.qml b/qml/IconItemDelegate.qml index 189335f9..e19af640 100644 --- a/qml/IconItemDelegate.qml +++ b/qml/IconItemDelegate.qml @@ -314,6 +314,15 @@ Control { Component { id: imageComponent + Loader { + anchors.fill: parent + sourceComponent: DesktopIntegration.isDciIcon(iconSource) ? dciIconComponent : imageIconComponent + } + } + + Component { + id: dciIconComponent + DciIcon { objectName: "appIcon" anchors.fill: parent @@ -325,6 +334,19 @@ Control { fillMode: Image.PreserveAspectFit } } + + Component { + id: imageIconComponent + + Image { + objectName: "appIcon" + anchors.fill: parent + source: "image://appicon/" + iconSource + fillMode: Image.PreserveAspectFit + sourceSize: Qt.size(root.maxIconSize, root.maxIconSize) + scale: (iconContainer.width / root.maxIconSize) * root.iconScaleFactor + } + } } // as topMargin diff --git a/shell-launcher-applet/launcheritem.cpp b/shell-launcher-applet/launcheritem.cpp index b1291038..dad59821 100644 --- a/shell-launcher-applet/launcheritem.cpp +++ b/shell-launcher-applet/launcheritem.cpp @@ -7,6 +7,7 @@ #include "../launchercontroller.h" #include #include +#include #include #include @@ -59,6 +60,7 @@ bool LauncherItem::init() DApplet::init(); DQmlEngine().engine()->addImageProvider(QLatin1String("blurhash"), new BlurhashImageProvider); + DQmlEngine().engine()->addImageProvider(QLatin1String("appicon"), new LauncherAppIconProvider); QDBusConnection connection = QDBusConnection::sessionBus(); if (!connection.registerService(QStringLiteral("org.deepin.dde.Launcher1")) ||