mirror of https://github.com/Alia5/GlosSI
Display executable/UWP icons throughout configurator
parent
7ae28a90c9
commit
00e6d17714
@ -0,0 +1 @@
|
|||||||
|
#include "ExeImageProvider.h"
|
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QQuickImageProvider>
|
||||||
|
#include <Windows.h>
|
||||||
|
class ExeImageProvider : public QQuickImageProvider {
|
||||||
|
public:
|
||||||
|
ExeImageProvider()
|
||||||
|
: QQuickImageProvider(QQuickImageProvider::Image)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize) override
|
||||||
|
{
|
||||||
|
HICON icon = 0;
|
||||||
|
std::wstring path = id.toStdWString();
|
||||||
|
icon = (HICON)LoadImage(
|
||||||
|
0,
|
||||||
|
path.data(),
|
||||||
|
IMAGE_ICON,
|
||||||
|
GetSystemMetrics(SM_CXSMICON),
|
||||||
|
GetSystemMetrics(SM_CYSMICON),
|
||||||
|
LR_LOADFROMFILE | LR_LOADMAP3DCOLORS);
|
||||||
|
if (!icon) {
|
||||||
|
ExtractIconEx(path.data(), 0, &icon, nullptr, 1);
|
||||||
|
if (!icon) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QImage::fromHICON(icon);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue