mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
fix for combobox bounce
This commit is contained in:
@@ -33,11 +33,13 @@ void Simulator_base::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
SPDLOG_DEBUG("Connecting callbacks");
|
||||
m_first_load = true;
|
||||
|
||||
connect(m_web_socket, &Web_socket_wrapper::on_command_cb, this, [=, this](json &j) { on_cmd_cb(j); });
|
||||
connect(m_web_socket, &Web_socket_wrapper::on_event_cb, this, [=, this](json &j) { on_event_cb(j); });
|
||||
connect(m_web_socket, &Web_socket_wrapper::on_closed, this, [=, this] { m_error_dialog->open(); });
|
||||
|
||||
m_web_socket->inhibit_events(true);
|
||||
m_web_socket->send_command(Web_socket_wrapper::Command::get_UI_elements);
|
||||
this->m_timer_update->start(m_refresh_rate);
|
||||
m_open = true;
|
||||
@@ -69,6 +71,11 @@ void Simulator_base::on_cmd_cb(json &j)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (m_first_load)
|
||||
{
|
||||
m_web_socket->inhibit_events(false);
|
||||
m_first_load = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Simulator_base::on_event_cb(json &j)
|
||||
|
||||
@@ -83,6 +83,7 @@ class Simulator_base : public QMainWindow
|
||||
uint32_t m_refresh_rate;
|
||||
NetworkError *m_error_dialog;
|
||||
bool m_open = false;
|
||||
bool m_first_load = true;
|
||||
std::vector<QWidget *> m_ui_lookup;
|
||||
};
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ void Web_socket_wrapper::send_command(Command command, QString id)
|
||||
|
||||
void Web_socket_wrapper::send_event(Event event, size_t id)
|
||||
{
|
||||
if (m_inhibit_events)
|
||||
return;
|
||||
json j;
|
||||
switch (event)
|
||||
{
|
||||
@@ -86,6 +88,8 @@ void Web_socket_wrapper::send_event(Event event, size_t id)
|
||||
|
||||
void Web_socket_wrapper::send_event(Event event, size_t id, double val)
|
||||
{
|
||||
if (m_inhibit_events)
|
||||
return;
|
||||
json j;
|
||||
switch (event)
|
||||
{
|
||||
@@ -102,6 +106,8 @@ void Web_socket_wrapper::send_event(Event event, size_t id, double val)
|
||||
|
||||
void Web_socket_wrapper::send_event(Event event, size_t id, QString val)
|
||||
{
|
||||
if (m_inhibit_events)
|
||||
return;
|
||||
json j;
|
||||
switch (event)
|
||||
{
|
||||
@@ -124,6 +130,8 @@ void Web_socket_wrapper::send_event(Event event, size_t id, QString val)
|
||||
|
||||
void Web_socket_wrapper::send_event(Event event, size_t id, uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload)
|
||||
{
|
||||
if (m_inhibit_events)
|
||||
return;
|
||||
json j;
|
||||
switch (event)
|
||||
{
|
||||
@@ -189,3 +197,8 @@ void Web_socket_wrapper::m_on_pong_timeout()
|
||||
m_web_socket->close();
|
||||
emit on_closed();
|
||||
}
|
||||
|
||||
void Web_socket_wrapper::inhibit_events(bool inhibit)
|
||||
{
|
||||
m_inhibit_events = inhibit;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ class Web_socket_wrapper : public QObject
|
||||
void send_event(Event event, size_t id, QString val);
|
||||
void send_event(Event event, size_t id, uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
void close();
|
||||
void inhibit_events(bool inhibit);
|
||||
|
||||
Q_SIGNALS:
|
||||
void on_connected();
|
||||
@@ -59,6 +60,7 @@ class Web_socket_wrapper : public QObject
|
||||
|
||||
private:
|
||||
bool m_connected = false;
|
||||
bool m_inhibit_events = false;
|
||||
QWebSocket *m_web_socket;
|
||||
QTimer *m_ping_timer;
|
||||
QTimer *m_pong_timer;
|
||||
|
||||
Reference in New Issue
Block a user