Warning, /rolisteam/rolisteam/src/libraries/qml_views/views/ConnectionForm.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQuick.Controls 0003 import QtQuick.Layouts 0004 import Profile 0005 import CustomItems 0006 0007 Item { 0008 id: _root 0009 property alias model: _list.model 0010 property alias currentProfile: _list.currentIndex 0011 0012 Action { 0013 id: _addProfile 0014 icon.name: "add_round" 0015 onTriggered: ProfileController.addProfile() 0016 } 0017 0018 Action { 0019 id: _cloneProfile 0020 icon.name: "cloning" 0021 onTriggered: ProfileController.cloneProfile(_list.currentIndex) 0022 } 0023 0024 0025 Action { 0026 id: _removeProfile 0027 icon.name: "delete" 0028 onTriggered: ProfileController.removeProfile(_list.currentIndex) 0029 } 0030 0031 SplitView { 0032 anchors.fill: parent 0033 Pane { 0034 SplitView.minimumWidth: 200 //list.contentWidth 0035 SplitView.preferredWidth: 200 0036 SplitView.maximumWidth: 400 0037 SplitView.fillHeight: true 0038 leftPadding: 2 0039 rightPadding: 2 0040 background: Rectangle { 0041 color: palette.base 0042 } 0043 GridLayout { 0044 anchors.fill: parent 0045 columns: 5 0046 0047 ListView { 0048 id: _list 0049 Layout.fillHeight: true 0050 Layout.fillWidth: true 0051 Layout.leftMargin: 0 0052 Layout.columnSpan: 5 0053 model: ProfileController.profileModel 0054 currentIndex: ProfileController.currentProfileIndex 0055 onCurrentIndexChanged: ProfileController.currentProfileIndex = _list.currentIndex //onsole.log("current changed: ",_list.currentIndex) 0056 0057 delegate: ItemDelegate { 0058 text: model.name 0059 width: _list.width 0060 highlighted: ProfileController.currentProfileIndex === index 0061 onClicked: _list.currentIndex = index 0062 } 0063 0064 ScrollIndicator.vertical: ScrollIndicator { } 0065 0066 } 0067 ToolButton { 0068 action: _addProfile 0069 icon.width: 32 0070 Layout.columnSpan: 2 0071 icon.color: "transparent" 0072 ToolTip.text: qsTr("New profile") 0073 } 0074 ToolButton { 0075 action: _cloneProfile 0076 ToolTip.text: qsTr("Clone profile") 0077 } 0078 ToolButton { 0079 action: _removeProfile 0080 Layout.columnSpan: 2 0081 icon.color: "transparent" 0082 ToolTip.text: qsTr("Remove profile") 0083 enabled: ProfileController.currentProfileIndex >= 0 0084 } 0085 } 0086 } 0087 0088 ScrollView { 0089 id: _scrollView 0090 SplitView.fillWidth: true 0091 0092 ColumnLayout { 0093 id: _lyt 0094 width: _scrollView.width 0095 height: Math.max(_scrollView.height, _lyt.implicitHeight) 0096 spacing: 0 0097 RowLayout { 0098 Layout.fillWidth: true 0099 Label { 0100 text: qsTr("Profile Name:") 0101 } 0102 RequiredTextField { 0103 Layout.fillWidth: true 0104 validInput: (text && ProfileController.profileName) 0105 text: ProfileController.profileName 0106 onTextChanged: ProfileController.profileName = text 0107 } 0108 } 0109 GroupBox { 0110 Layout.fillWidth: true 0111 Layout.alignment: Qt.AlignTop 0112 title: qsTr("Connection") 0113 GridLayout { 0114 anchors.fill: parent 0115 columns: 2 0116 Label { 0117 text: qsTr("Address:") 0118 } 0119 RequiredTextField { 0120 Layout.fillWidth: true 0121 text: ProfileController.address 0122 validInput: (text && ProfileController.address) 0123 enabled: !ProfileController.isServer 0124 onEditingFinished: ProfileController.address = text 0125 } 0126 Label { 0127 text: qsTr("Port:") 0128 } 0129 TextField { 0130 Layout.fillWidth: true 0131 validator: IntValidator {bottom: 1; top: 65535;} 0132 text: ProfileController.port 0133 onEditingFinished: ProfileController.port = text 0134 } 0135 Label { 0136 text: qsTr("Password:") 0137 } 0138 TextField { 0139 Layout.fillWidth: true 0140 echoMode: TextField.Password 0141 text: ProfileController.password 0142 onEditingFinished: ProfileController.password = text 0143 } 0144 CheckBox { 0145 id: _host 0146 Layout.columnSpan: 2 0147 text: qsTr("Host the game") 0148 checked: ProfileController.isServer 0149 onCheckedChanged: { 0150 ProfileController.isServer = _host.checked 0151 } 0152 } 0153 } 0154 } 0155 GroupBox { 0156 Layout.fillWidth: true 0157 title: qsTr("Player") 0158 Layout.alignment: Qt.AlignTop 0159 PersonEdit { 0160 id: person 0161 anchors.fill: parent 0162 imageData: ProfileController.playerAvatar 0163 characterName: ProfileController.playerName 0164 validInput: (characterName && ProfileController.playerName) 0165 color: ProfileController.playerColor 0166 onColorEdited: (col)=> ProfileController.playerColor = col 0167 onNameEdited: ProfileController.playerName = person.characterName 0168 onClicked: ProfileController.selectPlayerAvatar() 0169 CheckBox { 0170 id: _gameMaster 0171 Layout.columnSpan: 3 0172 text: qsTr("I'm the Game Master") 0173 checked: ProfileController.isGameMaster 0174 onCheckedChanged: { 0175 ProfileController.isGameMaster = _gameMaster.checked 0176 } 0177 } 0178 RowLayout { 0179 Layout.columnSpan: 3 0180 Layout.fillWidth: true 0181 Label { 0182 text: qsTr("Campaign Root:") 0183 opacity: ProfileController.isGameMaster ? 1.0 : 0.4 0184 } 0185 RequiredTextField { 0186 Layout.fillWidth: true 0187 text: ProfileController.campaignPath 0188 validInput: (text && ProfileController.campaignPath) 0189 enabled: ProfileController.isGameMaster 0190 opacity: enabled ? 1.0 : 0.4 0191 } 0192 ToolButton { 0193 icon.name: "folder" 0194 enabled: ProfileController.isGameMaster 0195 opacity: enabled ? 1.0 : 0.4 0196 icon.color: "transparent" 0197 onClicked: ProfileController.selectCampaignPath() 0198 } 0199 } 0200 } 0201 } 0202 GroupBox { 0203 id: _character 0204 Layout.fillHeight: true 0205 label: RowLayout { 0206 Label { 0207 text: qsTr("Characters") 0208 } 0209 ToolButton { 0210 icon.name: "add" 0211 icon.color: "transparent" 0212 onClicked: ProfileController.addCharacter() 0213 } 0214 } 0215 Layout.alignment: Qt.AlignTop 0216 Layout.fillWidth: true 0217 Layout.preferredHeight: _characterList.height + _buttonBar.height + padding + padding 0218 visible: !ProfileController.isGameMaster 0219 0220 ListView { 0221 id: _characterList 0222 width: _character.width 0223 height: contentHeight 0224 interactive: false 0225 0226 model: ProfileController.characterModel 0227 delegate: ItemDelegate { 0228 width: _characterList.width - _character.padding - _character.padding 0229 height: _itemLyt.height 0230 0231 PersonEdit { 0232 id: _itemLyt 0233 imageData: model.avatarData 0234 characterName: model.name 0235 width: parent.width 0236 color: model.color 0237 property bool editAvatar: false 0238 validInput: model.name && isSquare 0239 onClicked:{ 0240 _itemLyt.editAvatar = true 0241 ProfileController.selectCharacterAvatar(model.index) 0242 } 0243 onNameEdited: ProfileController.editCharacterName(model.index,_itemLyt.characterName) 0244 onColorEdited: (color)=>ProfileController.editCharacterColor(model.index,color) 0245 onImageDataChanged: { 0246 if(_itemLyt.editAvatar){ 0247 ProfileController.editCharacterAvatar(model.index, _itemLyt.imageData) 0248 _itemLyt.editAvatar = false 0249 } 0250 } 0251 line: [ 0252 ToolButton { 0253 icon.name: "remove" 0254 icon.color: "transparent" 0255 onClicked: ProfileController.removeCharacter(model.index) 0256 visible: index > 0 0257 } 0258 ] 0259 } 0260 } 0261 0262 } 0263 } 0264 Label { 0265 id: errorLbl 0266 text: ProfileController.errorMsg 0267 visible: ProfileController.errorMsg 0268 background: Rectangle { 0269 color: "red" 0270 } 0271 0272 } 0273 Label { 0274 id: infoLbl 0275 text: ProfileController.infoMsg 0276 visible: ProfileController.infoMsg 0277 background: Rectangle { 0278 color: "green" 0279 } 0280 } 0281 Item { 0282 Layout.alignment: Qt.AlignTop 0283 Layout.fillWidth: true 0284 Layout.fillHeight: true 0285 visible: ProfileController.isGameMaster 0286 } 0287 RowLayout { 0288 id: _buttonBar 0289 //Layout.alignment: Qt.AlignRight || Qt.AlignBottom 0290 Layout.fillWidth: true 0291 Button { 0292 id: _saveProfiles 0293 Layout.alignment: Qt.AlignLeft 0294 text: qsTr("Save profiles") 0295 onClicked: ProfileController.saveProfileModels() 0296 enabled: true 0297 background: Rectangle { 0298 color: _saveProfiles.down ? "darkgray" : "gray" 0299 } 0300 } 0301 0302 Item { 0303 Layout.fillWidth: true 0304 } 0305 0306 Button { 0307 id: _connectBtn 0308 Layout.alignment: Qt.AlignRight 0309 text: qsTr("Connect") 0310 focus: true 0311 enabled: ProfileController.canConnect 0312 onClicked: ProfileController.startConnection() //startNetworkConnection() 0313 opacity: enabled ? 1.0 : 0.4 0314 background: Rectangle { 0315 color: _connectBtn.down ? "darkgreen" : _connectBtn.enabled ? "green" : "darkgray" 0316 } 0317 } 0318 Button { 0319 id: _cancelBtn 0320 Layout.alignment: Qt.AlignRight 0321 text: qsTr("Cancel") 0322 onClicked: ProfileController.reject() 0323 background: Rectangle { 0324 color: _cancelBtn.down ? "darkgray" : "gray" 0325 } 0326 } 0327 } 0328 } 0329 } 0330 0331 } 0332 0333 }