core/icon: add icon image provider

This commit is contained in:
outfoxxed 2024-04-05 17:54:51 -07:00
parent 8e530b6b77
commit d47a7f2cff
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
5 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,16 @@
#include "iconimageprovider.hpp"
#include <qicon.h>
#include <qlogging.h>
#include <qpixmap.h>
QPixmap
IconImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) {
auto icon = QIcon::fromTheme(id);
auto targetSize = requestedSize.isValid() ? requestedSize : QSize(100, 100);
auto pixmap = icon.pixmap(targetSize.width(), targetSize.height());
if (size != nullptr) *size = pixmap.size();
return pixmap;
}