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                     ToolTip.text: qsTr("New profile")
0072                 }
0073                 ToolButton {
0074                     action: _cloneProfile
0075                     ToolTip.text: qsTr("Clone profile")
0076                 }
0077                 ToolButton {
0078                     action: _removeProfile
0079                     Layout.columnSpan: 2
0080                     ToolTip.text: qsTr("Remove profile")
0081                     enabled: ProfileController.currentProfileIndex >= 0
0082                 }
0083             }
0084         }
0085 
0086         ScrollView {
0087             id: _scrollView
0088             SplitView.fillWidth: true
0089 
0090             ColumnLayout {
0091                 id: _lyt
0092                 width: _scrollView.width
0093                 height: Math.max(_scrollView.height, _lyt.implicitHeight)
0094                 spacing: 0
0095                 RowLayout {
0096                     Layout.fillWidth: true
0097                     Label {
0098                         text: qsTr("Profile Name:")
0099                     }
0100                     RequiredTextField {
0101                         Layout.fillWidth: true
0102                         validInput: (text && ProfileController.profileName)
0103                         text: ProfileController.profileName
0104                         onTextChanged: ProfileController.profileName = text
0105                     }
0106                 }
0107                 GroupBox {
0108                     Layout.fillWidth: true
0109                     Layout.alignment: Qt.AlignTop
0110                     title: qsTr("Connection")
0111                     GridLayout {
0112                         anchors.fill: parent
0113                         columns: 2
0114                         Label {
0115                             text: qsTr("Address:")
0116                         }
0117                         RequiredTextField {
0118                             Layout.fillWidth: true
0119                             text: ProfileController.address
0120                             validInput: (text && ProfileController.address)
0121                             enabled: !ProfileController.isServer
0122                         }
0123                         Label {
0124                             text: qsTr("Port:")
0125                         }
0126                         TextField {
0127                             Layout.fillWidth: true
0128                             validator: IntValidator {bottom: 1; top: 65535;}
0129                             text: ProfileController.port
0130                             onEditingFinished: ProfileController.port = text
0131                         }
0132                         Label {
0133                             text: qsTr("Password:")
0134                         }
0135                         TextField {
0136                             Layout.fillWidth: true
0137                             echoMode: TextField.Password
0138                             text: ProfileController.password
0139                             onEditingFinished: ProfileController.password = text
0140                         }
0141                         CheckBox {
0142                             id: _host
0143                             Layout.columnSpan: 2
0144                             text: qsTr("Host the game")
0145                             checked: ProfileController.isServer
0146                             onCheckedChanged: {
0147                                 ProfileController.isServer =  _host.checked
0148                             }
0149                         }
0150                     }
0151                 }
0152                 GroupBox {
0153                     Layout.fillWidth: true
0154                     title: qsTr("Player")
0155                     Layout.alignment: Qt.AlignTop
0156                     PersonEdit {
0157                         id: person
0158                         anchors.fill: parent
0159                         imageData: ProfileController.playerAvatar
0160                         characterName: ProfileController.playerName
0161                         validInput: (characterName && ProfileController.playerName)
0162                         color: ProfileController.playerColor
0163                         onColorEdited: (col)=> ProfileController.playerColor = col
0164                         onNameEdited: ProfileController.playerName = person.characterName
0165                         onClicked: ProfileController.selectPlayerAvatar()
0166                         CheckBox {
0167                             id: _gameMaster
0168                             Layout.columnSpan: 3
0169                             text: qsTr("I'm the Game Master")
0170                             checked: ProfileController.isGameMaster
0171                             onCheckedChanged: {
0172                                 ProfileController.isGameMaster =  _gameMaster.checked
0173                             }
0174                         }
0175                         RowLayout {
0176                             Layout.columnSpan: 3
0177                             Layout.fillWidth: true
0178                             Label {
0179                                 text: qsTr("Campaign Root:")
0180                                 opacity: ProfileController.isGameMaster ? 1.0 : 0.4
0181                             }
0182                             RequiredTextField {
0183                                 Layout.fillWidth: true
0184                                 text: ProfileController.campaignPath
0185                                 validInput: (text && ProfileController.campaignPath)
0186                                 enabled: ProfileController.isGameMaster
0187                                 opacity: enabled ? 1.0 : 0.4
0188                             }
0189                             ToolButton {
0190                                 icon.name: "folder"
0191                                 enabled: ProfileController.isGameMaster
0192                                 opacity: enabled ? 1.0 : 0.4
0193                                 onClicked: ProfileController.selectCampaignPath()
0194                             }
0195                         }
0196                     }
0197                 }
0198                 GroupBox {
0199                     id: _character
0200                     label: RowLayout {
0201                         Label {
0202                             text: qsTr("Characters")
0203                         }
0204                         ToolButton {
0205                             icon.name: "add"
0206                             onClicked: ProfileController.addCharacter()
0207                         }
0208                     }
0209                     Layout.alignment: Qt.AlignTop
0210                     Layout.fillWidth: true
0211                     Layout.preferredHeight: _characterList.height + _buttonBar.height + padding + padding
0212                     visible: !ProfileController.isGameMaster
0213 
0214                     ListView {
0215                         id: _characterList
0216                         width: _character.width
0217                         height: contentHeight
0218                         interactive: false
0219                         model: ProfileController.characterModel
0220                         delegate: ItemDelegate {
0221                             width: _characterList.width - _character.padding - _character.padding
0222                             height: _itemLyt.height
0223 
0224                             PersonEdit {
0225                                 id: _itemLyt
0226                                 imageData: model.avatarData
0227                                 characterName: model.name
0228                                 width: parent.width
0229                                 color: model.color
0230                                 validInput: model.name && isSquare
0231                                 onClicked: ProfileController.selectCharacterAvatar(model.index)
0232                                 onNameEdited: ProfileController.editCharacterName(model.index,_itemLyt.characterName)
0233                                 onColorEdited: (color)=>ProfileController.editCharacterColor(model.index,color)
0234                                 onImageDataChanged: ProfileController.editCharacterAvatar(model.index, _itemLyt.imageData)
0235                                 line: [
0236                                     ToolButton {
0237                                         icon.name: "remove"
0238                                         onClicked: ProfileController.removeCharacter(model.index)
0239                                         visible: index > 0
0240                                     }
0241                                 ]
0242                             }
0243                         }
0244 
0245                     }
0246                 }
0247                 Label {
0248                     id: errorLbl
0249                     text: ProfileController.errorMsg
0250                     visible: ProfileController.errorMsg
0251                     background: Rectangle {
0252                         color: "red"
0253                     }
0254 
0255                 }
0256                 Label {
0257                     id: infoLbl
0258                     text: ProfileController.infoMsg
0259                     visible: ProfileController.infoMsg
0260                     background: Rectangle {
0261                         color: "green"
0262                     }
0263                 }
0264                 Item {
0265                     Layout.alignment: Qt.AlignTop
0266                     Layout.fillWidth: true
0267                     Layout.fillHeight: true
0268                     visible: ProfileController.isGameMaster
0269                 }
0270                 RowLayout {
0271                     id: _buttonBar
0272                     Layout.alignment: Qt.AlignRight || Qt.AlignBottom
0273                     Button {
0274                         id: _connectBtn
0275                         Layout.alignment: Qt.AlignRight
0276                         text: qsTr("Connect")
0277                         focus: true
0278                         enabled: ProfileController.canConnect
0279                         onClicked: ProfileController.startConnection() //startNetworkConnection()
0280                         opacity: enabled ? 1.0 : 0.4
0281                         background: Rectangle {
0282                             color: _connectBtn.down ? "darkgreen" : _connectBtn.enabled ? "green" : "darkgray"
0283                         }
0284                     }
0285                     Button {
0286                         id: _cancelBtn
0287                         Layout.alignment: Qt.AlignRight
0288                         text: qsTr("Cancel")
0289                         onClicked: ProfileController.reject()
0290                         background: Rectangle {
0291                             color: _cancelBtn.down ? "darkgray" : "gray"
0292                         }
0293                     }
0294                 }
0295             }
0296         }
0297 
0298     }
0299 
0300 }