refactor: move loadHidpiIcon from ActionManager to ToolButton.

setting loadHidpiIcon in ToolButton is better than ActionManager.
ToolButton has less code and its aim also include loading icon.
This commit is contained in:
2026-07-03 15:15:21 +08:00
parent f4d272e014
commit 7ea3524a90
4 changed files with 18 additions and 17 deletions
+14 -2
View File
@@ -4,9 +4,10 @@
#include "toolbutton.h"
#include "actionmanager.h"
#include "opacityhelper.h"
#include <QSvgRenderer>
#include <QGuiApplication>
#include <QPainter>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
@@ -29,7 +30,18 @@ ToolButton::ToolButton(bool hoverColor, QWidget *parent)
void ToolButton::setIconResourcePath(const QString &iconp)
{
this->setIcon(ActionManager::loadHidpiIcon(iconp, this->iconSize()));
this->setIcon(ToolButton::loadHidpiIcon(iconp, this->iconSize()));
}
QIcon ToolButton::loadHidpiIcon(const QString &resp, QSize sz)
{
QSvgRenderer r(resp);
QPixmap pm = QPixmap(sz * qApp->devicePixelRatio());
pm.fill(Qt::transparent);
QPainter p(&pm);
r.render(&p);
pm.setDevicePixelRatio(qApp->devicePixelRatio());
return QIcon(pm);
}
void ToolButton::setOpacity(qreal opacity, bool animated)