forked from quickshell/quickshell
core/icon: add icon image provider
This commit is contained in:
parent
8e530b6b77
commit
d47a7f2cff
5 changed files with 31 additions and 1 deletions
16
src/core/iconimageprovider.cpp
Normal file
16
src/core/iconimageprovider.cpp
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue