diff --git a/LukHudX.pro b/LukHudX.pro index ed7356f..d29ca74 100644 --- a/LukHudX.pro +++ b/LukHudX.pro @@ -1,7 +1,7 @@ ###################################################################### # Automatically generated by qmake (3.1) Wed Feb 8 13:19:20 2023 ###################################################################### -DEFINES += __LART_T24__ +DEFINES += __LART_T14__ QT += core gui widgets serialport @@ -34,7 +34,8 @@ HEADERS += \ src/contamudancas.h \ src/mainwindow.h \ #Biz Logic - src/store.h + src/store.h \ + src/tfortwindow.h SOURCES += \ #Constants Macros Aux stuff @@ -45,9 +46,11 @@ SOURCES += \ src/main.cpp \ src/mainwindow.cpp \ #Biz Logic - src/store.cpp + src/store.cpp \ + src/tfortwindow.cpp -FORMS += src/mainwindow.ui +FORMS += src/mainwindow.ui \ + src/tfortwindow.ui TRANSLATIONS += src/LukHudX_1_en_US.ts diff --git a/src/main.cpp b/src/main.cpp index 41215a0..cf8530f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,14 @@ * IDK who developed the "default" main.cpp, but it was not me. * @b Don't touch this unless you know what you are doing, theres very "few" things to "properly" implement here. **/ +#ifdef __LART_T14__ +#include "src/tfortwindow.h" +#endif + +#ifdef __LART_T24__ #include "mainwindow.h" +#endif + #include #include #include @@ -25,9 +32,14 @@ int main(int argc, char *argv[]){ } } - MainWindow w; - w.show(); - - return a.exec(); + #ifdef __LART_T24__ + MainWindow w; + w.show(); + #endif + #ifdef __LART_T14__ + TfortWindow w; + w.show(); + #endif + return a.exec(); -} \ No newline at end of file +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fca41ee..f0f42d4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -40,22 +40,7 @@ MainWindow::MainWindow(QWidget *parent, QString serialDev) * The magic occurs in qmake through the DEFINES variable. * @see bson_var.h **/ - #ifdef __LART_T14__ - FLabel* OilPressure_Label = this->findChild("OilPressure_Label"); - FLabel* OilTemperature_Label = this->findChild("OilTemperature_Label"); - FLabel* DataLogger_Label = this->findChild("DataLogger_Label"); - FLabel* Lambda_Label = this->findChild("Lambda_Label"); - FLabel* TcSlip_Label = this->findChild("TcSlip_Label"); - FLabel* TcLaunch_Label = this->findChild("TcLaunch_Label"); - - connect(store_ref, &store::dataLoggerChanged, DataLogger_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); - connect(store_ref, &store::lambdaChanged, Lambda_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); - connect(store_ref, &store::tcSlipChanged, TcSlip_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); - connect(store_ref, &store::tcLaunchChanged, TcLaunch_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); - - connect(store_ref, &store::oilPressureChanged, OilPressure_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); - connect(store_ref, &store::oilTemperatureChanged, OilTemperature_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); - #endif + #ifdef __LART_T24__ FLabel* Soc_Label = this->findChild("Soc_Label"); FLabel* BatteryTemperature_Label = this->findChild("BatteryTemperature_Label"); diff --git a/src/tfortwindow.cpp b/src/tfortwindow.cpp new file mode 100644 index 0000000..8c621b0 --- /dev/null +++ b/src/tfortwindow.cpp @@ -0,0 +1,81 @@ +/** +* @file mainwindow.cpp +* @brief This file contains the logic for the MainWindow class +* @see mainwindow.h +* @see store.h +* @see flabel.h +* @author João Vieira +* This piece of software was developed for the T24e project belonging to the LART Team +**/ +#include "tfortwindow.h" +#include "./ui_tfortwindow.h" +#include "./store.h" +#include +#include +#include "flabel.h" + +static store* store_ref; +/** +* @brief Constructor for the MainWindow Class. +* @b Connects @b **most** variables from the store to the FLabels on the screen. +**/ +TfortWindow::TfortWindow(QWidget *parent, QString serialDev) + : QMainWindow(parent) + , ui(new Ui::TfortWindow){ + + store_ref = new store(serialDev); + + ui->setupUi(this); + //store_ref->setParent(this); + //store_ref->requestSlotAttachment(); + + FLabel* EngineTemperature_Label= this->findChild("EngineTemperature_Label"); + FLabel* BatteryVoltage_Label = this->findChild("BatteryVoltage_Label"); + FLabel* VehicleSpeed_Label = this->findChild("VehicleSpeed_Label"); + connect(store_ref, &store::engineTemperatureChanged, EngineTemperature_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); + connect(store_ref, &store::batteryVoltageChanged, BatteryVoltage_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); + connect(store_ref, &store::vehicleSpeedChanged, VehicleSpeed_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); + /** + * @brief bellow is the spaggeti code thats preprocessed to permit portable use between vehicles + * The magic occurs in qmake through the DEFINES variable. + * @see bson_var.h + **/ + #ifdef __LART_T14__ + FLabel* OilPressure_Label = this->findChild("OilPressure_Label"); + FLabel* OilTemperature_Label = this->findChild("OilTemperature_Label"); + FLabel* DataLogger_Label = this->findChild("DataLogger_Label"); + FLabel* Lambda_Label = this->findChild("Lambda_Label"); + FLabel* TcSlip_Label = this->findChild("TcSlip_Label"); + FLabel* TcLaunch_Label = this->findChild("TcLaunch_Label"); + + connect(store_ref, &store::dataLoggerChanged, DataLogger_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); + connect(store_ref, &store::lambdaChanged, Lambda_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); + connect(store_ref, &store::tcSlipChanged, TcSlip_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); + connect(store_ref, &store::tcLaunchChanged, TcLaunch_Label, (void (FLabel::*)(int, int))&FLabel::setVisual); + + connect(store_ref, &store::oilPressureChanged, OilPressure_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); + connect(store_ref, &store::oilTemperatureChanged, OilTemperature_Label, (void (FLabel::*)(float, float))&FLabel::setVisual); + #endif + + + +} + + +/** +* @brief A getter for a store pointer. use with caution, +* with great power comes great *frickery... This function is by reference and should be used for startup stuff +* @returns a pointer to the store object +**/ +store* TfortWindow::getStore(){ + return store_ref; +} +/** +* @brief Destructor for the MainWindow Class. +* @b Deletes the store object. which can cause some odd behaviour to happen +**/ +TfortWindow::~TfortWindow(){ + store_ref->~store(); + delete ui; +} + diff --git a/src/tfortwindow.h b/src/tfortwindow.h new file mode 100644 index 0000000..b1c49d4 --- /dev/null +++ b/src/tfortwindow.h @@ -0,0 +1,23 @@ +#ifndef TFORTWINDOW_H +#define TFORTWINDOW_H +#include +#include "store.h" + +QT_BEGIN_NAMESPACE +namespace Ui { class TfortWindow; } +QT_END_NAMESPACE + +class TfortWindow : public QMainWindow +{ + Q_OBJECT + +public: + TfortWindow(QWidget *parent = nullptr, QString serialDev=nullptr); + store* getStore(); + ~TfortWindow(); + +private: + + Ui::TfortWindow *ui; +}; +#endif // TFORTWINDOW_H diff --git a/src/mainwindow_old.ui b/src/tfortwindow.ui similarity index 95% rename from src/mainwindow_old.ui rename to src/tfortwindow.ui index b6ca52d..e6e84c6 100644 --- a/src/mainwindow_old.ui +++ b/src/tfortwindow.ui @@ -1,7 +1,7 @@ - MainWindow - + TfortWindow + 0 @@ -474,6 +474,14 @@ true + + + 0 + 0 + 367 + 245 + + 1 @@ -618,7 +626,7 @@ - + 6 @@ -639,6 +647,12 @@ + + + 0 + 0 + + 0 @@ -666,7 +680,16 @@ - + + + + 0 + 0 + 3 + 25 + + + @@ -680,6 +703,12 @@ QLabel
src/flabel.h
+ + TfortWindow + QWidget +
src/tfortwindow.h
+ 1 +