diff --git a/assets/bg_buttons.png b/assets/bg_buttons.png new file mode 100644 index 0000000..49cab1c Binary files /dev/null and b/assets/bg_buttons.png differ diff --git a/assets/bg_dashcam.png b/assets/bg_dashcam.png new file mode 100644 index 0000000..238d207 Binary files /dev/null and b/assets/bg_dashcam.png differ diff --git a/assets/record-hot.png b/assets/record-hot.png new file mode 100644 index 0000000..14a339d Binary files /dev/null and b/assets/record-hot.png differ diff --git a/assets/resources.qrc b/assets/resources.qrc index f9f36ed..48d1528 100644 --- a/assets/resources.qrc +++ b/assets/resources.qrc @@ -18,5 +18,10 @@ day-hot.png night-hot.png slider.png + bg_dashcam.png + bg_buttons.png + record-hot.png + stop-hot.png + save-hot.png diff --git a/assets/save-hot.png b/assets/save-hot.png new file mode 100644 index 0000000..a2382fc Binary files /dev/null and b/assets/save-hot.png differ diff --git a/assets/stop-hot.png b/assets/stop-hot.png new file mode 100644 index 0000000..cba734a Binary files /dev/null and b/assets/stop-hot.png differ diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index 4e4f969..97d5395 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -50,7 +50,11 @@ signals: void toggleCursor(); void TriggerScriptDay(); void TriggerScriptNight(); - void toggleCamera(); + void cameraShow(); + void cameraHide(); + void cameraStop(); + void cameraSave(); + void cameraRecord(); void openConnectDialog(); void showBrightnessSlider(); @@ -62,6 +66,8 @@ private slots: void switchGuiToDay(); void switchGuiToNight(); void showTime(); + void cameraControlShow(); + void cameraControlHide(); private: Ui::MainWindow* ui_; @@ -78,6 +84,9 @@ private: bool wallpaperNightFileExists = false; bool wallpaperDevFileExists = false; bool wallpaperDevNightFileExists = false; + + bool masterButtonBGState = false; + bool dashcamBGState = false; }; } diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index e1a62b1..002b7df 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -90,7 +90,13 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->setupUi(this); connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings); connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::exit); - connect(ui_->pushButtonToggleCamera, &QPushButton::clicked, this, &MainWindow::toggleCamera); + connect(ui_->pushButtonCameraShow, &QPushButton::clicked, this, &MainWindow::cameraShow); + connect(ui_->pushButtonCameraShow, &QPushButton::clicked, this, &MainWindow::cameraControlShow); + connect(ui_->pushButtonCameraHide, &QPushButton::clicked, this, &MainWindow::cameraHide); + connect(ui_->pushButtonCameraHide, &QPushButton::clicked, this, &MainWindow::cameraControlHide); + connect(ui_->pushButtonStop, &QPushButton::clicked, this, &MainWindow::cameraStop); + connect(ui_->pushButtonRecord, &QPushButton::clicked, this, &MainWindow::cameraRecord); + connect(ui_->pushButtonSave, &QPushButton::clicked, this, &MainWindow::cameraSave); connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor); connect(ui_->pushButtonDay, &QPushButton::clicked, this, &MainWindow::TriggerScriptDay); connect(ui_->pushButtonDay, &QPushButton::clicked, this, &MainWindow::switchGuiToDay); @@ -119,8 +125,19 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->pushButtonToggleCursor->hide(); } + QPixmap image; + image.load(":/bg_buttons.png"); + ui_->masterButtonBG->setPixmap(image); + ui_->pushButtonStop->hide(); + ui_->pushButtonRecord->hide(); + ui_->pushButtonSave->hide(); + if (!cameraButtonForce) { - ui_->pushButtonToggleCamera->hide(); + ui_->pushButtonCameraShow->hide(); + ui_->pushButtonCameraHide->hide(); + } else { + ui_->pushButtonCameraShow->show(); + ui_->pushButtonCameraHide->hide(); } if (!wifiButtonForce) { @@ -136,7 +153,7 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->horizontalSliderBrightness->hide(); if (!configuration->showClock()) { - ui_->Digital_clock->hide(); + ui_->Digital_clock->hide(); } // init bg's on startup @@ -185,6 +202,7 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBrightness_clicked() { this->brightnessSliderVisible = !this->brightnessSliderVisible; if (this->brightnessSliderVisible) { + f1x::openauto::autoapp::ui::MainWindow::cameraControlHide(); // Get the current brightness value this->brightnessFile = new QFile(this->brightnessFilename); if (this->brightnessFile->open(QIODevice::ReadOnly)) { @@ -261,6 +279,31 @@ void f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay() } } +void f1x::openauto::autoapp::ui::MainWindow::cameraControlHide() +{ + ui_->pushButtonCameraHide->hide(); + ui_->pushButtonStop->hide(); + ui_->pushButtonRecord->hide(); + ui_->pushButtonSave->hide(); + ui_->dashcamBG->hide(); + this->dashcamBGState = false; + ui_->pushButtonCameraShow->show(); +} + +void f1x::openauto::autoapp::ui::MainWindow::cameraControlShow() +{ + ui_->pushButtonCameraShow->hide(); + QPixmap image; + image.load(":/bg_dashcam.png"); + ui_->dashcamBG->setPixmap(image); + ui_->dashcamBG->show(); + ui_->pushButtonStop->show(); + ui_->pushButtonRecord->show(); + ui_->pushButtonSave->show(); + this->dashcamBGState = true; + ui_->pushButtonCameraHide->show(); +} + void f1x::openauto::autoapp::ui::MainWindow::showTime() { QTime time=QTime::currentTime(); diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index 8daa900..534a304 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -14,6 +14,16 @@ MainWindow + + + + 20 + 20 + 640 + 440 + + + @@ -43,12 +53,6 @@ 64 - - false - - - false - true @@ -101,12 +105,6 @@ 64 - - false - - - false - true @@ -136,12 +134,6 @@ 64 - - false - - - false - true @@ -171,12 +163,6 @@ 64 - - false - - - false - true @@ -200,12 +186,6 @@ 64 - - false - - - false - true @@ -235,7 +215,7 @@ Qt::Horizontal - + 30 @@ -254,8 +234,28 @@ 64 - - false + + true + + + + + + 30 + 314 + 64 + 64 + + + + + :/camera-hot.png:/camera-hot.png + + + + 64 + 64 + true @@ -280,8 +280,84 @@ 64 - - false + + true + + + + + + 130 + 20 + 640 + 440 + + + + + + + 146 + 384 + 64 + 64 + + + + + :/stop-hot.png:/stop-hot.png + + + + 64 + 64 + + + + true + + + + + + 216 + 384 + 64 + 64 + + + + + :/record-hot.png:/record-hot.png + + + + 64 + 64 + + + + true + + + + + + 690 + 384 + 64 + 64 + + + + + :/save-hot.png:/save-hot.png + + + + 64 + 64 + true diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index 5f8cc2d..0c4b5e7 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -110,10 +110,46 @@ int main(int argc, char* argv[]) qApplication.setOverrideCursor(cursor); }); - QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCamera, [&qApplication]() { + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraHide, [&qApplication]() { #ifdef RASPBERRYPI3 - system("/opt/crankshaft/toggle_rpicam.sh &"); - OPENAUTO_LOG(info) << "[CS] Ran RPiCam script."; + system("/opt/crankshaft/cameracontrol.py Background &"); + OPENAUTO_LOG(info) << "[CS] Ran RPiCameraControl script."; +#else + OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Cam script."; +#endif + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraShow, [&qApplication]() { +#ifdef RASPBERRYPI3 + system("/opt/crankshaft/cameracontrol.py Foreground &"); + OPENAUTO_LOG(info) << "[CS] Ran RPiCameraControl script."; +#else + OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Cam script."; +#endif + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraRecord, [&qApplication]() { +#ifdef RASPBERRYPI3 + system("/opt/crankshaft/cameracontrol.py Record &"); + OPENAUTO_LOG(info) << "[CS] Ran RPiCameraControl script."; +#else + OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Cam script."; +#endif + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraStop, [&qApplication]() { +#ifdef RASPBERRYPI3 + system("/opt/crankshaft/cameracontrol.py Stop &"); + OPENAUTO_LOG(info) << "[CS] Ran RPiCameraControl script."; +#else + OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Cam script."; +#endif + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraSave, [&qApplication]() { +#ifdef RASPBERRYPI3 + system("/opt/crankshaft/cameracontrol.py Save &"); + OPENAUTO_LOG(info) << "[CS] Ran RPiCameraControl script."; #else OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Cam script."; #endif