mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
enable icon from theme in qml plugins
This commit is contained in:
parent
18ebbc2ade
commit
f42049eb12
|
@ -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)
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user