diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b96f18..425b2ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ find_package(Qt5 COMPONENTS # find kde framework components # see: https://api.kde.org/frameworks/index.html > KWindowSystem find_package(KF5WindowSystem REQUIRED) +find_package(Qt5Xdg REQUIRED) # 查找其他组件 # see: https://cmake.org/cmake/help/v3.16/module/FindPkgConfig.html @@ -134,6 +135,7 @@ target_link_libraries(${PROJECT_NAME} Qt5::DBus Qt5::X11Extras KF5::WindowSystem + Qt5Xdg ${SingleApplication} ${UKUI_MENU_EXTERNAL_LIBS} ) diff --git a/src/appdata/app-icon-provider.cpp b/src/appdata/app-icon-provider.cpp index a2b068a..aedb1fb 100644 --- a/src/appdata/app-icon-provider.cpp +++ b/src/appdata/app-icon-provider.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace UkuiMenu { @@ -65,6 +66,9 @@ void AppIconProvider::loadPixmap(const QString &id, QPixmap &pixmap) } else { isOk = loadPixmapFromTheme(id, pixmap); + if (!isOk) { + isOk = loadPixmapFromXdg(id, pixmap); + } } if (!isOk) { @@ -113,7 +117,6 @@ bool AppIconProvider::loadPixmapFromPath(const QString &path, QPixmap &pixmap) bool AppIconProvider::loadPixmapFromTheme(const QString &name, QPixmap &pixmap) { if (!QIcon::hasThemeIcon(name)) { - qWarning() << "Error: loadPixmapFromTheme, icon dose not exists. name:" << name; return false; } QIcon icon = QIcon::fromTheme(name); @@ -128,4 +131,16 @@ void AppIconProvider::loadDefault(QPixmap &pixmap) } } +bool AppIconProvider::loadPixmapFromXdg(const QString &name, QPixmap &pixmap) +{ + QIcon icon = XdgIcon::fromTheme(name); + if (icon.isNull()) { + qWarning() << "Error: loadPixmapFromXdg, icon dose not exists. name:" << name; + return false; + } + + pixmap = icon.pixmap(AppIconProvider::s_defaultSize); + return true; +} + } // UkuiMenu diff --git a/src/appdata/app-icon-provider.h b/src/appdata/app-icon-provider.h index fa0c676..51100ac 100644 --- a/src/appdata/app-icon-provider.h +++ b/src/appdata/app-icon-provider.h @@ -37,6 +37,7 @@ private: static bool loadPixmapFromUrl(const QUrl &url, QPixmap &pixmap); static bool loadPixmapFromPath(const QString &path, QPixmap &pixmap); static bool loadPixmapFromTheme(const QString &name, QPixmap &pixmap); + static bool loadPixmapFromXdg(const QString &name, QPixmap &pixmap); private: static QSize s_defaultSize;