From 52571310d06e2c20d2959c7f6ca2d9e6a1cf281c Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 12 Dec 2022 12:13:12 +0100 Subject: allow manual serial port specification --- confui/confui.pro | 3 ++- confui/main.cpp | 7 +++---- confui/main.h | 7 +++++++ confui/mainwindow.cpp | 7 +++++++ 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 confui/main.h diff --git a/confui/confui.pro b/confui/confui.pro index 7dcd66c..237f22d 100644 --- a/confui/confui.pro +++ b/confui/confui.pro @@ -26,7 +26,8 @@ HEADERS += \ ../shared/bin.h \ ../shared/protocol.h \ ../shared/serial_parse.h \ - ../shared/consts.h + ../shared/consts.h \ + main.h CONFIG += c++17 CONFIG += force_debug_info diff --git a/confui/main.cpp b/confui/main.cpp index 6c3ab56..52c54d8 100644 --- a/confui/main.cpp +++ b/confui/main.cpp @@ -1,10 +1,9 @@ +#include "main.h" #include "mainwindow.h" -#include - int main(int argc, char *argv[]) { - QApplication a(argc, argv); + g_cd_app = new QApplication(argc, argv); CDMainWindow w; w.show(); - return a.exec(); + return g_cd_app->exec(); } diff --git a/confui/main.h b/confui/main.h new file mode 100644 index 0000000..10e9da6 --- /dev/null +++ b/confui/main.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +extern QApplication* g_cd_app; +int main(int argc, char *argv[]); + diff --git a/confui/mainwindow.cpp b/confui/mainwindow.cpp index b0a1857..1fd34c4 100644 --- a/confui/mainwindow.cpp +++ b/confui/mainwindow.cpp @@ -1,14 +1,17 @@ #include #include #include +#include #include "mainwindow.h" #include "ui_tab_automations.h" #include "ui_tab_node_overview.h" #include "serial.h" +#include "main.h" CDMeshConnector *g_cd_mesh_connector = nullptr; CDSerialConnector *g_cd_serial = nullptr; +QApplication* g_cd_app = nullptr; CDMainWindow::~CDMainWindow() { delete this->mesh_connector; } @@ -28,6 +31,10 @@ CDMainWindow::CDMainWindow(QWidget *parent) : QMainWindow(parent) { tab_bar_widget->addTab(this->node_overview_tab, "node overview"); tab_bar_widget->addTab(this->automations_tab, "automations"); + // manually connect to serial port + if (g_cd_app->arguments().length() > 1 && g_cd_app->arguments().at(1).length() > 0) + g_cd_serial->connect(g_cd_app->arguments().at(1).toStdString()); + setMenuBar(menu_bar); setCentralWidget(tab_bar_widget); update(); -- cgit v1.2.3