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
+6 -9
View File
@@ -1,13 +1,12 @@
#include "UI_checkbox.hpp"
UI_checkbox::UI_checkbox() : UI_x_boxes(UI_CHECKBOX_TYPE), m_selected(), m_on_change(nullptr)
UI_checkbox::UI_checkbox(QObject* parrent) : UI_x_boxes(UI_CHECKBOX_TYPE, parrent), m_selected()
{
}
UI_checkbox::UI_checkbox(std::string id, std::string text, Color fg_color, Color bg_color,
std::vector<std::string> options,
std::function<void(std::string, std::vector<std::string>)> on_change)
: UI_x_boxes(id, UI_CHECKBOX_TYPE, text, fg_color, bg_color, options), m_selected(), m_on_change(on_change)
std::vector<std::string> options, QObject* parrent)
: UI_x_boxes(id, UI_CHECKBOX_TYPE, text, fg_color, bg_color, options, parrent), m_selected()
{
for (size_t i = 0; i < m_options.size(); i++)
{
@@ -15,7 +14,7 @@ UI_checkbox::UI_checkbox(std::string id, std::string text, Color fg_color, Color
}
}
UI_checkbox::UI_checkbox(const json &j) : UI_x_boxes(UI_CHECKBOX_TYPE), m_selected(), m_on_change(nullptr)
UI_checkbox::UI_checkbox(const json &j, QObject* parrent) : UI_x_boxes(UI_CHECKBOX_TYPE, parrent), m_selected()
{
from_json(j);
}
@@ -25,10 +24,8 @@ void UI_checkbox::toggle_selected(size_t selected)
if (selected >= m_options.size())
return;
m_selected[selected] = !m_selected[selected];
if (m_on_change != nullptr)
{
std::thread([this] { m_on_change(m_id, selected_text()); }).detach();
}
emit value_changed();
emit on_change(m_id, selected_text()[selected]);
}
void UI_checkbox::toggle_selected(std::string selected)