diff --git a/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.cpp b/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.cpp index 1846efb0a..2cfdc6416 100644 --- a/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.cpp +++ b/src/lib/plugins/qml/api/browseraction/qmlbrowseraction.cpp @@ -210,7 +210,11 @@ void QmlBrowserActionButton::setToolTip(const QString &toolTip) void QmlBrowserActionButton::setIcon(const QString &icon) { m_iconUrl = icon; - AbstractButtonInterface::setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl)))); + if (QIcon::hasThemeIcon(m_iconUrl)) { + AbstractButtonInterface::setIcon(QIcon::fromTheme(m_iconUrl)); + } else { + AbstractButtonInterface::setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl)))); + } } void QmlBrowserActionButton::setBadgeText(const QString &badgeText) diff --git a/src/lib/plugins/qml/api/menus/qmlaction.cpp b/src/lib/plugins/qml/api/menus/qmlaction.cpp index 53c50d702..5f5d2518f 100644 --- a/src/lib/plugins/qml/api/menus/qmlaction.cpp +++ b/src/lib/plugins/qml/api/menus/qmlaction.cpp @@ -33,8 +33,13 @@ void QmlAction::setProperties(const QVariantMap &map) for (const QString &key : map.keys()) { if (key == QSL("icon")) { - QUrl url = map.value(key).toUrl(); - QIcon icon(QzTools::getPathFromUrl(url)); + QString iconPath = map.value(key).toString(); + QIcon icon; + if (QIcon::hasThemeIcon(iconPath)) { + icon = QIcon::fromTheme(iconPath); + } else { + icon = QIcon(QzTools::getPathFromUrl(QUrl::fromEncoded(iconPath.toUtf8()))); + } m_action->setIcon(icon); } else if (key == QSL("shortcut")) { m_action->setShortcut(QKeySequence(map.value(key).toString())); diff --git a/src/lib/plugins/qml/api/menus/qmlmenu.cpp b/src/lib/plugins/qml/api/menus/qmlmenu.cpp index b1d1bef2c..defbe689b 100644 --- a/src/lib/plugins/qml/api/menus/qmlmenu.cpp +++ b/src/lib/plugins/qml/api/menus/qmlmenu.cpp @@ -64,8 +64,13 @@ QmlMenu *QmlMenu::addMenu(const QVariantMap &map) QMenu *newMenu = new QMenu(); for (const QString &key : map.keys()) { if (key == QSL("icon")) { - QUrl url = map.value(key).toUrl(); - QIcon icon(QzTools::getPathFromUrl(url)); + QString iconPath = map.value(key).toString(); + QIcon icon; + if (QIcon::hasThemeIcon(iconPath)) { + icon = QIcon::fromTheme(iconPath); + } else { + icon = QIcon(QzTools::getPathFromUrl(QUrl::fromEncoded(iconPath.toUtf8()))); + } newMenu->setIcon(icon); continue; } diff --git a/src/lib/plugins/qml/api/sidebar/qmlsidebar.cpp b/src/lib/plugins/qml/api/sidebar/qmlsidebar.cpp index 6fa4078d5..aef011bde 100644 --- a/src/lib/plugins/qml/api/sidebar/qmlsidebar.cpp +++ b/src/lib/plugins/qml/api/sidebar/qmlsidebar.cpp @@ -131,7 +131,11 @@ QAction *QmlSideBarHelper::createMenuAction() { QAction *action = new QAction(m_title); action->setShortcut(QKeySequence(m_shortcut)); - action->setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl)))); + if (QIcon::hasThemeIcon(m_iconUrl)) { + action->setIcon(QIcon::fromTheme(m_iconUrl)); + } else { + action->setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl)))); + } action->setCheckable(m_checkable); return action; }