import QtQuick import QtQuick.Controls Item { id: root scale: 2 Frame { id: join_server anchors.centerIn: parent background: Rectangle { color: "#88888888" radius: 2 } Column { spacing: 8 ComboBox { id: server_addr model: [] editable: true onEditTextChanged: { if (model.indexOf(editText) === -1) { passwordEdit.text = ""; } else { let data = config.savedPassword[editText]; screenNameEdit.text = data.username; passwordEdit.text = data.shorten_password; } } } TextField { id: screenNameEdit text: "player" onTextChanged: { passwordEdit.text = ""; let data = config.savedPassword[server_addr.editText]; if (data) { if (text === data.username) { passwordEdit.text = data.shorten_password; } } } } /*TextField { id: avatarEdit text: "liubei" }*/ TextField { id: passwordEdit text: "" echoMode: TextInput.Password passwordCharacter: "*" } Button { text: "Join Server" enabled: passwordEdit.text !== "" onClicked: { config.serverAddr = server_addr.editText; config.screenName = screenNameEdit.text; config.password = passwordEdit.text; mainWindow.busy = true; Backend.joinServer(server_addr.editText); } } Button { text: "Console start" enabled: passwordEdit.text !== "" onClicked: { config.serverAddr = "127.0.0.1"; config.screenName = screenNameEdit.text; config.password = passwordEdit.text; mainWindow.busy = true; Backend.startServer(9527); Backend.joinServer("127.0.0.1"); } } } } Component.onCompleted: { config.loadConf(); server_addr.model = Object.keys(config.savedPassword); server_addr.onModelChanged(); server_addr.currentIndex = server_addr.model.indexOf(config.lastLoginServer); let data = config.savedPassword[config.lastLoginServer]; screenNameEdit.text = data.username; passwordEdit.text = data.shorten_password; } }