Sfoglia il codice sorgente

Created GUI + Signal Handling

Cyamond 4 anni fa
parent
commit
895f3c8f09
6 ha cambiato i file con 146 aggiunte e 0 eliminazioni
  1. 17 0
      gui/CMakeLists.txt
  2. 34 0
      gui/src/main.cpp
  3. 51 0
      gui/src/main.qml
  4. 5 0
      gui/src/qml.qrc
  5. 14 0
      gui/src/qmlhandler.cpp
  6. 25 0
      gui/src/qmlhandler.h

+ 17 - 0
gui/CMakeLists.txt

@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(CCats-GUI LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+find_package(Threads)
+find_package(Boost 1.67 REQUIRED COMPONENTS system)
+find_package(Qt5 COMPONENTS Core Quick REQUIRED)
+
+add_executable(${PROJECT_NAME} src/main.cpp src/qmlhandler.cpp src/qml.qrc)
+
+target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} Qt5::Core Qt5::Quick)
+
+

+ 34 - 0
gui/src/main.cpp

@@ -0,0 +1,34 @@
+#include <QGuiApplication>
+#include <QObject>
+#include <QQmlApplicationEngine>
+#include <iostream>
+
+#include "qmlhandler.h"
+
+int main(int argc, char *argv[]) {
+  QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+  QGuiApplication app(argc, argv);
+
+  QQmlApplicationEngine engine;
+  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+  if (engine.rootObjects().isEmpty())
+    return -1;
+
+  QMLHandler fooBar;
+
+  QObject *item =
+      engine.rootObjects().first()->findChild<QObject *>("connectbutton");
+  QObject *item2 =
+      engine.rootObjects().first()->findChild<QObject *>("disconnectbutton");
+
+  QObject::connect(item, SIGNAL(clicked()), &fooBar, SLOT(onClick()));
+  QObject::connect(item2, SIGNAL(clicked()), &fooBar, SLOT(onClick2()));
+
+  QObject::connect(&fooBar, SIGNAL(setStatusMessage(QVariant)),
+                   engine.rootObjects().first(),
+                   SLOT(setStatusMessage(QVariant)));
+
+  return app.exec();
+}

+ 51 - 0
gui/src/main.qml

@@ -0,0 +1,51 @@
+import QtQuick 2.9
+import QtQuick.Window 2.2
+import QtQuick.Controls 1.5
+
+Window {
+    visible: true
+    width: 1280
+    height: 720
+    color: "#191919"
+    title: qsTr("Covert Channel | Control Panel")
+
+    function setStatusMessage(text) {
+        console.log("BAM 3")
+        statusmessage.text = text
+    }
+
+    Text {
+        id: statusmessage
+        objectName: "statusmessage"
+        x: 210
+        y: 583
+        width: 861
+        height: 109
+        color: "#ffffff"
+        text: qsTr("...Status Message...")
+        font.family: "Courier"
+        horizontalAlignment: Text.AlignHCenter
+        fontSizeMode: Text.FixedSize
+        font.pixelSize: 59
+    }
+
+    Button {
+        id: connectbutton
+        objectName: "connectbutton"
+        x: 504
+        y: 183
+        width: 273
+        height: 73
+        text: qsTr("Connect")
+    }
+
+    Button {
+        id: disconnectbutton
+        objectName: "disconnectbutton"
+        x: 504
+        y: 304
+        width: 273
+        height: 73
+        text: qsTr("Disconnect")
+    }
+}

+ 5 - 0
gui/src/qml.qrc

@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>main.qml</file>
+    </qresource>
+</RCC>

+ 14 - 0
gui/src/qmlhandler.cpp

@@ -0,0 +1,14 @@
+//
+// Created by Tobi on 14.11.2019.
+//
+
+#include "qmlhandler.h"
+
+QMLHandler::QMLHandler(QObject *parent) : QObject(parent) {}
+
+void QMLHandler::onClick() {
+  qInfo() << "BAM";
+  emit setStatusMessage("Connecting");
+}
+
+void QMLHandler::onClick2() { qInfo() << "BAM 2"; }

+ 25 - 0
gui/src/qmlhandler.h

@@ -0,0 +1,25 @@
+//
+// Created by Tobi on 14.11.2019.
+//
+
+#ifndef CCATS_GUI_QMLHANDLER_H
+#define CCATS_GUI_QMLHANDLER_H
+
+#include <QDebug>
+#include <QObject>
+
+class QMLHandler : public QObject {
+  Q_OBJECT
+
+public:
+  explicit QMLHandler(QObject *parent = 0);
+
+signals:
+  void setStatusMessage(QVariant text);
+
+public slots:
+  void onClick();
+  void onClick2();
+};
+
+#endif // CCATS_GUI_QMLHANDLER_H