|
| 1 | +// -*- coding: utf-8; -*- |
| 2 | +// |
| 3 | +// Copyright (C) 2015 - 2025 Lionel Ott |
| 4 | +// |
| 5 | +// This program is free software: you can redistribute it and/or modify |
| 6 | +// it under the terms of the GNU General Public License as published by |
| 7 | +// the Free Software Foundation, either version 3 of the License, or |
| 8 | +// (at your option) any later version. |
| 9 | +// |
| 10 | +// This program is distributed in the hope that it will be useful, |
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +// GNU General Public License for more details. |
| 14 | +// |
| 15 | +// You should have received a copy of the GNU General Public License |
| 16 | +// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | + |
| 19 | +import QtQuick |
| 20 | +import QtQuick.Controls |
| 21 | +import QtQuick.Layouts |
| 22 | +import QtQuick.Window |
| 23 | + |
| 24 | +import QtQuick.Controls.Universal |
| 25 | + |
| 26 | +import Gremlin.Device |
| 27 | +import Gremlin.Profile |
| 28 | +import Gremlin.UI |
| 29 | + |
| 30 | + |
| 31 | +Window { |
| 32 | + id: _root |
| 33 | + |
| 34 | + minimumWidth: 900 |
| 35 | + minimumHeight: 500 |
| 36 | + |
| 37 | + title: "Auto Mapper" |
| 38 | + |
| 39 | + DeviceListModel { |
| 40 | + id: physicalDevices |
| 41 | + deviceType: "physical" |
| 42 | + } |
| 43 | + |
| 44 | + DeviceListModel { |
| 45 | + id: virtualDevices |
| 46 | + deviceType: "virtual" |
| 47 | + } |
| 48 | + |
| 49 | + property AutoMapper autoMapper: backend.getAutoMapper() |
| 50 | + |
| 51 | + // Properties to track the selected devices |
| 52 | + property var selectedPhysicalDevices: ({}) |
| 53 | + property var selectedVJoyDevices: ({}) |
| 54 | + property bool overwriteNonEmpty: false |
| 55 | + property bool repeatVJoy: false |
| 56 | + |
| 57 | + // Main layout container |
| 58 | + Rectangle { |
| 59 | + anchors.fill: parent |
| 60 | + anchors.margins: 10 |
| 61 | + |
| 62 | + Column { |
| 63 | + id: mainColumn |
| 64 | + anchors.fill: parent |
| 65 | + spacing: 10 |
| 66 | + |
| 67 | + // Main content area |
| 68 | + Row { |
| 69 | + id: contentRow |
| 70 | + width: parent.width |
| 71 | + height: parent.height - 60 // Leave space for the button |
| 72 | + spacing: 20 |
| 73 | + |
| 74 | + // Left side - Physical devices |
| 75 | + Column { |
| 76 | + id: physicalColumn |
| 77 | + width: parent.width * 0.45 |
| 78 | + height: parent.height |
| 79 | + spacing: 5 |
| 80 | + |
| 81 | + // Overwrite non-empty physical inputs toggle |
| 82 | + CheckBox { |
| 83 | + id: overwriteCheckbox |
| 84 | + width: parent.width |
| 85 | + text: qsTr("Overwrite non-empty physical inputs") |
| 86 | + checked: overwriteNonEmpty |
| 87 | + onCheckedChanged: overwriteNonEmpty = checked |
| 88 | + } |
| 89 | + |
| 90 | + // Physical devices list |
| 91 | + GroupBox { |
| 92 | + width: parent.width |
| 93 | + height: parent.height - overwriteCheckbox.height - 5 |
| 94 | + title: qsTr("Physical Devices") |
| 95 | + |
| 96 | + ScrollView { |
| 97 | + id: physicalScroll |
| 98 | + anchors.fill: parent |
| 99 | + clip: true |
| 100 | + |
| 101 | + Column { |
| 102 | + width: physicalScroll.width - 20 // Account for padding |
| 103 | + spacing: 5 |
| 104 | + padding: 5 |
| 105 | + |
| 106 | + Repeater { |
| 107 | + model: physicalDevices |
| 108 | + delegate: CheckBox { |
| 109 | + width: parent.width - 10 |
| 110 | + text: model.name |
| 111 | + checked: false |
| 112 | + onCheckedChanged: { |
| 113 | + selectedPhysicalDevices[model.guid] = checked; |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + // Right side - vJoy devices |
| 123 | + Column { |
| 124 | + id: vjoyColumn |
| 125 | + width: parent.width * 0.45 |
| 126 | + height: parent.height |
| 127 | + spacing: 5 |
| 128 | + |
| 129 | + // Repeat vJoy devices toggle |
| 130 | + CheckBox { |
| 131 | + id: repeatVJoyCheckbox |
| 132 | + width: parent.width |
| 133 | + text: qsTr("Repeat vJoy devices") |
| 134 | + checked: repeatVJoy |
| 135 | + onCheckedChanged: repeatVJoy = checked |
| 136 | + } |
| 137 | + |
| 138 | + // vJoy devices list |
| 139 | + GroupBox { |
| 140 | + width: parent.width |
| 141 | + height: parent.height - repeatVJoyCheckbox.height - 5 |
| 142 | + title: qsTr("vJoy Devices") |
| 143 | + |
| 144 | + ScrollView { |
| 145 | + id: vjoyScroll |
| 146 | + anchors.fill: parent |
| 147 | + clip: true |
| 148 | + |
| 149 | + Column { |
| 150 | + width: vjoyScroll.width - 20 // Account for padding |
| 151 | + spacing: 5 |
| 152 | + padding: 5 |
| 153 | + |
| 154 | + Repeater { |
| 155 | + model: virtualDevices |
| 156 | + delegate: CheckBox { |
| 157 | + width: parent.width - 10 |
| 158 | + text: model.name |
| 159 | + checked: false |
| 160 | + onCheckedChanged: { |
| 161 | + selectedVJoyDevices[model.vjoy_id] = checked; |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | + } |
| 167 | + } |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + // Create Mappings button |
| 172 | + Button { |
| 173 | + id: createButton |
| 174 | + text: qsTr("Create 1:1 vJoy mappings") |
| 175 | + onClicked: { |
| 176 | + autoMapper.create_mappings( |
| 177 | + selectedPhysicalDevices, selectedVJoyDevices, |
| 178 | + overwriteNonEmpty, repeatVJoy); |
| 179 | + } |
| 180 | + anchors.horizontalCenter: parent.horizontalCenter |
| 181 | + width: Math.min(300, parent.width * 0.4) |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | +} |
0 commit comments