2021-10-24 19:50:35 +00:00
|
|
|
|
/*
|
2022-01-06 23:38:21 +00:00
|
|
|
|
Copyright 2021-2022 Peter Repukat - FlatspotSoftware
|
2021-10-24 19:50:35 +00:00
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
import QtQuick 6.2
|
|
|
|
|
import QtQuick.Controls 6.2
|
|
|
|
|
import QtQuick.Layouts 6.2
|
|
|
|
|
import QtQuick.Controls.Material 6.2
|
|
|
|
|
import QtQuick.Dialogs 6.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: propsContent
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2021-10-24 23:14:03 +00:00
|
|
|
|
property alias fileDialog: fileDialog
|
2021-10-25 16:00:34 +00:00
|
|
|
|
property alias uwpSelectDialog: uwpSelectDialog
|
2021-10-24 19:50:35 +00:00
|
|
|
|
signal cancel()
|
|
|
|
|
signal done(var shortcut)
|
|
|
|
|
|
2022-09-23 10:48:13 +00:00
|
|
|
|
property var shortcutInfo: ({})
|
2021-10-24 19:50:35 +00:00
|
|
|
|
|
|
|
|
|
function resetInfo() {
|
|
|
|
|
shortcutInfo = ({
|
2022-09-23 10:48:13 +00:00
|
|
|
|
"controller": {
|
|
|
|
|
"maxControllers": 1,
|
|
|
|
|
"emulateDS4": false,
|
|
|
|
|
"allowDesktopConfig": false
|
|
|
|
|
},
|
|
|
|
|
"devices": {
|
|
|
|
|
"hideDevices": true,
|
|
|
|
|
"realDeviceIds": false
|
|
|
|
|
},
|
|
|
|
|
"icon": null,
|
|
|
|
|
"launch": {
|
|
|
|
|
"closeOnExit": true,
|
|
|
|
|
"launch": false,
|
|
|
|
|
"launchAppArgs": null,
|
|
|
|
|
"launchPath": null,
|
|
|
|
|
"waitForChildProcs": true
|
|
|
|
|
},
|
|
|
|
|
"name": null,
|
|
|
|
|
"version": 1,
|
|
|
|
|
"window": {
|
|
|
|
|
"disableOverlay": false,
|
|
|
|
|
"maxFps": null,
|
|
|
|
|
"scale": null,
|
|
|
|
|
"windowMode": false
|
|
|
|
|
},
|
|
|
|
|
"extendedLogging": false
|
2021-10-24 19:50:35 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
2022-09-23 10:48:13 +00:00
|
|
|
|
|
|
|
|
|
Component.onCompleted: function() {
|
|
|
|
|
resetInfo()
|
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
|
|
|
|
|
onShortcutInfoChanged: function() {
|
2022-09-27 22:20:16 +00:00
|
|
|
|
if (!shortcutInfo) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (nameInput) { // basic info (not in collapsible container)
|
|
|
|
|
nameInput.text = shortcutInfo.name || ""
|
|
|
|
|
launchApp.checked = shortcutInfo.launch.launch
|
|
|
|
|
pathInput.text = shortcutInfo.launch.launchPath || ""
|
|
|
|
|
argsInput.text = shortcutInfo.launch.launchAppArgs || ""
|
|
|
|
|
}
|
2022-09-28 10:45:34 +00:00
|
|
|
|
if (advancedTargetSettings) { // advanced settings (collapsible container)
|
|
|
|
|
advancedTargetSettings.shortcutInfo = shortcutInfo;
|
2022-09-23 14:09:24 +00:00
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Flickable {
|
|
|
|
|
id: flickable
|
|
|
|
|
anchors.margins: 0
|
2021-10-24 19:50:35 +00:00
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.bottom: parent.bottom
|
2022-03-14 19:13:27 +00:00
|
|
|
|
clip: true
|
|
|
|
|
ScrollBar.vertical: ScrollBar {
|
2022-03-05 15:11:14 +00:00
|
|
|
|
|
2022-03-14 19:13:27 +00:00
|
|
|
|
}
|
|
|
|
|
contentWidth: propscolumn.width
|
|
|
|
|
contentHeight: propscolumn.height
|
|
|
|
|
flickableDirection: Flickable.VerticalFlick
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
id: propscolumn
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.leftMargin: 32
|
|
|
|
|
spacing: 4
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: topspacing
|
|
|
|
|
width: 1
|
|
|
|
|
height: 32
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: namewrapper
|
|
|
|
|
width: parent.width / 3
|
|
|
|
|
height: 64
|
|
|
|
|
Label {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
|
id: nameLabel
|
|
|
|
|
font.bold: true
|
|
|
|
|
text: qsTr("Name")
|
|
|
|
|
}
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.top: nameLabel.bottom
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
id: nameInput
|
|
|
|
|
placeholderText: qsTr("...")
|
|
|
|
|
text: shortcutInfo.name
|
|
|
|
|
onTextChanged: shortcutInfo.name = text
|
|
|
|
|
validator: RegularExpressionValidator { regularExpression: /([0-z]|\s|.)+/gm }
|
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Item {
|
|
|
|
|
width: 1
|
|
|
|
|
height: 8
|
|
|
|
|
}
|
|
|
|
|
RPane {
|
2022-03-05 15:11:14 +00:00
|
|
|
|
width: parent.width
|
2022-03-14 19:13:27 +00:00
|
|
|
|
radius: 4
|
|
|
|
|
Material.elevation: 32
|
|
|
|
|
bgOpacity: 0.97
|
|
|
|
|
Column {
|
2021-10-24 19:50:35 +00:00
|
|
|
|
width: parent.width
|
2022-03-14 19:13:27 +00:00
|
|
|
|
height: parent.height
|
|
|
|
|
spacing: 4
|
|
|
|
|
Row {
|
|
|
|
|
spacing: 32
|
|
|
|
|
width: parent.width
|
2022-03-05 15:11:14 +00:00
|
|
|
|
CheckBox {
|
2022-03-14 19:13:27 +00:00
|
|
|
|
id: launchApp
|
|
|
|
|
text: qsTr("Launch app")
|
2022-09-27 22:20:16 +00:00
|
|
|
|
checked: shortcutInfo ? shortcutInfo.launch.launch : false
|
2022-03-14 19:13:27 +00:00
|
|
|
|
onCheckedChanged: function() {
|
2022-09-23 10:48:13 +00:00
|
|
|
|
shortcutInfo.launch.launch = checked
|
2022-03-14 19:13:27 +00:00
|
|
|
|
if (checked) {
|
2022-09-23 14:09:24 +00:00
|
|
|
|
if (closeOnExit) {
|
|
|
|
|
closeOnExit.enabled = true;
|
|
|
|
|
if (closeOnExit.checked) {
|
|
|
|
|
waitForChildren.enabled = true;
|
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
}
|
|
|
|
|
allowDesktopConfig.enabled = true;
|
|
|
|
|
} else {
|
|
|
|
|
waitForChildren.enabled = false;
|
|
|
|
|
closeOnExit.enabled = false;
|
|
|
|
|
allowDesktopConfig.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-05 15:11:14 +00:00
|
|
|
|
}
|
2021-11-12 14:31:36 +00:00
|
|
|
|
}
|
2022-03-05 15:11:14 +00:00
|
|
|
|
Item {
|
2022-03-14 19:13:27 +00:00
|
|
|
|
width: 1
|
|
|
|
|
height: 8
|
2022-03-05 15:11:14 +00:00
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
id: launchlayout
|
|
|
|
|
spacing: 4
|
2022-09-23 13:29:39 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.leftMargin: 32
|
|
|
|
|
anchors.rightMargin: 32
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Image {
|
|
|
|
|
id: maybeIcon
|
|
|
|
|
source: shortcutInfo.icon
|
|
|
|
|
? shortcutInfo.icon.endsWith(".exe")
|
|
|
|
|
? "image://exe/" + shortcutInfo.icon
|
|
|
|
|
: "file:///" + shortcutInfo.icon
|
2022-09-23 10:48:13 +00:00
|
|
|
|
: ''
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Layout.preferredWidth: 48
|
|
|
|
|
Layout.preferredHeight: 48
|
|
|
|
|
visible: shortcutInfo.icon
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-03-05 15:11:14 +00:00
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Item {
|
|
|
|
|
Layout.preferredWidth: 8
|
|
|
|
|
Layout.preferredHeight: 8
|
|
|
|
|
visible: shortcutInfo.icon
|
2022-03-05 15:11:14 +00:00
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Item {
|
|
|
|
|
Layout.preferredWidth: parent.width / 2
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
height: 64
|
|
|
|
|
Label {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
|
id: pathLabel
|
|
|
|
|
font.bold: true
|
|
|
|
|
text: qsTr("Path")
|
|
|
|
|
}
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.top: pathLabel.bottom
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
id: pathInput
|
|
|
|
|
placeholderText: qsTr("...")
|
|
|
|
|
enabled: launchApp.checked
|
2022-09-23 10:48:13 +00:00
|
|
|
|
text: shortcutInfo.launch.launchPath || ""
|
|
|
|
|
onTextChanged: shortcutInfo.launch.launchPath = text
|
2022-03-14 19:13:27 +00:00
|
|
|
|
}
|
2022-03-05 15:11:14 +00:00
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Button {
|
|
|
|
|
Layout.preferredWidth: 64
|
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
text: qsTr("...")
|
|
|
|
|
onClicked: fileDialog.open();
|
|
|
|
|
}
|
|
|
|
|
Button {
|
|
|
|
|
Layout.preferredWidth: 64
|
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
|
text: qsTr("UWP")
|
|
|
|
|
visible: uiModel.isWindows
|
|
|
|
|
onClicked: uwpSelectDialog.open();
|
|
|
|
|
}
|
|
|
|
|
Item {
|
|
|
|
|
height: 1
|
|
|
|
|
Layout.preferredWidth: 12
|
|
|
|
|
}
|
|
|
|
|
Item {
|
|
|
|
|
Layout.preferredWidth: parent.width / 2.5
|
|
|
|
|
height: 64
|
|
|
|
|
Label {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
|
id: argslabel
|
|
|
|
|
font.bold: true
|
|
|
|
|
text: qsTr("Launch Arguments")
|
|
|
|
|
}
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.top: argslabel.bottom
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
id: argsInput
|
|
|
|
|
enabled: launchApp.checked
|
2022-09-23 10:48:13 +00:00
|
|
|
|
text: shortcutInfo.launch.launchAppArgs
|
|
|
|
|
onTextChanged: shortcutInfo.launch.launchAppArgs = text
|
2022-03-14 19:13:27 +00:00
|
|
|
|
}
|
2022-03-05 15:11:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Item {
|
|
|
|
|
width: 1
|
|
|
|
|
height: 8
|
|
|
|
|
}
|
2022-03-05 15:11:14 +00:00
|
|
|
|
|
2022-09-28 10:45:34 +00:00
|
|
|
|
AdvancedTargetSettings {
|
|
|
|
|
id: advancedTargetSettings
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
2022-09-23 11:42:44 +00:00
|
|
|
|
|
2022-03-14 19:13:27 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: bottomspacing
|
|
|
|
|
width: 1
|
|
|
|
|
height: 32
|
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
spacing: 8
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.right: parent.right
|
2022-03-14 19:13:27 +00:00
|
|
|
|
anchors.margins: 24
|
|
|
|
|
anchors.bottomMargin: 16
|
2021-10-24 19:50:35 +00:00
|
|
|
|
Button {
|
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
|
onClicked: function() {
|
2022-09-27 22:20:16 +00:00
|
|
|
|
resetInfo();
|
2021-10-24 19:50:35 +00:00
|
|
|
|
cancel()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Button {
|
2022-09-27 22:07:58 +00:00
|
|
|
|
text: qsTr("💾 Save")
|
2021-10-24 19:50:35 +00:00
|
|
|
|
highlighted: true
|
2021-10-24 23:14:03 +00:00
|
|
|
|
enabled: nameInput.acceptableInput
|
2021-10-24 19:50:35 +00:00
|
|
|
|
onClicked: function() {
|
|
|
|
|
done(shortcutInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
|
id: fileDialog
|
|
|
|
|
title: qsTr("Please choose a Program to Launch")
|
|
|
|
|
nameFilters: uiModel.isWindows ? ["Executable files (*.exe *.bat *.ps1)"] : []
|
|
|
|
|
onAccepted: {
|
|
|
|
|
if (fileDialog.selectedFile != null) {
|
|
|
|
|
pathInput.text = fileDialog.selectedFile.toString().replace("file:///", "")
|
|
|
|
|
if (nameInput.text == "") {
|
|
|
|
|
nameInput.text = pathInput.text.replace(/.*(\\|\/)/,"").replace(/\.[0-z]*$/, "")
|
2021-10-28 17:33:56 +00:00
|
|
|
|
shortcutInfo.icon = nameInput.text
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
launchApp.checked = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onRejected: {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-25 16:00:34 +00:00
|
|
|
|
UWPSelectDialog {
|
|
|
|
|
id: uwpSelectDialog
|
|
|
|
|
onConfirmed: function(modelData) {
|
|
|
|
|
if (nameInput.text == "") {
|
|
|
|
|
nameInput.text = modelData.AppName
|
|
|
|
|
}
|
2021-10-27 18:32:41 +00:00
|
|
|
|
if (modelData.IconPath) {
|
|
|
|
|
shortcutInfo.icon = modelData.IconPath
|
|
|
|
|
}
|
2021-10-25 16:00:34 +00:00
|
|
|
|
pathInput.text = modelData.AppUMId
|
|
|
|
|
launchApp.checked = true
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
|
2022-09-04 14:18:02 +00:00
|
|
|
|
InfoDialog {
|
|
|
|
|
id: helpInfoDialog
|
|
|
|
|
titleText: qsTr("")
|
|
|
|
|
text: qsTr("")
|
|
|
|
|
extraButton: false
|
|
|
|
|
extraButtonText: qsTr("")
|
|
|
|
|
onConfirmedExtra: function(data) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|