Commit 81025662 authored by CHEVALIER Arthur's avatar CHEVALIER Arthur Committed by Mathieu Faverge

fix(qt): Fixing compatibility between Qt4 and Qt5

parent 2685b928
......@@ -53,7 +53,7 @@ CTestTestfile.cmake
# Generated directories
plugins/*/*_autogen
src/*_autogen
build
build*
# Generated files
src/common/ViteConfig.hpp
......
......@@ -16,15 +16,21 @@
# @authors MARCOUEILLE Jule
# @authors NOISETTE Pascal
# @authors REDONDY Arthur
# @authors VUCHENER Clment
# @authors VUCHENER Clément
# @authors RICHART Nicolas
#
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
configure_file(
"Configuration.in"
"Configuration.hpp"
)
set (MATRIXVISUALIZER_hdrs
MatrixVisualizer.hpp
Configuration.hpp
Helper.hpp
Parsers/Parser.hpp
......@@ -56,10 +62,22 @@ set (MATRIXVISUALIZER_srcs
Common/Node.cpp
)
QT5_WRAP_UI(MATRIXVISUALIZER_forms
set (MATRIXVISUALIZER_forms_tmp
Plugin.ui
)
IF(USE_QT5)
QT5_WRAP_UI(MATRIXVISUALIZER_forms
${MATRIXVISUALIZER_forms_tmp}
)
else(USE_QT5)
QT4_WRAP_UI(MATRIXVISUALIZER_forms
${MATRIXVISUALIZER_forms_tmp}
)
endif(USE_QT5)
include_directories(${CMAKE_BINARY_DIR}/plugins/MatrixVisualizer)
add_library(MatrixVisualizer SHARED ${MATRIXVISUALIZER_srcs} ${MATRIXVISUALIZER_forms})
#############################################
......@@ -67,6 +85,8 @@ add_library(MatrixVisualizer SHARED ${MATRIXVISUALIZER_srcs} ${MATRIXVISUALIZER_
#############################################
IF(USE_QT5)
qt5_use_modules(MatrixVisualizer Widgets Core Xml OpenGL UiTools)
ELSE(USE_QT5)
qt4_use_modules(MatrixVisualizer Core Xml OpenGL UiTools)
ENDIF(USE_QT5)
TARGET_LINK_LIBRARIES(MatrixVisualizer
......
#ifndef CONFIGURATION_HPP
#define CONFIGURATION_HPP
#cmakedefine USE_QT5
#endif
......@@ -2,6 +2,7 @@
#include "../Helper.hpp"
#include <cstdlib>
#include <cstring>
#include <cmath>
......
#include "MatrixVisualizer.hpp"
#include "Configuration.hpp"
#include <QFileDialog>
Plugin *create() { return Matrix_visualizer::Get(); }
......@@ -28,17 +29,19 @@ Matrix_visualizer* Matrix_visualizer::Get()
void Matrix_visualizer::connect_widgets()
{
#ifdef USE_QT5
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,
QObject::connect(this->tool_button_infos, &QToolButton::clicked,
this, &on_tool_button_infos_clicked);
QObject::connect(this->button_logs_clear, &QToolButton::clicked,
QObject::connect(this->tool_button_logs, &QToolButton::clicked,
this, &on_tool_button_logs_clicked);
#endif
}
Matrix_visualizer::~Matrix_visualizer(){
......
......@@ -10,6 +10,7 @@
#include "ui_Plugin.h"
class Matrix_visualizer : public Plugin, public Ui::Matrix_visualizer_plugin_ui {
Q_OBJECT
public:
static Matrix_visualizer* Get();
~Matrix_visualizer();
......
......@@ -112,7 +112,7 @@
<set>Qt::AlignRight</set>
</property>
<item>
<widget class="QToolButton" name="button_infos_clear">
<widget class="QToolButton" name="tool_button_infos">
<property name="text">
<string>Clear</string>
</property>
......@@ -143,7 +143,7 @@
<set>Qt::AlignRight</set>
</property>
<item>
<widget class="QToolButton" name="button_logs_clear">
<widget class="QToolButton" name="tool_button_logs">
<property name="text">
<string>Clear</string>
</property>
......
......@@ -35,7 +35,11 @@ static void drawEmpty()
}
MatrixGLWidget::MatrixGLWidget(QWidget* parent, symbol_matrix_t* matrix)
#ifdef USE_QT5
: QOpenGLWidget(parent)
#else
: QGLWidget(parent)
#endif
{
this->setFixedSize(MATRIX_WINDOW_LENGTH, MATRIX_WINDOW_HEIGHT);
......@@ -52,7 +56,9 @@ MatrixGLWidget::~MatrixGLWidget()
void MatrixGLWidget::initializeGL()
{
#ifdef USE_QT5
initializeOpenGLFunctions();
#endif
glClearColor(BACKGROUND_COLOR_R, BACKGROUND_COLOR_G, BACKGROUND_COLOR_B, 1.f);
glMatrixMode(GL_PROJECTION);
......@@ -78,7 +84,9 @@ void MatrixGLWidget::paintGL()
{
int i, j;
#ifdef USE_QT5
initializeOpenGLFunctions();
#endif
glClear(GL_COLOR_BUFFER_BIT);
for (i = 0; i < NB_BLOK_BY_SIDE; ++i)
......
#ifndef MATRIX_GL_WIDGET_HPP
#define MATRIX_GL_WIDGET_HPP
#include "Configuration.hpp"
#include <QtOpenGL/QtOpenGL>
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#ifdef USE_QT5
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#else
#include <QGLWidget>
#endif
#include <QKeyEvent>
#include "../Formats/SymbolMatrix.hpp"
#include "../Common/QuadTree.hpp"
class MatrixGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
class MatrixGLWidget :
#ifdef USE_QT5
public QOpenGLWidget, protected QOpenGLFunctions
#else
public QGLWidget
#endif
{
public:
MatrixGLWidget(QWidget* parent, symbol_matrix_t* matrix);
......
......@@ -8,7 +8,7 @@ Matrix_window::Matrix_window(symbol_matrix_t* matrix)
QVBoxLayout* layout = new QVBoxLayout(widget);
m_gl = new MatrixGLWidget(nullptr, matrix);
m_gl->setObjectName(QStringLiteral("matrix_gl_visualizer"));
m_gl->setObjectName(QString("matrix_gl_visualizer"));
m_label = new QLabel(nullptr);
m_label->setText("Infos: ");
......@@ -26,7 +26,7 @@ Matrix_window::~Matrix_window()
void Matrix_window::closeEvent(QCloseEvent* event)
{
// Dgueu
// Dgueu
delete this;
}
......
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