Browse Source

implemented login form

Cyamond 5 years ago
parent
commit
2654c0a53b
3 changed files with 51 additions and 14 deletions
  1. 48 12
      gui/src/IpPopupForm.ui.qml
  2. 1 1
      gui/src/qmlhandler.cpp
  3. 2 1
      gui/src/qmlhandler.h

+ 48 - 12
gui/src/IpPopupForm.ui.qml

@@ -4,7 +4,7 @@ import QtQuick.Layouts 1.3
 
 Popup {
     id: popup
-    height: 200
+    height: 400
     dim: true
     clip: false
     width: 400
@@ -12,12 +12,19 @@ Popup {
     focus: true
     closePolicy: Popup.NoAutoClose
 
+    Connections {
+        target: _qmlHandler
+        onIpPopupSetStatus: {
+            ipPopupStatusText.text = status
+        }
+    }
+
     ColumnLayout {
         anchors.fill: parent
 
         Text {
             Layout.alignment: Qt.AlignCenter
-            id: popupText
+            id: ipPopupTitle
             color: "#ffffff"
             text: qsTr("Enter the IP to connect:")
             horizontalAlignment: Text.AlignHCenter
@@ -27,23 +34,52 @@ Popup {
 
         TextField {
             Layout.alignment: Qt.AlignCenter
-            id: popupIpInput
+            id: ipPopupIpInput
             selectByMouse: true
             focus: true
             text: qsTr("")
-            placeholderText: "Enter IP"
+            placeholderText: "IP-Address"
             horizontalAlignment: Text.AlignHCenter
             validator: RegExpValidator {
                 regExp: /^(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))\.(\d|[1-9]\d|1\d\d|2([0-4]\d|5[0-5]))$/
             }
             // @disable-check M222
-            Keys.onReturnPressed: popupConnectButton.activate()
+            Keys.onReturnPressed: ipPopupConnectButton.activate()
+            // @disable-check M222
+            Keys.onEnterPressed: ipPopupConnectButton.activate()
+        }
+
+        TextField {
+            Layout.alignment: Qt.AlignCenter
+            id: ipPopupUsernameInput
+            selectByMouse: true
+            focus: true
+            text: qsTr("")
+            placeholderText: "Username"
+            horizontalAlignment: Text.AlignHCenter
+            // @disable-check M222
+            Keys.onReturnPressed: ipPopupConnectButton.activate()
+            // @disable-check M222
+            Keys.onEnterPressed: ipPopupConnectButton.activate()
+        }
+
+        TextField {
+            Layout.alignment: Qt.AlignCenter
+            id: ipPopupPasswordInput
+            selectByMouse: true
+            focus: true
+            text: qsTr("")
+            placeholderText: "Password"
+            horizontalAlignment: Text.AlignHCenter
+            // @disable-check M222
+            Keys.onReturnPressed: ipPopupConnectButton.activate()
             // @disable-check M222
-            Keys.onEnterPressed: popupConnectButton.activate()
+            Keys.onEnterPressed: ipPopupConnectButton.activate()
+            echoMode: TextInput.Password
         }
 
         Text {
-            id: popupStatusText
+            id: ipPopupStatusText
             color: "#df3f3f"
             text: qsTr("")
             horizontalAlignment: Text.AlignHCenter
@@ -54,22 +90,22 @@ Popup {
 
         Button {
             Layout.alignment: Qt.AlignCenter
-            id: popupConnectButton
+            id: ipPopupConnectButton
             text: qsTr("Connect")
-            enabled: popupIpInput.acceptableInput
+            enabled: (ipPopupIpInput.acceptableInput && ipPopupUsernameInput.text != "" && ipPopupPasswordInput.text != "")
             font.pointSize: 16
             // @disable-check M223
             onClicked: {
                 // @disable-check M222
-                popupConnectButton.activate()
+                ipPopupConnectButton.activate()
             }
 
             // @disable-check M222
             function activate() {
                 // @disable-check M223
-                if (popupIpInput.acceptableInput) {
+                if (ipPopupConnectButton.enabled) {
                     // @disable-check M222
-                    _qmlHandler.onIpPopupEnterIp(popupIpInput.text)
+                    _qmlHandler.onIpPopupConnectButton(ipPopupIpInput.text, ipPopupUsernameInput.text, ipPopupUsernameInput.text)
                     // @disable-check M222
                     popup.close()
                 }

+ 1 - 1
gui/src/qmlhandler.cpp

@@ -145,7 +145,7 @@ void QMLHandler::onSettingsSwitchServerButton() {
 }
 
 // Ip Popup
-void QMLHandler::onIpPopupEnterIp(QString ip) {
+void QMLHandler::onIpPopupConnectButton(QString ip, QString username, QString password) {
   pid_t pid = 0;
 
   pipe(inpipefd);

+ 2 - 1
gui/src/qmlhandler.h

@@ -37,6 +37,7 @@ signals:
   void settingsOpenSwitchServerPopup();
 
   // Ip Popup
+  void ipPopupSetStatus(QString status);
 
   // Switch Popup
 
@@ -63,7 +64,7 @@ public slots:
   void onSettingsSwitchServerButton();
 
   // Ip Popup
-  void onIpPopupEnterIp(QString ip);
+  void onIpPopupConnectButton(QString ip, QString username, QString password);
 
   // Switch Popup
   void onSwitchPopupEnterIp(QString ip);