Browse Source

added new popups, layout is done

Cyamond 5 years ago
parent
commit
cd1ca86f7e

+ 22 - 38
gui/src/SwitchIpPopupForm.ui.qml → gui/src/IpPopup.ui.qml

@@ -17,7 +17,7 @@ Popup {
 
         Text {
             Layout.alignment: Qt.AlignCenter
-            id: switchText
+            id: ipPopupText
             color: "#ffffff"
             text: qsTr("Enter the IP to connect:")
             horizontalAlignment: Text.AlignHCenter
@@ -27,23 +27,23 @@ Popup {
 
         TextField {
             Layout.alignment: Qt.AlignCenter
-            id: switchIpInput
+            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: switchConnectButton.activate()
+            Keys.onReturnPressed: ipPopupConnectButton.activate()
             // @disable-check M222
-            Keys.onEnterPressed: switchConnectButton.activate()
+            Keys.onEnterPressed: ipPopupConnectButton.activate()
         }
 
         Text {
-            id: switchStatusText
+            id: ipPopupStatusText
             color: "#df3f3f"
             text: qsTr("")
             horizontalAlignment: Text.AlignHCenter
@@ -52,42 +52,26 @@ Popup {
             font.pixelSize: 20
         }
 
-        RowLayout {
+        Button {
             Layout.alignment: Qt.AlignCenter
-
-            Button {
-                Layout.alignment: Qt.AlignLeft
-                id: switchConnectButton
-                text: qsTr("Connect")
-                rightPadding: 8
-                padding: 12
-                enabled: switchIpInput.acceptableInput
-                font.pointSize: 16
-                // @disable-check M223
-                onClicked: {
-                    // @disable-check M222
-                    switchConnectButton.activate()
-                }
-
+            id: ipPopupConnectButton
+            text: qsTr("Connect")
+            rightPadding: 8
+            padding: 12
+            enabled: ipPopupIpInput.acceptableInput
+            font.pointSize: 16
+            // @disable-check M223
+            onClicked: {
                 // @disable-check M222
-                function activate() {
-                    // @disable-check M223
-                    if (switchIpInput.acceptableInput) {
-                        // @disable-check M222
-                        _qmlHandler.onSwitchPopupEnterIp(switchIpInput.text)
-                        // @disable-check M222
-                        popup.close()
-                    }
-                }
+                ipPopupConnectButton.activate()
             }
 
-            Button {
-                Layout.alignment: Qt.AlignRight
-                id: switchCancelButton
-                text: qsTr("Cancel")
-                font.pointSize: 16
+            // @disable-check M222
+            function activate() {
                 // @disable-check M223
-                onClicked: {
+                if (ipPopupIpInput.acceptableInput) {
+                    // @disable-check M222
+                    _qmlHandler.onIpPopupConnectButton(ipPopupIpInput.text)
                     // @disable-check M222
                     popup.close()
                 }

+ 0 - 154
gui/src/IpPopupForm.ui.qml

@@ -1,154 +0,0 @@
-import QtQuick 2.4
-import QtQuick.Controls 2.3
-import QtQuick.Layouts 1.3
-
-Popup {
-    id: popup
-    height: 450
-    dim: true
-    clip: false
-    width: 400
-    modal: true
-    focus: true
-    closePolicy: Popup.NoAutoClose
-
-    Connections {
-        target: _qmlHandler
-        onIpPopupSetStatus: {
-            ipPopupStatusText.text = status
-        }
-        onIpPopupClose: {
-            popup.close()
-        }
-    }
-
-    Page {
-        anchors.fill: parent
-
-        header: TabBar {
-            id: header
-            currentIndex: swipeView.currentIndex
-            contentHeight: 50
-
-            TabButton {
-                text: qsTr("Login")
-            }
-
-            TabButton {
-                text: qsTr("Signup")
-            }
-        }
-
-        SwipeView {
-            id: swipeView
-            anchors.fill: parent
-            currentIndex: header.currentIndex
-            clip: true
-
-            Page {
-                ColumnLayout {
-                    anchors.fill: parent
-
-                    Text {
-                        Layout.alignment: Qt.AlignCenter
-                        id: ipPopupTitle
-                        color: "#ffffff"
-                        text: qsTr("Login")
-                        horizontalAlignment: Text.AlignHCenter
-                        verticalAlignment: Text.AlignVCenter
-                        font.pixelSize: 20
-                    }
-
-                    TextField {
-                        Layout.alignment: Qt.AlignCenter
-                        id: ipPopupIpInput
-                        selectByMouse: true
-                        focus: true
-                        text: qsTr("")
-                        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: 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: ipPopupConnectButton.activate()
-                        echoMode: TextInput.Password
-                    }
-
-                    Text {
-                        id: ipPopupStatusText
-                        color: "#df3f3f"
-                        text: qsTr("")
-                        horizontalAlignment: Text.AlignHCenter
-                        verticalAlignment: Text.AlignVCenter
-                        Layout.alignment: Qt.AlignCenter
-                        font.pixelSize: 20
-                    }
-
-                    Button {
-                        Layout.alignment: Qt.AlignCenter
-                        id: ipPopupConnectButton
-                        text: qsTr("Connect")
-                        enabled: (ipPopupIpInput.acceptableInput
-                                  && ipPopupUsernameInput.text != ""
-                                  && ipPopupPasswordInput.text != "")
-                        font.pointSize: 16
-                        // @disable-check M223
-                        onClicked: {
-                            // @disable-check M222
-                            ipPopupConnectButton.activate()
-                        }
-
-                        // @disable-check M222
-                        function activate() {
-                            // @disable-check M223
-                            if (ipPopupConnectButton.enabled) {
-                                // @disable-check M222
-                                _qmlHandler.onIpPopupConnectButton(
-                                            ipPopupIpInput.text,
-                                            ipPopupUsernameInput.text,
-                                            ipPopupUsernameInput.text)
-                            }
-                        }
-                    }
-                }
-            }
-
-            Page {
-                Button {
-                    text: qsTr("HallO")
-                }
-            }
-        }
-    }
-}

+ 83 - 0
gui/src/LoginForm.ui.qml

@@ -0,0 +1,83 @@
+import QtQuick 2.12
+import QtQuick.Controls 2.5
+import QtQuick.Layouts 1.3
+
+Page {
+    width: 400
+    height: 400
+    ColumnLayout {
+        anchors.fill: parent
+
+        Text {
+            Layout.alignment: Qt.AlignCenter
+            id: loginTitle
+            color: "#ffffff"
+            text: qsTr("Login")
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+            font.pixelSize: 20
+        }
+
+        TextField {
+            Layout.alignment: Qt.AlignCenter
+            id: loginUsernameInput
+            selectByMouse: true
+            focus: true
+            text: qsTr("")
+            placeholderText: "Username"
+            horizontalAlignment: Text.AlignHCenter
+            // @disable-check M222
+            Keys.onReturnPressed: loginLoginButton.activate()
+            // @disable-check M222
+            Keys.onEnterPressed: loginLoginButton.activate()
+        }
+
+        TextField {
+            Layout.alignment: Qt.AlignCenter
+            id: loginPasswordInput
+            selectByMouse: true
+            focus: true
+            text: qsTr("")
+            placeholderText: "Password"
+            horizontalAlignment: Text.AlignHCenter
+            // @disable-check M222
+            Keys.onReturnPressed: loginLoginButton.activate()
+            // @disable-check M222
+            Keys.onEnterPressed: loginLoginButton.activate()
+            echoMode: TextInput.Password
+        }
+
+        Text {
+            id: loginStatusText
+            color: "#df3f3f"
+            text: qsTr("")
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+            Layout.alignment: Qt.AlignCenter
+            font.pixelSize: 20
+        }
+
+        Button {
+            Layout.alignment: Qt.AlignCenter
+            id: loginLoginButton
+            text: qsTr("Login")
+            enabled: (loginUsernameInput.text != ""
+                      && loginPasswordInput.text != "")
+            font.pointSize: 16
+            // @disable-check M223
+            onClicked: {
+                // @disable-check M222
+                loginLoginButton.activate()
+            }
+
+            // @disable-check M222
+            function activate() {
+                // @disable-check M223
+                if (loginLoginButton.enabled) {
+                    // @disable-check M222
+
+                }
+            }
+        }
+    }
+}

+ 47 - 0
gui/src/LoginSignupPopup.ui.qml

@@ -0,0 +1,47 @@
+import QtQuick 2.4
+import QtQuick.Controls 2.3
+import QtQuick.Layouts 1.3
+
+Popup {
+    id: popup
+    height: 450
+    dim: true
+    clip: false
+    width: 400
+    modal: true
+    focus: true
+    closePolicy: Popup.NoAutoClose
+
+    Page {
+        anchors.fill: parent
+
+        header: TabBar {
+            id: header
+            currentIndex: swipeView.currentIndex
+            contentHeight: 50
+
+            TabButton {
+                text: qsTr("Login")
+            }
+
+            TabButton {
+                text: qsTr("Signup")
+            }
+        }
+
+        SwipeView {
+            id: swipeView
+            anchors.fill: parent
+            currentIndex: header.currentIndex
+            clip: true
+
+            LoginForm {
+
+            }
+
+            SignupForm {
+
+            }
+        }
+    }
+}

+ 99 - 0
gui/src/SignupForm.ui.qml

@@ -0,0 +1,99 @@
+import QtQuick 2.12
+import QtQuick.Controls 2.5
+import QtQuick.Layouts 1.3
+
+Page {
+  width: 400
+  height: 400
+  ColumnLayout {
+      anchors.fill: parent
+
+      Text {
+          Layout.alignment: Qt.AlignCenter
+          id: signupTitle
+          color: "#ffffff"
+          text: qsTr("Signup")
+          horizontalAlignment: Text.AlignHCenter
+          verticalAlignment: Text.AlignVCenter
+          font.pixelSize: 20
+      }
+
+      TextField {
+          Layout.alignment: Qt.AlignCenter
+          id: signupUsernameInput
+          selectByMouse: true
+          focus: true
+          text: qsTr("")
+          placeholderText: "Username"
+          horizontalAlignment: Text.AlignHCenter
+          // @disable-check M222
+          Keys.onReturnPressed: signupRegisterButton.activate()
+          // @disable-check M222
+          Keys.onEnterPressed: signupRegisterButton.activate()
+      }
+
+      TextField {
+          Layout.alignment: Qt.AlignCenter
+          id: signupPasswordOneInput
+          selectByMouse: true
+          focus: true
+          text: qsTr("")
+          placeholderText: "Password"
+          horizontalAlignment: Text.AlignHCenter
+          // @disable-check M222
+          Keys.onReturnPressed: signupRegisterButton.activate()
+          // @disable-check M222
+          Keys.onEnterPressed: signupRegisterButton.activate()
+          echoMode: TextInput.Password
+      }
+
+      TextField {
+          Layout.alignment: Qt.AlignCenter
+          id: signupPasswordTwoInput
+          selectByMouse: true
+          focus: true
+          text: qsTr("")
+          placeholderText: "Repeat Passw."
+          horizontalAlignment: Text.AlignHCenter
+          // @disable-check M222
+          Keys.onReturnPressed: signupRegisterButton.activate()
+          // @disable-check M222
+          Keys.onEnterPressed: signupRegisterButton.activate()
+          echoMode: TextInput.Password
+      }
+
+      Text {
+          id: signupStatusText
+          color: "#df3f3f"
+          text: qsTr("")
+          horizontalAlignment: Text.AlignHCenter
+          verticalAlignment: Text.AlignVCenter
+          Layout.alignment: Qt.AlignCenter
+          font.pixelSize: 20
+      }
+
+      Button {
+          Layout.alignment: Qt.AlignCenter
+          id: signupRegisterButton
+          text: qsTr("Register")
+          enabled: (signupUsernameInput.text != ""
+                    && signupPasswordOneInput.text != ""
+                    && signupPasswordTwoInput.text != "")
+          font.pointSize: 16
+          // @disable-check M223
+          onClicked: {
+              // @disable-check M222
+              signupRegisterButton.activate()
+          }
+
+          // @disable-check M222
+          function activate() {
+              // @disable-check M223
+              if (signupRegisterButton.enabled) {
+                  // @disable-check M222
+
+              }
+          }
+      }
+   }
+}

+ 6 - 5
gui/src/main.qml

@@ -71,20 +71,21 @@ ApplicationWindow {
 
     }
 
-    IpPopupForm {
-        id: ipDialog
+    LoginSignupPopup {
+        id: loginSignupPopup
         x: Math.round((parent.width - width) / 2)
         y: Math.round((parent.height - height) / 2)
     }
 
-    SwitchIpPopupForm {
-        id: switchDialog
+    IpPopup {
+        id: ipPopup
         x: Math.round((parent.width - width) / 2)
         y: Math.round((parent.height - height) / 2)
+        onClosed: loginSignupPopup.open()
     }
 
     Component.onCompleted: {
       swipeView.interactive = false
-      ipDialog.open()
+      ipPopup.open()
     }
 }

+ 4 - 2
gui/src/qml.qrc

@@ -6,9 +6,11 @@
         <file>SettingsForm.ui.qml</file>
         <file>MessagesForm.ui.qml</file>
         <file>qtquickcontrols2.conf</file>
-        <file>IpPopupForm.ui.qml</file>
+        <file>LoginSignupPopup.ui.qml</file>
         <file>HelpForm.ui.qml</file>
         <file>FooterForm.ui.qml</file>
-        <file>SwitchIpPopupForm.ui.qml</file>
+        <file>IpPopup.ui.qml</file>
+        <file>LoginForm.ui.qml</file>
+        <file>SignupForm.ui.qml</file>
     </qresource>
 </RCC>

+ 6 - 9
gui/src/qmlhandler.cpp

@@ -211,8 +211,7 @@ void QMLHandler::onSettingsSwitchServerButton() {
 }
 
 // Ip Popup
-void QMLHandler::onIpPopupConnectButton(QString ip, QString username,
-                                        QString password) {
+void QMLHandler::onIpPopupConnectButton(QString ip) {
   pid_t pid = 0;
 
   pipe(inpipefd);
@@ -238,19 +237,17 @@ void QMLHandler::onIpPopupConnectButton(QString ip, QString username,
   // TODO: Not hardcoded
   emit footerSetStatus("Connected to " + ip);
 
-  _USERNAME = username;
-  _PASSWORD = password;
-
   close(outpipefd[0]);
   close(inpipefd[1]);
 
   std::thread(&QMLHandler::readPipeLoop, this).detach();
 }
 
-// Switch Popup
-void QMLHandler::onSwitchPopupEnterIp(QString ip) {
-  qInfo() << "Switching to " << ip;
-}
+// Login
+void QMLHandler::onLoginLoginButton(QString username, QString password) {}
+
+// Signup
+void QMLHandler::onSignupRegisterButton(QString username, QString password) {}
 
 // Footer
 void QMLHandler::onFooterGetStatusButton() {

+ 6 - 3
gui/src/qmlhandler.h

@@ -65,10 +65,13 @@ public slots:
   void onSettingsSwitchServerButton();
 
   // Ip Popup
-  void onIpPopupConnectButton(QString ip, QString username, QString password);
+  void onIpPopupConnectButton(QString ip);
 
-  // Switch Popup
-  void onSwitchPopupEnterIp(QString ip);
+  // Login
+  void onLoginLoginButton(QString username, QString password);
+
+  // Signup
+  void onSignupRegisterButton(QString username, QString password);
 
   // Footer
   void onFooterGetStatusButton();