diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-12-05 17:11:10 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-12-05 17:11:10 +0100 |
commit | 67e263e63994c908d34ec3344cb4dff830b356d1 (patch) | |
tree | eb3d81e2a1cd347d10ba90a1de2b4ab2c257ce47 /confui/ui_automation.cpp | |
parent | 8c3eaff565c9af6b12f59569982a42be1e66c69a (diff) |
automations tab layout done
Diffstat (limited to 'confui/ui_automation.cpp')
-rw-r--r-- | confui/ui_automation.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/confui/ui_automation.cpp b/confui/ui_automation.cpp index f427930..2a04edb 100644 --- a/confui/ui_automation.cpp +++ b/confui/ui_automation.cpp @@ -1,7 +1,10 @@ #include "ui_automation.h" +#include "mesh_connector.h" + +using std::pair; CDAutomationWidget::~CDAutomationWidget() { } -CDAutomationWidget::CDAutomationWidget(cd_s_automation* automation, QWidget *parent) : QWidget(parent) { +CDAutomationWidget::CDAutomationWidget(cd_s_automation* automation, QWidget* parent) : QWidget(parent) { set_automation(automation); main_layout = new QHBoxLayout; @@ -28,8 +31,27 @@ void CDAutomationWidget::set_automation(cd_s_automation* automation) { void CDAutomationWidget::update() { button_remove->setText("Delete"); + map<cd_mac_addr_cpp_t, cd_s_node*> nodes = g_cd_mesh_connector->get_nodes(false); + + for (pair<cd_mac_addr_cpp_t, cd_s_node*> node : nodes) { + QString label = ""; + label.append(QString::fromLocal8Bit(node.second->name, node.second->name_len)); + label.append(" ("); + label.append(QString::fromStdString(cd_mac_to_string(node.second->address))); + label.append(")"); + + QString userData = QString::fromLocal8Bit((char*) node.second->address, 6); + dropdown_button->addItem(label, userData); + dropdown_light->addItem(label, userData); + } + + dropdown_button->setCurrentIndex(dropdown_button->findData(QString::fromLocal8Bit((char*) _automation->button->address, 6))); + dropdown_action->clear(); dropdown_action->addItem("Toggles", CD_AUTOMATION_TYPE_TOGGLE); dropdown_action->addItem("Switches on", CD_AUTOMATION_TYPE_TURN_ON); dropdown_action->addItem("Switches off", CD_AUTOMATION_TYPE_TURN_OFF); + dropdown_action->setCurrentIndex(dropdown_action->findData(_automation->type)); + + dropdown_light->setCurrentIndex(dropdown_light->findData(QString::fromLocal8Bit((char*) _automation->light->address, 6))); } |