mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
Move to Qt
Everything seems to be working Only timer is not moved over
This commit is contained in:
+7
-10
@@ -1,17 +1,16 @@
|
||||
#include "UI_combobox.hpp"
|
||||
|
||||
UI_combobox::UI_combobox() : UI_x_boxes(UI_COMBOBOX_TYPE)
|
||||
UI_combobox::UI_combobox(QObject* parrent) : UI_x_boxes(UI_COMBOBOX_TYPE, parrent)
|
||||
{
|
||||
}
|
||||
|
||||
UI_combobox::UI_combobox(std::string id, std::string text, Color fg_color, Color bg_color,
|
||||
std::vector<std::string> options, size_t selected,
|
||||
std::function<void(std::string, std::string)> on_change)
|
||||
: UI_x_boxes(id, UI_COMBOBOX_TYPE, text, fg_color, bg_color, options), m_selected(selected), m_on_change(on_change)
|
||||
std::vector<std::string> options, size_t selected, QObject* parrent)
|
||||
: UI_x_boxes(id, UI_COMBOBOX_TYPE, text, fg_color, bg_color, options, parrent), m_selected(selected)
|
||||
{
|
||||
}
|
||||
|
||||
UI_combobox::UI_combobox(const json &j) : UI_x_boxes(UI_COMBOBOX_TYPE), m_on_change(nullptr)
|
||||
UI_combobox::UI_combobox(const json &j, QObject* parrent) : UI_x_boxes(UI_COMBOBOX_TYPE, parrent)
|
||||
{
|
||||
from_json(j);
|
||||
}
|
||||
@@ -21,10 +20,8 @@ void UI_combobox::set_selected(size_t selected)
|
||||
if (selected == m_selected)
|
||||
return;
|
||||
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());
|
||||
}
|
||||
|
||||
void UI_combobox::set_selected(std::string selected)
|
||||
@@ -68,4 +65,4 @@ json UI_combobox::to_json() const
|
||||
json j = UI_x_boxes::to_json();
|
||||
j["selected"] = m_options[m_selected];
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user