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