Initial integration of the code widget
This commit is contained in:
parent
2f3069a388
commit
417608478d
|
@ -32,6 +32,8 @@ find_package(Qt6 REQUIRED COMPONENTS Core)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
|
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/QCodeEditor")
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
main.cpp
|
main.cpp
|
||||||
channelwidget.cpp
|
channelwidget.cpp
|
||||||
|
@ -44,7 +46,8 @@ add_executable(${PROJECT_NAME}
|
||||||
)
|
)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE ON)
|
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE ON)
|
||||||
target_compile_options(${PROJECT_NAME} PUBLIC "-Wall")
|
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)
|
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 )
|
qt_add_resources(${PROJECT_NAME} "resources" PREFIX "/" FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/eismultiplexerqt.png )
|
||||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
|
|
|
@ -1,19 +1,28 @@
|
||||||
#include <eismultiplexer.h>
|
#include <eismultiplexer.h>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent):
|
||||||
: QMainWindow(parent)
|
QMainWindow(parent),
|
||||||
, ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow),
|
||||||
|
codeEditor(this)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
enumerateDevices();
|
enumerateDevices();
|
||||||
|
|
||||||
connect(ui->actionQuit, &QAction::triggered, this, [this]()
|
codeEditor.setAutoIndentation(true);
|
||||||
{
|
codeEditor.setAutoParentheses(true);
|
||||||
close();
|
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()
|
MainWindow::~MainWindow()
|
||||||
|
@ -92,3 +101,15 @@ void MainWindow::enumerateDevices()
|
||||||
free(serials);
|
free(serials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::generateExample()
|
||||||
|
{
|
||||||
|
QString example =
|
||||||
|
"import eismultiplexer\n\n"
|
||||||
|
"from time import sleep";
|
||||||
|
|
||||||
|
for (const auto& channel : channels)
|
||||||
|
{
|
||||||
|
example.append(QString("eismultiplexer"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <QCodeEditor>
|
||||||
|
#include <QPythonCompleter>
|
||||||
|
#include <QPythonHighlighter>
|
||||||
|
|
||||||
#include "channelwidget.h"
|
#include "channelwidget.h"
|
||||||
|
|
||||||
|
@ -16,6 +19,9 @@ class MainWindow : public QMainWindow
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
std::vector<std::shared_ptr<ChannelWidget>> channels;
|
std::vector<std::shared_ptr<ChannelWidget>> channels;
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
QCodeEditor codeEditor;
|
||||||
|
QPythonHighlighter highligter;
|
||||||
|
QPythonCompleter completer;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void channelStateChanged(uint16_t device, uint16_t channel);
|
void channelStateChanged(uint16_t device, uint16_t channel);
|
||||||
|
@ -26,6 +32,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enumerateDevices();
|
void enumerateDevices();
|
||||||
|
void generateExample();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -14,7 +14,41 @@
|
||||||
<string>EisMultiplexer-Qt</string>
|
<string>EisMultiplexer-Qt</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="codeLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonStop">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::MediaPlaybackStop"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonRun">
|
||||||
|
<property name="text">
|
||||||
|
<string>Run</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::MediaPlaybackStart"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
|
@ -25,7 +59,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>788</width>
|
<width>595</width>
|
||||||
<height>537</height>
|
<height>537</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -52,16 +86,46 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>File</string>
|
<string>File</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
|
<addaction name="actionSave"/>
|
||||||
|
<addaction name="actionSave_As"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::ApplicationExit"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Quit</string>
|
<string>Quit</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSave">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::DocumentSave"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSave_As">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::DocumentSaveAs"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Save As</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionOpen">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="QIcon::ThemeIcon::DocumentOpen"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
Loading…
Reference in a new issue