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:
+14
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user