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)
|
void QmlBrowserActionButton::setIcon(const QString &icon)
|
||||||
{
|
{
|
||||||
m_iconUrl = icon;
|
m_iconUrl = icon;
|
||||||
|
if (QIcon::hasThemeIcon(m_iconUrl)) {
|
||||||
|
AbstractButtonInterface::setIcon(QIcon::fromTheme(m_iconUrl));
|
||||||
|
} else {
|
||||||
AbstractButtonInterface::setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl))));
|
AbstractButtonInterface::setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlBrowserActionButton::setBadgeText(const QString &badgeText)
|
void QmlBrowserActionButton::setBadgeText(const QString &badgeText)
|
||||||
|
|
|
@ -33,8 +33,13 @@ void QmlAction::setProperties(const QVariantMap &map)
|
||||||
|
|
||||||
for (const QString &key : map.keys()) {
|
for (const QString &key : map.keys()) {
|
||||||
if (key == QSL("icon")) {
|
if (key == QSL("icon")) {
|
||||||
QUrl url = map.value(key).toUrl();
|
QString iconPath = map.value(key).toString();
|
||||||
QIcon icon(QzTools::getPathFromUrl(url));
|
QIcon icon;
|
||||||
|
if (QIcon::hasThemeIcon(iconPath)) {
|
||||||
|
icon = QIcon::fromTheme(iconPath);
|
||||||
|
} else {
|
||||||
|
icon = QIcon(QzTools::getPathFromUrl(QUrl::fromEncoded(iconPath.toUtf8())));
|
||||||
|
}
|
||||||
m_action->setIcon(icon);
|
m_action->setIcon(icon);
|
||||||
} else if (key == QSL("shortcut")) {
|
} else if (key == QSL("shortcut")) {
|
||||||
m_action->setShortcut(QKeySequence(map.value(key).toString()));
|
m_action->setShortcut(QKeySequence(map.value(key).toString()));
|
||||||
|
|
|
@ -64,8 +64,13 @@ QmlMenu *QmlMenu::addMenu(const QVariantMap &map)
|
||||||
QMenu *newMenu = new QMenu();
|
QMenu *newMenu = new QMenu();
|
||||||
for (const QString &key : map.keys()) {
|
for (const QString &key : map.keys()) {
|
||||||
if (key == QSL("icon")) {
|
if (key == QSL("icon")) {
|
||||||
QUrl url = map.value(key).toUrl();
|
QString iconPath = map.value(key).toString();
|
||||||
QIcon icon(QzTools::getPathFromUrl(url));
|
QIcon icon;
|
||||||
|
if (QIcon::hasThemeIcon(iconPath)) {
|
||||||
|
icon = QIcon::fromTheme(iconPath);
|
||||||
|
} else {
|
||||||
|
icon = QIcon(QzTools::getPathFromUrl(QUrl::fromEncoded(iconPath.toUtf8())));
|
||||||
|
}
|
||||||
newMenu->setIcon(icon);
|
newMenu->setIcon(icon);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,11 @@ QAction *QmlSideBarHelper::createMenuAction()
|
||||||
{
|
{
|
||||||
QAction *action = new QAction(m_title);
|
QAction *action = new QAction(m_title);
|
||||||
action->setShortcut(QKeySequence(m_shortcut));
|
action->setShortcut(QKeySequence(m_shortcut));
|
||||||
|
if (QIcon::hasThemeIcon(m_iconUrl)) {
|
||||||
|
action->setIcon(QIcon::fromTheme(m_iconUrl));
|
||||||
|
} else {
|
||||||
action->setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl))));
|
action->setIcon(QIcon(QzTools::getPathFromUrl(QUrl(m_iconUrl))));
|
||||||
|
}
|
||||||
action->setCheckable(m_checkable);
|
action->setCheckable(m_checkable);
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user