diff options
author | Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> | 2025-03-23 20:27:31 -0400 |
---|---|---|
committer | Siddarth-Suresh <65844402+Siddarth-Suresh@users.noreply.github.com> | 2025-03-23 20:27:31 -0400 |
commit | b400e932ce310e856a5fcbc49ecce522c9cad1b3 (patch) | |
tree | 91eea37c01bda87b115b33c63c02dc41c192243f | |
parent | fab7d9dcf249762eeac89a11487856e7569c66d5 (diff) |
Initial GUI Commit
-rw-r--r-- | CMakeLists.txt | 30 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | inc/cache.h | 1 | ||||
-rw-r--r-- | inc/dram.h | 1 | ||||
-rw-r--r-- | src/gui/GUI.cc | 39 | ||||
-rw-r--r-- | src/gui/GUI.h | 27 | ||||
-rw-r--r-- | src/gui/GUI.ui | 55 | ||||
-rw-r--r-- | src/gui/gui.py | 0 | ||||
-rw-r--r-- | src/gui/main.cc | 11 | ||||
-rw-r--r-- | src/gui/resources.qrc | 5 | ||||
-rw-r--r-- | src/gui/resources/input.txt | 1 |
11 files changed, 171 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a48922..64cd30d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,12 @@ include_directories( # gather source files file(GLOB_RECURSE SRCS "src/*.cc") list(REMOVE_ITEM SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc") +#exclude gui files from cli executable +foreach(file ${SRCS}) + if(file MATCHES "${CMAKE_CURRENT_SOURCE_DIR}/src/gui/.*") + list(REMOVE_ITEM SRCS ${file}) + endif() +endforeach() # find python3 components find_package(Python3 COMPONENTS Development REQUIRED) @@ -41,3 +47,27 @@ target_link_libraries(tests PRIVATE Catch2::Catch2WithMain PRIVATE Python3::Pyth include(CTest) include(Catch) catch_discover_tests(tests) + +# ================================ +# Qt6 GUI Integration +# ================================ +cmake_minimum_required(VERSION 3.16) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +# Find Qt6 Components +find_package(Qt6 REQUIRED COMPONENTS Widgets) + + +# Gather GUI Source Files +file(GLOB_RECURSE GUI_SRCS "src/gui/*.cc") + +# Gather GUI Resources +qt_add_resources(GUI_RESOURCES "src/gui/resources.qrc") + +# GUI executable +qt_add_executable("${PROJECT_NAME}_gui" ${GUI_SRCS} ${SRCS} ${GUI_RESOURCES}) +target_link_libraries("${PROJECT_NAME}_gui" PRIVATE Qt6::Widgets) + @@ -5,6 +5,7 @@ - g++ (GCC) 11.4.0 - python 3.10 or newer - catch2 version 3.5.3 +- Qt version 6.8.2 ## to compile Generate the build directory with diff --git a/inc/cache.h b/inc/cache.h index ef9c9e4..88fd352 100644 --- a/inc/cache.h +++ b/inc/cache.h @@ -4,6 +4,7 @@ #include "storage.h" #include <array> #include <ostream> +#include <functional> class Cache : public Storage { @@ -3,6 +3,7 @@ #include "definitions.h" #include "storage.h" #include <ostream> +#include <functional> class Dram : public Storage { diff --git a/src/gui/GUI.cc b/src/gui/GUI.cc new file mode 100644 index 0000000..5577e6e --- /dev/null +++ b/src/gui/GUI.cc @@ -0,0 +1,39 @@ +#include "GUI.h" +#include "./ui_GUI.h" +#include <QFile> +#include <QTextStream> + +GUI::GUI(QWidget *parent) + : QWidget(parent) + , ui(new Ui::GUI) +{ + ui->setupUi(this); + loadTxtFile(); +} + +GUI::~GUI() +{ + delete ui; +} + +void GUI::loadTxtFile(){ + QFile inputFile(":/resources/input.txt"); + inputFile.open(QIODevice::ReadOnly); + + QTextStream in(&inputFile); + QString line = in.readAll(); + inputFile.close(); + + ui->textEdit->setPlainText(line); + QTextCursor cursor = ui->textEdit->textCursor(); + cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1); +} + +void GUI::on_pushButton_clicked() +{ + QString searchString = ui->lineEdit->text(); + ui->textEdit->find(searchString, QTextDocument::FindWholeWords); +} + + + diff --git a/src/gui/GUI.h b/src/gui/GUI.h new file mode 100644 index 0000000..b06f310 --- /dev/null +++ b/src/gui/GUI.h @@ -0,0 +1,27 @@ +#ifndef GUI_H +#define GUI_H + +#include <QWidget> + +QT_BEGIN_NAMESPACE +namespace Ui { +class GUI; +} +QT_END_NAMESPACE + +class GUI : public QWidget +{ + Q_OBJECT + +public: + GUI(QWidget *parent = nullptr); + ~GUI(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::GUI *ui; + void loadTxtFile(); +}; +#endif // GUI_H diff --git a/src/gui/GUI.ui b/src/gui/GUI.ui new file mode 100644 index 0000000..bce52c2 --- /dev/null +++ b/src/gui/GUI.ui @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GUI</class> + <widget class="QWidget" name="GUI"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>GUI</string> + </property> + <widget class="QWidget" name=""> + <property name="geometry"> + <rect> + <x>60</x> + <y>30</y> + <width>317</width> + <height>232</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>keyword</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"/> + </item> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>find</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QTextEdit" name="textEdit"/> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/gui/gui.py b/src/gui/gui.py deleted file mode 100644 index e69de29..0000000 --- a/src/gui/gui.py +++ /dev/null diff --git a/src/gui/main.cc b/src/gui/main.cc new file mode 100644 index 0000000..e592da9 --- /dev/null +++ b/src/gui/main.cc @@ -0,0 +1,11 @@ +#include "GUI.h" + +#include <QApplication> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + GUI w; + w.show(); + return a.exec(); +} diff --git a/src/gui/resources.qrc b/src/gui/resources.qrc new file mode 100644 index 0000000..44aaefa --- /dev/null +++ b/src/gui/resources.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/resources"> + <file alias = "input.txt">resources/input.txt</file> + </qresource> +</RCC> diff --git a/src/gui/resources/input.txt b/src/gui/resources/input.txt new file mode 100644 index 0000000..fc1c3cf --- /dev/null +++ b/src/gui/resources/input.txt @@ -0,0 +1 @@ +Lorem Ipsum
\ No newline at end of file |