mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-09 07:59:48 +00:00
added (no resolved ) login view
This commit is contained in:
parent
1b379cc553
commit
0a800b4454
SnakeClient/SnakeApp
@ -13,6 +13,8 @@ Popup {
|
||||
transformOrigin: Item.Center
|
||||
|
||||
property bool autoClose: true
|
||||
property bool clickClose: true
|
||||
|
||||
property int closeInterval: 15000;
|
||||
property int margin : 0
|
||||
|
||||
@ -60,7 +62,7 @@ Popup {
|
||||
opacity = 0;
|
||||
}
|
||||
|
||||
closePolicy: (autoClose)? Popup.NoAutoClose: Popup.CloseOnReleaseOutside
|
||||
closePolicy: (!clickClose || autoClose)? Popup.NoAutoClose: Popup.CloseOnReleaseOutside
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ Rectangle {
|
||||
|
||||
color: (model) ? model.color : "#11ff32";
|
||||
|
||||
width: (model) ? model.w * mainWindow.point: 0;
|
||||
height: (model) ? model.h * mainWindow.point: 0;
|
||||
width: (model) ? model.w * metrix.gamePt: 0;
|
||||
height: (model) ? model.h * metrix.gamePt: 0;
|
||||
|
||||
x: (model) ? model.x * mainWindow.point - devX: 0;
|
||||
y: (model) ? model.y * mainWindow.point - devY: 0;
|
||||
x: (model) ? model.x * metrix.gamePt - devX: 0;
|
||||
y: (model) ? model.y * metrix.gamePt - devY: 0;
|
||||
|
||||
radius: (model) ? model.radius * mainWindow.point : 0;
|
||||
radius: (model) ? model.radius * metrix.gamePt : 0;
|
||||
|
||||
transform: Rotation {
|
||||
origin.x: devX;
|
||||
|
@ -6,9 +6,88 @@ import QtGraphicalEffects 1.12
|
||||
|
||||
Item {
|
||||
id: element
|
||||
|
||||
// -1 general state (Without Data)
|
||||
// -2 wait for ansever
|
||||
property int loginStatus : -1
|
||||
readonly property var resultLoginEnum: [
|
||||
qsTr("Success"), // 0
|
||||
qsTr("Authorization fail"), // 1
|
||||
qsTr("Client is offline "), // 2
|
||||
]
|
||||
|
||||
readonly property int currentView: tabBar.currentIndex
|
||||
readonly property var resultEnum: [
|
||||
qsTr("Success"), // 0
|
||||
qsTr("Password must be at least 8 characters"), // 1
|
||||
qsTr("Name must be at least 1 characters"), // 2
|
||||
qsTr("Passwords must match"), // 3
|
||||
|
||||
qsTr("The letter must match the pattern 'X@xxxx.xxx'") // 4
|
||||
|
||||
]
|
||||
|
||||
signal sigNewUser(var gmail, var userName, var password);
|
||||
signal sigLogin(var gmail, var password);
|
||||
|
||||
|
||||
function _checkLogin() {
|
||||
const pass = loginPass.text;
|
||||
const email = loginEmail.text;
|
||||
|
||||
if (pass.length < 8) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (email.search(/[a-z\-A-Z0-9_]+@[a-z\-A-Z0-9_]+\.[a-z\-A-Z0-9_]+/) < 0) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
function _checkRegister () {
|
||||
const pass = registerPassword.text;
|
||||
const pass2 = registerPassword2.text;
|
||||
|
||||
const email = registerEmail.text;
|
||||
const login = registerName.text;
|
||||
|
||||
if (pass.length < 8) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (login.length < 1) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (pass !== pass2) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (email.search(/[a-z\-A-Z0-9_]+@[a-z\-A-Z0-9_]+\.[a-z\-A-Z0-9_]+/) < 0) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function checkData(isregisterForm) {
|
||||
if (isregisterForm) {
|
||||
return _checkRegister();
|
||||
}
|
||||
|
||||
return _checkLogin();
|
||||
}
|
||||
|
||||
function waitforAnsver() {
|
||||
loginStatus = -2;
|
||||
}
|
||||
|
||||
SwipeView {
|
||||
id: swipeView
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottom: bottons.top
|
||||
anchors.top: tabBar.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
@ -24,14 +103,22 @@ Item {
|
||||
id: columnLayout
|
||||
anchors.fill: parent
|
||||
|
||||
Label {
|
||||
text: qsTr("Email")
|
||||
}
|
||||
TextField {
|
||||
placeholderText: "Write Your Email"
|
||||
id: loginEmail
|
||||
placeholderText: "Enter Your Email"
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Passsword")
|
||||
}
|
||||
TextField {
|
||||
placeholderText: qsTr("Write Your passsword")
|
||||
id: loginPass
|
||||
placeholderText: qsTr("Enter Your passsword")
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
||||
@ -39,13 +126,6 @@ Item {
|
||||
cursorVisible: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("sign in")
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -57,25 +137,39 @@ Item {
|
||||
anchors.fill: parent
|
||||
|
||||
|
||||
Label {
|
||||
text: qsTr("Email")
|
||||
}
|
||||
TextField {
|
||||
placeholderText: "Write Your Email"
|
||||
id: registerEmail;
|
||||
placeholderText: qsTr("Enter Your Email")
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("User Name")
|
||||
}
|
||||
TextField {
|
||||
id: registerName;
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
|
||||
placeholderText: qsTr("Write Your Name")
|
||||
placeholderText: qsTr("Enter Your Name")
|
||||
echoMode: TextInput.NoEcho
|
||||
cursorVisible: true
|
||||
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Password")
|
||||
}
|
||||
TextField {
|
||||
placeholderText: qsTr("Write Your passsword")
|
||||
id: registerPassword;
|
||||
|
||||
placeholderText: qsTr("Enter Your passsword")
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
@ -83,10 +177,18 @@ Item {
|
||||
cursorVisible: true
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("sign Up")
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
||||
Label {
|
||||
text: qsTr("Repeat password")
|
||||
}
|
||||
TextField {
|
||||
id: registerPassword2;
|
||||
|
||||
placeholderText: qsTr("Enter Your passsword again")
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
Layout.fillWidth: true
|
||||
echoMode: TextInput.Password
|
||||
cursorVisible: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,7 +215,87 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id : bottons
|
||||
Button {
|
||||
text: qsTr("Cancel")
|
||||
|
||||
onClicked: {
|
||||
Qt.quit()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Button {
|
||||
text: tabBar.currentItem.text
|
||||
|
||||
onClicked: {
|
||||
|
||||
const messageIndex = checkData(tabBar.currentIndex);
|
||||
if (messageIndex === 0) {
|
||||
|
||||
if (tabBar.currentIndex) {
|
||||
// register request
|
||||
sigNewUser(registerEmail.text, register.);
|
||||
waitforAnsver();
|
||||
} else {
|
||||
//login request
|
||||
sigLogin(loginEmail.text, loginPass.text);
|
||||
waitforAnsver();
|
||||
}
|
||||
} else {
|
||||
errorMessage.text = resultEnum[messageIndex];
|
||||
errorMessage._show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
|
||||
BasePopUp {
|
||||
id: errorMessage;
|
||||
property string text: ""
|
||||
Label {
|
||||
id: sourceText;
|
||||
text: errorMessage.text
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
color: "#ff4500"
|
||||
|
||||
radius: height / 4;
|
||||
}
|
||||
|
||||
height: 2 * metrix.controlPtMaterial;
|
||||
width: 5 * metrix.controlPtMaterial
|
||||
x: 0;
|
||||
y: 0;
|
||||
}
|
||||
|
||||
BasePopUp {
|
||||
id: busy
|
||||
modal: true
|
||||
autoClose: false;
|
||||
clickClose: false;
|
||||
BusyIndicator {
|
||||
running: loginStatus < 0
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
visible: loginStatus < 0;
|
||||
|
||||
height: 2 * metrix.controlPtMaterial
|
||||
width: height
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,6 @@ Item {
|
||||
id: about;
|
||||
width: parent.width / 2
|
||||
height: parent.height / 2;
|
||||
x: parent.width / 2 - width / 2
|
||||
y: parent.height / 2 - height / 2
|
||||
|
||||
source: About {}
|
||||
}
|
||||
@ -111,15 +109,15 @@ Item {
|
||||
PagePopUp {
|
||||
id: loginPopUp
|
||||
source: LoginView {
|
||||
|
||||
id: loginView
|
||||
}
|
||||
|
||||
visible: true;
|
||||
|
||||
width: parent.width / 2
|
||||
height: parent.height / 2;
|
||||
x: parent.width / 2 - width / 2
|
||||
y: parent.height / 2 - height / 2
|
||||
modal: true;
|
||||
autoClose: false
|
||||
clickClose: false
|
||||
width: 10 * metrix.controlPtMaterial
|
||||
height: ((loginView.currentView)? 12 : 7) * metrix.controlPtMaterial;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,11 +4,13 @@ import QtQuick.Controls.Material 2.0
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
Item {
|
||||
property real mm: Screen.pixelDensity
|
||||
property real sm: 10 * mm
|
||||
readonly property int pointCount: 100;
|
||||
readonly property real mm: Screen.pixelDensity
|
||||
readonly property real sm: 10 * mm
|
||||
readonly property real dsm: Math.sqrt(Math.pow(Screen.desktopAvailableWidth, 2) + Math.pow(Screen.desktopAvailableHeight, 2)) / sm
|
||||
property real pt: getfactor(dsm) * sm
|
||||
property real controlPtMaterial: Material.buttonHeight
|
||||
readonly property real pt: getfactor(dsm) * sm
|
||||
readonly property real controlPtMaterial: Material.buttonHeight
|
||||
readonly property real gamePt: (width < height) ? width / pointCount : height / pointCount;
|
||||
|
||||
function getfactor(dsm) {
|
||||
if (dsm < 30) {
|
||||
@ -20,4 +22,6 @@ Item {
|
||||
} else
|
||||
return 4;
|
||||
}
|
||||
|
||||
anchors.fill: parent;
|
||||
}
|
||||
|
@ -29,4 +29,7 @@ BasePopUp {
|
||||
pagePopUp.close();
|
||||
}
|
||||
}
|
||||
|
||||
x: parent.width / 2 - width / 2
|
||||
y: parent.height / 2 - height / 2
|
||||
}
|
||||
|
@ -158,12 +158,12 @@ Item {
|
||||
NotificationForm {
|
||||
z: -1
|
||||
id: notification;
|
||||
margin: mainWindow.point;
|
||||
margin: metrix.gamePt;
|
||||
|
||||
x: parent.width - width - margin;
|
||||
y: margin;
|
||||
|
||||
width: 40 * mainWindow.point;
|
||||
width: 40 * metrix.gamePt;
|
||||
height: width * 0.5
|
||||
|
||||
}
|
||||
@ -174,10 +174,10 @@ Item {
|
||||
text: "<<"
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: point
|
||||
anchors.leftMargin: metrix.gamePt
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: point
|
||||
anchors.topMargin: metrix.gamePt
|
||||
z: 1
|
||||
|
||||
onClicked: {
|
||||
@ -193,10 +193,10 @@ Item {
|
||||
text: (isPause)? "▶" :"||"
|
||||
|
||||
anchors.left: returnToMenu.right
|
||||
anchors.leftMargin: point
|
||||
anchors.leftMargin: metrix.gamePt
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: point
|
||||
anchors.topMargin: metrix.gamePt
|
||||
z: returnToMenu.z
|
||||
|
||||
onClicked: {
|
||||
@ -221,14 +221,14 @@ Item {
|
||||
text: qsTr("lvl long: ") + ((model)? model.long_: "0")
|
||||
}
|
||||
|
||||
width: 35 * point;
|
||||
width: 35 * metrix.gamePt;
|
||||
height: pause.height;
|
||||
|
||||
anchors.left: pause.right
|
||||
anchors.leftMargin: point
|
||||
anchors.leftMargin: metrix.gamePt
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: point
|
||||
anchors.topMargin: metrix.gamePt
|
||||
z: returnToMenu.z
|
||||
|
||||
visible: !showMenu
|
||||
@ -247,14 +247,14 @@ Item {
|
||||
text: qsTr("general long: ") + ((model)? model.generalLong: "0")
|
||||
}
|
||||
|
||||
width: 35 * point;
|
||||
width: 35 * metrix.gamePt;
|
||||
height: long_.height;
|
||||
|
||||
anchors.left: long_.right
|
||||
anchors.leftMargin: point
|
||||
anchors.leftMargin: metrix.gamePt
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: point
|
||||
anchors.topMargin: metrix.gamePt
|
||||
z: returnToMenu.z
|
||||
|
||||
visible: !showMenu
|
||||
|
@ -13,9 +13,7 @@ ApplicationWindow {
|
||||
mainWindow.showFullScreen();
|
||||
}
|
||||
|
||||
readonly property int pointCount: 100;
|
||||
|
||||
property real point: (width < height) ? width/pointCount : height/pointCount;
|
||||
Metrix {id: metrix}
|
||||
|
||||
Scene {
|
||||
|
@ -4,4 +4,4 @@ Style=Material
|
||||
[Material]
|
||||
Accent=Teal
|
||||
Primary=BlueGrey
|
||||
Theme=Dark
|
||||
Theme=Light
|
||||
|
Loading…
x
Reference in New Issue
Block a user