Latest changes

This commit is contained in:
hawkeyexp 2018-07-09 00:07:37 +02:00
parent 9816a04557
commit 3514384742
5 changed files with 179 additions and 77 deletions

View File

@ -75,6 +75,7 @@ private slots:
void toggleExit();
void showRearCamBG();
void hideRearCamBG();
void saveVolumeOnExit();
private:
Ui::MainWindow* ui_;

View File

@ -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);

View File

@ -29,6 +29,7 @@
#include <QFont>
#include <thread>
#include <chrono>
#include <string>
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();
}
}
}
}

View File

@ -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);

View File

@ -1120,7 +1120,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</rect>
</property>
<property name="title">
<string>Master System Volume</string>
<string>Master System Playback Volume</string>
</property>
<widget class="QLabel" name="labelSystemVolumeValue">
<property name="geometry">
@ -1156,12 +1156,58 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="Timers">
<widget class="QGroupBox" name="groupBoxSystemCapture">
<property name="geometry">
<rect>
<x>0</x>
<y>200</y>
<width>621</width>
<height>81</height>
</rect>
</property>
<property name="title">
<string>Master System Capture Volume</string>
</property>
<widget class="QLabel" name="labelSystemCaptureValue">
<property name="geometry">
<rect>
<x>570</x>
<y>40</y>
<width>41</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>100</string>
</property>
</widget>
<widget class="QSlider" name="horizontalSliderSystemCapture">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>531</width>
<height>32</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QSlider::handle:horizontal { background: white; height: 32px; width: 52px; margin: 0 0;}
QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="Timers">
<property name="geometry">
<rect>
<x>0</x>
<y>300</y>
<width>621</width>
<height>91</height>
</rect>
</property>