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 toggleExit();
void showRearCamBG(); void showRearCamBG();
void hideRearCamBG(); void hideRearCamBG();
void saveVolumeOnExit();
private: private:
Ui::MainWindow* ui_; Ui::MainWindow* ui_;

View File

@ -52,6 +52,7 @@ private slots:
void onUpdateScreenDPI(int value); void onUpdateScreenDPI(int value);
void onShowBindings(); void onShowBindings();
void onUpdateSystemVolume(int value); void onUpdateSystemVolume(int value);
void onUpdateSystemCapture(int value);
private: private:
void showEvent(QShowEvent* event); void showEvent(QShowEvent* event);

View File

@ -29,6 +29,7 @@
#include <QFont> #include <QFont>
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include <string>
namespace f1x namespace f1x
{ {
@ -54,6 +55,28 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi
QLabel { color: #ffffff; font-weight: bold;} \ 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 // Set default font and size
int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf");
QString family = QFontDatabase::applicationFontFamilies(id).at(0); 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::cameraStop);
connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::cameraHide); connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::cameraHide);
connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::cameraControlHide); 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_->pushButtonShutdown, &QPushButton::clicked, this, &MainWindow::exit);
connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::saveVolumeOnExit);
connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::reboot); connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::reboot);
connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &MainWindow::toggleExit); connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &MainWindow::toggleExit);
connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor); connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor);
@ -426,26 +451,20 @@ void f1x::openauto::autoapp::ui::MainWindow::hideRearCamBG()
ui_->pushButtonRearcamBack->hide(); 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() void f1x::openauto::autoapp::ui::MainWindow::showTime()
{ {
QTime time=QTime::currentTime(); QTime time=QTime::currentTime();
QString time_text=time.toString("hh : mm : ss"); QString time_text=time.toString("hh : mm : ss");
ui_->Digital_clock->setText(time_text); if ((time.second() % 2) == 0) {
time_text[3] = ' ';
using namespace std::this_thread; // sleep_for time_text[8] = ' ';
using namespace std::chrono; // milliseconds
sleep_for(milliseconds(5));
/**if (configuration_->showClock()) {
if (ui_->Digital_clock->isVisible() == true) {
ui_->Digital_clock->hide();
}
} else {
if (ui_->Digital_clock->isVisible() == false) {
ui_->Digital_clock->show();
}
}**/
QFileInfo phoneConnectedFile("/tmp/android_device"); QFileInfo phoneConnectedFile("/tmp/android_device");
if (phoneConnectedFile.exists()) { if (phoneConnectedFile.exists()) {
@ -495,6 +514,7 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime()
f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay(); f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay();
} }
} }
if (this->cameraButtonForce) { if (this->cameraButtonForce) {
if (this->rearCamEnabled) { if (this->rearCamEnabled) {
if (!this->rearcamState) { if (!this->rearcamState) {
@ -512,3 +532,20 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime()
} }
} }
} }
ui_->Digital_clock->setText(time_text);
using namespace std::this_thread; // sleep_for
using namespace std::chrono; // milliseconds
sleep_for(milliseconds(10));
/**if (configuration_->showClock()) {
if (ui_->Digital_clock->isVisible() == true) {
ui_->Digital_clock->hide();
}
} else {
if (ui_->Digital_clock->isVisible() == false) {
ui_->Digital_clock->show();
}
}**/
}

View File

