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_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)
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
#include <eismultiplexer.h>
|
||||
#include <QMessageBox>
|
||||
#include <QMessageBox>
|
||||
#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"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include <memory>
|
||||
#include <QCodeEditor>
|
||||
#include <QPythonCompleter>
|
||||
#include <QPythonHighlighter>
|
||||
|
||||
#include "channelwidget.h"
|
||||
|
||||
|
@ -16,6 +19,9 @@ class MainWindow : public QMainWindow
|
|||
Q_OBJECT
|
||||
std::vector<std::shared_ptr<ChannelWidget>> 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
|
||||
|
|
|
@ -14,7 +14,41 @@
|
|||
<string>EisMultiplexer-Qt</string>
|
||||
</property>
|
||||
<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>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
|
@ -25,7 +59,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>788</width>
|
||||
<width>595</width>
|
||||
<height>537</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -52,16 +86,46 @@
|
|||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_As"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="QIcon::ThemeIcon::ApplicationExit"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Reference in a new issue