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.Layouts 6.2
|
|
|
|
|
import QtQuick.Controls 6.2
|
|
|
|
|
import QtQuick.Controls.Material 6.2
|
2021-10-28 09:41:27 +00:00
|
|
|
|
import QtQuick.Dialogs 6.2
|
2021-10-24 23:14:03 +00:00
|
|
|
|
import Qt5Compat.GraphicalEffects
|
2021-10-24 19:50:35 +00:00
|
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
|
id: shortcutgrid
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
anchors.topMargin: margins
|
|
|
|
|
visible: model.length > 0
|
|
|
|
|
signal editClicked(var index, var shortcutInfo)
|
2021-10-25 16:00:34 +00:00
|
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
|
2021-10-24 23:14:03 +00:00
|
|
|
|
|
2021-10-24 19:50:35 +00:00
|
|
|
|
property real margins: 16
|
2021-10-24 23:14:03 +00:00
|
|
|
|
cellWidth: 292 + 16
|
|
|
|
|
cellHeight: 190 + 16
|
2021-10-24 19:50:35 +00:00
|
|
|
|
readonly property real displayedItems: Math.floor((parent.width - margins*2) / cellWidth)
|
|
|
|
|
width: displayedItems * cellWidth
|
|
|
|
|
model: uiModel.targetList;
|
2021-10-24 23:14:03 +00:00
|
|
|
|
GridView.delayRemove: true
|
|
|
|
|
|
2022-01-04 15:51:43 +00:00
|
|
|
|
property var manualInfo: null
|
|
|
|
|
|
2021-10-24 23:14:03 +00:00
|
|
|
|
// TODO: animations only properly work with abstractListModel... grrr...
|
|
|
|
|
addDisplaced: Transition {
|
|
|
|
|
NumberAnimation { properties: "x,y"; duration: 300 }
|
|
|
|
|
}
|
|
|
|
|
add: Transition {
|
|
|
|
|
ParallelAnimation {
|
|
|
|
|
NumberAnimation { property: "opacity"; from: 0; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
NumberAnimation { properties: "x,y"; from: height; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
populate: Transition {
|
|
|
|
|
ParallelAnimation {
|
|
|
|
|
NumberAnimation { property: "opacity"; from: 0; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
NumberAnimation { properties: "x,y"; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remove: Transition {
|
|
|
|
|
NumberAnimation { property: "opacity"; to: 0; duration: 300; easing.type: Easing.InQuad }
|
|
|
|
|
}
|
|
|
|
|
removeDisplaced: Transition {
|
|
|
|
|
NumberAnimation { properties: "x,y"; duration: 300; easing.type: Easing.InQuad }
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-04 15:51:43 +00:00
|
|
|
|
Dialog {
|
|
|
|
|
id: manualAddDialog
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
visible: false
|
|
|
|
|
modal: true
|
|
|
|
|
dim: true
|
|
|
|
|
parent: Overlay.overlay
|
|
|
|
|
Overlay.modal: Rectangle {
|
|
|
|
|
color: Qt.rgba(0,0,0,0.4)
|
|
|
|
|
opacity: backdropOpacity
|
|
|
|
|
Behavior on opacity {
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
duration: 300
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
property real backdropOpacity: 1.0
|
|
|
|
|
enter: Transition {
|
|
|
|
|
NumberAnimation{target: madcontent; property: "y"; from: parent.height; to: 16; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
NumberAnimation{target: madbackground; property: "y"; from: parent.height; to: 0; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
NumberAnimation{target: manualAddDialog; property: "backdropOpacity"; from: 0; to: 1; duration: 300; easing.type: Easing.OutQuad }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit: Transition {
|
|
|
|
|
NumberAnimation{target: madcontent; property: "y"; from: 16; to: parent.height; duration: 300; easing.type: Easing.InQuad }
|
|
|
|
|
NumberAnimation{target: madbackground; property: "y"; from: 0; to: parent.height; duration: 300; easing.type: Easing.InQuad }
|
|
|
|
|
NumberAnimation{target: manualAddDialog; property: "backdropOpacity"; from: 1; to: 0; duration: 300; easing.type: Easing.InQuad }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
background: RPane {
|
|
|
|
|
id: madbackground
|
|
|
|
|
radius: 4
|
|
|
|
|
Material.elevation: 64
|
|
|
|
|
bgOpacity: 0.97
|
|
|
|
|
}
|
|
|
|
|
contentItem: Item {
|
|
|
|
|
id: madcontent
|
|
|
|
|
implicitWidth: steamscreener.width
|
|
|
|
|
implicitHeight: madtext.height + 16 + steamscreener.height + 16 + madrow.height
|
|
|
|
|
|
|
|
|
|
Label {
|
|
|
|
|
id: madtext
|
|
|
|
|
text: qsTr("Add \"GlosSITarget\" as game to Steam and change it's properties (in Steam) to this:")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image {
|
|
|
|
|
anchors.top: madtext.bottom
|
|
|
|
|
anchors.left: madtext.left
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
id: steamscreener
|
|
|
|
|
source: "qrc:/steamscreener.png"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
id: madnameinput
|
|
|
|
|
text: manualInfo ? manualInfo.name : ""
|
|
|
|
|
anchors.top: steamscreener.top
|
|
|
|
|
anchors.left: steamscreener.left
|
|
|
|
|
anchors.topMargin: 72
|
|
|
|
|
anchors.leftMargin: 92
|
|
|
|
|
readOnly: true
|
|
|
|
|
background: Item {}
|
|
|
|
|
width: 550
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
id: glossiPathInput
|
|
|
|
|
text: manualInfo ? manualInfo.launch : ""
|
|
|
|
|
anchors.top: steamscreener.top
|
|
|
|
|
anchors.left: steamscreener.left
|
|
|
|
|
anchors.topMargin: 192
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
readOnly: true
|
|
|
|
|
background: Item {}
|
|
|
|
|
width: 550
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
id: startDirInput
|
|
|
|
|
text: manualInfo ? manualInfo.launchDir : ""
|
|
|
|
|
anchors.top: steamscreener.top
|
|
|
|
|
anchors.left: steamscreener.left
|
|
|
|
|
anchors.topMargin: 266
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
readOnly: true
|
|
|
|
|
background: Item {}
|
|
|
|
|
width: 550
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FluentTextInput {
|
|
|
|
|
id: launchOptsInput
|
|
|
|
|
text: manualInfo ? manualInfo.config : ""
|
|
|
|
|
anchors.top: steamscreener.top
|
|
|
|
|
anchors.left: steamscreener.left
|
|
|
|
|
anchors.topMargin: 432
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
readOnly: true
|
|
|
|
|
background: Item {}
|
|
|
|
|
width: 550
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
id: madrow
|
|
|
|
|
anchors.top: steamscreener.bottom
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
|
|
Button {
|
|
|
|
|
text: qsTr("OK")
|
|
|
|
|
onClicked: function(){
|
|
|
|
|
manualAddDialog.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-28 09:41:27 +00:00
|
|
|
|
InfoDialog {
|
|
|
|
|
id: writeErrorDialog
|
|
|
|
|
titleText: qsTr("Error")
|
|
|
|
|
text: qsTr("Error writing shortcuts.vdf...")
|
2022-01-04 15:51:43 +00:00
|
|
|
|
extraButton: true
|
|
|
|
|
extraButtonText: qsTr("Manual instructions")
|
|
|
|
|
onConfirmedExtra: function(data) {
|
|
|
|
|
manualAddDialog.open();
|
|
|
|
|
}
|
2021-10-28 09:41:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 19:50:35 +00:00
|
|
|
|
delegate: RPane {
|
2021-10-27 18:32:41 +00:00
|
|
|
|
id: delegateRoot
|
2021-10-24 19:50:35 +00:00
|
|
|
|
color: Qt.lighter(Material.background, 1.6)
|
|
|
|
|
bgOpacity: 0.3
|
|
|
|
|
radius: 8
|
2021-10-24 23:14:03 +00:00
|
|
|
|
width: 292
|
|
|
|
|
height: 190
|
2021-10-24 19:50:35 +00:00
|
|
|
|
Material.elevation: 4
|
2021-10-24 23:14:03 +00:00
|
|
|
|
clip: true
|
2021-10-27 18:32:41 +00:00
|
|
|
|
property bool isInSteam: uiModel.isInSteam(modelData);
|
2021-10-28 17:33:56 +00:00
|
|
|
|
|
|
|
|
|
Image {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
id: maybeIcon
|
2021-11-12 14:31:36 +00:00
|
|
|
|
source: !!modelData.icon
|
2021-10-28 17:33:56 +00:00
|
|
|
|
? modelData.icon.endsWith(".exe")
|
|
|
|
|
? "image://exe/" + modelData.icon
|
|
|
|
|
: "file:///" + modelData.icon
|
|
|
|
|
: null
|
|
|
|
|
width: 48
|
|
|
|
|
height: 48
|
2021-11-12 14:31:36 +00:00
|
|
|
|
visible: !!modelData.icon
|
2021-10-28 17:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 19:50:35 +00:00
|
|
|
|
Label {
|
2021-10-24 23:14:03 +00:00
|
|
|
|
id: label
|
2021-10-24 19:50:35 +00:00
|
|
|
|
anchors.top: parent.top
|
2021-10-28 17:33:56 +00:00
|
|
|
|
anchors.leftMargin: 8
|
|
|
|
|
anchors.left: maybeIcon.right
|
2021-10-24 23:14:03 +00:00
|
|
|
|
anchors.right: parent.right
|
2021-10-24 19:50:35 +00:00
|
|
|
|
text: modelData.name
|
|
|
|
|
font.bold: true
|
|
|
|
|
font.pixelSize: 16
|
2021-10-25 16:00:34 +00:00
|
|
|
|
elide: Text.ElideRight
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 23:14:03 +00:00
|
|
|
|
Column {
|
2021-10-28 17:33:56 +00:00
|
|
|
|
anchors.top: maybeIcon.bottom
|
2021-10-24 23:14:03 +00:00
|
|
|
|
anchors.left: parent.left
|
2021-10-27 18:32:41 +00:00
|
|
|
|
anchors.bottom: buttonrow.top
|
2021-10-24 23:14:03 +00:00
|
|
|
|
anchors.margins: 12
|
2021-10-28 09:41:27 +00:00
|
|
|
|
spacing: 8
|
2021-10-24 23:14:03 +00:00
|
|
|
|
Row {
|
|
|
|
|
spacing: 8
|
2021-11-12 14:31:36 +00:00
|
|
|
|
visible: !!modelData.launchPath && modelData.launchPath.length > 0
|
2021-10-24 23:14:03 +00:00
|
|
|
|
Label {
|
2021-10-25 16:00:34 +00:00
|
|
|
|
id: typeLabel
|
2021-11-12 14:31:36 +00:00
|
|
|
|
text: uiModel.isWindows && !!modelData.launchPath
|
2021-10-24 23:14:03 +00:00
|
|
|
|
? modelData.launchPath.replace(/^.{1,3}:/, "").length < modelData.launchPath.length
|
|
|
|
|
? "Win32"
|
|
|
|
|
: "UWP"
|
|
|
|
|
: qsTr("Launch")
|
|
|
|
|
font.bold: true
|
|
|
|
|
}
|
|
|
|
|
Label {
|
|
|
|
|
property string te: modelData.launchPath
|
|
|
|
|
? modelData.launchPath.replace(/.*(\\|\/)/gm, "")
|
|
|
|
|
: ""
|
|
|
|
|
text: uiModel.isWindows ? te : te.replace(/\..{3}$/, "")
|
2021-10-25 16:00:34 +00:00
|
|
|
|
width: 292 - typeLabel.width - 72
|
|
|
|
|
elide: Text.ElideRight
|
2021-10-24 23:14:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-28 09:41:27 +00:00
|
|
|
|
Row {
|
|
|
|
|
visible: false // TODO: dunno about this...
|
|
|
|
|
spacing: 4
|
|
|
|
|
Label {
|
|
|
|
|
text: qsTr("Is in")
|
|
|
|
|
font.bold: true
|
|
|
|
|
}
|
|
|
|
|
Image {
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
source: "qrc:/svg/steam.svg"
|
|
|
|
|
width: 16
|
|
|
|
|
height: 16
|
|
|
|
|
smooth: true
|
|
|
|
|
mipmap: true
|
|
|
|
|
ColorOverlay {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
source: parent
|
|
|
|
|
color: "white"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Item {
|
|
|
|
|
width: 4
|
|
|
|
|
height: 1
|
|
|
|
|
}
|
|
|
|
|
Label {
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
text: delegateRoot.isInSteam ? qsTr("Yes") : qsTr("No")
|
|
|
|
|
width: 292 - typeLabel.width - 72
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-24 23:14:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Button {
|
2021-10-27 18:32:41 +00:00
|
|
|
|
id: steambutton
|
2021-10-24 23:14:03 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
width: 72
|
2021-10-27 18:32:41 +00:00
|
|
|
|
onClicked: function(){
|
|
|
|
|
if (delegateRoot.isInSteam) {
|
2022-01-04 14:38:28 +00:00
|
|
|
|
if (!uiModel.removeFromSteam(modelData.name, "")) {
|
2021-10-28 09:41:27 +00:00
|
|
|
|
writeErrorDialog.open();
|
2021-10-27 18:32:41 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-01-04 14:38:28 +00:00
|
|
|
|
if (!uiModel.addToSteam(modelData, "")) {
|
2022-01-04 15:51:43 +00:00
|
|
|
|
manualInfo = uiModel.manualProps(modelData);
|
2021-10-28 09:41:27 +00:00
|
|
|
|
writeErrorDialog.open();
|
2021-10-27 18:32:41 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-04 15:51:43 +00:00
|
|
|
|
if (steamShortcutsChanged == false) {
|
|
|
|
|
steamChangedDialog.open();
|
|
|
|
|
}
|
2021-10-27 18:32:41 +00:00
|
|
|
|
delegateRoot.isInSteam = uiModel.isInSteam(modelData)
|
2021-10-28 09:41:27 +00:00
|
|
|
|
steamShortcutsChanged = true
|
2021-10-27 18:32:41 +00:00
|
|
|
|
}
|
|
|
|
|
highlighted: delegateRoot.isInSteam
|
2021-10-28 09:41:27 +00:00
|
|
|
|
Material.accent: Material.color(Material.Red, Material.Shade800)
|
2021-10-24 23:14:03 +00:00
|
|
|
|
Row {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
spacing: 8
|
|
|
|
|
Label {
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-27 18:32:41 +00:00
|
|
|
|
text: delegateRoot.isInSteam ? "-" : "+"
|
2021-10-24 23:14:03 +00:00
|
|
|
|
font.bold: true
|
|
|
|
|
font.pixelSize: 24
|
|
|
|
|
}
|
|
|
|
|
Image {
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
source: "qrc:/svg/steam.svg"
|
|
|
|
|
width: 22
|
|
|
|
|
height: 22
|
|
|
|
|
smooth: true
|
|
|
|
|
mipmap: true
|
|
|
|
|
ColorOverlay {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
source: parent
|
|
|
|
|
color: "white"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 20:27:20 +00:00
|
|
|
|
Row {
|
2021-10-27 18:32:41 +00:00
|
|
|
|
id: buttonrow
|
2021-10-24 19:50:35 +00:00
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.bottom: parent.bottom
|
2021-10-24 20:27:20 +00:00
|
|
|
|
spacing: 4
|
|
|
|
|
|
2021-10-24 23:14:03 +00:00
|
|
|
|
RoundButton {
|
|
|
|
|
onClicked: uiModel.deleteTarget(index)
|
2021-10-24 20:27:20 +00:00
|
|
|
|
highlighted: true
|
2021-10-24 23:14:03 +00:00
|
|
|
|
Material.accent: Material.color(Material.Red, Material.Shade900)
|
|
|
|
|
Image {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
source: "qrc:/svg/delete_white_24dp.svg"
|
|
|
|
|
width: 16
|
|
|
|
|
height: 16
|
|
|
|
|
}
|
2021-10-24 20:27:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 23:14:03 +00:00
|
|
|
|
RoundButton {
|
2021-10-24 20:27:20 +00:00
|
|
|
|
onClicked: editClicked(index, modelData)
|
2021-10-24 23:14:03 +00:00
|
|
|
|
highlighted: true
|
|
|
|
|
Image {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
source: "qrc:/svg/edit_white_24dp.svg"
|
|
|
|
|
width: 16
|
|
|
|
|
height: 16
|
|
|
|
|
}
|
2021-10-24 20:27:20 +00:00
|
|
|
|
}
|
2021-10-24 19:50:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|