some tinkering
This commit is contained in:
parent
c966d95058
commit
ed1ed9fb49
10 changed files with 230 additions and 229 deletions
|
@ -1,5 +1,5 @@
|
|||
qt_add_qml_module(magpieQml
|
||||
URI "qml"
|
||||
URI qml
|
||||
VERSION 1.0
|
||||
STATIC
|
||||
RESOURCE_PREFIX /
|
||||
|
@ -11,3 +11,5 @@ qt_add_qml_module(magpieQml
|
|||
)
|
||||
|
||||
target_link_libraries(magpie PRIVATE magpieQml)
|
||||
|
||||
add_subdirectory(Forms)
|
||||
|
|
12
qml/Forms/CMakeLists.txt
Normal file
12
qml/Forms/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
qt_add_qml_module(magpieForms
|
||||
URI "qml.Forms"
|
||||
VERSION 1.0
|
||||
STATIC
|
||||
RESOURCE_PREFIX /
|
||||
NO_PLUGIN
|
||||
QML_FILES
|
||||
Login.qml
|
||||
Register.qml
|
||||
)
|
||||
|
||||
target_link_libraries(magpie PRIVATE magpieForms)
|
74
qml/Forms/Login.qml
Normal file
74
qml/Forms/Login.qml
Normal file
|
@ -0,0 +1,74 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
import magpie.API
|
||||
|
||||
Column {
|
||||
signal register()
|
||||
|
||||
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: register()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
77
qml/Forms/Register.qml
Normal file
77
qml/Forms/Register.qml
Normal file
|
@ -0,0 +1,77 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
import magpie.API
|
||||
|
||||
Column {
|
||||
signal login()
|
||||
|
||||
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: login()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,14 +2,12 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import API
|
||||
import magpie.API
|
||||
|
||||
Page {
|
||||
property string address
|
||||
property bool valid: false
|
||||
|
||||
signal back()
|
||||
signal success(address: string)
|
||||
|
||||
title: qsTr("Chosing a server")
|
||||
|
||||
|
@ -59,11 +57,7 @@ Page {
|
|||
width: column.width + 60
|
||||
height: column.height + 60
|
||||
closePolicy: Popup.CloseOnEscape
|
||||
onClosed: function () {
|
||||
modal.inProgress = false;
|
||||
if (valid)
|
||||
success(address);
|
||||
}
|
||||
onClosed: modal.inProgress = false
|
||||
|
||||
Column {
|
||||
id: column
|
||||
|
@ -113,10 +107,8 @@ Page {
|
|||
}
|
||||
|
||||
function check () {
|
||||
if (valid) {
|
||||
success(address);
|
||||
if (modal.inProgress)
|
||||
return;
|
||||
}
|
||||
|
||||
modal.inProgress = true;
|
||||
status.text = qsTr("Checking") + " " + address + "...";
|
||||
|
@ -132,11 +124,8 @@ Page {
|
|||
else
|
||||
status.text = qsTr("Success");
|
||||
|
||||
valid = !!success;
|
||||
if (valid) {
|
||||
address = input.text;
|
||||
if (!!success)
|
||||
modal.close()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
148
qml/Welcome.qml
148
qml/Welcome.qml
|
@ -2,7 +2,8 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import API
|
||||
import magpie.API
|
||||
import "Forms" as Forms
|
||||
|
||||
Page {
|
||||
signal pickServer(address: string)
|
||||
|
@ -53,145 +54,16 @@ Page {
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Forms.Login {
|
||||
id: login
|
||||
visible: !forms.registering
|
||||
onRegister: 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Forms.Register {
|
||||
id: register
|
||||
visible: forms.registering
|
||||
onLogin: forms.registering = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
28
qml/main.qml
28
qml/main.qml
|
@ -4,10 +4,11 @@ import QtQuick.Controls
|
|||
import QtQuick.Layouts
|
||||
import QtCore
|
||||
|
||||
import API
|
||||
import magpie.API
|
||||
|
||||
ApplicationWindow {
|
||||
property int counter: 0
|
||||
property bool pickingServer: false
|
||||
|
||||
id: window
|
||||
width: 640
|
||||
|
@ -24,23 +25,32 @@ ApplicationWindow {
|
|||
id: stack
|
||||
initialItem: welcome
|
||||
anchors.fill: parent
|
||||
StackView.onRemoved: pickingServer = false
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: API
|
||||
function onAddressChanged (url) {
|
||||
if (pickingServer && url.toString().length > 0)
|
||||
stack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
Welcome {
|
||||
id: welcome
|
||||
onPickServer: function (address) {
|
||||
const pick = pickComponent.createObject(stack);
|
||||
pick.address = address;
|
||||
stack.push(pick)
|
||||
stack.push(pick);
|
||||
pickingServer = true;
|
||||
}
|
||||
}
|
||||
|
||||
ServerPick {
|
||||
visible: false
|
||||
id: pick
|
||||
onBack: stack.pop()
|
||||
onSuccess: function (address) {
|
||||
API.address = address
|
||||
stack.pop();
|
||||
Component {
|
||||
id: pickComponent
|
||||
ServerPick {
|
||||
StackView.onRemoved: destroy()
|
||||
onBack: stack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue