From 01efd8d02d37073fd27ecfd3e94eb0996620ed1f Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 15 Oct 2022 14:54:10 +0200 Subject: [PATCH] GlosSIConfig: QML: change shortcut Icon --- GlosSIConfig/Resource.rc | 8 +-- GlosSIConfig/qml.qrc | 1 + GlosSIConfig/qml/ShortcutCards.qml | 3 +- GlosSIConfig/qml/ShortcutProps.qml | 52 ++++++++++++++----- .../svg/add_photo_alternate_white_24dp.svg | 1 + 5 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 GlosSIConfig/svg/add_photo_alternate_white_24dp.svg diff --git a/GlosSIConfig/Resource.rc b/GlosSIConfig/Resource.rc index 73c56a6..713a137 100644 --- a/GlosSIConfig/Resource.rc +++ b/GlosSIConfig/Resource.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,1,0,2033009290000 - PRODUCTVERSION 0,1,0,2033009290000 + FILEVERSION 0,1,0,2034000568418 + PRODUCTVERSION 0,1,0,2034000568418 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "Peter Repukat - FlatspotSoftware" VALUE "FileDescription", "GlosSI - Config" - VALUE "FileVersion", "0.1.0.2-33-g929abfe" + VALUE "FileVersion", "0.1.0.2-34-gb568418" VALUE "InternalName", "GlosSIConfig" VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware" VALUE "OriginalFilename", "GlosSIConfig.exe" VALUE "ProductName", "GlosSI" - VALUE "ProductVersion", "0.1.0.2-33-g929abfe" + VALUE "ProductVersion", "0.1.0.2-34-gb568418" END END BLOCK "VarFileInfo" diff --git a/GlosSIConfig/qml.qrc b/GlosSIConfig/qml.qrc index c9a5eaa..64cc986 100644 --- a/GlosSIConfig/qml.qrc +++ b/GlosSIConfig/qml.qrc @@ -23,5 +23,6 @@ qml/GlobalConf.qml svg/settings_fill_white_24dp.svg qml/EGSSelectDialog.qml + svg/add_photo_alternate_white_24dp.svg diff --git a/GlosSIConfig/qml/ShortcutCards.qml b/GlosSIConfig/qml/ShortcutCards.qml index 85593a2..830514b 100644 --- a/GlosSIConfig/qml/ShortcutCards.qml +++ b/GlosSIConfig/qml/ShortcutCards.qml @@ -215,10 +215,9 @@ GridView { ? modelData.icon.endsWith(".exe") ? "image://exe/" + modelData.icon : "file:///" + modelData.icon - : null + : 'qrc:/svg/add_photo_alternate_white_24dp.svg' width: 48 height: 48 - visible: !!modelData.icon } Label { diff --git a/GlosSIConfig/qml/ShortcutProps.qml b/GlosSIConfig/qml/ShortcutProps.qml index 30862f5..784fbc1 100644 --- a/GlosSIConfig/qml/ShortcutProps.qml +++ b/GlosSIConfig/qml/ShortcutProps.qml @@ -53,6 +53,14 @@ Item { if (advancedTargetSettings) { // advanced settings (collapsible container) advancedTargetSettings.shortcutInfo = shortcutInfo; } + if (maybeIcon) { + console.log("meh"); + maybeIcon.source = shortcutInfo.icon + ? shortcutInfo.icon.endsWith(".exe") + ? "image://exe/" + shortcutInfo.icon + : "file:///" + shortcutInfo.icon + : 'qrc:/svg/add_photo_alternate_white_24dp.svg'; + } } Flickable { @@ -153,24 +161,27 @@ Item { spacing: 4 anchors.left: parent.left anchors.right: parent.right - anchors.leftMargin: 32 - anchors.rightMargin: 32 - Image { - id: maybeIcon - source: shortcutInfo.icon - ? shortcutInfo.icon.endsWith(".exe") - ? "image://exe/" + shortcutInfo.icon - : "file:///" + shortcutInfo.icon - : '' - Layout.preferredWidth: 48 - Layout.preferredHeight: 48 - visible: shortcutInfo.icon + anchors.leftMargin: 8 + anchors.rightMargin: 16 + Button { + id: iconButton + Layout.preferredWidth: 56 + Layout.preferredHeight: 64 Layout.alignment: Qt.AlignVCenter + flat: true + contentItem: Image { + id: maybeIcon + source: shortcutInfo.icon + ? shortcutInfo.icon.endsWith(".exe") + ? "image://exe/" + shortcutInfo.icon + : "file:///" + shortcutInfo.icon + : 'qrc:/svg/add_photo_alternate_white_24dp.svg' + } + onClicked: iconFileDialog.open() } Item { Layout.preferredWidth: 8 Layout.preferredHeight: 8 - visible: shortcutInfo.icon } Item { Layout.preferredWidth: parent.width / 2 @@ -296,6 +307,21 @@ Item { } } + + FileDialog { + id: iconFileDialog + title: qsTr("Please choose an icon") + nameFilters: uiModel.isWindows ? ["Image/Executable (*.exe *.png *.ico *.jpg)"] : ["Image (*.png *.ico *.jpg)"] + onAccepted: { + if (iconFileDialog.selectedFile != null) { + shortcutInfo.icon = iconFileDialog.selectedFile.toString().replace("file:///", "") + shortcutInfo = shortcutInfo; + } + } + onRejected: { + + } + } UWPSelectDialog { id: uwpSelectDialog diff --git a/GlosSIConfig/svg/add_photo_alternate_white_24dp.svg b/GlosSIConfig/svg/add_photo_alternate_white_24dp.svg new file mode 100644 index 0000000..927af10 --- /dev/null +++ b/GlosSIConfig/svg/add_photo_alternate_white_24dp.svg @@ -0,0 +1 @@ + \ No newline at end of file