@ -50,6 +50,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat
connect(ui_->pushButtonResetToDefaults, &QPushButton::clicked, this, &SettingsWindow::onResetToDefaults); connect(ui_->pushButtonResetToDefaults, &QPushButton::clicked, this, &SettingsWindow::onResetToDefaults);
connect(ui_->pushButtonShowBindings, &QPushButton::clicked, this, &SettingsWindow::onShowBindings); connect(ui_->pushButtonShowBindings, &QPushButton::clicked, this, &SettingsWindow::onShowBindings);
connect(ui_->horizontalSliderSystemVolume, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemVolume); connect(ui_->horizontalSliderSystemVolume, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemVolume);
connect(ui_->horizontalSliderSystemCapture, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemCapture);
} }
SettingsWindow::~SettingsWindow() SettingsWindow::~SettingsWindow()
@ -106,7 +107,8 @@ void SettingsWindow::onSave()
configuration_->save(); 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(); this->close();
} }
@ -243,7 +245,11 @@ void SettingsWindow::onUpdateScreenDPI(int value)
void SettingsWindow::onUpdateSystemVolume(int value) void SettingsWindow::onUpdateSystemVolume(int value)
{ {
ui_->labelSystemVolumeValue->setText(QString::number(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() void SettingsWindow::loadSystemValues()
@ -274,7 +280,7 @@ void SettingsWindow::loadSystemValues()
ui_->valueSystemBuildDate->setText(""); ui_->valueSystemBuildDate->setText("");
} }
system("/usr/local/bin/oasysif getvolume"); system("/usr/local/bin/autoapp_helper getvolume");
QFileInfo rFile("/tmp/return_value"); QFileInfo rFile("/tmp/return_value");
if (rFile.exists()) { if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile returnFile(QString("/tmp/return_value"));
@ -286,7 +292,18 @@ void SettingsWindow::loadSystemValues()
ui_->horizontalSliderSystemVolume->setValue(currentvol.toInt()); 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()) { if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly); returnFile.open(QIODevice::ReadOnly);
@ -296,7 +313,7 @@ void SettingsWindow::loadSystemValues()
ui_->valueSystemFreeMem->setText(currentmem); ui_->valueSystemFreeMem->setText(currentmem);
} }
system("/usr/local/bin/oasysif getcpufreq"); system("/usr/local/bin/autoapp_helper getcpufreq");
if (rFile.exists()) { if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly); returnFile.open(QIODevice::ReadOnly);
@ -306,7 +323,7 @@ void SettingsWindow::loadSystemValues()
ui_->valueSystemCPUFreq->setText(currentfreq); ui_->valueSystemCPUFreq->setText(currentfreq);
} }
system("/usr/local/bin/oasysif getcputemp"); system("/usr/local/bin/autoapp_helper getcputemp");
if (rFile.exists()) { if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly); returnFile.open(QIODevice::ReadOnly);
@ -316,7 +333,7 @@ void SettingsWindow::loadSystemValues()
ui_->valueSystemCPUTemp->setText(cputemp); ui_->valueSystemCPUTemp->setText(cputemp);
} }
system("/usr/local/bin/oasysif getshutdown"); system("/usr/local/bin/autoapp_helper getshutdown");
if (rFile.exists()) { if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly); returnFile.open(QIODevice::ReadOnly);
@ -326,7 +343,7 @@ void SettingsWindow::loadSystemValues()
ui_->valueShutdownTimer->setText(shutdowntimer); ui_->valueShutdownTimer->setText(shutdowntimer);
} }
system("/usr/local/bin/oasysif getdisconnect"); system("/usr/local/bin/autoapp_helper getdisconnect");
if (rFile.exists()) { if (rFile.exists()) {
QFile returnFile(QString("/tmp/return_value")); QFile returnFile(QString("/tmp/return_value"));
returnFile.open(QIODevice::ReadOnly); returnFile.open(QIODevice::ReadOnly);

View File

@ -1120,7 +1120,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>Master System Volume</string> <string>Master System Playback Volume</string>
</property> </property>
<widget class="QLabel" name="labelSystemVolumeValue"> <widget class="QLabel" name="labelSystemVolumeValue">
<property name="geometry"> <property name="geometry">
@ -1156,12 +1156,58 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;}</string>
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QGroupBox" name="Timers"> <widget class="QGroupBox" name="groupBoxSystemCapture">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>200</y> <y>200</y>
<width>621</width> <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> <height>91</height>
</rect> </rect>
</property> </property>