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:
+2
-13
@@ -5,22 +5,11 @@
|
||||
#include "actionmanager.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "toolbutton.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
|
||||
QIcon ActionManager::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 ActionManager::setupAction(MainWindow *mainWindow)
|
||||
{
|
||||
// region: Action and Its Icon Creation
|
||||
@@ -34,7 +23,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
||||
auto create_action = [] (QWidget *w, QAction **a, QString i, QString an, bool iconFromTheme = false) {
|
||||
*a = new QAction(w);
|
||||
if (!i.isNull())
|
||||
(*a)->setIcon(iconFromTheme ? QIcon::fromTheme(i) : ActionManager::loadHidpiIcon(i));
|
||||
(*a)->setIcon(iconFromTheme ? QIcon::fromTheme(i) : ToolButton::loadHidpiIcon(i));
|
||||
(*a)->setObjectName(an);
|
||||
w->addAction(*a);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user