瀏覽代碼

finished us11: gui layout - base layout is mostly done

Cyamond 5 年之前
父節點
當前提交
834e778781

+ 42 - 30
gui/src/FooterForm.ui.qml

@@ -1,40 +1,52 @@
 import QtQuick 2.4
-import QtQuick.Controls 1.4
+import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.3
 
-Item {
+Page {
     width: 1280
     height: 200
 
-    Rectangle {
-        id: background
-        x: 0
-        y: 0
-        width: 1280
-        height: 200
-        color: "#4a4a4a"
-
-        Text {
-            id: statusText
-            x: 0
-            y: 0
-            width: 1280
-            height: 30
-            color: "#ffffff"
-            text: qsTr("Status: Connected to foobar")
-            font.pixelSize: 23
+    Connections {
+        target: _qmlHandler
+        onLog: {
+            footerLog.append(logText)
+            footerFlickable.contentY = footerLog.height - footerFlickable.height
         }
     }
 
-    TextArea {
-        id: logText
-        x: 0
-        y: 30
-        width: 1280
-        height: 170
-        backgroundVisible: false
-        readOnly: true
-        text: qsTr("Log goes here\nNew Line works as well")
-        font.pointSize: 15
-        textColor: "#ffffff"
+    Rectangle {
+        anchors.fill: parent
+        color: "#404040"
+
+        ColumnLayout {
+            anchors.fill: parent
+
+            Text {
+                id: footerStatusText
+                height: 30
+                color: "#ffffff"
+                text: qsTr("Status: Connected to foobar")
+                font.pixelSize: 23
+                Layout.preferredHeight: 30
+                Layout.preferredWidth: parent.width
+            }
+
+            Flickable {
+                id: footerFlickable
+                flickableDirection: Flickable.VerticalFlick
+                Layout.preferredHeight: 170
+                Layout.preferredWidth: parent.width
+
+                TextArea.flickable: TextArea {
+                    id: footerLog
+                    wrapMode: TextArea.Wrap
+                    text: qsTr("Log goes here\nNew Line works as well")
+                    font.pointSize: 15
+                }
+
+                ScrollBar.vertical: ScrollBar {
+                }
+            }
+        }
     }
 }

+ 13 - 1
gui/src/HelpForm.ui.qml

@@ -1,8 +1,20 @@
 import QtQuick 2.12
 import QtQuick.Controls 2.5
-import QtQuick.Dialogs 1.0
 
 Page {
     width: 1280
     height: 470
+
+    Text {
+        id: helpPlaceholder
+        x: 220
+        y: 135
+        width: 840
+        height: 200
+        color: "#ffffff"
+        text: qsTr("Tons of useful information goes here")
+        horizontalAlignment: Text.AlignHCenter
+        verticalAlignment: Text.AlignVCenter
+        font.pixelSize: 40
+    }
 }

+ 5 - 2
gui/src/IpPopupForm.ui.qml

@@ -31,12 +31,15 @@ Popup {
             text: qsTr("")
             placeholderText: "Enter IP"
             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]))$/
+            }
         }
 
         Text {
             id: popupStatusText
             color: "#df3f3f"
-            text: qsTr("")
+            text: qsTr("Text field for status")
             horizontalAlignment: Text.AlignHCenter
             verticalAlignment: Text.AlignVCenter
             Layout.alignment: Qt.AlignCenter
@@ -52,7 +55,7 @@ Popup {
             // @disable-check M223
             onClicked: {
                 // @disable-check M222
-                _qmlHandler.onEnterIp(popupIpInput.text)
+                _qmlHandler.onIpPopupEnterIp(popupIpInput.text)
                 // @disable-check M222
                 popup.close()
             }

+ 51 - 31
gui/src/MessagesForm.ui.qml

@@ -1,5 +1,6 @@
 import QtQuick 2.12
 import QtQuick.Controls 2.5
+import QtQuick.Layouts 1.3
 
 Page {
     width: 1280
@@ -7,40 +8,59 @@ Page {
 
     font.capitalization: Font.MixedCase
 
-    ScrollView {
-        id: scrollView
-        x: 0
-        y: 0
-        width: 1280
-        height: 400
-
-        TextArea {
-            id: messagesLog
-            width: 1280
-            height: 400
-            readOnly: true
-            text: qsTr("Log goes here\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well\nNew Line works as well")
-            font.pointSize: 15
+    Connections {
+        target: _qmlHandler
+        onMessage: {
+            messagesLog.append(msg)
+            messagesFlickable.contentY = messagesLog.height - messagesFlickable.height
         }
     }
 
-    TextField {
-        id: messageInput
-        x: 20
-        y: 400
-        width: 1060
-        height: 70
-        placeholderText: "Enter message..."
-        text: qsTr("")
-        font.pixelSize: 20
-    }
+    ColumnLayout {
+        anchors.fill: parent
+
+        Flickable {
+            id: messagesFlickable
+            flickableDirection: Flickable.VerticalFlick
+            Layout.preferredHeight: 400
+            Layout.preferredWidth: parent.width
+
+            TextArea.flickable: TextArea {
+                id: messagesLog
+                wrapMode: TextArea.Wrap
+                text: qsTr("Messages go here\nNew Line works as well")
+                font.pointSize: 15
+            }
+
+            ScrollBar.vertical: ScrollBar {
+            }
+        }
 
-    Button {
-        id: sendButton
-        x: 1100
-        y: 400
-        width: 180
-        height: 70
-        text: qsTr("Send")
+        RowLayout {
+            Layout.preferredHeight: 70
+            Layout.preferredWidth: parent.width
+
+            TextField {
+                id: messagesInputField
+                Layout.preferredWidth: 1060
+                Layout.preferredHeight: parent.height
+                placeholderText: "Enter message..."
+                text: qsTr("")
+                font.pixelSize: 20
+            }
+
+            Button {
+                id: messagesSendButton
+                Layout.preferredWidth: 180
+                Layout.preferredHeight: parent.height
+                text: qsTr("Send")
+
+                // @disable-check M223
+                onClicked: {
+                    // @disable-check M222
+                    _qmlHandler.onMessagesSendButton(messagesInputField.text)
+                }
+            }
+        }
     }
 }

+ 6 - 18
gui/src/ReceivingForm.ui.qml

@@ -4,25 +4,13 @@ import QtQuick.Controls 2.5
 Page {
     width: 1280
     height: 470
-    title: "Receiving"
 
-    Label {
-        color: "#000000"
-        text: "This is where the UI for receiving files goes."
-        font.pointSize: 30
-        anchors.verticalCenterOffset: 1
-        anchors.horizontalCenterOffset: 1
-        z: 3
-        anchors.centerIn: parent
-    }
-
-    Rectangle {
-        id: rectangle
-        x: 0
-        y: 0
-        width: 1280
-        height: 670
+    Text {
+        id: receivingPlaceholder
+        x: 154
+        y: 212
         color: "#ffffff"
-        z: 2
+        text: qsTr("This will be implemented with the actual functionality")
+        font.pixelSize: 40
     }
 }

+ 13 - 8
gui/src/SendingForm.ui.qml

@@ -11,13 +11,13 @@ Page {
 
     Connections {
         target: _qmlHandler
-        onSetFileUrlText: {
-            fileUrlText.text = signalText
+        onSendingSetFileUrlText: {
+            sendingSelectedFileText.text = signalText
         }
     }
 
     Button {
-        id: clearFileButton
+        id: sendingClearFileButton
         x: 900
         y: 40
         width: 260
@@ -27,7 +27,7 @@ Page {
     }
 
     Button {
-        id: selectFileButton
+        id: sendingSelectFileButton
         x: 120
         y: 40
         width: 260
@@ -42,7 +42,7 @@ Page {
     }
 
     Text {
-        id: fileUrlText
+        id: sendingSelectedFileText
         x: 54
         y: 186
         width: 1172
@@ -55,23 +55,28 @@ Page {
     }
 
     FileDialog {
-        id: fileDialog
+        id: sendingFileDialog
         title: "Please choose a file"
         folder: shortcuts.home
         // @disable-check M223
         onAccepted: {
             // @disable-check M222
-            _qmlHandler.onSelectFile(fileDialog.fileUrl)
+            _qmlHandler.onSendingSelectFileButton(fileDialog.fileUrl)
         }
     }
 
     Button {
-        id: sendFileButton
+        id: sendingSendFileButton
         x: 510
         y: 304
         width: 260
         height: 90
         text: qsTr("Send File")
         font.pointSize: 16
+        // @disable-check M223
+        onClicked: {
+            // @disable-check M222
+            _qmlHandler.onSendingSendFileButton()
+        }
     }
 }

+ 64 - 1
gui/src/SettingsForm.ui.qml

@@ -1,8 +1,71 @@
 import QtQuick 2.12
 import QtQuick.Controls 2.5
-import QtQuick.Dialogs 1.0
 
 Page {
     width: 1280
     height: 470
+
+    font.capitalization: Font.MixedCase
+
+    ComboBox {
+        id: settingsCovertMethodPicker
+        x: 328
+        y: 59
+        width: 285
+        height: 48
+
+        model: ListModel {
+            ListElement {
+                text: "Method 1"
+            }
+            ListElement {
+                text: "Method 2"
+            }
+            ListElement {
+                text: "Method 3"
+            }
+        }
+    }
+
+    Text {
+        id: settingsCovertMethodText
+        x: 56
+        y: 71
+        color: "#ffffff"
+        text: qsTr("Covert Channel Method:")
+        font.pixelSize: 20
+    }
+
+    Button {
+        id: settingsSwitchServerButton
+        x: 549
+        y: 343
+        width: 182
+        height: 71
+        text: qsTr("Switch Server")
+        font.pointSize: 15
+        // @disable-check M223
+        onClicked: {
+            // @disable-check M222
+            _qmlHandler.onSettingsSwitchServerButton()
+        }
+    }
+
+    Text {
+        id: settingsSaveIpText
+        x: 56
+        y: 154
+        color: "#ffffff"
+        text: qsTr("Save last IP:")
+        font.pixelSize: 20
+    }
+
+    Switch {
+        id: settingsSaveIpSwitch
+        x: 328
+        y: 142
+        text: qsTr("")
+        checked: false
+        display: AbstractButton.IconOnly
+    }
 }

+ 82 - 0
gui/src/SwitchIpPopupForm.ui.qml

@@ -0,0 +1,82 @@
+import QtQuick 2.4
+import QtQuick.Controls 2.3
+import QtQuick.Layouts 1.3
+
+Popup {
+    id: popup
+    height: 200
+    dim: true
+    clip: false
+    width: 400
+    modal: true
+    focus: true
+    closePolicy: Popup.NoAutoClose
+
+    ColumnLayout {
+        anchors.fill: parent
+
+        Text {
+            Layout.alignment: Qt.AlignCenter
+            id: switchText
+            color: "#ffffff"
+            text: qsTr("Enter the IP to connect:")
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+            font.pixelSize: 20
+        }
+
+        TextField {
+            Layout.alignment: Qt.AlignCenter
+            id: switchIpInput
+            text: qsTr("")
+            placeholderText: "Enter IP"
+            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]))$/
+            }
+        }
+
+        Text {
+            id: switchStatusText
+            color: "#df3f3f"
+            text: qsTr("Text field for status")
+            horizontalAlignment: Text.AlignHCenter
+            verticalAlignment: Text.AlignVCenter
+            Layout.alignment: Qt.AlignCenter
+            font.pixelSize: 20
+        }
+
+        RowLayout {
+            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
+                    _qmlHandler.onSwitchPopupEnterIp(popupIpInput.text)
+                    // @disable-check M222
+                    popup.close()
+                }
+            }
+
+            Button {
+                Layout.alignment: Qt.AlignRight
+                id: switchCancelButton
+                text: qsTr("Cancel")
+                font.pointSize: 16
+                // @disable-check M223
+                onClicked: {
+                    // @disable-check M222
+                    popup.close()
+                }
+            }
+        }
+    }
+}

+ 13 - 0
gui/src/main.qml

@@ -8,6 +8,13 @@ ApplicationWindow {
     height: 720
     title: qsTr("Covert Channel - Control Panel")
 
+    Connections {
+        target: _qmlHandler
+        onSettingsOpenSwitchServerPopup: {
+            switchDialog.open()
+        }
+    }
+
     SwipeView {
         id: swipeView
         anchors.fill: parent
@@ -70,5 +77,11 @@ ApplicationWindow {
         y: Math.round((parent.height - height) / 2)
     }
 
+    SwitchIpPopupForm {
+        id: switchDialog
+        x: Math.round((parent.width - width) / 2)
+        y: Math.round((parent.height - height) / 2)
+    }
+
     Component.onCompleted: ipDialog.open()
 }

+ 1 - 0
gui/src/qml.qrc

@@ -9,5 +9,6 @@
         <file>IpPopupForm.ui.qml</file>
         <file>HelpForm.ui.qml</file>
         <file>FooterForm.ui.qml</file>
+        <file>SwitchIpPopupForm.ui.qml</file>
     </qresource>
 </RCC>

+ 30 - 4
gui/src/qmlhandler.cpp

@@ -2,11 +2,37 @@
 
 QMLHandler::QMLHandler(QObject *parent) : QObject(parent) {}
 
-void QMLHandler::onSelectFile(QUrl url) {
+// Sending
+void QMLHandler::onSendingSelectFileButton(QUrl url) {
     qInfo() << "File Selected: " << url.toString();
-    emit setFileUrlText("Selected File: " + url.toString());
+    emit sendingSetFileUrlText("Selected File: " + url.toString());
 }
 
-void QMLHandler::onEnterIp(QString ip) {
-    qInfo() << ip;
+void QMLHandler::onSendingSendFileButton() {
+    qInfo() << "Sending File";
+    emit log("Sending File");
+}
+
+
+// Receiving
+
+
+// Messages
+void QMLHandler::onMessagesSendButton(QString msg) {
+    emit message(msg);
+}
+
+// Settings
+void QMLHandler::onSettingsSwitchServerButton() {
+    emit settingsOpenSwitchServerPopup();
+}
+
+// Ip Popup
+void QMLHandler::onIpPopupEnterIp(QString ip) {
+    qInfo() << "Connecting to " << ip;
+}
+
+// Switch Popup
+void QMLHandler::onSwitchPopupEnterIp(QString ip) {
+    qInfo() << "Switching to " << ip;
 }

+ 34 - 3
gui/src/qmlhandler.h

@@ -13,11 +13,42 @@ public:
   explicit QMLHandler(QObject *parent = 0);
 
 signals:
-  void setFileUrlText(QString signalText);
+  // Sending
+  void sendingSetFileUrlText(QString signalText);
+
+  // Receiving
+
+  // Messages
+  void message(QString msg);
+
+  // Settings
+  void settingsOpenSwitchServerPopup();
+
+  // Ip Popup
+
+  // Switch Popup
+
+  // Footer
+  void log(QString logText);
 
 public slots:
-  void onSelectFile(QUrl url);
-  void onEnterIp(QString ip);
+  // Sending
+  void onSendingSelectFileButton(QUrl url);
+  void onSendingSendFileButton();
+
+  // Receiving
+
+  // Messages
+  void onMessagesSendButton(QString msg);
+
+  // Settings
+  void onSettingsSwitchServerButton();
+
+  // Ip Popup
+  void onIpPopupEnterIp(QString ip);
+
+  // Switch Popup
+  void onSwitchPopupEnterIp(QString ip);
 };
 
 #endif // QMLHANDLER_H