Commit 0f351d01 authored by CHEVALIER Arthur's avatar CHEVALIER Arthur Committed by Mathieu Faverge

feat(ignore): Adding build directory into .gitignore

feat(ui): Adding signals for all buttons
parent 8c821928
......@@ -53,6 +53,7 @@ CTestTestfile.cmake
# Generated directories
plugins/*/*_autogen
src/*_autogen
build
# Generated files
src/common/ViteConfig.hpp
......@@ -65,4 +66,4 @@ moc*
ui*
# Binary
src/vite
vite
#include <iostream>
#include <cstdarg>
// Qt
#include <QFileDialog>
#include <QWidget>
#include <QString>
#include "plugin/Plugin.hpp"
// Generated
......@@ -7,8 +13,29 @@
#include "MatrixVisualizer.hpp"
Matrix_visualizer* Matrix_visualizer::s_plugin = nullptr;
Matrix_visualizer::Matrix_visualizer() {
setupUi(this);
s_plugin = this;
this->connect_widgets();
}
void Matrix_visualizer::connect_widgets()
{
QObject::connect(this->tool_button_symbol, &QToolButton::clicked,
this, &on_tool_button_symbol_clicked);
QObject::connect(this->tool_button_values, &QToolButton::clicked,
this, &on_tool_button_values_clicked);
QObject::connect(this->button_infos_clear, &QToolButton::clicked,
this, &on_tool_button_infos_clicked);
QObject::connect(this->button_logs_clear, &QToolButton::clicked,
this, &on_tool_button_logs_clicked);
}
Matrix_visualizer::~Matrix_visualizer(){
......@@ -32,5 +59,76 @@ std::string Matrix_visualizer::get_name(){
}
void Matrix_visualizer::execute(){
QString symbol_filepath = this->line_edit_symbol->text();
QString values_filepath = this->line_edit_values->text();
if (symbol_filepath.size() == 0)
{
this->log(LogStatus::ERROR, "Empty filepath for symbol matrix file...");
return;
}
if (values_filepath.size() == 0)
{
this->log(LogStatus::WARNING, "Empty filepath for values file...");
}
}
void Matrix_visualizer::log(LogStatus status, const char* format, ...)
{
va_list ap;
va_start(ap, format);
char message[256] = {0};
vsnprintf(message, 256, format, ap);
va_end(ap);
QString previous_text = this->text_edit_logs->toPlainText();
switch(status)
{
case WARNING:
previous_text += "Warning: ";
break;
case ERROR:
previous_text += "ERROR: ";
break;
default:
break;
}
previous_text += message;
previous_text += '\n';
this->text_edit_logs->clear();
this->text_edit_logs->setText(previous_text);
}
/***********************
* Buttons
**********************/
void Matrix_visualizer::on_tool_button_symbol_clicked()
{
QString symbol_filepath = QFileDialog::getOpenFileName(s_plugin, tr("Open file"), "C://");
s_plugin->line_edit_symbol->setText(symbol_filepath);
}
void Matrix_visualizer::on_tool_button_values_clicked()
{
QString values_filepath = QFileDialog::getOpenFileName(s_plugin, tr("Open file"), "C://");
s_plugin->line_edit_values->setText(values_filepath);
}
void Matrix_visualizer::on_tool_button_infos_clicked()
{
s_plugin->text_edit_infos->setText("");
}
void Matrix_visualizer::on_tool_button_logs_clicked()
{
s_plugin->text_edit_logs->setText("");
}
#ifndef MATRIX_VISUALIZER_HPP
#define MATRIX_VISUALIZER_HPP
class Matrix_visualizer : public Plugin, protected Ui::Matrix_visualizer_widget_ui {
class Matrix_visualizer : public Plugin, public Ui::Matrix_visualizer_widget_ui {
public:
enum LogStatus
{
MESSAGE,
WARNING,
ERROR,
COUNT
};
public:
Matrix_visualizer();
~Matrix_visualizer();
......@@ -12,8 +22,22 @@ public:
void set_arguments(std::map<std::string /*argname*/, QVariant* /*argValue*/>);
std::string get_name();
void log(LogStatus status, const char* format, ...);
private:
void connect_widgets();
public slots:
void execute();
private slots:
static void on_tool_button_symbol_clicked();
static void on_tool_button_values_clicked();
static void on_tool_button_infos_clicked();
static void on_tool_button_logs_clicked();
private:
static Matrix_visualizer* s_plugin;
};
extern "C"
......
......@@ -13,6 +13,9 @@
<string>Inputs:</string>
</property>
<layout class="QVBoxLayout" name="vertical_layout">
<property name="alignment">
<set>Qt::AlignTop</set>
</property>
<item>
<widget class="QLabel" name="label_symbol">
<property name="text">
......@@ -103,6 +106,20 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<item>
<widget class="QToolButton" name="button_infos_clear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......@@ -120,6 +137,20 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<item>
<widget class="QToolButton" name="button_logs_clear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment