Move to Qt

Everything seems to be working
Only timer is not moved over
This commit is contained in:
2024-09-12 16:59:54 +02:00
parent fc181726b9
commit 9eef1fc3ff
39 changed files with 399 additions and 501 deletions
+23 -2
View File
@@ -2,11 +2,26 @@
#include "can_debugger.hpp"
#include "test_sim.hpp"
#include <unordered_set>
#include <QDebug>
Simulators::Simulators()
Simulators::Simulators(uint16_t port, QObject* parrent) :
QObject(parrent),
m_server(new Websocket(port, this))
{
qDebug() << port;
INSERT_SIMULATOR(Test_Sim);
INSERT_SIMULATOR(Can_Debugger);
setup_connections();
}
void Simulators::setup_connections()
{
connect(m_server, &Websocket::on_message, this, [this](QWebSocket* conn, QString message){
QString response = message_parser(message);
if (response.isEmpty() || response == "{}")
return;
m_server->send(conn, response);
});
}
std::string Simulators::active_simulator_name() const
@@ -59,7 +74,13 @@ void Simulators::switch_simulator(std::string name)
return;
}
this->stop();
if (!this->m_current_simulator.empty())
{
disconnect(m_simulators.at(m_current_simulator).get());
}
this->m_current_simulator = name;
connect(m_simulators.at(m_current_simulator).get(), &Simulator_base::sim_changed, this, [this]{m_server->broadcast(QString::fromStdString(changed_UI_items().dump()));});
this->run();
}
@@ -139,4 +160,4 @@ json Simulators::changed_UI_items()
m_before = after;
return changed;
}
}