diff options
-rw-r--r-- | confui/confui.pro | 14 | ||||
-rw-r--r-- | confui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | confui/mainwindow.h | 8 | ||||
-rw-r--r-- | confui/mesh_connector.h | 4 | ||||
-rw-r--r-- | confui/ui_automation.cpp | 35 | ||||
-rw-r--r-- | confui/ui_automation.h | 28 | ||||
-rw-r--r-- | confui/ui_automations.h | 15 | ||||
-rw-r--r-- | confui/ui_node.cpp | 17 | ||||
-rw-r--r-- | confui/ui_node.h | 2 | ||||
-rw-r--r-- | confui/ui_node_overview.cpp | 28 | ||||
-rw-r--r-- | confui/ui_node_overview.h | 15 | ||||
-rw-r--r-- | confui/ui_tab_automations.cpp (renamed from confui/ui_automations.cpp) | 6 | ||||
-rw-r--r-- | confui/ui_tab_automations.h | 15 | ||||
-rw-r--r-- | confui/ui_tab_node_overview.cpp | 55 | ||||
-rw-r--r-- | confui/ui_tab_node_overview.h | 15 |
15 files changed, 174 insertions, 91 deletions
diff --git a/confui/confui.pro b/confui/confui.pro index 2fef635..e0950b9 100644 --- a/confui/confui.pro +++ b/confui/confui.pro @@ -4,16 +4,18 @@ SOURCES += \ main.cpp \ mainwindow.cpp \ mesh_connector.cpp \ - ui_automations.cpp \ - ui_node_overview.cpp \ - ui_node.cpp + ui_tab_automations.cpp \ + ui_tab_node_overview.cpp \ + ui_node.cpp \ + ui_automation.cpp HEADERS += \ mainwindow.h \ mesh_connector.h \ - ui_automations.h \ - ui_node_overview.h \ - ui_node.h + ui_tab_automations.h \ + ui_tab_node_overview.h \ + ui_node.h \ + ui_automation.h CONFIG += c++17 CONFIG += force_debug_info diff --git a/confui/mainwindow.cpp b/confui/mainwindow.cpp index 27bdb6c..ca78603 100644 --- a/confui/mainwindow.cpp +++ b/confui/mainwindow.cpp @@ -3,8 +3,8 @@ #include <QTabWidget> #include "mainwindow.h" -#include "ui_automations.h" -#include "ui_node_overview.h" +#include "ui_tab_automations.h" +#include "ui_tab_node_overview.h" CDMainWindow::CDMainWindow(QWidget *parent) : QMainWindow(parent) { this->mesh_connector = new CDMeshConnector(); @@ -13,8 +13,8 @@ CDMainWindow::CDMainWindow(QWidget *parent) : QMainWindow(parent) { menu_bar->addMenu("ayo"); QTabWidget* tab_bar_widget = new QTabWidget(this); - this->automations_widget = new CDAutomationsWidget(this); - this->node_overview_widget = new CDNodeOverviewWidget(this); + this->automations_widget = new CDAutomationsTabWidget(this); + this->node_overview_widget = new CDNodeOverviewTabWidget(this); tab_bar_widget->addTab(this->node_overview_widget, "node overview"); tab_bar_widget->addTab(this->automations_widget, "automations"); diff --git a/confui/mainwindow.h b/confui/mainwindow.h index 61b2f24..a4e7a59 100644 --- a/confui/mainwindow.h +++ b/confui/mainwindow.h @@ -7,16 +7,16 @@ #include "mesh_connector.h" -class CDAutomationsWidget; -class CDNodeOverviewWidget; +class CDAutomationsTabWidget; +class CDNodeOverviewTabWidget; class CDMainWindow : public QMainWindow { Q_OBJECT public: CDMeshConnector *mesh_connector = nullptr; - CDAutomationsWidget* automations_widget = nullptr; - CDNodeOverviewWidget* node_overview_widget = nullptr; + CDAutomationsTabWidget* automations_widget = nullptr; + CDNodeOverviewTabWidget* node_overview_widget = nullptr; CDMainWindow(QWidget *parent = nullptr); ~CDMainWindow(); diff --git a/confui/mesh_connector.h b/confui/mesh_connector.h index b248e27..238414c 100644 --- a/confui/mesh_connector.h +++ b/confui/mesh_connector.h @@ -29,8 +29,8 @@ typedef struct { typedef struct { cd_e_automation_type type; - cd_s_node button; - cd_s_node light; + cd_s_node* button; + cd_s_node* light; } cd_s_automation; class CDMeshConnector { diff --git a/confui/ui_automation.cpp b/confui/ui_automation.cpp new file mode 100644 index 0000000..f427930 --- /dev/null +++ b/confui/ui_automation.cpp @@ -0,0 +1,35 @@ +#include "ui_automation.h" + +CDAutomationWidget::~CDAutomationWidget() { } +CDAutomationWidget::CDAutomationWidget(cd_s_automation* automation, QWidget *parent) : QWidget(parent) { + set_automation(automation); + + main_layout = new QHBoxLayout; + + dropdown_button = new QComboBox; + dropdown_action = new QComboBox; + dropdown_light = new QComboBox; + button_remove = new QPushButton; + + main_layout->addWidget(dropdown_button); + main_layout->addWidget(dropdown_action); + main_layout->addWidget(dropdown_light); + main_layout->addStretch(); + main_layout->addWidget(button_remove); + + update(); + setLayout(main_layout); +} + +void CDAutomationWidget::set_automation(cd_s_automation* automation) { + _automation = automation; +} + +void CDAutomationWidget::update() { + button_remove->setText("Delete"); + + 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); +} diff --git a/confui/ui_automation.h b/confui/ui_automation.h new file mode 100644 index 0000000..d69c4d7 --- /dev/null +++ b/confui/ui_automation.h @@ -0,0 +1,28 @@ +#pragma once + +#include <QWidget> +#include <QHBoxLayout> +#include <QPushButton> +#include <QString> +#include <QComboBox> + +#include "mesh_connector.h" + +class CDAutomationWidget : public QWidget { + Q_OBJECT + +private: + cd_s_automation* _automation; + + QHBoxLayout* main_layout; + QComboBox* dropdown_button; + QComboBox* dropdown_action; + QComboBox* dropdown_light; + QPushButton* button_remove; + +public: + CDAutomationWidget(cd_s_automation* automation, QWidget *parent = nullptr); + virtual ~CDAutomationWidget(); + virtual void update(); + virtual void set_automation(cd_s_automation* automation); +}; diff --git a/confui/ui_automations.h b/confui/ui_automations.h deleted file mode 100644 index c60bf9f..0000000 --- a/confui/ui_automations.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include <QMainWindow> - -#include "mainwindow.h" - -class CDAutomationsWidget : public QWidget { - Q_OBJECT - -public: - CDMainWindow *mainwindow = nullptr; - - CDAutomationsWidget(CDMainWindow *main_window = nullptr); - virtual ~CDAutomationsWidget(); -}; diff --git a/confui/ui_node.cpp b/confui/ui_node.cpp index 3621083..3f1b43b 100644 --- a/confui/ui_node.cpp +++ b/confui/ui_node.cpp @@ -5,23 +5,16 @@ CDNodeWidget::CDNodeWidget(cd_s_node* node, QWidget *parent) : QWidget(parent) { set_node(node); main_layout = new QHBoxLayout; - float_left = new QHBoxLayout; - float_right = new QHBoxLayout; switch_on_off = new QCheckBox; button_add_remove = new QPushButton; label_node_address = new QLabel; label_node_name = new QLabel; - float_left->addWidget(label_node_name); - float_left->addWidget(label_node_address); - float_left->addStretch(); - - float_right->addStretch(); - float_right->addWidget(switch_on_off); - float_right->addWidget(button_add_remove); - - main_layout->addLayout(float_left); - main_layout->addLayout(float_right); + main_layout->addWidget(label_node_name); + main_layout->addWidget(label_node_address); + main_layout->addStretch(); + main_layout->addWidget(switch_on_off); + main_layout->addWidget(button_add_remove); update(); setLayout(main_layout); diff --git a/confui/ui_node.h b/confui/ui_node.h index f5fdbbd..0b7049c 100644 --- a/confui/ui_node.h +++ b/confui/ui_node.h @@ -16,8 +16,6 @@ private: cd_s_node* _node; QHBoxLayout* main_layout; - QHBoxLayout* float_left; - QHBoxLayout* float_right; QLabel* label_node_name; QLabel* label_node_address; QCheckBox* switch_on_off; diff --git a/confui/ui_node_overview.cpp b/confui/ui_node_overview.cpp deleted file mode 100644 index 466e5b2..0000000 --- a/confui/ui_node_overview.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <QWidget> -#include <QLabel> -#include <QVBoxLayout> - -#include "ui_node_overview.h" -#include "ui_node.h" - -CDNodeOverviewWidget::~CDNodeOverviewWidget() { } -CDNodeOverviewWidget::CDNodeOverviewWidget(CDMainWindow* main_window) : QWidget(main_window) { - this->mainwindow = main_window; - - QVBoxLayout* main_layout = new QVBoxLayout; - - const char* n_name = "berta"; - cd_s_node n = { - .address = { 0x00, 0xff, 0x21, 0x69, 0xf2, 0x31 }, - .name_len = strlen(n_name), - .name = n_name, - .light_on = true, - .provisioned = true, - }; - - CDNodeWidget* nd_w = new CDNodeWidget(&n, this); - - main_layout->addWidget(nd_w); - - setLayout(main_layout); -} diff --git a/confui/ui_node_overview.h b/confui/ui_node_overview.h deleted file mode 100644 index bf5f120..0000000 --- a/confui/ui_node_overview.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include <QMainWindow> - -#include "mainwindow.h" - -class CDNodeOverviewWidget : public QWidget { - Q_OBJECT - -public: - CDMainWindow *mainwindow = nullptr; - - CDNodeOverviewWidget(CDMainWindow *main_window = nullptr); - virtual ~CDNodeOverviewWidget(); -}; diff --git a/confui/ui_automations.cpp b/confui/ui_tab_automations.cpp index 94c1618..d1148d5 100644 --- a/confui/ui_automations.cpp +++ b/confui/ui_tab_automations.cpp @@ -2,10 +2,10 @@ #include <QWidget> #include <QLabel> -#include "ui_automations.h" +#include "ui_tab_automations.h" -CDAutomationsWidget::~CDAutomationsWidget() { } -CDAutomationsWidget::CDAutomationsWidget(CDMainWindow* main_window) : QWidget(main_window) { +CDAutomationsTabWidget::~CDAutomationsTabWidget() { } +CDAutomationsTabWidget::CDAutomationsTabWidget(CDMainWindow* main_window) : QWidget(main_window) { this->mainwindow = main_window; QVBoxLayout* main_layout = new QVBoxLayout; diff --git a/confui/ui_tab_automations.h b/confui/ui_tab_automations.h new file mode 100644 index 0000000..4cb63c8 --- /dev/null +++ b/confui/ui_tab_automations.h @@ -0,0 +1,15 @@ +#pragma once + +#include <QMainWindow> + +#include "mainwindow.h" + +class CDAutomationsTabWidget : public QWidget { + Q_OBJECT + +public: + CDMainWindow *mainwindow = nullptr; + + CDAutomationsTabWidget(CDMainWindow *main_window = nullptr); + virtual ~CDAutomationsTabWidget(); +}; diff --git a/confui/ui_tab_node_overview.cpp b/confui/ui_tab_node_overview.cpp new file mode 100644 index 0000000..4dd2007 --- /dev/null +++ b/confui/ui_tab_node_overview.cpp @@ -0,0 +1,55 @@ +#include <QWidget> +#include <QLabel> +#include <QVBoxLayout> + +#include "ui_tab_node_overview.h" +#include "ui_node.h" +#include "ui_automation.h" + +class CDAddAutomationWidget : public QWidget { +public: + CDAddAutomationWidget(QWidget* parent) : QWidget(parent) { + QHBoxLayout* main_layout = new QHBoxLayout; + QPushButton* button_add = new QPushButton("Add automation"); + + main_layout->addStretch(); + main_layout->addWidget(button_add); + main_layout->addStretch(); + + setLayout(main_layout); + } + + ~CDAddAutomationWidget() {} +}; + +CDNodeOverviewTabWidget::~CDNodeOverviewTabWidget() { } +CDNodeOverviewTabWidget::CDNodeOverviewTabWidget(CDMainWindow* main_window) : QWidget(main_window) { + this->mainwindow = main_window; + + QVBoxLayout* main_layout = new QVBoxLayout; + + const char* n_name = "berta"; + cd_s_node n = { + .address = { 0x00, 0xff, 0x21, 0x69, 0xf2, 0x31 }, + .name_len = strlen(n_name), + .name = n_name, + .light_on = true, + .provisioned = true, + }; + + cd_s_automation a = { + .type = CD_AUTOMATION_TYPE_TOGGLE, + .button = &n, + .light = &n, + }; + + CDNodeWidget* nd_w = new CDNodeWidget(&n, this); + CDAutomationWidget* au_w = new CDAutomationWidget(&a, this); + CDAddAutomationWidget* ad_w = new CDAddAutomationWidget(this); + + main_layout->addWidget(nd_w); + main_layout->addWidget(au_w); + main_layout->addWidget(ad_w); + + setLayout(main_layout); +} diff --git a/confui/ui_tab_node_overview.h b/confui/ui_tab_node_overview.h new file mode 100644 index 0000000..954237d --- /dev/null +++ b/confui/ui_tab_node_overview.h @@ -0,0 +1,15 @@ +#pragma once + +#include <QMainWindow> + +#include "mainwindow.h" + +class CDNodeOverviewTabWidget : public QWidget { + Q_OBJECT + +public: + CDMainWindow *mainwindow = nullptr; + + CDNodeOverviewTabWidget(CDMainWindow *main_window = nullptr); + virtual ~CDNodeOverviewTabWidget(); +}; |