some experiments about sending form
This commit is contained in:
parent
be3d8b0e77
commit
c966d95058
7 changed files with 305 additions and 21 deletions
|
@ -2,6 +2,8 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import API
|
||||
|
||||
Page {
|
||||
property string address
|
||||
property bool valid: false
|
||||
|
|
158
qml/Welcome.qml
158
qml/Welcome.qml
|
@ -2,9 +2,9 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
Page {
|
||||
property string serverAddress
|
||||
import API
|
||||
|
||||
Page {
|
||||
signal pickServer(address: string)
|
||||
|
||||
title: qsTr("Welcome")
|
||||
|
@ -32,7 +32,7 @@ Page {
|
|||
}
|
||||
Label {
|
||||
horizontalAlignment: Label.AlignLeft
|
||||
text: serverAddress || qsTr("choose")
|
||||
text: API.state === API.NoServer ? qsTr("choose") : API.address
|
||||
font {
|
||||
italic: true
|
||||
underline: true
|
||||
|
@ -40,7 +40,157 @@ Page {
|
|||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: pickServer(serverAddress)
|
||||
onClicked: pickServer(API.address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: forms
|
||||
property bool registering: false
|
||||
|
||||
visible: API.state === API.NotAuthenticated
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
topPadding: 10
|
||||
|
||||
Column {
|
||||
visible: forms.registering === false
|
||||
spacing: 10
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Please, log in to your account")
|
||||
font {
|
||||
pixelSize: 14
|
||||
}
|
||||
}
|
||||
|
||||
Grid {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
columns: 2
|
||||
columnSpacing: 10
|
||||
rowSpacing: 5
|
||||
verticalItemAlignment: Grid.AlignVCenter
|
||||
horizontalItemAlignment: Grid.AlignRight
|
||||
|
||||
Label {
|
||||
text: qsTr("Login") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: login
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Password") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: password
|
||||
echoMode: TextField.Password
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Login")
|
||||
onClicked: function () {
|
||||
console.log("Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 5
|
||||
topPadding: 10
|
||||
|
||||
Label {
|
||||
text: qsTr("Don't have account?")
|
||||
}
|
||||
Label {
|
||||
text: qsTr("Sign up") + "!"
|
||||
font {
|
||||
italic: true
|
||||
underline: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: forms.registering = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
visible: forms.registering === true
|
||||
spacing: 10
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Please, chose login and password")
|
||||
font {
|
||||
pixelSize: 14
|
||||
}
|
||||
}
|
||||
|
||||
Grid {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
columns: 2
|
||||
columnSpacing: 10
|
||||
rowSpacing: 5
|
||||
verticalItemAlignment: Grid.AlignVCenter
|
||||
horizontalItemAlignment: Grid.AlignRight
|
||||
|
||||
Label {
|
||||
text: qsTr("Login") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: newLogin
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Password") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: newPassword
|
||||
echoMode: TextField.Password
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Register")
|
||||
onClicked: API.sendRegister(newLogin.text, newPassword.text, function (err, result) {
|
||||
if (err)
|
||||
console.error("err")
|
||||
|
||||
console.log(result);
|
||||
})
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 5
|
||||
topPadding: 10
|
||||
|
||||
Label {
|
||||
text: qsTr("Already have an account?")
|
||||
}
|
||||
Label {
|
||||
text: qsTr("Log in") + "!"
|
||||
font {
|
||||
italic: true
|
||||
underline: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: forms.registering = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
qml/main.qml
10
qml/main.qml
|
@ -4,6 +4,7 @@ import QtQuick.Controls
|
|||
import QtQuick.Layouts
|
||||
import QtCore
|
||||
|
||||
import API
|
||||
|
||||
ApplicationWindow {
|
||||
property int counter: 0
|
||||
|
@ -27,25 +28,18 @@ ApplicationWindow {
|
|||
|
||||
Welcome {
|
||||
id: welcome
|
||||
serverAddress: settings.serverAddress
|
||||
onPickServer: function (address) {
|
||||
pick.address = address;
|
||||
stack.push(pick)
|
||||
}
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
|
||||
property string serverAddress
|
||||
}
|
||||
|
||||
ServerPick {
|
||||
visible: false
|
||||
id: pick
|
||||
onBack: stack.pop()
|
||||
onSuccess: function (address) {
|
||||
settings.serverAddress = address;
|
||||
API.address = address
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue