Commit 8902f509 authored by Yann Boucher's avatar Yann Boucher
Browse files

Works on linux with default QT 5.9 packages

parent 0e9e2a7e
Pipeline #79851 passed with stages
in 46 seconds
......@@ -19,7 +19,7 @@ Application développée dans le cadre de l’UV LO21 qui permet de répondre à
- [Auteurs et licence](#auteurs)
## Pour commencer
Avoir une version de **Qt** d'au moins 5.12. Projet principalement testé sur Qt 5.15.2.
Avoir une version de **Qt** d'au moins 5.9. Projet principalement testé sur Qt 5.15.2.
Le projet a été testé et fonctionne sur Qt 6, mais il est conseillé d'utiliser une version récente de Qt 5.
Testé avec les compilateurs suivants :
......
......@@ -18,6 +18,7 @@ Fichier définissant la classe Property représentant une propriété chargable,
#include <memory>
#include <limits>
#include <exception>
#include <cassert>
#include <QWidget>
#include <QLayout>
......
......@@ -6,6 +6,7 @@
#include "interface.hpp"
#include <stdlib.h>
#include <string>
#include <cassert>
#include <QListWidget>
#include <QColorDialog>
#include <QMessageBox>
......
......@@ -25,6 +25,7 @@ Cette classe représente le widget utilisé pour l'affichage et l'interaction av
#include <vector>
#include <cstdlib>
#include <cassert>
#include <qmath.h>
......
......@@ -717,7 +717,6 @@ void MainWindow::play_bad_apple()
{
static QJsonArray bad_apple_frame_list;
static QTimer bad_apple_timer;
static bool bad_apple_connected;
#ifdef BAD_APPLE_AUDIO
static QMediaPlayer bad_apple_player;
#endif
......@@ -738,9 +737,8 @@ void MainWindow::play_bad_apple()
bad_apple_timer.stop();
bad_apple_frame_list = frames["data"].toArray();
if (!bad_apple_connected)
{
bad_apple_timer.callOnTimeout([this]
connect(&bad_apple_timer, &QTimer::timeout, this, [this]
{
#ifdef BAD_APPLE_AUDIO
unsigned frame_idx;
......@@ -775,7 +773,7 @@ void MainWindow::play_bad_apple()
}
ui->grid_view->copy_grid(grid);
});
}, Qt::UniqueConnection);
};
// On coupe la simulation si elle est en train de s'exécuter
......@@ -788,7 +786,7 @@ void MainWindow::play_bad_apple()
bad_apple_player.setMedia(QUrl::fromLocalFile("extras/bad-apple.wav"));
bad_apple_player.play();
#else
QMessageBox::information(this, "", "Music functionnality is only available with Qt 5");
QMessageBox::information(this, "", "Music functionnality is only available with Qt Multimedia module (might be unavailable with Qt 6)");
#endif
bad_apple_elapsed.start();
......@@ -801,7 +799,6 @@ void MainWindow::play_snake()
static QTimer snake_timer;
static Coord snake_dir;
static std::list<Coord> snake_body;
static bool snake_connected = false;
statusBar()->showMessage("Controls : ZQSD", 60000);
......@@ -898,9 +895,9 @@ void MainWindow::play_snake()
on_playPauseButton_clicked();
}
if (!snake_connected)
{
snake_timer.callOnTimeout([this]
connect(&snake_timer, &QTimer::timeout, this, [this]
{
if (m_arrow_key_state[0] && snake_dir != Coord{+1, 0})
snake_dir = {-1, 0};
......@@ -911,8 +908,8 @@ void MainWindow::play_snake()
else if (m_arrow_key_state[3] && snake_dir != Coord{0, +1})
snake_dir = {0, -1};
advance_snake(false);
});
snake_connected = true;
}, Qt::UniqueConnection);
}
snake_timer.start(100);
}
......
......@@ -120,7 +120,7 @@ QJsonValue PropertyLoaderVisitor::fetch_value(Property &prop)
return val;
}
else
return current()[prop.identifier().c_str()];
return current().toObject().value(prop.identifier().c_str());
}
void PropertyLoaderVisitor::visit(StringProperty &prop)
......
......@@ -8,6 +8,7 @@ qtHaveModule(multimedia): QT += multimedia
CONFIG += c++14
TEMPLATE = app
TARGET = cellulut
# Optimisations, flag pour garder les infos de debug
QMAKE_CXXFLAGS += -O3 -g
......
......@@ -25,17 +25,17 @@ void CellulutTests::test_alphabet(){
unsigned char cb=sc.getBlue();
unsigned char cr=sc.getRed();
unsigned char cg=sc.getGreen();
QCOMPARE(cb,126);
QCOMPARE(cg,5);
QCOMPARE(cr,1);
QCOMPARE(cb,(unsigned char)126);
QCOMPARE(cg,(unsigned char)5);
QCOMPARE(cr,(unsigned char)1);
state test2=a.getState(2);
stateColor sc2 =test2.getColor();
unsigned char cb2=sc2.getBlue();
unsigned char cr2=sc2.getRed();
unsigned char cg2=sc2.getGreen();
QCOMPARE(cb2,74);
QCOMPARE(cg2,245);
QCOMPARE(cr2,144);
QCOMPARE(cb2,(unsigned char)74);
QCOMPARE(cg2,(unsigned char)245);
QCOMPARE(cr2,(unsigned char)144);
}
......@@ -31,7 +31,7 @@ void CellulutTests::test_arbitrary_neighborhood_rule()
prop->accept(visit);
}
QCOMPARE(rule.getFormats().size(), 1ul);
QCOMPARE(rule.getFormats().size(), 1u);
QCOMPARE(rule.getFormats()[0].positions.size(), coords.size());
auto list = rule.getFormats()[0].positions;
......
......@@ -37,11 +37,11 @@ void CellulutTests::test_factory()
std::unique_ptr<Transition> life_trans = Factory<Transition>::make("life-like");
QVERIFY(life_trans != nullptr);
QCOMPARE(life_trans->say_hi(), "Life hi!\n");
QCOMPARE(life_trans->say_hi(), std::string("Life hi!\n"));
std::unique_ptr<Transition> gens_trans = Factory<Transition>::make("generations");
QVERIFY(gens_trans != nullptr);
QCOMPARE(gens_trans->say_hi(), "Generations hi!\n");
QCOMPARE(gens_trans->say_hi(), std::string("Generations hi!\n"));
QVERIFY(nullptr == Factory<Transition>::make("<invalid>"));
......
......@@ -27,12 +27,12 @@ void CellulutTests::test_history()
// On pop la première grille puis la deuxième
Grid popGrid = historyTest.popGrid();
QCOMPARE(popGrid.get_state(pos2), 3ul);
QCOMPARE(popGrid.get_state(pos2), 3u);
Grid topGrid = historyTest.topGrid();
QVERIFY(topGrid.get_state(pos1) == 2);
popGrid = historyTest.popGrid();
QCOMPARE(popGrid.get_state(pos1), 2ul);
QCOMPARE(popGrid.get_state(pos1), 2u);
QVERIFY(historyTest.isEmpty() == true);
// Push de trois grille (taille max de la pile de l'history = 2)
......@@ -41,11 +41,11 @@ void CellulutTests::test_history()
historyTest.pushGrid(gridTest3); // La première grille est supprimée
popGrid = historyTest.popGrid();
QCOMPARE(popGrid.get_state(pos3), 4ul);
QCOMPARE(popGrid.get_state(pos3), 4u);
topGrid = historyTest.topGrid();
QVERIFY(topGrid.get_state(pos2) == 3);
popGrid = historyTest.popGrid();
QCOMPARE(popGrid.get_state(pos2), 3ul);
QCOMPARE(popGrid.get_state(pos2), 3u);
QVERIFY(historyTest.isEmpty() == true);
}
......@@ -28,7 +28,7 @@ void CellulutTests::test_property()
test.coords.load_from_neighborhood(n);
QCOMPARE(test.coords.size(), 3ul);
QCOMPARE(test.coords.size(), 3u);
for (unsigned i = 0; i < test.coords.size(); ++i)
{
CoordinateProperty& coord = static_cast<CoordinateProperty&>(test.coords.at(i));
......
......@@ -24,8 +24,8 @@ void CellulutTests::test_structure()
QVERIFY(std::is_permutation(normalized_coords.begin(), normalized_coords.end(), s1.begin()));
QVERIFY(std::is_permutation(normalized_coords.begin(), normalized_coords.end(), s2.begin()));
QCOMPARE(s1.width(), 3ul);
QCOMPARE(s1.height(), 2ul);
QCOMPARE(s1.width(), 3u);
QCOMPARE(s1.height(), 2u);
s1.load(empty.begin(), empty.end());
QVERIFY(s1.size() == 0);
......@@ -40,8 +40,8 @@ void CellulutTests::test_structure()
QCOMPARE(s1.size(), coords.size()); // 2 cellules non nulles, on ignore les cellules à zéro qui sont toujours implicites
QVERIFY(std::is_permutation(normalized_coords.begin(), normalized_coords.end(), s1.begin()));
QCOMPARE(s1.width(), 3ul);
QCOMPARE(s1.height(), 2ul);
QCOMPARE(s1.width(), 3u);
QCOMPARE(s1.height(), 2u);
}
}
......@@ -39,7 +39,7 @@ void CellulutTests::test_rle_structurereader()
try {
Structure stru = rle.read_structure();
QCOMPARE(stru.size(), 5ul);
QCOMPARE(stru.size(), 5u);
QVERIFY(std::count(stru.begin(), stru.end(), std::make_pair<Coord, unsigned>(Coord{1, 0}, 1)) == 1);
}
catch (const std::exception& ex)
......@@ -55,7 +55,7 @@ void CellulutTests::test_rle_structurereader()
try {
Structure stru = rle.read_structure();
QCOMPARE(stru.size(), 36ul);
QCOMPARE(stru.size(), 36u);
}
catch (const std::exception& ex)
{
......@@ -70,7 +70,7 @@ void CellulutTests::test_rle_structurereader()
try {
Structure stru = rle.read_structure();
QCOMPARE(stru.size(), 16ul);
QCOMPARE(stru.size(), 16u);
std::map<int, int> state_count;
for (auto pair : stru)
......@@ -96,7 +96,7 @@ void CellulutTests::test_json_structurereader()
try {
Structure stru = rle.read_structure();
QCOMPARE(stru.size(), 2ul);
QCOMPARE(stru.size(), 2u);
QVERIFY(std::count(stru.begin(), stru.end(), std::make_pair<Coord, unsigned>(Coord{0, 0}, 1)) == 1);
QVERIFY(std::count(stru.begin(), stru.end(), std::make_pair<Coord, unsigned>(Coord{2, 3}, 3)) == 1);
}
......
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