diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index 803ff9a..679750a 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -75,6 +75,7 @@ private slots: void toggleExit(); void showRearCamBG(); void hideRearCamBG(); + void saveVolumeOnExit(); private: Ui::MainWindow* ui_; diff --git a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp index bf934ab..9d37d8d 100644 --- a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp @@ -52,6 +52,7 @@ private slots: void onUpdateScreenDPI(int value); void onShowBindings(); void onUpdateSystemVolume(int value); + void onUpdateSystemCapture(int value); private: void showEvent(QShowEvent* event); diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index b7fdd20..355b3c1 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace f1x { @@ -54,6 +55,28 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi QLabel { color: #ffffff; font-weight: bold;} \ "); + // restore audio vol on startup if file exists + QFileInfo volFile("/boot/crankshaft/volume"); + if (volFile.exists()) { + QFile volumeFile(QString("/boot/crankshaft/volume")); + volumeFile.open(QIODevice::ReadOnly); + QTextStream data_volume(&volumeFile); + QString linevolume = data_volume.readAll(); + volumeFile.close(); + system((std::string("/usr/local/bin/autoapp_helper setvolume ") + std::string(linevolume.toStdString())).c_str()); + } + + // restore audio vol on startup if file exists + QFileInfo capvolFile("/boot/crankshaft/capvolume"); + if (capvolFile.exists()) { + QFile capvolumeFile(QString("/boot/crankshaft/capvolume")); + capvolumeFile.open(QIODevice::ReadOnly); + QTextStream data_capvolume(&capvolumeFile); + QString linecapvolume = data_capvolume.readAll(); + capvolumeFile.close(); + system((std::string("/usr/local/bin/autoapp_helper setcapvolume ") + std::string(linecapvolume.toStdString())).c_str()); + } + // Set default font and size int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); @@ -107,7 +130,9 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::cameraStop); connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::cameraHide); connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::cameraControlHide); + connect(ui_->pushButtonShutdown, &QPushButton::clicked, this, &MainWindow::saveVolumeOnExit); connect(ui_->pushButtonShutdown, &QPushButton::clicked, this, &MainWindow::exit); + connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::saveVolumeOnExit); connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::reboot); connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &MainWindow::toggleExit); connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor); @@ -426,16 +451,93 @@ void f1x::openauto::autoapp::ui::MainWindow::hideRearCamBG() ui_->pushButtonRearcamBack->hide(); } +void f1x::openauto::autoapp::ui::MainWindow::saveVolumeOnExit() +{ + system("/usr/local/bin/autoapp_helper savevolume"); + system("/usr/local/bin/autoapp_helper savecapvolume"); +} + void f1x::openauto::autoapp::ui::MainWindow::showTime() { - + QTime time=QTime::currentTime(); QString time_text=time.toString("hh : mm : ss"); + if ((time.second() % 2) == 0) { + time_text[3] = ' '; + time_text[8] = ' '; + + QFileInfo phoneConnectedFile("/tmp/android_device"); + if (phoneConnectedFile.exists()) { + if (ui_->phoneConnected->isVisible() == false) { + ui_->phoneConnected->setText("Phone connected"); + ui_->phoneConnected->show(); + } + } else { + if (ui_->phoneConnected->isVisible() == true) { + ui_->phoneConnected->hide(); + } + } + + QFileInfo nightModeFile("/tmp/night_mode_enabled"); + this->nightModeEnabled = nightModeFile.exists(); + + if (this->cameraButtonForce) { + QFileInfo rearCamFile("/tmp/rearcam_enabled"); + this->rearCamEnabled = rearCamFile.exists(); + + QFileInfo dashCamRecordingFile("/tmp/dashcam_is_recording"); + this->dashCamRecording = dashCamRecordingFile.exists(); + + if (this->dashcamBGState) { + if (this->dashCamRecording) { + if (ui_->pushButtonRecord->isVisible() == true) { + ui_->pushButtonRecordActive->show(); + ui_->pushButtonRecord->hide(); + } + } else { + if (ui_->pushButtonRecordActive->isVisible() == true) { + ui_->pushButtonRecord->show(); + ui_->pushButtonRecordActive->hide(); + } + } + } + } + + if (this->nightModeEnabled) { + if (!this->DayNightModeState) { + this->DayNightModeState = true; + f1x::openauto::autoapp::ui::MainWindow::switchGuiToNight(); + } + } else { + if (this->DayNightModeState) { + this->DayNightModeState = false; + f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay(); + } + } + + if (this->cameraButtonForce) { + if (this->rearCamEnabled) { + if (!this->rearcamState) { + this->rearcamState = true; + f1x::openauto::autoapp::ui::MainWindow::cameraControlHide(); + f1x::openauto::autoapp::ui::MainWindow::showRearCamBG(); + f1x::openauto::autoapp::ui::MainWindow::showRearCam(); + } + } else { + if (this->rearcamState) { + this->rearcamState = false; + f1x::openauto::autoapp::ui::MainWindow::hideRearCamBG(); + f1x::openauto::autoapp::ui::MainWindow::hideRearCam(); + } + } + } + } + ui_->Digital_clock->setText(time_text); using namespace std::this_thread; // sleep_for using namespace std::chrono; // milliseconds - sleep_for(milliseconds(5)); + sleep_for(milliseconds(10)); /**if (configuration_->showClock()) { if (ui_->Digital_clock->isVisible() == true) { @@ -446,69 +548,4 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() ui_->Digital_clock->show(); } }**/ - - QFileInfo phoneConnectedFile("/tmp/android_device"); - if (phoneConnectedFile.exists()) { - if (ui_->phoneConnected->isVisible() == false) { - ui_->phoneConnected->setText("Phone connected"); - ui_->phoneConnected->show(); - } - } else { - if (ui_->phoneConnected->isVisible() == true) { - ui_->phoneConnected->hide(); - } - } - - QFileInfo nightModeFile("/tmp/night_mode_enabled"); - this->nightModeEnabled = nightModeFile.exists(); - - if (this->cameraButtonForce) { - QFileInfo rearCamFile("/tmp/rearcam_enabled"); - this->rearCamEnabled = rearCamFile.exists(); - - QFileInfo dashCamRecordingFile("/tmp/dashcam_is_recording"); - this->dashCamRecording = dashCamRecordingFile.exists(); - - if (this->dashcamBGState) { - if (this->dashCamRecording) { - if (ui_->pushButtonRecord->isVisible() == true) { - ui_->pushButtonRecordActive->show(); - ui_->pushButtonRecord->hide(); - } - } else { - if (ui_->pushButtonRecordActive->isVisible() == true) { - ui_->pushButtonRecord->show(); - ui_->pushButtonRecordActive->hide(); - } - } - } - } - - if (this->nightModeEnabled) { - if (!this->DayNightModeState) { - this->DayNightModeState = true; - f1x::openauto::autoapp::ui::MainWindow::switchGuiToNight(); - } - } else { - if (this->DayNightModeState) { - this->DayNightModeState = false; - f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay(); - } - } - if (this->cameraButtonForce) { - if (this->rearCamEnabled) { - if (!this->rearcamState) { - this->rearcamState = true; - f1x::openauto::autoapp::ui::MainWindow::cameraControlHide(); - f1x::openauto::autoapp::ui::MainWindow::showRearCamBG(); - f1x::openauto::autoapp::ui::MainWindow::showRearCam(); - } - } else { - if (this->rearcamState) { - this->rearcamState = false; - f1x::openauto::autoapp::ui::MainWindow::hideRearCamBG(); - f1x::openauto::autoapp::ui::MainWindow::hideRearCam(); - } - } - } } diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index d6a84e4..f656a9d 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -50,6 +50,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat connect(ui_->pushButtonResetToDefaults, &QPushButton::clicked, this, &SettingsWindow::onResetToDefaults); connect(ui_->pushButtonShowBindings, &QPushButton::clicked, this, &SettingsWindow::onShowBindings); connect(ui_->horizontalSliderSystemVolume, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemVolume); + connect(ui_->horizontalSliderSystemCapture, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemCapture); } SettingsWindow::~SettingsWindow() @@ -106,7 +107,8 @@ void SettingsWindow::onSave() configuration_->save(); - system((std::string("/usr/local/bin/oasysif setvolume ") + std::to_string(ui_->horizontalSliderSystemVolume->value())).c_str()); + system((std::string("/usr/local/bin/autoapp_helper setvolume ") + std::to_string(ui_->horizontalSliderSystemVolume->value())).c_str()); + system((std::string("/usr/local/bin/autoapp_helper setcapvolume ") + std::to_string(ui_->horizontalSliderSystemCapture->value())).c_str()); this->close(); } @@ -243,7 +245,11 @@ void SettingsWindow::onUpdateScreenDPI(int value) void SettingsWindow::onUpdateSystemVolume(int value) { ui_->labelSystemVolumeValue->setText(QString::number(value)); - //system((std::string("/usr/local/bin/oasysif setvolume ") + std::to_string(value)).c_str()); +} + +void SettingsWindow::onUpdateSystemCapture(int value) +{ + ui_->labelSystemCaptureValue->setText(QString::number(value)); } void SettingsWindow::loadSystemValues() @@ -274,7 +280,7 @@ void SettingsWindow::loadSystemValues() ui_->valueSystemBuildDate->setText(""); } - system("/usr/local/bin/oasysif getvolume"); + system("/usr/local/bin/autoapp_helper getvolume"); QFileInfo rFile("/tmp/return_value"); if (rFile.exists()) { QFile returnFile(QString("/tmp/return_value")); @@ -286,7 +292,18 @@ void SettingsWindow::loadSystemValues() ui_->horizontalSliderSystemVolume->setValue(currentvol.toInt()); } - system("/usr/local/bin/oasysif getfreemem"); + system("/usr/local/bin/autoapp_helper getcapvolume"); + if (rFile.exists()) { + QFile returnFile(QString("/tmp/return_value")); + returnFile.open(QIODevice::ReadOnly); + QTextStream data_return(&returnFile); + QString currentcapvol = data_return.readAll(); + returnFile.close(); + ui_->labelSystemCaptureValue->setText(currentcapvol); + ui_->horizontalSliderSystemCapture->setValue(currentcapvol.toInt()); + } + + system("/usr/local/bin/autoapp_helper getfreemem"); if (rFile.exists()) { QFile returnFile(QString("/tmp/return_value")); returnFile.open(QIODevice::ReadOnly); @@ -296,7 +313,7 @@ void SettingsWindow::loadSystemValues() ui_->valueSystemFreeMem->setText(currentmem); } - system("/usr/local/bin/oasysif getcpufreq"); + system("/usr/local/bin/autoapp_helper getcpufreq"); if (rFile.exists()) { QFile returnFile(QString("/tmp/return_value")); returnFile.open(QIODevice::ReadOnly); @@ -306,7 +323,7 @@ void SettingsWindow::loadSystemValues() ui_->valueSystemCPUFreq->setText(currentfreq); } - system("/usr/local/bin/oasysif getcputemp"); + system("/usr/local/bin/autoapp_helper getcputemp"); if (rFile.exists()) { QFile returnFile(QString("/tmp/return_value")); returnFile.open(QIODevice::ReadOnly); @@ -316,7 +333,7 @@ void SettingsWindow::loadSystemValues() ui_->valueSystemCPUTemp->setText(cputemp); } - system("/usr/local/bin/oasysif getshutdown"); + system("/usr/local/bin/autoapp_helper getshutdown"); if (rFile.exists()) { QFile returnFile(QString("/tmp/return_value")); returnFile.open(QIODevice::ReadOnly); @@ -326,7 +343,7 @@ void SettingsWindow::loadSystemValues() ui_->valueShutdownTimer->setText(shutdowntimer); } - system("/usr/local/bin/oasysif getdisconnect"); + system("/usr/local/bin/autoapp_helper getdisconnect"); if (rFile.exists()) { QFile returnFile(QString("/tmp/return_value")); returnFile.open(QIODevice::ReadOnly); diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index e3a54f2..bf1fedc 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -1120,7 +1120,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} - Master System Volume + Master System Playback Volume @@ -1156,12 +1156,58 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} - + 0 200 621 + 81 + + + + Master System Capture Volume + + + + + 570 + 40 + 41 + 31 + + + + 100 + + + + + + 20 + 40 + 531 + 32 + + + + QSlider::handle:horizontal { background: white; height: 32px; width: 52px; margin: 0 0;} +QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} + + + 100 + + + Qt::Horizontal + + + + + + + 0 + 300 + 621 91