mirror of
https://github.com/Alia5/GlosSI.git
synced 2024-10-30 15:20:38 +00:00
Display executable/UWP icons throughout configurator
This commit is contained in:
parent
7ae28a90c9
commit
00e6d17714
1
GlosSIConfig/ExeImageProvider.cpp
Normal file
1
GlosSIConfig/ExeImageProvider.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "ExeImageProvider.h"
|
30
GlosSIConfig/ExeImageProvider.h
Normal file
30
GlosSIConfig/ExeImageProvider.h
Normal file
@ -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);
|
||||
}
|
||||
};
|
@ -132,6 +132,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ExeImageProvider.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="UIModel.cpp" />
|
||||
<None Include=".clang-format" />
|
||||
@ -149,6 +150,7 @@
|
||||
<QtMoc Include="UIModel.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ExeImageProvider.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="resource1.h" />
|
||||
<ClInclude Include="UWPFetch.h" />
|
||||
|
@ -34,6 +34,9 @@
|
||||
<ClCompile Include="UIModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExeImageProvider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="qml\main.qml">
|
||||
@ -83,6 +86,9 @@
|
||||
<ClInclude Include="resource1.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExeImageProvider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="manifest.xml">
|
||||
|
@ -51,8 +51,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,0,0,6800050
|
||||
PRODUCTVERSION 0,0,0,6800050
|
||||
FILEVERSION 0,0,0,7002809
|
||||
PRODUCTVERSION 0,0,0,7002809
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@ -69,12 +69,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
|
||||
VALUE "FileDescription", "GlosSI - Config"
|
||||
VALUE "FileVersion", "0.0.0.68fbe50"
|
||||
VALUE "FileVersion", "0.0.0.7ae28a9"
|
||||
VALUE "InternalName", "GlosSIConfig"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
|
||||
VALUE "OriginalFilename", "GlosSIConfig.exe"
|
||||
VALUE "ProductName", "GlosSi"
|
||||
VALUE "ProductVersion", "0.0.0.68fbe50"
|
||||
VALUE "ProductVersion", "0.0.0.7ae28a9"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
@ -106,3 +106,79 @@ END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ limitations under the License.
|
||||
#include <Windows.h>
|
||||
#include <dwmapi.h>
|
||||
#pragma comment(lib, "Dwmapi.lib")
|
||||
#include "ExeImageProvider.h"
|
||||
#endif
|
||||
|
||||
#include "UIModel.h"
|
||||
@ -72,6 +73,9 @@ int main(int argc, char* argv[])
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
UIModel uimodel;
|
||||
#ifdef _WIN32
|
||||
engine.addImageProvider(QLatin1String("exe"), new ExeImageProvider());
|
||||
#endif
|
||||
engine.rootContext()->setContextProperty("uiModel", QVariant::fromValue(&uimodel));
|
||||
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
||||
if (engine.rootObjects().isEmpty())
|
||||
|
@ -81,10 +81,26 @@ GridView {
|
||||
Material.elevation: 4
|
||||
clip: true
|
||||
property bool isInSteam: uiModel.isInSteam(modelData);
|
||||
|
||||
Image {
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
id: maybeIcon
|
||||
source: modelData.icon
|
||||
? modelData.icon.endsWith(".exe")
|
||||
? "image://exe/" + modelData.icon
|
||||
: "file:///" + modelData.icon
|
||||
: null
|
||||
width: 48
|
||||
height: 48
|
||||
visible: modelData.icon
|
||||
}
|
||||
|
||||
Label {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 8
|
||||
anchors.left: maybeIcon.right
|
||||
anchors.right: parent.right
|
||||
text: modelData.name
|
||||
font.bold: true
|
||||
@ -93,7 +109,7 @@ GridView {
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.top: label.bottom
|
||||
anchors.top: maybeIcon.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: buttonrow.top
|
||||
anchors.margins: 12
|
||||
@ -152,18 +168,6 @@ GridView {
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: buttonrow.top
|
||||
id: maybeIcon
|
||||
anchors.bottomMargin: 8
|
||||
source: modelData.icon ? "file:///" + modelData.icon : null
|
||||
// TODO: extract exe icons.
|
||||
width: 48
|
||||
height: 48
|
||||
visible: modelData.icon
|
||||
}
|
||||
|
||||
Button {
|
||||
id: steambutton
|
||||
anchors.left: parent.left
|
||||
|
@ -133,6 +133,23 @@ Item {
|
||||
id: launchlayout
|
||||
spacing: 4
|
||||
width: parent.width
|
||||
Image {
|
||||
id: maybeIcon
|
||||
source: shortcutInfo.icon
|
||||
? shortcutInfo.icon.endsWith(".exe")
|
||||
? "image://exe/" + shortcutInfo.icon
|
||||
: "file:///" + shortcutInfo.icon
|
||||
: null
|
||||
Layout.preferredWidth: 48
|
||||
Layout.preferredHeight: 48
|
||||
visible: shortcutInfo.icon
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
Item {
|
||||
Layout.preferredWidth: 8
|
||||
Layout.preferredHeight: 8
|
||||
visible: shortcutInfo.icon
|
||||
}
|
||||
Item {
|
||||
Layout.preferredWidth: parent.width / 2
|
||||
Layout.fillWidth: true
|
||||
@ -273,6 +290,7 @@ Item {
|
||||
pathInput.text = fileDialog.selectedFile.toString().replace("file:///", "")
|
||||
if (nameInput.text == "") {
|
||||
nameInput.text = pathInput.text.replace(/.*(\\|\/)/,"").replace(/\.[0-z]*$/, "")
|
||||
shortcutInfo.icon = nameInput.text
|
||||
}
|
||||
launchApp.checked = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user