disabled icons grayscale
This commit is contained in:
parent
3c74c44c09
commit
89f58821e7
10
src/icon.cpp
10
src/icon.cpp
|
@ -1,7 +1,10 @@
|
|||
#include "icon.h"
|
||||
#include <QFileInfo>
|
||||
#include <QPainter>
|
||||
#include "helper.h"
|
||||
|
||||
const int ICON_SIZE = 64;
|
||||
|
||||
/*
|
||||
Action names:
|
||||
actionOpenFile
|
||||
|
@ -132,5 +135,12 @@ QIcon Icon::get(QString actionName, QIcon defaultIcon)
|
|||
if (!QFileInfo::exists(path)) return defaultIcon;
|
||||
QIcon icon(path);
|
||||
if (icon.isNull()) return defaultIcon;
|
||||
// disabled icon
|
||||
QImage img(ICON_SIZE, ICON_SIZE, QImage::Format_ARGB32);
|
||||
QPainter p(&img);
|
||||
p.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
p.drawPixmap(img.rect(), QPixmap(path));
|
||||
p.fillRect(img.rect(), QColor(128, 128, 128));
|
||||
icon.addPixmap(QPixmap::fromImage(img), QIcon::Disabled);
|
||||
return icon;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue