diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f22417..cc85769 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,8 @@ find_package(Qt6 REQUIRED COMPONENTS Core) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) +add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/QCodeEditor") + add_executable(${PROJECT_NAME} main.cpp channelwidget.cpp @@ -44,7 +46,8 @@ add_executable(${PROJECT_NAME} ) set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE ON) target_compile_options(${PROJECT_NAME} PUBLIC "-Wall") -target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::Core ${EISMULIPLEXER_LIBRARIES}) +target_include_directories(${PROJECT_NAME} PUBLIC QCodeEditor) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::Core ${EISMULIPLEXER_LIBRARIES} QCodeEditor) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/resources/eismultiplexerqt.png PROPERTIES QT_RESOURCE_ALIAS eismultiplexerqt.png) qt_add_resources(${PROJECT_NAME} "resources" PREFIX "/" FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/eismultiplexerqt.png ) install(TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/mainwindow.cpp b/mainwindow.cpp index b69934e..f764d9a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,19 +1,28 @@ #include #include +#include #include "mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) +MainWindow::MainWindow(QWidget *parent): + QMainWindow(parent), + ui(new Ui::MainWindow), + codeEditor(this) { ui->setupUi(this); enumerateDevices(); - connect(ui->actionQuit, &QAction::triggered, this, [this]() - { - close(); - }); + codeEditor.setAutoIndentation(true); + codeEditor.setAutoParentheses(true); + codeEditor.setHighlighter(&highligter); + codeEditor.setCompleter(&completer); + QFont font("Monospace"); + font.setStyleHint(QFont::TypeWriter); + codeEditor.setFont(font); + + ui->codeLayout->addWidget(&codeEditor); + + connect(ui->actionQuit, &QAction::triggered, this, [this]() {close();}); } MainWindow::~MainWindow() @@ -92,3 +101,15 @@ void MainWindow::enumerateDevices() free(serials); } +void MainWindow::generateExample() +{ + QString example = + "import eismultiplexer\n\n" + "from time import sleep"; + + for (const auto& channel : channels) + { + example.append(QString("eismultiplexer")); + } +} + diff --git a/mainwindow.h b/mainwindow.h index cb1a19c..090ecb0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include #include "channelwidget.h" @@ -16,6 +19,9 @@ class MainWindow : public QMainWindow Q_OBJECT std::vector> channels; Ui::MainWindow *ui; + QCodeEditor codeEditor; + QPythonHighlighter highligter; + QPythonCompleter completer; signals: void channelStateChanged(uint16_t device, uint16_t channel); @@ -26,6 +32,7 @@ public: private: void enumerateDevices(); + void generateExample(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 53aca8f..fbf1285 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -14,7 +14,41 @@ EisMultiplexer-Qt - + + + + + 10 + + + + + + + false + + + Stop + + + + + + + + + + Run + + + + + + + + + + @@ -25,7 +59,7 @@ 0 0 - 788 + 595 537 @@ -52,16 +86,46 @@ File + + + + + + Quit + + + + + + Save + + + + + + + + Save As + + + + + + + + Open + +