From b6c705544b25d714c63d2b56dc1542889fd84b96 Mon Sep 17 00:00:00 2001 From: hawkeyexp Date: Wed, 16 Jan 2019 20:45:41 +0100 Subject: [PATCH] latest dev --- .../autoapp/Configuration/Configuration.hpp | 16 + .../autoapp/Configuration/IConfiguration.hpp | 8 + .../f1x/openauto/autoapp/UI/MainWindow.hpp | 48 + .../openauto/autoapp/UI/SettingsWindow.hpp | 8 +- .../f1x/openauto/autoapp/UI/WarningDialog.hpp | 1 + src/autoapp/App.cpp | 19 +- src/autoapp/Configuration/Configuration.cpp | 155 +- src/autoapp/Service/AndroidAutoEntity.cpp | 16 +- src/autoapp/UI/ConnectDialog.cpp | 14 + src/autoapp/UI/MainWindow.cpp | 230 ++- src/autoapp/UI/SettingsWindow.cpp | 538 +++--- src/autoapp/UI/UpdateDialog.cpp | 15 +- src/autoapp/UI/mainwindow.ui | 553 +++++- src/autoapp/UI/settingswindow.ui | 1555 +++++++++++------ src/autoapp/UI/warningdialog.ui | 56 +- src/autoapp/autoapp.cpp | 103 +- 16 files changed, 2370 insertions(+), 965 deletions(-) diff --git a/include/f1x/openauto/autoapp/Configuration/Configuration.hpp b/include/f1x/openauto/autoapp/Configuration/Configuration.hpp index 8d4b8f4..300ab2c 100644 --- a/include/f1x/openauto/autoapp/Configuration/Configuration.hpp +++ b/include/f1x/openauto/autoapp/Configuration/Configuration.hpp @@ -20,6 +20,10 @@ #include #include +#include +#include +#include +#include namespace f1x { @@ -64,6 +68,8 @@ public: bool hideBrightnessControl() const override; void showNetworkinfo(bool value) override; bool showNetworkinfo() const override; + void hideWarning(bool value) override; + bool hideWarning() const override; std::string getMp3MasterPath() const override; void setMp3MasterPath(const std::string& value) override; @@ -76,6 +82,10 @@ public: bool showAutoPlay() const override; void showAutoPlay(bool value) override; + QString getCSValue(QString searchString) const override; + QString readFileContent(QString fileName) const override; + QString getParamFromFile(QString fileName, QString searchString) const override; + aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override; void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) override; aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override; @@ -89,6 +99,8 @@ public: bool getTouchscreenEnabled() const override; void setTouchscreenEnabled(bool value) override; + bool playerButtonControl() const override; + void playerButtonControl(bool value) override; ButtonCodes getButtonCodes() const override; void setButtonCodes(const ButtonCodes& value) override; @@ -121,6 +133,7 @@ private: bool showCursor_; bool hideBrightnessControl_; bool showNetworkinfo_; + bool hideWarning_; std::string mp3MasterPath_; std::string mp3SubFolder_; int32_t mp3Track_; @@ -133,6 +146,7 @@ private: int32_t omxLayerIndex_; QRect videoMargins_; bool enableTouchscreen_; + bool enablePlayerControl_; ButtonCodes buttonCodes_; BluetoothAdapterType bluetoothAdapterType_; std::string bluetoothRemoteAdapterAddress_; @@ -153,6 +167,7 @@ private: static const std::string cGeneralShowCursorKey; static const std::string cGeneralHideBrightnessControlKey; static const std::string cGeneralShowNetworkinfoKey; + static const std::string cGeneralHideWarningKey; static const std::string cGeneralHandednessOfTrafficTypeKey; @@ -177,6 +192,7 @@ private: static const std::string cBluetoothRemoteAdapterAddressKey; static const std::string cInputEnableTouchscreenKey; + static const std::string cInputEnablePlayerControlKey; static const std::string cInputPlayButtonKey; static const std::string cInputPauseButtonKey; static const std::string cInputTogglePlayButtonKey; diff --git a/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp b/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp index a1e6521..42d6ffe 100644 --- a/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp +++ b/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp @@ -72,6 +72,8 @@ public: virtual bool hideBrightnessControl() const = 0; virtual void showNetworkinfo(bool value) = 0; virtual bool showNetworkinfo() const = 0; + virtual void hideWarning(bool value) = 0; + virtual bool hideWarning() const = 0; virtual std::string getMp3MasterPath() const = 0; virtual void setMp3MasterPath(const std::string& value) = 0; @@ -84,6 +86,10 @@ public: virtual bool showAutoPlay() const = 0; virtual void showAutoPlay(bool value) = 0; + virtual QString getCSValue(QString searchString) const = 0; + virtual QString readFileContent(QString fileName) const = 0; + virtual QString getParamFromFile(QString fileName, QString searchString) const = 0; + virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0; virtual void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) = 0; virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0; @@ -97,6 +103,8 @@ public: virtual bool getTouchscreenEnabled() const = 0; virtual void setTouchscreenEnabled(bool value) = 0; + virtual bool playerButtonControl() const = 0; + virtual void playerButtonControl(bool value) = 0; virtual ButtonCodes getButtonCodes() const = 0; virtual void setButtonCodes(const ButtonCodes& value) = 0; diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index a521377..23e0a5e 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -42,6 +42,10 @@ #include #include +#include + +#include +//#include namespace Ui { @@ -79,6 +83,12 @@ signals: void cameraStop(); void cameraSave(); void cameraRecord(); + void cameraPosYUp(); + void cameraPosYDown(); + void cameraZoomPlus(); + void cameraZoomMinus(); + void cameraFlipX(); + void cameraFlipY(); void openConnectDialog(); void openWifiDialog(); void openUpdateDialog(); @@ -89,6 +99,7 @@ signals: void hideRearCam(); void TriggerAppStart(); void TriggerAppStop(); + void CloseAllDialogs(); private slots: void on_horizontalSliderBrightness_valueChanged(int value); @@ -148,6 +159,9 @@ private slots: void resetRetryUSBMessage(); void updateNetworkInfo(); bool check_file_exist(const char *filename); + void KeyPress(QString key); + + void hostModeStateChanged(QBluetoothLocalDevice::HostMode); private: Ui::MainWindow* ui_; @@ -250,6 +264,40 @@ private: bool udevupdate = false; bool openautoupdate = false; bool systemupdate = false; + + int camera_ycorection; + int camera_zoom; + + QBluetoothLocalDevice *localDevice; + +protected: + void keyPressEvent(QKeyEvent *event) override + { + if (event->key() == Qt::Key_C) { + MainWindow::KeyPress("C"); + } + if (event->key() == Qt::Key_X) { + MainWindow::KeyPress("X"); + } + if (event->key() == Qt::Key_V) { + MainWindow::KeyPress("V"); + } + if (event->key() == Qt::Key_N) { + MainWindow::KeyPress("N"); + } + if (event->key() == Qt::Key_B) { + MainWindow::KeyPress("B"); + } + if (event->key() == Qt::Key_H) { + MainWindow::KeyPress("H"); + } + if (event->key() == Qt::Key_A) { + MainWindow::KeyPress("A"); + } + if (event->key() == Qt::Key_L) { + MainWindow::KeyPress("L"); + } + } }; } diff --git a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp index bf36071..2c431d3 100644 --- a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp @@ -22,6 +22,7 @@ #include #include #include +#include class QCheckBox; class QTimer; @@ -77,8 +78,10 @@ private slots: void onUpdateBrightness5(int value); void on_pushButtonNetwork0_clicked(); void on_pushButtonNetwork1_clicked(); + void updateSystemInfo(); + void updateInfo(); -private slots: +public slots: void show_tab1(); void show_tab2(); void show_tab3(); @@ -99,9 +102,6 @@ private: Ui::SettingsWindow* ui_; configuration::IConfiguration::Pointer configuration_; - - QString hotspotssid; - QString wifissid; }; } diff --git a/include/f1x/openauto/autoapp/UI/WarningDialog.hpp b/include/f1x/openauto/autoapp/UI/WarningDialog.hpp index 5190f96..7bbe432 100644 --- a/include/f1x/openauto/autoapp/UI/WarningDialog.hpp +++ b/include/f1x/openauto/autoapp/UI/WarningDialog.hpp @@ -21,6 +21,7 @@ public: explicit WarningDialog(QWidget *parent = nullptr); ~WarningDialog() override; +private: Ui::WarningDialog* ui_; private slots: diff --git a/src/autoapp/App.cpp b/src/autoapp/App.cpp index 78a7e20..a765ee3 100644 --- a/src/autoapp/App.cpp +++ b/src/autoapp/App.cpp @@ -110,14 +110,14 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle) { // ignore autostart if exit to csng was used if (!disableAutostartEntity) { - OPENAUTO_LOG(info) << "[App] Autostart Entity allowed - let's go."; + OPENAUTO_LOG(info) << "[App] Start Android Auto allowed - let's go."; connectedAccessoriesEnumerator_->cancel(); auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle)); androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice)); androidAutoEntity_->start(*this); } else { - OPENAUTO_LOG(info) << "[App] Autostart Entity not allowed - skip."; + OPENAUTO_LOG(info) << "[App] Start Android Auto not allowed - skip."; } } catch(const aasdk::error::Error& error) @@ -157,21 +157,12 @@ void App::onAndroidAutoQuit() strand_.dispatch([this, self = this->shared_from_this()]() { OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit."; - try { - androidAutoEntity_->stop(); - androidAutoEntity_.reset(); - } catch (...) { - OPENAUTO_LOG(info) << "[App] Exception in onAndroidAutoQuit."; - } + androidAutoEntity_->stop(); + androidAutoEntity_.reset(); if(!isStopped_) { - try { - this->waitForDevice(); - } catch (...) { - OPENAUTO_LOG(info) << "[App] Exception in onAndroidAutoQuit - waitfordevice."; - } - + this->waitForDevice(); } }); } diff --git a/src/autoapp/Configuration/Configuration.cpp b/src/autoapp/Configuration/Configuration.cpp index 8496c44..52b86e4 100644 --- a/src/autoapp/Configuration/Configuration.cpp +++ b/src/autoapp/Configuration/Configuration.cpp @@ -42,6 +42,7 @@ const std::string Configuration::cGeneralShowLuxKey = "General.ShowLux"; const std::string Configuration::cGeneralShowCursorKey = "General.ShowCursor"; const std::string Configuration::cGeneralHideBrightnessControlKey = "General.HideBrightnessControl"; const std::string Configuration::cGeneralShowNetworkinfoKey = "General.ShowNetworkinfo"; +const std::string Configuration::cGeneralHideWarningKey = "General.HideWarning"; const std::string Configuration::cGeneralHandednessOfTrafficTypeKey = "General.HandednessOfTrafficType"; @@ -66,6 +67,7 @@ const std::string Configuration::cBluetoothAdapterTypeKey = "Bluetooth.AdapterTy const std::string Configuration::cBluetoothRemoteAdapterAddressKey = "Bluetooth.RemoteAdapterAddress"; const std::string Configuration::cInputEnableTouchscreenKey = "Input.EnableTouchscreen"; +const std::string Configuration::cInputEnablePlayerControlKey = "Input.EnablePlayerControl"; const std::string Configuration::cInputPlayButtonKey = "Input.PlayButton"; const std::string Configuration::cInputPauseButtonKey = "Input.PauseButton"; const std::string Configuration::cInputTogglePlayButtonKey = "Input.TogglePlayButton"; @@ -107,6 +109,7 @@ void Configuration::load() showLux_ = iniConfig.get(cGeneralShowLuxKey, false); showCursor_ = iniConfig.get(cGeneralShowCursorKey, false); hideBrightnessControl_ = iniConfig.get(cGeneralHideBrightnessControlKey, false); + hideWarning_ = iniConfig.get(cGeneralHideWarningKey, false); showNetworkinfo_ = iniConfig.get(cGeneralShowNetworkinfoKey, false); mp3MasterPath_ = iniConfig.get(cGeneralMp3MasterPathKey, "/media/MYMEDIA"); mp3SubFolder_ = iniConfig.get(cGeneralMp3SubFolderKey, "/"); @@ -119,12 +122,13 @@ void Configuration::load() videoResolution_ = static_cast(iniConfig.get(cVideoResolutionKey, aasdk::proto::enums::VideoResolution::_480p)); - screenDPI_ = iniConfig.get(cVideoScreenDPIKey, 100); + screenDPI_ = iniConfig.get(cVideoScreenDPIKey, 140); omxLayerIndex_ = iniConfig.get(cVideoOMXLayerIndexKey, 1); videoMargins_ = QRect(0, 0, iniConfig.get(cVideoMarginWidth, 0), iniConfig.get(cVideoMarginHeight, 0)); enableTouchscreen_ = iniConfig.get(cInputEnableTouchscreenKey, true); + enablePlayerControl_ = iniConfig.get(cInputEnablePlayerControlKey, false); this->readButtonCodes(iniConfig); bluetoothAdapterType_ = static_cast(iniConfig.get(cBluetoothAdapterTypeKey, @@ -156,6 +160,7 @@ void Configuration::reset() showLux_ = false; showCursor_ = false; hideBrightnessControl_ = false; + hideWarning_ = false; showNetworkinfo_ = false; mp3MasterPath_ = "/media/MYMEDIA"; mp3SubFolder_ = "/"; @@ -164,10 +169,11 @@ void Configuration::reset() showAutoPlay_ = false; videoFPS_ = aasdk::proto::enums::VideoFPS::_30; videoResolution_ = aasdk::proto::enums::VideoResolution::_480p; - screenDPI_ = 100; + screenDPI_ = 140; omxLayerIndex_ = 1; videoMargins_ = QRect(0, 0, 0, 0); enableTouchscreen_ = true; + enablePlayerControl_ = false; buttonCodes_.clear(); bluetoothAdapterType_ = BluetoothAdapterType::NONE; bluetoothRemoteAdapterAddress_ = ""; @@ -190,6 +196,7 @@ void Configuration::save() iniConfig.put(cGeneralShowLuxKey, showLux_); iniConfig.put(cGeneralShowCursorKey, showCursor_); iniConfig.put(cGeneralHideBrightnessControlKey, hideBrightnessControl_); + iniConfig.put(cGeneralHideWarningKey, hideWarning_); iniConfig.put(cGeneralShowNetworkinfoKey, showNetworkinfo_); iniConfig.put(cGeneralMp3MasterPathKey, mp3MasterPath_); iniConfig.put(cGeneralMp3SubFolderKey, mp3SubFolder_); @@ -205,6 +212,7 @@ void Configuration::save() iniConfig.put(cVideoMarginHeight, videoMargins_.height()); iniConfig.put(cInputEnableTouchscreenKey, enableTouchscreen_); + iniConfig.put(cInputEnablePlayerControlKey, enablePlayerControl_); this->writeButtonCodes(iniConfig); iniConfig.put(cBluetoothAdapterTypeKey, static_cast(bluetoothAdapterType_)); @@ -335,6 +343,16 @@ bool Configuration::hideBrightnessControl() const return hideBrightnessControl_; } +void Configuration::hideWarning(bool value) +{ + hideWarning_ = value; +} + +bool Configuration::hideWarning() const +{ + return hideWarning_; +} + void Configuration::showNetworkinfo(bool value) { showNetworkinfo_ = value; @@ -455,6 +473,16 @@ void Configuration::setTouchscreenEnabled(bool value) enableTouchscreen_ = value; } +bool Configuration::playerButtonControl() const +{ + return enablePlayerControl_; +} + +void Configuration::playerButtonControl(bool value) +{ + enablePlayerControl_ = value; +} + Configuration::ButtonCodes Configuration::getButtonCodes() const { return buttonCodes_; @@ -515,6 +543,129 @@ void Configuration::setAudioOutputBackendType(AudioOutputBackendType value) audioOutputBackendType_ = value; } +QString Configuration::getCSValue(QString searchString) const +{ + using namespace std; + ifstream inFile; + ifstream inFile2; + string line; + searchString = searchString.append("="); + inFile.open("/boot/crankshaft/crankshaft_env.sh"); + inFile2.open("/opt/crankshaft/crankshaft_default_env.sh"); + + size_t pos; + + if(inFile) { + while(inFile.good()) + { + getline(inFile,line); // get line from file + if (line[0] != '#') { + pos=line.find(searchString.toStdString()); // search + if(pos!=std::string::npos) // string::npos is returned if string is not found + { + int equalPosition = line.find("="); + QString value = line.substr(equalPosition + 1).c_str(); + value.replace("\"",""); + OPENAUTO_LOG(info) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString(); + return value; + } + } + } + OPENAUTO_LOG(warning) << "[Configuration] unable to find cs param: " << searchString.toStdString(); + OPENAUTO_LOG(warning) << "[Configuration] Fallback to /opt/crankshaft/crankshaft_default_env.sh)"; + while(inFile2.good()) + { + getline(inFile2,line); // get line from file + if (line[0] != '#') { + pos=line.find(searchString.toStdString()); // search + if(pos!=std::string::npos) // string::npos is returned if string is not found + { + int equalPosition = line.find("="); + QString value = line.substr(equalPosition + 1).c_str(); + value.replace("\"",""); + OPENAUTO_LOG(info) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString(); + return value; + } + } + } + return ""; + } else { + OPENAUTO_LOG(warning) << "[Configuration] unable to open cs param file (/boot/crankshaft/crankshaft_env.sh)"; + OPENAUTO_LOG(warning) << "[Configuration] Fallback to /opt/crankshaft/crankshaft_default_env.sh)"; + + while(inFile2.good()) + { + getline(inFile2,line); // get line from file + if (line[0] != '#') { + pos=line.find(searchString.toStdString()); // search + if(pos!=std::string::npos) // string::npos is returned if string is not found + { + int equalPosition = line.find("="); + QString value = line.substr(equalPosition + 1).c_str(); + value.replace("\"",""); + OPENAUTO_LOG(info) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString(); + return value; + } + } + } + return ""; + } +} + +QString Configuration::getParamFromFile(QString fileName, QString searchString) const +{ + OPENAUTO_LOG(info) << "[Configuration] Request param from file: " << fileName.toStdString() << " param: " << searchString.toStdString(); + using namespace std; + ifstream inFile; + string line; + if (!searchString.contains("dtoverlay")) { + searchString = searchString.append("="); + } + inFile.open(fileName.toStdString()); + + size_t pos; + + if(inFile) { + while(inFile.good()) + { + getline(inFile,line); // get line from file + if (line[0] != '#') { + pos=line.find(searchString.toStdString()); // search + if(pos!=std::string::npos) // string::npos is returned if string is not found + { + int equalPosition = line.find("="); + QString value = line.substr(equalPosition + 1).c_str(); + value.replace("\"",""); + OPENAUTO_LOG(info) << "[Configuration] Param from file: " << fileName.toStdString() << " found: " << searchString.toStdString() << " Value:" << value.toStdString(); + return value; + } + } + } + return ""; + } else { + return ""; + } +} + +QString Configuration::readFileContent(QString fileName) const +{ + using namespace std; + ifstream inFile; + string line; + inFile.open(fileName.toStdString()); + string result = ""; + if(inFile) { + while(inFile.good()) + { + getline(inFile,line); // get line from file + result.append(line); + } + return result.c_str(); + } else { + return ""; + } +} + void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig) { this->insertButtonCode(iniConfig, cInputPlayButtonKey, aasdk::proto::enums::ButtonCode::PLAY); diff --git a/src/autoapp/Service/AndroidAutoEntity.cpp b/src/autoapp/Service/AndroidAutoEntity.cpp index 81c6702..fa37e34 100644 --- a/src/autoapp/Service/AndroidAutoEntity.cpp +++ b/src/autoapp/Service/AndroidAutoEntity.cpp @@ -74,12 +74,16 @@ void AndroidAutoEntity::stop() strand_.dispatch([this, self = this->shared_from_this()]() { OPENAUTO_LOG(info) << "[AndroidAutoEntity] stop."; - eventHandler_ = nullptr; - std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::stop, std::placeholders::_1)); - pinger_->cancel(); - messenger_->stop(); - transport_->stop(); - cryptor_->deinit(); + try { + eventHandler_ = nullptr; + std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::stop, std::placeholders::_1)); + pinger_->cancel(); + messenger_->stop(); + transport_->stop(); + cryptor_->deinit(); + } catch (...) { + OPENAUTO_LOG(info) << "[AndroidAutoEntity] exception in stop."; + } }); } diff --git a/src/autoapp/UI/ConnectDialog.cpp b/src/autoapp/UI/ConnectDialog.cpp index 6b0862e..3236155 100644 --- a/src/autoapp/UI/ConnectDialog.cpp +++ b/src/autoapp/UI/ConnectDialog.cpp @@ -146,6 +146,20 @@ void ConnectDialog::loadClientList() } } versionFile.close(); + if (ui_->listWidgetClients->count() == 1) { + this->setControlsEnabledStatus(false); + const auto& ipAddress = ui_->lineEditIPAddress->text().toStdString(); + auto socket = std::make_shared(ioService_); + ui_->progressBarConnect->show(); + try + { + tcpWrapper_.asyncConnect(*socket, ipAddress, 5277, std::bind(&ConnectDialog::connectHandler, this, std::placeholders::_1, ipAddress, socket)); + } + catch(const boost::system::system_error& se) + { + emit connectionFailed(QString(se.what())); + } + } } else { ui_->lineEditIPAddress->setText(""); } diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index a3a47d7..ff4f4b4 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -50,6 +49,7 @@ namespace ui MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent) : QMainWindow(parent) , ui_(new Ui::MainWindow) + , localDevice(new QBluetoothLocalDevice) { // set default bg color to black this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);}"); @@ -130,16 +130,15 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->clockOnlyWidget->hide(); - // by default hide bluetooth button on init ui_->pushButtonBluetooth->hide(); + ui_->labelBluetoothPairable->hide(); // by default hide media player ui_->mediaWidget->hide(); - ui_->pushButtonUSB->hide(); ui_->SysinfoTopLeft->hide(); - ui_->pushButtonAndroidAuto->hide(); + ui_->ButtonAndroidAuto->hide(); ui_->pushButtonAndroidAuto2->hide(); ui_->SysinfoTopLeft2->hide(); @@ -153,6 +152,11 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->networkInfo->hide(); } + if (!this->devModeEnabled) { + ui_->labelLock->hide(); + ui_->labelLockDummy->hide(); + } + if (check_file_exist("/etc/crankshaft.branch")) { QFile branchFile(QString("/etc/crankshaft.branch")); branchFile.open(QIODevice::ReadOnly); @@ -183,6 +187,12 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi 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_->pushButtonUp, &QPushButton::clicked, this, &MainWindow::cameraPosYUp); + connect(ui_->pushButtonDown, &QPushButton::clicked, this, &MainWindow::cameraPosYDown); + connect(ui_->pushButtonPlus, &QPushButton::clicked, this, &MainWindow::cameraZoomPlus); + connect(ui_->pushButtonMinus, &QPushButton::clicked, this, &MainWindow::cameraZoomMinus); + this->camera_ycorection=configuration->getCSValue("RPICAM_YCORRECTION").toInt(); + this->camera_zoom=configuration->getCSValue("RPICAM_ZOOM").toInt(); } else { ui_->pushButtonCameraShow->hide(); ui_->pushButtonCameraShow2->hide(); @@ -375,19 +385,11 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->devlabel_right->hide(); } - // Load configured brightness values - system("/usr/local/bin/autoapp_helper getbrightnessvalues"); - QFile paramFile(QString("/tmp/br_values")); - paramFile.open(QIODevice::ReadOnly); - QTextStream data_param(¶mFile); - QStringList brigthnessvalues = data_param.readAll().split("#"); - paramFile.close(); - - // set brightness slider attribs - ui_->horizontalSliderBrightness->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderBrightness->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderBrightness->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderBrightness->setTickInterval(brigthnessvalues[2].toInt()); + // set brightness slider attribs from cs config + ui_->horizontalSliderBrightness->setMinimum(configuration->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness->setMaximum(configuration->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness->setSingleStep(configuration->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness->setTickInterval(configuration->getCSValue("BR_STEP").toInt()); // run monitor for custom brightness command if enabled in crankshaft_env.sh if (std::ifstream("/tmp/custombrightness")) { @@ -396,7 +398,6 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi ui_->pushButtonBrightness2->show(); } this->customBrightnessControl = true; - system("/usr/local/bin/autoapp_helper startcustombrightness &"); } // read param file @@ -545,6 +546,13 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi watcher_tmp->addPath("/tmp"); connect(watcher_tmp, &QFileSystemWatcher::directoryChanged, this, &MainWindow::tmpChanged); + // Experimental test code + localDevice = new QBluetoothLocalDevice(this); + + connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), + this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode))); + + hostModeStateChanged(localDevice->hostMode()); updateNetworkInfo(); } @@ -558,6 +566,24 @@ MainWindow::~MainWindow() } } +void f1x::openauto::autoapp::ui::MainWindow::hostModeStateChanged(QBluetoothLocalDevice::HostMode mode) +{ + if (mode != QBluetoothLocalDevice::HostPoweredOff) { + this->bluetoothEnabled = true; + ui_->pushButtonBluetooth->show(); + if (std::ifstream("/tmp/bluetooth_pairable")) { + ui_->labelBluetoothPairable->show(); + ui_->pushButtonBluetooth->hide(); + } else { + ui_->labelBluetoothPairable->hide(); + } + } else { + this->bluetoothEnabled = false; + ui_->pushButtonBluetooth->hide(); + ui_->labelBluetoothPairable->hide(); + } +} + void f1x::openauto::autoapp::ui::MainWindow::updateNetworkInfo() { QNetworkInterface wlan0if = QNetworkInterface::interfaceFromName("wlan0"); @@ -568,26 +594,12 @@ void f1x::openauto::autoapp::ui::MainWindow::updateNetworkInfo() //qDebug() << "wlan0: " << wlan0.ip(); ui_->value_ip->setText(wlan0.ip().toString().simplified()); ui_->value_mask->setText(wlan0.netmask().toString().simplified()); - if (std::ifstream("/tmp/wifi_ssid")) { - QFile wifiData(QString("/tmp/wifi_ssid")); - wifiData.open(QIODevice::ReadOnly); - QTextStream gateway_date(&wifiData); - QString linedate = gateway_date.readAll(); - wifiData.close(); - ui_->value_ssid->setText(linedate.simplified()); + if (std::ifstream("/tmp/hotspot_active")) { + ui_->value_ssid->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid")); } else { - ui_->value_ssid->setText(""); - } - if (std::ifstream("/tmp/gateway_wlan0")) { - QFile gatewayData(QString("/tmp/gateway_wlan0")); - gatewayData.open(QIODevice::ReadOnly); - QTextStream gateway_date(&gatewayData); - QString linedate = gateway_date.readAll(); - gatewayData.close(); - ui_->value_gw->setText(linedate.simplified()); - } else { - ui_->value_gw->setText(""); + ui_->value_ssid->setText(configuration_->readFileContent("/tmp/wifi_ssid")); } + ui_->value_gw->setText(configuration_->readFileContent("/tmp/gateway_wlan0")); } } else { //qDebug() << "wlan0: down"; @@ -783,7 +795,9 @@ void f1x::openauto::autoapp::ui::MainWindow::updateAlpha() ui_->pushButtonDummy3->setStyleSheet( "background-color: rgba(186, 189, 182, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); ui_->pushButtonDebug->setStyleSheet( "background-color: rgba(85, 87, 83, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); ui_->pushButtonMusic->setStyleSheet( "background-color: rgba(78, 154, 6, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); - ui_->pushButtonAndroidAuto->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); + ui_->pushButtonAndroidAuto->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px; border-top: 0px;"); + ui_->labelAndroidAutoBottom->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-top: 0px;"); + ui_->labelAndroidAutoTop->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px;"); ui_->pushButtonNoDevice->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); ui_->pushButtonNoWiFiDevice->setStyleSheet( "background-color: rgba(252, 175, 62, " + alp + " ); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);"); // old style @@ -877,6 +891,10 @@ void f1x::openauto::autoapp::ui::MainWindow::playerShow() ui_->VolumeSliderControlPlayer->show(); ui_->VolumeSliderControl->hide(); ui_->BrightnessSliderControl->hide(); + ui_->networkInfo->hide(); + if (player->state() == QMediaPlayer::PlayingState) { + on_pushButtonBackToPlayer_clicked(); + } } void f1x::openauto::autoapp::ui::MainWindow::playerHide() @@ -890,6 +908,9 @@ void f1x::openauto::autoapp::ui::MainWindow::playerHide() ui_->VolumeSliderControl->show(); ui_->VolumeSliderControlPlayer->hide(); ui_->BrightnessSliderControl->hide(); + if (configuration_->showNetworkinfo()) { + ui_->networkInfo->hide(); + } f1x::openauto::autoapp::ui::MainWindow::updateBG(); f1x::openauto::autoapp::ui::MainWindow::tmpChanged(); } @@ -1218,6 +1239,12 @@ void f1x::openauto::autoapp::ui::MainWindow::on_comboBoxAlbum_currentIndexChange { this->albumfolder = arg1; MainWindow::scanFiles(); + ui_->pushButtonPlayerPause->hide(); + ui_->pushButtonPlayerStop->hide(); + ui_->pushButtonList->hide(); + ui_->pushButtonBackToPlayer->hide(); + ui_->labelCurrentPlaying->setText(""); + ui_->playerPositionTime->setText(""); } void f1x::openauto::autoapp::ui::MainWindow::setTrigger() @@ -1344,6 +1371,12 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPrevAlbum_clicke ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); player->play(); } + if (ui_->mp3selectWidget->isVisible() == false) { + ui_->pushButtonPlayerBack->show(); + ui_->pushButtonList->show(); + ui_->pushButtonPlayerPause->show(); + ui_->pushButtonPlayerStop->show(); + } } void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextAlbum_clicked() @@ -1361,6 +1394,12 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextAlbum_clicke ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); player->play(); } + if (ui_->mp3selectWidget->isVisible() == false) { + ui_->pushButtonPlayerBack->show(); + ui_->pushButtonList->show(); + ui_->pushButtonPlayerPause->show(); + ui_->pushButtonPlayerStop->show(); + } } void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBackToPlayer_clicked() @@ -1370,6 +1409,8 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBackToPlayer_clicked() ui_->pushButtonBackToPlayer->hide(); ui_->pushButtonPlayerPlayList->hide(); ui_->pushButtonList->show(); + ui_->pushButtonPlayerPause->show(); + ui_->pushButtonPlayerStop->show(); } void f1x::openauto::autoapp::ui::MainWindow::on_StateChanged(QMediaPlayer::State state) @@ -1399,6 +1440,40 @@ bool f1x::openauto::autoapp::ui::MainWindow::check_file_exist(const char *fileNa } } +void f1x::openauto::autoapp::ui::MainWindow::KeyPress(QString key) +{ + if (configuration_->playerButtonControl()) { + if (key == "C") { + on_pushButtonPlayerPause_clicked(); + } + if (key == "X") { + on_pushButtonPlayerPlayList_clicked(); + } + if (key == "V") { + on_pushButtonPlayerPrevBig_clicked(); + } + if (key == "N") { + on_pushButtonPlayerNextBig_clicked(); + } + if (key == "B") { + on_pushButtonPlayerPause_clicked(); + } + if (key == "A") { + on_pushButtonPlayerPrevAlbum_clicked(); + } + if (key == "L") { + on_pushButtonPlayerNextAlbum_clicked(); + } + if (key == "H") { + if (ui_->mediaWidget->isVisible() == false) { + playerShow(); + } else { + playerHide(); + } + } + } +} + void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() { try { @@ -1414,6 +1489,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() // check if system is in display off mode (tap2wake) if (std::ifstream("/tmp/blankscreen")) { if (ui_->centralWidget->isVisible() == true) { + CloseAllDialogs(); ui_->centralWidget->hide(); } } else { @@ -1432,6 +1508,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } if (ui_->headerWidget->isVisible() == true) { ui_->headerWidget->hide(); + CloseAllDialogs(); } if (ui_->mediaWidget->isVisible() == true) { ui_->mediaWidget->hide(); @@ -1484,33 +1561,57 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() // check if phone is conencted to usb if (std::ifstream("/tmp/android_device")) { - if (ui_->pushButtonAndroidAuto->isVisible() == false) { - ui_->pushButtonAndroidAuto->show(); + if (ui_->ButtonAndroidAuto->isVisible() == false) { + ui_->ButtonAndroidAuto->show(); ui_->pushButtonNoDevice->hide(); } if (ui_->pushButtonAndroidAuto2->isVisible() == false) { ui_->pushButtonAndroidAuto2->show(); ui_->pushButtonNoDevice2->hide(); } + try { + QFile deviceData(QString("/tmp/android_device")); + deviceData.open(QIODevice::ReadOnly); + QTextStream data_date(&deviceData); + QString linedate = data_date.readAll().split("\n")[1]; + deviceData.close(); + ui_->labelAndroidAutoBottom->setText(linedate.simplified().replace("_"," ")); + } catch (...) { + ui_->labelAndroidAutoBottom->setText(""); + } } else { - if (ui_->pushButtonAndroidAuto->isVisible() == true) { + if (ui_->ButtonAndroidAuto->isVisible() == true) { ui_->pushButtonNoDevice->show(); - ui_->pushButtonAndroidAuto->hide(); + ui_->ButtonAndroidAuto->hide(); } if (ui_->pushButtonAndroidAuto2->isVisible() == true) { ui_->pushButtonNoDevice2->show(); ui_->pushButtonAndroidAuto2->hide(); } + ui_->labelAndroidAutoBottom->setText(""); } - // check if bluetooth available - this->bluetoothEnabled = check_file_exist("/tmp/button_bluetooth_visible"); - + // check if bluetooth pairable if (this->bluetoothEnabled) { - if (ui_->pushButtonBluetooth->isVisible() == false) { - ui_->pushButtonBluetooth->show(); + if (std::ifstream("/tmp/bluetooth_pairable")) { + if (ui_->labelBluetoothPairable->isVisible() == false) { + ui_->labelBluetoothPairable->show(); + } + if (ui_->pushButtonBluetooth->isVisible() == true) { + ui_->pushButtonBluetooth->hide(); + } + } else { + if (ui_->labelBluetoothPairable->isVisible() == true) { + ui_->labelBluetoothPairable->hide(); + } + if (ui_->pushButtonBluetooth->isVisible() == false) { + ui_->pushButtonBluetooth->show(); + } } } else { + if (ui_->labelBluetoothPairable->isVisible() == true) { + ui_->labelBluetoothPairable->hide(); + } if (ui_->pushButtonBluetooth->isVisible() == true) { ui_->pushButtonBluetooth->hide(); } @@ -1518,7 +1619,7 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() // check if a device is connected via bluetooth if (std::ifstream("/tmp/btdevice")) { - if (ui_->btDevice->isVisible() == false) { + if (ui_->btDevice->isVisible() == false || ui_->btDevice->text().simplified() == "") { QFile phoneBTData(QString("/tmp/btdevice")); phoneBTData.open(QIODevice::ReadOnly); QTextStream data_date(&phoneBTData); @@ -1747,7 +1848,9 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } } else { if (ui_->networkInfo->isVisible() == false) { - ui_->networkInfo->show(); + if (ui_->mediaWidget->isVisible() == false) { + ui_->networkInfo->show(); + } } } @@ -1836,5 +1939,36 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } } } + + if (std::ifstream("/tmp/btdevice") || std::ifstream("/tmp/media_playing") || std::ifstream("/tmp/dev_mode_enabled") || std::ifstream("/tmp/android_device")) { + if (ui_->labelLock->isVisible() == false) { + ui_->labelLock->show(); + ui_->labelLockDummy->show(); + } + } else { + if (ui_->labelLock->isVisible() == true) { + ui_->labelLock->hide(); + ui_->labelLockDummy->hide(); + } + } updateNetworkInfo(); + + //QString localDeviceName; + //QString localDeviceAddress; + + //if (localDevice->isValid()) { + // localDeviceName = localDevice->name(); + // localDeviceAddress = localDevice->address().toString(); + // QList btdevices; + // btdevices = localDevice->connectedDevices(); + + // int count = btdevices.count(); + // if (count > 0) { + // QBluetoothAddress btdevice = btdevices[0]; + // QString btmac = btdevice.toString(); + // ui_->btDevice->setText("BT: " + QString::number(count)); + // } else { + // ui_->btDevice->setText("BT: " + QString::number(count)); + // } + //} } diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index bafd80e..03290b7 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -1,4 +1,4 @@ -/*subfolder +/*subfolder * This file is part of openauto project. * Copyright (C) 2018 f1x.studio (Michal Szwaj) * @@ -28,6 +28,7 @@ #include #include #include +#include namespace f1x { @@ -75,6 +76,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat connect(ui_->radioButtonClient, &QPushButton::clicked, this, &SettingsWindow::onStopHotspot); connect(ui_->pushButtonSetTime, &QPushButton::clicked, this, &SettingsWindow::setTime); connect(ui_->pushButtonSetTime, &QPushButton::clicked, this, &SettingsWindow::close); + connect(ui_->pushButtonNTP, &QPushButton::clicked, [&]() { system("/usr/local/bin/crankshaft rtc sync &"); }); connect(ui_->pushButtonNTP, &QPushButton::clicked, this, &SettingsWindow::close); connect(ui_->pushButtonCheckNow, &QPushButton::clicked, [&]() { system("/usr/local/bin/crankshaft update check &"); }); connect(ui_->pushButtonDebuglog, &QPushButton::clicked, this, &SettingsWindow::close); @@ -98,6 +100,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat ui_->labelBluetoothAdapterAddress->hide(); ui_->lineEditExternalBluetoothAdapterAddress->hide(); ui_->labelTestInProgress->hide(); + ui_->pushButtonShowBindings->hide(); connect(ui_->pushButtonTab1, &QPushButton::clicked, this, &SettingsWindow::show_tab1); connect(ui_->pushButtonTab2, &QPushButton::clicked, this, &SettingsWindow::show_tab2); @@ -118,10 +121,31 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat ui_->label_modeswitchprogress->setText("Ok"); ui_->label_notavailable->hide(); + QString wifi_ssid = configuration_->getCSValue("WIFI_SSID"); + QString wifi2_ssid = configuration_->getCSValue("WIFI2_SSID"); + + ui_->pushButtonNetwork0->setText(wifi_ssid); + ui_->pushButtonNetwork1->setText(wifi2_ssid); + + if (!std::ifstream("/boot/crankshaft/network1.conf")) { + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetwork0->show(); + } + if (!std::ifstream("/boot/crankshaft/network0.conf")) { + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetwork0->setText(configuration_->getCSValue("WIFI2_SSID")); + } + if (!std::ifstream("/boot/crankshaft/network0.conf") && !std::ifstream("/boot/crankshaft/network1.conf")) { + ui_->pushButtonNetwork0->hide(); + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetworkAuto->hide(); + ui_->label_notavailable->show(); + } + if (std::ifstream("/tmp/hotspot_active")) { ui_->radioButtonClient->setChecked(0); ui_->radioButtonHotspot->setChecked(1); - ui_->lineEditWifiSSID->setText(this->hotspotssid); + ui_->lineEditWifiSSID->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid")); ui_->lineEditPassword->show(); ui_->label_password->show(); ui_->lineEditPassword->setText("1234567890"); @@ -130,13 +154,17 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat } else { ui_->radioButtonClient->setChecked(1); ui_->radioButtonHotspot->setChecked(0); - ui_->lineEditWifiSSID->setText(this->wifissid); + ui_->lineEditWifiSSID->setText(configuration_->readFileContent("/tmp/wifi_ssid")); ui_->lineEditPassword->hide(); ui_->label_password->hide(); ui_->lineEditPassword->setText(""); ui_->clientNetworkSelect->hide(); ui_->label_notavailable->show(); } + + QTimer *refresh=new QTimer(this); + connect(refresh, SIGNAL(timeout()),this,SLOT(updateInfo())); + refresh->start(5000); } SettingsWindow::~SettingsWindow() @@ -144,6 +172,16 @@ SettingsWindow::~SettingsWindow() delete ui_; } +void SettingsWindow::updateInfo() +{ + if (ui_->tab6->isVisible() == true) { + updateSystemInfo(); + } + if (ui_->tab5->isVisible() == true) { + updateNetworkInfo(); + } +} + void SettingsWindow::onSave() { configuration_->setHandednessOfTrafficType(ui_->radioButtonLeftHandDrive->isChecked() ? configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE : configuration::HandednessOfTrafficType::RIGHT_HAND_DRIVE); @@ -159,6 +197,7 @@ void SettingsWindow::onSave() configuration_->showNetworkinfo(ui_->checkBoxNetworkinfo->isChecked()); configuration_->mp3AutoPlay(ui_->checkBoxAutoPlay->isChecked()); configuration_->showAutoPlay(ui_->checkBoxShowPlayer->isChecked()); + configuration_->hideWarning(ui_->checkBoxDontShowAgain->isChecked()); configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() ? aasdk::proto::enums::VideoFPS::_30 : aasdk::proto::enums::VideoFPS::_60); @@ -184,6 +223,8 @@ void SettingsWindow::onSave() configuration_->setTouchscreenEnabled(ui_->checkBoxEnableTouchscreen->isChecked()); this->saveButtonCheckBoxes(); + configuration_->playerButtonControl(ui_->checkBoxPlayerControl->isChecked()); + if(ui_->radioButtonDisableBluetooth->isChecked()) { configuration_->setBluetoothAdapterType(configuration::BluetoothAdapterType::NONE); @@ -362,6 +403,22 @@ void SettingsWindow::onSave() params.append("0"); } params.append("#"); + if (ui_->checkBoxFlipX ->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + if (ui_->checkBoxFlipY ->isChecked()) { + params.append("1"); + } else { + params.append("0"); + } + params.append("#"); + params.append( std::string(ui_->comboBoxRotation->currentText().toStdString()) ); + params.append("#"); + params.append( std::string(ui_->comboBoxResolution->currentText().toStdString()) ); + params.append("#"); system((std::string("/usr/local/bin/autoapp_helper setparams#") + std::string(params) + std::string(" &") ).c_str()); this->close(); @@ -400,6 +457,7 @@ void SettingsWindow::load() ui_->checkBoxNetworkinfo->setChecked(configuration_->showNetworkinfo()); ui_->checkBoxAutoPlay->setChecked(configuration_->mp3AutoPlay()); ui_->checkBoxShowPlayer->setChecked(configuration_->showAutoPlay()); + ui_->checkBoxDontShowAgain->setChecked(configuration_->hideWarning()); ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_30); ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_60); @@ -416,6 +474,7 @@ void SettingsWindow::load() ui_->checkBoxEnableTouchscreen->setChecked(configuration_->getTouchscreenEnabled()); this->loadButtonCheckBoxes(); + ui_->checkBoxPlayerControl->setChecked(configuration_->playerButtonControl()); ui_->radioButtonDisableBluetooth->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::NONE); ui_->radioButtonUseLocalBluetoothAdapter->setChecked(configuration_->getBluetoothAdapterType() == configuration::BluetoothAdapterType::LOCAL); @@ -431,7 +490,7 @@ void SettingsWindow::load() ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::QT); ui_->checkBoxHardwareSave->setChecked(false); - QStorageInfo storage("/media/CSSTORAGE"); + QStorageInfo storage("/media/USBDRIVES/CSSTORAGE"); storage.refresh(); if (storage.isValid() && storage.isReady()) { if (storage.isReadOnly()) { @@ -619,130 +678,104 @@ void SettingsWindow::syncNTPTime() void SettingsWindow::loadSystemValues() { - system("/usr/local/bin/autoapp_helper getoutputs"); - system("/usr/local/bin/autoapp_helper getinputs"); - system("/usr/local/bin/autoapp_helper getparams"); - system("/usr/local/bin/autoapp_helper getbrightnessvalues"); - // set brightness slider attribs - QFile paramFile(QString("/tmp/br_values")); - paramFile.open(QIODevice::ReadOnly); - QTextStream data_param(¶mFile); - QStringList brigthnessvalues = data_param.readAll().split("#"); - paramFile.close(); + ui_->horizontalSliderDay->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderDay->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderDay->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderDay->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderDay->setValue(configuration_->getCSValue("BR_DAY").toInt()); - ui_->horizontalSliderDay->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderDay->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderDay->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderDay->setTickInterval(brigthnessvalues[2].toInt()); - ui_->horizontalSliderDay->setValue(brigthnessvalues[3].toInt()); + ui_->horizontalSliderNight->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderNight->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderNight->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderNight->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderNight->setValue(configuration_->getCSValue("BR_NIGHT").toInt()); - ui_->horizontalSliderNight->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderNight->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderNight->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderNight->setTickInterval(brigthnessvalues[2].toInt()); - ui_->horizontalSliderNight->setValue(brigthnessvalues[4].toInt()); + ui_->horizontalSliderBrightness1->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness1->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness1->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness1->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness1->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderBrightness1->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderBrightness1->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderBrightness1->setTickInterval(brigthnessvalues[2].toInt()); + ui_->horizontalSliderBrightness2->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness2->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness2->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness2->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness2->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderBrightness2->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderBrightness2->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderBrightness2->setTickInterval(brigthnessvalues[2].toInt()); + ui_->horizontalSliderBrightness3->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness3->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness3->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness3->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness3->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderBrightness3->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderBrightness3->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderBrightness3->setTickInterval(brigthnessvalues[2].toInt()); + ui_->horizontalSliderBrightness4->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness4->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness4->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness4->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); - ui_->horizontalSliderBrightness4->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderBrightness4->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderBrightness4->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderBrightness4->setTickInterval(brigthnessvalues[2].toInt()); - - ui_->horizontalSliderBrightness5->setMinimum(brigthnessvalues[0].toInt()); - ui_->horizontalSliderBrightness5->setMaximum(brigthnessvalues[1].toInt()); - ui_->horizontalSliderBrightness5->setSingleStep(brigthnessvalues[2].toInt()); - ui_->horizontalSliderBrightness5->setTickInterval(brigthnessvalues[2].toInt()); + ui_->horizontalSliderBrightness5->setMinimum(configuration_->getCSValue("BR_MIN").toInt()); + ui_->horizontalSliderBrightness5->setMaximum(configuration_->getCSValue("BR_MAX").toInt()); + ui_->horizontalSliderBrightness5->setSingleStep(configuration_->getCSValue("BR_STEP").toInt()); + ui_->horizontalSliderBrightness5->setTickInterval(configuration_->getCSValue("BR_STEP").toInt()); // set tsl2561 slider attribs - QFile param2File(QString("/tmp/tsl2561_values")); - param2File.open(QIODevice::ReadOnly); - QTextStream data_param2(¶m2File); - QStringList brigthnessvalues2 = data_param2.readAll().split("#"); - param2File.close(); - - ui_->horizontalSliderLux1->setValue(brigthnessvalues2[0].toInt()); - ui_->horizontalSliderBrightness1->setValue(brigthnessvalues2[1].toInt()); - ui_->horizontalSliderLux2->setValue(brigthnessvalues2[2].toInt()); - ui_->horizontalSliderBrightness2->setValue(brigthnessvalues2[3].toInt()); - ui_->horizontalSliderLux3->setValue(brigthnessvalues2[4].toInt()); - ui_->horizontalSliderBrightness3->setValue(brigthnessvalues2[5].toInt()); - ui_->horizontalSliderLux4->setValue(brigthnessvalues2[6].toInt()); - ui_->horizontalSliderBrightness4->setValue(brigthnessvalues2[7].toInt()); - ui_->horizontalSliderLux5->setValue(brigthnessvalues2[8].toInt()); - ui_->horizontalSliderBrightness5->setValue(brigthnessvalues2[9].toInt()); - ui_->comboBoxCheckInterval->setCurrentText(brigthnessvalues2[10]); - ui_->comboBoxNightmodeStep->setCurrentText(brigthnessvalues2[11]); + ui_->horizontalSliderLux1->setValue(configuration_->getCSValue("LUX_LEVEL_1").toInt()); + ui_->horizontalSliderBrightness1->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_1").toInt()); + ui_->horizontalSliderLux2->setValue(configuration_->getCSValue("LUX_LEVEL_2").toInt()); + ui_->horizontalSliderBrightness2->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_2").toInt()); + ui_->horizontalSliderLux3->setValue(configuration_->getCSValue("LUX_LEVEL_3").toInt()); + ui_->horizontalSliderBrightness3->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_3").toInt()); + ui_->horizontalSliderLux4->setValue(configuration_->getCSValue("LUX_LEVEL_4").toInt()); + ui_->horizontalSliderBrightness4->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_4").toInt()); + ui_->horizontalSliderLux5->setValue(configuration_->getCSValue("LUX_LEVEL_5").toInt()); + ui_->horizontalSliderBrightness5->setValue(configuration_->getCSValue("DISP_BRIGHTNESS_5").toInt()); + ui_->comboBoxCheckInterval->setCurrentText(configuration_->getCSValue("TSL2561_CHECK_INTERVAL")); + ui_->comboBoxNightmodeStep->setCurrentText(configuration_->getCSValue("TSL2561_DAYNIGHT_ON_STEP")); if (std::ifstream("/tmp/return_value")) { - QFile paramFile(QString("/tmp/return_value")); - paramFile.open(QIODevice::ReadOnly); - QTextStream data_param(¶mFile); - QStringList getparams = data_param.readAll().split("#"); - paramFile.close(); + QString return_values = configuration_->readFileContent("/tmp/return_value"); + QStringList getparams = return_values.split("#"); // version string - ui_->valueSystemVersion->setText(getparams[0]); + ui_->valueSystemVersion->setText(configuration_->readFileContent("/etc/crankshaft.build")); // date string - ui_->valueSystemBuildDate->setText(getparams[1]); + ui_->valueSystemBuildDate->setText(configuration_->readFileContent("/etc/crankshaft.date")); // set volume - ui_->labelSystemVolumeValue->setText(getparams[2]); - ui_->horizontalSliderSystemVolume->setValue(getparams[2].toInt()); + ui_->labelSystemVolumeValue->setText(configuration_->readFileContent("/boot/crankshaft/volume")); + ui_->horizontalSliderSystemVolume->setValue(configuration_->readFileContent("/boot/crankshaft/volume").toInt()); // set cap volume - ui_->labelSystemCaptureValue->setText(getparams[3]); - ui_->horizontalSliderSystemCapture->setValue(getparams[3].toInt()); + ui_->labelSystemCaptureValue->setText(configuration_->readFileContent("/boot/crankshaft/capvolume")); + ui_->horizontalSliderSystemCapture->setValue(configuration_->readFileContent("/boot/crankshaft/capvolume").toInt()); // set shutdown - ui_->valueShutdownTimer->setText(getparams[4]); - ui_->spinBoxShutdown->setValue(getparams[5].toInt()); + ui_->valueShutdownTimer->setText("- - -"); + ui_->spinBoxShutdown->setValue(configuration_->getCSValue("DISCONNECTION_POWEROFF_MINS").toInt()); // set disconnect - ui_->valueDisconnectTimer->setText(getparams[6]); - ui_->spinBoxDisconnect->setValue(getparams[7].toInt()); + ui_->valueDisconnectTimer->setText("- - -"); + ui_->spinBoxDisconnect->setValue(configuration_->getCSValue("DISCONNECTION_SCREEN_POWEROFF_SECS").toInt()); // set day/night - ui_->spinBoxDay->setValue(getparams[8].toInt()); - ui_->spinBoxNight->setValue(getparams[9].toInt()); + ui_->spinBoxDay->setValue(configuration_->getCSValue("RTC_DAY_START").toInt()); + ui_->spinBoxNight->setValue(configuration_->getCSValue("RTC_NIGHT_START").toInt()); // set gpios - if (getparams[10] == "1") { + if (configuration_->getCSValue("ENABLE_GPIO") == "1") { ui_->checkBoxGPIO->setChecked(true); } else { ui_->checkBoxGPIO->setChecked(false); } - ui_->comboBoxDevMode->setCurrentText(getparams[11]); - ui_->comboBoxInvert->setCurrentText(getparams[12]); - ui_->comboBoxX11->setCurrentText(getparams[13]); - ui_->comboBoxRearcam->setCurrentText(getparams[14]); - ui_->comboBoxAndroid->setCurrentText(getparams[15]); + ui_->comboBoxDevMode->setCurrentText(configuration_->getCSValue("DEV_PIN")); + ui_->comboBoxInvert->setCurrentText(configuration_->getCSValue("INVERT_PIN")); + ui_->comboBoxX11->setCurrentText(configuration_->getCSValue("X11_PIN")); + ui_->comboBoxRearcam->setCurrentText(configuration_->getCSValue("REARCAM_PIN")); + ui_->comboBoxAndroid->setCurrentText(configuration_->getCSValue("ANDROID_PIN")); // set mode - if (getparams[16] == "0") { + if (configuration_->getCSValue("START_X11") == "0") { ui_->radioButtonEGL->setChecked(true); } else { ui_->radioButtonX11->setChecked(true); } // set rotation - if (getparams[17] == "0") { + if (configuration_->getCSValue("FLIP_SCREEN") == "0") { ui_->radioButtonScreenNormal->setChecked(true); } else { ui_->radioButtonScreenRotated->setChecked(true); } - // set free mem - ui_->valueSystemFreeMem->setText(getparams[18]); - // set cpu freq - ui_->valueSystemCPUFreq->setText(getparams[19] + "MHz"); - // set cpu temp - ui_->valueSystemCPUTemp->setText(getparams[20]); if (std::ifstream("/tmp/get_inputs")) { QFile inputsFile(QString("/tmp/get_inputs")); @@ -782,23 +815,8 @@ void SettingsWindow::loadSystemValues() } } - if (std::ifstream("/tmp/get_default_output")) { - QFile defaultoutputFile(QString("/tmp/get_default_output")); - defaultoutputFile.open(QIODevice::ReadOnly); - QTextStream data_return(&defaultoutputFile); - QStringList defoutput = data_return.readAll().split("\n"); - defaultoutputFile.close(); - ui_->comboBoxPulseOutput->setCurrentText(defoutput[0]); - } - - if (std::ifstream("/tmp/get_default_input")) { - QFile defaultinputFile(QString("/tmp/get_default_input")); - defaultinputFile.open(QIODevice::ReadOnly); - QTextStream data_return(&defaultinputFile); - QStringList definput = data_return.readAll().split("\n"); - defaultinputFile.close(); - ui_->comboBoxPulseInput->setCurrentText(definput[0]); - } + ui_->comboBoxPulseOutput->setCurrentText(configuration_->readFileContent("/tmp/get_default_output")); + ui_->comboBoxPulseInput->setCurrentText(configuration_->readFileContent("/tmp/get_default_input")); if (std::ifstream("/tmp/timezone_listing")) { QFile zoneFile(QString("/tmp/timezone_listing")); @@ -820,129 +838,157 @@ void SettingsWindow::loadSystemValues() } // set rtc - ui_->comboBoxHardwareRTC->setCurrentText(getparams[21]); - // set timezone - ui_->comboBoxTZ->setCurrentText(getparams[22]); + QString rtcstring = configuration_->getParamFromFile("/boot/config.txt","dtoverlay=i2c-rtc"); + if (rtcstring != "") { + QStringList rtc = rtcstring.split(","); + ui_->comboBoxHardwareRTC->setCurrentText(rtc[1].trimmed()); + // set timezone + ui_->comboBoxTZ->setCurrentText(configuration_->readFileContent("/etc/timezone")); + } else { + ui_->comboBoxHardwareRTC->setCurrentText("none"); + } // set dac QString dac = "Custom"; - if (getparams[23] == "allo-boss-dac-pcm512x-audio") { + if (getparams[4] == "allo-boss-dac-pcm512x-audio") { dac = "Allo - Boss"; } - if (getparams[23] == "allo-piano-dac-pcm512x-audio") { + if (getparams[4] == "allo-piano-dac-pcm512x-audio") { dac = "Allo - Piano"; } - if (getparams[23] == "iqaudio-dacplus") { + if (getparams[4] == "iqaudio-dacplus") { dac = "IQaudIO - Pi-DAC Plus/Pro/Zero"; } - if (getparams[23] == "iqaudio-dacplus,unmute_amp") { + if (getparams[4] == "iqaudio-dacplus,unmute_amp") { dac = "IQaudIO - Pi-Digi Amp Plus"; } - if (getparams[23] == "iqaudio-dacplus,auto_mute_amp") { + if (getparams[4] == "iqaudio-dacplus,auto_mute_amp") { dac = "IQaudIO - Pi-Digi Amp Plus - Automute"; } - if (getparams[23] == "iqaudio-digi-wm8804-audio") { + if (getparams[4] == "iqaudio-digi-wm8804-audio") { dac = "IQaudIO - Pi-Digi Plus"; } - if (getparams[23] == "audioinjector-wm8731-audio") { + if (getparams[4] == "audioinjector-wm8731-audio") { dac = "Audioinjector - Zero/Stereo"; } - if (getparams[23] == "hifiberry-dac") { + if (getparams[4] == "hifiberry-dac") { dac = "Hifiberry - DAC"; } - if (getparams[23] == "hifiberry-dacplus") { + if (getparams[4] == "hifiberry-dacplus") { dac = "Hifiberry - DAC Plus"; } - if (getparams[23] == "hifiberry-digi") { + if (getparams[4] == "hifiberry-digi") { dac = "Hifiberry - Digi"; } - if (getparams[23] == "hifiberry-digi-pro") { + if (getparams[4] == "hifiberry-digi-pro") { dac = "Hifiberry - Digi Pro"; } - if (getparams[23] == "hifiberry-amp") { + if (getparams[4] == "hifiberry-amp") { dac = "Hifiberry - DAC Amp"; } - if (getparams[23] == "audio") { + if (getparams[4] == "audio") { dac = "Raspberry Pi - Onboard"; } ui_->comboBoxHardwareDAC->setCurrentText(dac); // set shutdown disable - if (getparams[24] == "1") { + if (configuration_->getCSValue("DISCONNECTION_POWEROFF_DISABLE") == "1") { ui_->checkBoxDisableShutdown->setChecked(true); } else { ui_->checkBoxDisableShutdown->setChecked(false); } // set screen off disable - if (getparams[25] == "1") { + if (configuration_->getCSValue("DISCONNECTION_SCREEN_POWEROFF_DISABLE") == "1") { ui_->checkBoxDisableScreenOff->setChecked(true); } else { ui_->checkBoxDisableScreenOff->setChecked(false); } // set custom brightness command - if (getparams[26] != "0") { - ui_->labelCustomBrightnessCommand->setText(getparams[26] + " brvalue"); + if (configuration_->getCSValue("CUSTOM_BRIGHTNESS_COMMAND") != "") { + ui_->labelCustomBrightnessCommand->setText(configuration_->getCSValue("CUSTOM_BRIGHTNESS_COMMAND") + " brvalue"); } else { ui_->labelCustomBrightnessCommand->setText("Disabled"); } // set debug mode - if (getparams[27] == "1") { + if (configuration_->getCSValue("DEBUG_MODE") == "1") { ui_->radioButtonDebugmodeEnabled->setChecked(true); } else { ui_->radioButtonDebugmodeDisabled->setChecked(true); } // GPIO based shutdown - ui_->comboBoxGPIOShutdown->setCurrentText(getparams[28]); - ui_->spinBoxGPIOShutdownDelay->setValue(getparams[29].toInt()); + ui_->comboBoxGPIOShutdown->setCurrentText(configuration_->getCSValue("IGNITION_PIN")); + ui_->spinBoxGPIOShutdownDelay->setValue(configuration_->getCSValue("IGNITION_DELAY").toInt()); - // Wifi Credentials - this->wifissid = getparams[30]; - - // Wifi Hotspot Credentials - if (getparams[31] == "1") { + // Wifi Hotspot + if (configuration_->getCSValue("ENABLE_HOTSPOT") == "1") { ui_->checkBoxHotspot->setChecked(true); } else { ui_->checkBoxHotspot->setChecked(false); } - this->hotspotssid = getparams[32]; - // set cam - ui_->comboBoxCam->setCurrentText(getparams[33]); + if (configuration_->getParamFromFile("/boot/config.txt","start_x") == "1") { + ui_->comboBoxCam->setCurrentText("enabled"); + } else { + ui_->comboBoxCam->setCurrentText("disabled"); + } + if (configuration_->getCSValue("RPICAM_HFLIP") == "1") { + ui_->checkBoxFlipX->setChecked(true); + } else { + ui_->checkBoxFlipX->setChecked(false); + } + if (configuration_->getCSValue("RPICAM_VFLIP") == "1") { + ui_->checkBoxFlipY->setChecked(true); + } else { + ui_->checkBoxFlipY->setChecked(false); + } + ui_->comboBoxRotation->setCurrentText(configuration_->getCSValue("RPICAM_ROTATION")); + ui_->comboBoxResolution->setCurrentText(configuration_->getCSValue("RPICAM_RESOLUTION")); // set bluetooth - if (getparams[34] == "1") { + if (configuration_->getCSValue("ENABLE_BLUETOOTH") == "1") { // check external bluetooth enabled - if (getparams[36] == "1") { + if (configuration_->getCSValue("EXTERNAL_BLUETOOTH") == "1") { ui_->radioButtonUseExternalBluetoothAdapter->setChecked(true); } else { ui_->radioButtonUseLocalBluetoothAdapter->setChecked(true); } // mac - ui_->lineEditExternalBluetoothAdapterAddress->setText(getparams[37]); + //ui_->lineEditExternalBluetoothAdapterAddress->setText(getparams[37]); } else { ui_->radioButtonDisableBluetooth->setChecked(true); ui_->lineEditExternalBluetoothAdapterAddress->setText(""); } - if (getparams[35] == "1") { + if (configuration_->getCSValue("ENABLE_PAIRABLE") == "1") { ui_->checkBoxBluetoothAutoPair->setChecked(true); } else { ui_->checkBoxBluetoothAutoPair->setChecked(false); } // set bluetooth type - ui_->comboBoxBluetooth->setCurrentText(getparams[38]); + if (configuration_->getCSValue("ENABLE_BLUETOOTH") == "1") { + QString bt = configuration_->getParamFromFile("/boot/config.txt","dtoverlay=pi3-disable-bt"); + if (bt.contains("pi3-disable-bt")) { + ui_->comboBoxBluetooth->setCurrentText("external"); + } else { + ui_->comboBoxBluetooth->setCurrentText("builtin"); + } + } else { + ui_->comboBoxBluetooth->setCurrentText("none"); + } + // set sdoc - if (getparams[39] == "enabled") { + QString sdoc = configuration_->getParamFromFile("/boot/config.txt","dtoverlay=sdtweak"); + if (sdoc.contains("sdtweak")) { ui_->comboBoxSDOC->setCurrentIndex(1); } else { ui_->comboBoxSDOC->setCurrentIndex(0); } // set lightsensor - if (getparams[40] == "enabled") { + if (std::ifstream("/etc/cs_lightsensor")) { ui_->comboBoxLS->setCurrentIndex(1); ui_->groupBoxSliderDay->hide(); ui_->groupBoxSliderNight->hide(); @@ -952,24 +998,26 @@ void SettingsWindow::loadSystemValues() ui_->groupBoxSliderDay->show(); ui_->groupBoxSliderNight->show(); } - ui_->comboBoxDayNight->setCurrentText(getparams[41]); - if (getparams[42] == "1") { + ui_->comboBoxDayNight->setCurrentText(configuration_->getCSValue("DAYNIGHT_PIN")); + if (configuration_->getCSValue("RTC_DAYNIGHT") == "1") { ui_->checkBoxDisableDayNightRTC->setChecked(false); } else { ui_->checkBoxDisableDayNightRTC->setChecked(true); } - if (getparams[43] == "csnganimation") { + QString theme = configuration_->getParamFromFile("/etc/plymouth/plymouthd.conf","Theme"); + if (theme == "csnganimation") { ui_->radioButtonAnimatedCSNG->setChecked(true); } - else if (getparams[43] == "crankshaft") { + else if (theme == "crankshaft") { ui_->radioButtonCSNG->setChecked(true); } - else if (getparams[43] == "custom") { + else if (theme == "custom") { ui_->radioButtonCustom->setChecked(true); } - ui_->comboBoxCountryCode->setCurrentIndex(ui_->comboBoxCountryCode->findText(getparams[44], Qt::MatchFlag::MatchStartsWith)); + // wifi country code + ui_->comboBoxCountryCode->setCurrentIndex(ui_->comboBoxCountryCode->findText(configuration_->getCSValue("WIFI_COUNTRY"), Qt::MatchFlag::MatchStartsWith)); // set screen blank instead off - if (getparams[45] == "1") { + if (configuration_->getCSValue("SCREEN_POWEROFF_OVERRIDE") == "1") { ui_->checkBoxBlankOnly->setChecked(true); } else { ui_->checkBoxBlankOnly->setChecked(false); @@ -1013,11 +1061,11 @@ void SettingsWindow::onStartHotspot() ui_->radioButtonHotspot->setEnabled(0); ui_->lineEdit_wlan0->setText(""); ui_->lineEditWifiSSID->setText(""); + ui_->pushButtonNetworkAuto->hide(); qApp->processEvents(); std::remove("/tmp/manual_hotspot_control"); std::ofstream("/tmp/manual_hotspot_control"); system("/opt/crankshaft/service_hotspot.sh start &"); - QTimer::singleShot(15000, this, SLOT(updateNetworkInfo())); } void SettingsWindow::onStopHotspot() @@ -1030,9 +1078,57 @@ void SettingsWindow::onStopHotspot() ui_->lineEdit_wlan0->setText(""); ui_->lineEditWifiSSID->setText(""); ui_->lineEditPassword->setText(""); + ui_->pushButtonNetworkAuto->hide(); qApp->processEvents(); system("/opt/crankshaft/service_hotspot.sh stop &"); - QTimer::singleShot(15000, this, SLOT(updateNetworkInfo())); +} + +void SettingsWindow::updateSystemInfo() +{ + // free ram + struct sysinfo info; + sysinfo(&info); + ui_->valueSystemFreeMem->setText(QString::number(info.freeram/1024/1024) + " MB"); + // current cpu speed + QString freq = configuration_->readFileContent("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq"); + int currentfreq = freq.toInt()/1000; + ui_->valueSystemCPUFreq->setText(QString::number(currentfreq) + "MHz"); + // current cpu temp + QString temp = configuration_->readFileContent("/sys/class/thermal/thermal_zone0/temp"); + int currenttemp = temp.toInt()/1000; + ui_->valueSystemCPUTemp->setText(QString::number(currenttemp) + "°C"); + // get remaining times + QProcess process; + process.start("/bin/bash", QStringList() << "-c" << "systemctl list-timers -all | grep disconnect | awk {'print $1'}"); + process.waitForFinished(-1); + QString stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "n/a") { + process.start("/bin/bash", QStringList() << "-c" << "systemctl list-timers -all | grep disconnect | awk {'print $5\" \"$6'}"); + process.waitForFinished(-1); + QString stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "") { + ui_->valueDisconnectTimer->setText(stdout.simplified()); + } else { + ui_->valueDisconnectTimer->setText("Stopped"); + } + } else { + ui_->valueDisconnectTimer->setText("Stopped"); + } + process.start("/bin/bash", QStringList() << "-c" << "systemctl list-timers -all | grep shutdown | awk {'print $1'}"); + process.waitForFinished(-1); + stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "n/a") { + process.start("/bin/bash", QStringList() << "-c" << "systemctl list-timers -all | grep shutdown | awk {'print $5\" \"$6'}"); + process.waitForFinished(-1); + QString stdout = process.readAllStandardOutput(); + if (stdout.simplified() != "") { + ui_->valueShutdownTimer->setText(stdout.simplified()); + } else { + ui_->valueShutdownTimer->setText("Stopped"); + } + } else { + ui_->valueShutdownTimer->setText("Stopped"); + } } void SettingsWindow::show_tab1() @@ -1169,64 +1265,75 @@ void f1x::openauto::autoapp::ui::SettingsWindow::on_pushButtonAudioTest_clicked( void f1x::openauto::autoapp::ui::SettingsWindow::updateNetworkInfo() { - QNetworkInterface eth0if = QNetworkInterface::interfaceFromName("eth0"); - if (eth0if.flags().testFlag(QNetworkInterface::IsUp)) { - QList entrieseth0 = eth0if.addressEntries(); - if (!entrieseth0.isEmpty()) { - QNetworkAddressEntry eth0 = entrieseth0.first(); - //qDebug() << "eth0: " << eth0.ip(); - ui_->lineEdit_eth0->setText(eth0.ip().toString()); - } - } else { - //qDebug() << "eth0: down"; - ui_->lineEdit_eth0->setText("interface down"); - } - - QNetworkInterface wlan0if = QNetworkInterface::interfaceFromName("wlan0"); - if (wlan0if.flags().testFlag(QNetworkInterface::IsUp)) { - QList entrieswlan0 = wlan0if.addressEntries(); - if (!entrieswlan0.isEmpty()) { - QNetworkAddressEntry wlan0 = entrieswlan0.first(); - //qDebug() << "wlan0: " << wlan0.ip(); - ui_->lineEdit_wlan0->setText(wlan0.ip().toString()); - } - if (std::ifstream("/tmp/wifi_ssid")) { - QFile wifiData(QString("/tmp/wifi_ssid")); - wifiData.open(QIODevice::ReadOnly); - QTextStream gateway_date(&wifiData); - QString linedate = gateway_date.readAll(); - wifiData.close(); - ui_->lineEditWifiSSID->setText(linedate.simplified()); + if (!std::ifstream("/tmp/mode_change_progress")) { + QNetworkInterface eth0if = QNetworkInterface::interfaceFromName("eth0"); + if (eth0if.flags().testFlag(QNetworkInterface::IsUp)) { + QList entrieseth0 = eth0if.addressEntries(); + if (!entrieseth0.isEmpty()) { + QNetworkAddressEntry eth0 = entrieseth0.first(); + //qDebug() << "eth0: " << eth0.ip(); + ui_->lineEdit_eth0->setText(eth0.ip().toString()); + } } else { - ui_->lineEditWifiSSID->setText(""); + //qDebug() << "eth0: down"; + ui_->lineEdit_eth0->setText("interface down"); } - } else { - //qDebug() << "wlan0: down"; - ui_->lineEdit_wlan0->setText("interface down"); - } - if (std::ifstream("/tmp/hotspot_active")) { - ui_->radioButtonClient->setEnabled(1); - ui_->radioButtonHotspot->setEnabled(1); - ui_->radioButtonHotspot->setChecked(1); - ui_->radioButtonClient->setChecked(0); - ui_->label_modeswitchprogress->setText("Ok"); - ui_->lineEditWifiSSID->setText(this->hotspotssid); - ui_->lineEditPassword->show(); - ui_->label_password->show(); - ui_->lineEditPassword->setText("1234567890"); - } else { - ui_->radioButtonClient->setEnabled(1); - ui_->radioButtonHotspot->setEnabled(1); - ui_->radioButtonHotspot->setChecked(0); - ui_->radioButtonClient->setChecked(1); - ui_->label_modeswitchprogress->setText("Ok"); - ui_->lineEditWifiSSID->setText(this->wifissid); - ui_->lineEditPassword->hide(); - ui_->label_password->hide(); - ui_->lineEditPassword->setText(""); - ui_->clientNetworkSelect->show(); - ui_->label_notavailable->hide(); + QNetworkInterface wlan0if = QNetworkInterface::interfaceFromName("wlan0"); + if (wlan0if.flags().testFlag(QNetworkInterface::IsUp)) { + QList entrieswlan0 = wlan0if.addressEntries(); + if (!entrieswlan0.isEmpty()) { + QNetworkAddressEntry wlan0 = entrieswlan0.first(); + //qDebug() << "wlan0: " << wlan0.ip(); + ui_->lineEdit_wlan0->setText(wlan0.ip().toString()); + } + } else { + //qDebug() << "wlan0: down"; + ui_->lineEdit_wlan0->setText("interface down"); + } + + if (std::ifstream("/tmp/hotspot_active")) { + ui_->radioButtonClient->setEnabled(1); + ui_->radioButtonHotspot->setEnabled(1); + ui_->radioButtonHotspot->setChecked(1); + ui_->radioButtonClient->setChecked(0); + ui_->label_modeswitchprogress->setText("Ok"); + ui_->lineEditWifiSSID->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid")); + ui_->lineEditPassword->show(); + ui_->label_password->show(); + ui_->lineEditPassword->setText("1234567890"); + ui_->clientNetworkSelect->hide(); + ui_->pushButtonNetworkAuto->hide(); + ui_->label_notavailable->show(); + } else { + ui_->radioButtonClient->setEnabled(1); + ui_->radioButtonHotspot->setEnabled(1); + ui_->radioButtonHotspot->setChecked(0); + ui_->radioButtonClient->setChecked(1); + ui_->label_modeswitchprogress->setText("Ok"); + ui_->lineEditWifiSSID->setText(configuration_->readFileContent("/tmp/wifi_ssid")); + ui_->lineEditPassword->hide(); + ui_->label_password->hide(); + ui_->lineEditPassword->setText(""); + ui_->clientNetworkSelect->show(); + ui_->label_notavailable->hide(); + ui_->pushButtonNetworkAuto->show(); + + if (!std::ifstream("/boot/crankshaft/network1.conf")) { + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetwork0->show(); + } + if (!std::ifstream("/boot/crankshaft/network0.conf")) { + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetwork0->setText(configuration_->getCSValue("WIFI2_SSID")); + } + if (!std::ifstream("/boot/crankshaft/network0.conf") && !std::ifstream("/boot/crankshaft/network1.conf")) { + ui_->pushButtonNetwork0->hide(); + ui_->pushButtonNetwork1->hide(); + ui_->pushButtonNetworkAuto->hide(); + ui_->label_notavailable->show(); + } + } } } @@ -1236,7 +1343,7 @@ void f1x::openauto::autoapp::ui::SettingsWindow::on_pushButtonNetwork0_clicked() ui_->lineEditWifiSSID->setText(""); ui_->lineEditPassword->setText(""); qApp->processEvents(); - system("/usr/local/bin/crankshaft network 0 &"); + system("/usr/local/bin/crankshaft network 0 >/dev/null 2>&1 &"); } @@ -1246,6 +1353,5 @@ void f1x::openauto::autoapp::ui::SettingsWindow::on_pushButtonNetwork1_clicked() ui_->lineEditWifiSSID->setText(""); ui_->lineEditPassword->setText(""); qApp->processEvents(); - system("/usr/local/bin/crankshaft network 1 &"); - QTimer::singleShot(15000, this, SLOT(updateNetworkInfo())); + system("/usr/local/bin/crankshaft network 1 >/dev/null 2>&1 &"); } diff --git a/src/autoapp/UI/UpdateDialog.cpp b/src/autoapp/UI/UpdateDialog.cpp index c1ed7a6..a1684ab 100644 --- a/src/autoapp/UI/UpdateDialog.cpp +++ b/src/autoapp/UI/UpdateDialog.cpp @@ -39,7 +39,7 @@ UpdateDialog::UpdateDialog(QWidget *parent) connect(watcher_tmp, &QFileSystemWatcher::directoryChanged, this, &UpdateDialog::updateCheck); watcher_download = new QFileSystemWatcher(this); - watcher_download->addPath("/media/CSSTORAGE"); + watcher_download->addPath("/media/USBDRIVES/CSSTORAGE"); connect(watcher_download, &QFileSystemWatcher::directoryChanged, this, &UpdateDialog::downloadCheck); } @@ -94,7 +94,7 @@ void f1x::openauto::autoapp::ui::UpdateDialog::on_pushButtonUpdateCheck_clicked( void f1x::openauto::autoapp::ui::UpdateDialog::downloadCheck() { - QDir directory("/media/CSSTORAGE"); + QDir directory("/media/USBDRIVES/CSSTORAGE"); QStringList files = directory.entryList(QStringList() << "*.zip", QDir::AllEntries, QDir::Name); foreach(QString filename, files) { if (filename != "") { @@ -136,6 +136,9 @@ void f1x::openauto::autoapp::ui::UpdateDialog::updateCheck() ui_->progressBarOpenauto->hide(); ui_->labelOpenautoOK->show(); } + } else { + ui_->labelOpenautoOK->hide(); + ui_->pushButtonUpdateOpenauto->hide(); } if (std::ifstream("/tmp/system_update_ready")) { @@ -153,15 +156,21 @@ void f1x::openauto::autoapp::ui::UpdateDialog::updateCheck() if (std::ifstream("/tmp/system_update_downloading")) { ui_->labelSystemOK->hide(); ui_->pushButtonUpdateSystem->hide(); + ui_->pushButtonUpdateCheck->hide(); ui_->progressBarSystem->show(); - QFileInfo downloadfile = "/media/CSSTORAGE/" + ui_->labelDownload->text(); + QFileInfo downloadfile = "/media/USBDRIVES/CSSTORAGE/" + ui_->labelDownload->text(); if (downloadfile.exists()) { qint64 size = downloadfile.size(); size = size/1024/1024; ui_->progressBarSystem->setValue(size); } + } else { + if (ui_->pushButtonUpdateCheck->isVisible() == false) { + ui_->pushButtonUpdateCheck->show(); + } } + if (!std::ifstream("/tmp/system_update_available") && !std::ifstream("/tmp/system_update_downloading")) { ui_->progressBarSystem->hide(); ui_->labelSystemOK->show(); diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index be77935..0460a9e 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 929 - 1511 + 1010 + 1657 @@ -139,6 +139,40 @@ 0 + + + + + 0 + 0 + + + + + 40 + 24 + + + + + 40 + 24 + + + + background-color: rgb(78, 154, 6); +color: rgb(239, 239, 239); +outline: none; +border-radius: 4px; + + + Lock + + + Qt::AlignCenter + + + @@ -221,7 +255,7 @@ border-radius: 4px; - 8 + 10 75 true @@ -241,11 +275,23 @@ color: rgb(211, 215, 207); - + 0 0 + + + 0 + 24 + + + + + 16777215 + 24 + + DejaVu Sans @@ -326,6 +372,34 @@ color: rgb(211, 215, 207); + + + + + 0 + 0 + + + + + 40 + 24 + + + + + 40 + 24 + + + + background-color: rgba(0, 0, 0, 0); + + + + + + @@ -607,7 +681,7 @@ color: rgb(0, 102, 255); - + Qt::Horizontal @@ -644,8 +718,8 @@ color: rgb(0, 102, 255); - 75 - true + 50 + false @@ -679,10 +753,44 @@ border-radius: 4px; + + + + + 0 + 0 + + + + + 80 + 24 + + + + + 80 + 24 + + + + background-color: rgb(32, 74, 135); +color: rgb(255, 255, 255); +outline: none; +border-radius: 4px; + + + <html><head/><body><p><span style=" color:#29ffff;">Pairable</span></p></body></html> + + + Qt::AlignCenter + + + - + 0 0 @@ -1340,41 +1448,124 @@ border: no-border; 0 - + 0 0 - - - 75 - true - - - - background-color: rgba(48, 140, 198, 0.5); + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + background-color: rgba(48, 140, 198, 0.5); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); outline: none; +border-bottom: 0px; + + + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + background-color: rgba(48, 140, 198, 0.5); +color: rgb(255, 255, 255); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; +border-top: 0px; +border-bottom: 0px; - - - - - - - :/aausb-hot.png - - - - - 50 - 50 - - + + + + + + + :/aausb-hot.png + + + + + 50 + 50 + + + + false + + + + + + + + 0 + 0 + + + + + 75 + true + + + + background-color: rgba(48, 140, 198, 0.5); +color: rgb(255, 255, 255); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +outline: none; +border-top: 0px; + + + + + + Qt::AlignHCenter|Qt::AlignTop + + + + @@ -3208,7 +3399,7 @@ outline: none; 0 - + 0 @@ -3218,11 +3409,260 @@ outline: none; background-color: rgba(0, 0, 0, 1); border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); - - - +border: 2px solid rgba(255,255,255,0.5); +outline: none; + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + background-color: rgba(0, 0, 0, 0); +border: 0px; + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 66 + 66 + + + + + 66 + 16777215 + + + + + 75 + true + + + + background-color: rgba(136, 138, 133, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +border-left: 0px; +border-top: 0px; +color: rgb(255, 255, 255); +outline: none; + + + Up + + + + + + + + 0 + 0 + + + + + 66 + 66 + + + + + 66 + 16777215 + + + + + 75 + true + + + + background-color: rgba(136, 138, 133, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +border-left: 0px; +border-bottom: 0px; +color: rgb(255, 255, 255); +outline: none; + + + Down + + + + + + + + + + + 0 + 0 + + + + background-color: rgba(0, 0, 0, 0); +border: 0px; +outline: none; + + + + + + + + + + + 0 + 0 + + + + background-color: rgba(0, 0, 0, 0); +border: 0px; + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 66 + 66 + + + + + 66 + 16777215 + + + + + 16 + 75 + true + + + + background-color: rgba(136, 138, 133, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +border-right: 0px; +border-top: 0px; +color: rgb(255, 255, 255); +outline: none; + + + + + + + + + + + + 0 + 0 + + + + + 66 + 66 + + + + + 66 + 16777215 + + + + + 16 + 75 + true + + + + background-color: rgba(136, 138, 133, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +border-right: 0px; +border-bottom: 0px; +color: rgb(255, 255, 255); +outline: none; + + + - + + + + + + + @@ -4780,45 +5220,6 @@ outline: none; - - - - - 0 - 0 - - - - - 0 - 40 - - - - - 16777215 - 40 - - - - - 12 - 75 - true - - - - background-color: rgba(186, 189, 182, 0.7); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); -outline: none; - - - USB - - - diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index cd0a36e..a47496c 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -7,7 +7,7 @@ 0 0 800 - 3473 + 3601 @@ -299,53 +299,111 @@ outline: none; 6 - + 0 0 - - Handedness of traffic - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - + + + 0 + 0 + + 0 + - 2 + 0 - + - + 0 0 - - Left-hand drive + + Handedness of traffic - - true + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 0 + + + 2 + + + + + + 0 + 0 + + + + Left-hand drive + + + true + + + + + + + + 0 + 0 + + + + Right-hand drive + + + + - + - + 0 0 - - Right-hand drive + + Safety Warning + + + 2 + + + 2 + + + + + + 0 + 0 + + + + Don't show again + + + + @@ -2188,223 +2246,420 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} 2 - - - - - Enable touchscreen - - - - - - - Show cursor (needs reboot!) - - - - - - - Buttons - - - - 0 + + + General + + + + 9 + + + 9 + + + 0 + + + 9 + + + 0 + + + + + Enable touchscreen - - 0 + + + + + + Show cursor (needs reboot!) - - 9 - - - - - Next track - - - - - - - Play - - - - - - - Call end - - - - - - - Enter - - - - - - - Left - - - - - - - Previous track - - - - - - - Voice command - - - - - - - Toggle play - - - - - - - Back - - - - - - - Right - - - - - - - Scroll wheel - - - - - - - Home - - - - - - - Pause - - - - - - - Down - - - - - - - Up - - - - - - - Phone - - - - - - - - 0 - 0 - - - - - 120 - 20 - - - - Select all - - - - - - - - 0 - 0 - - - - - 120 - 20 - - - - Clear selection - - - - - - - - 0 - 0 - - - - - 120 - 20 - - - - Show bindings - - - - - - - + + + + - - - - 0 - 0 - - - - + + + Button Controls Android Auto + + + 0 + + + 0 + + + 9 + + + + + Up [Up] + + + + + + + Left [Left] + + + + + + + Previous track [V] + + + + + + + Play [X] + + + + + + + Call end [O] + + + + + + + Toggle play [B] + + + + + + + Voice command [M] + + + + + + + Back [Esc] + + + + + + + Pause [C] + + + + + + + Home [H] + + + + + + + Enter [Enter] + + + + + + + Down [Down] + + + + + + + Scroll wheel [1] / [2] + + + + + + + + 0 + 0 + + + + + 120 + 20 + + + + Select all + + + + + + + + 0 + 0 + + + + + 120 + 20 + + + + Show bindings + + + + + + + Right [Right] + + + + + + + Phone [P] + + + + + + + Next track [N] + + + + + + + + 0 + 0 + + + + + 120 + 20 + + + + Clear selection + + + + + + + + Button Controls Media Player + + + + 0 + + + 0 + + + 9 + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Toggle Play [B] + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Next track [N] + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Play [X] + + + + + + + Enable Controls + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Next album [A] + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Pause [C] + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Home [H] + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Previous track [V] + + + + + + + + 0 + 0 + + + + + 0 + 24 + + + + Previous album [L] + + + + + + + + + + Qt::Vertical + + + + 20 + 4 + + + + @@ -3401,26 +3656,32 @@ outline: none; 0 + + + 0 + 80 + + Force Client Network To Use - + - 0 + 2 0 - 0 + 2 2 - + - + 0 0 @@ -3437,11 +3698,12 @@ outline: none; 24 - - not available + + background-color: rgb(78, 154, 6); +outline: none; - - Qt::AlignCenter + + Auto @@ -3486,6 +3748,18 @@ outline: none; 0 + + + 0 + 24 + + + + + 16777215 + 24 + + 75 @@ -3497,7 +3771,7 @@ outline: none; outline: none; - Default + Config 1 @@ -3509,6 +3783,18 @@ outline: none; 0 + + + 0 + 24 + + + + + 16777215 + 24 + + 75 @@ -3520,30 +3806,41 @@ outline: none; outline: none; - Phone Hotspot - - - - - - - - 0 - 0 - - - - background-color: rgb(78, 154, 6); -outline: none; - - - Auto + Config 2 + + + + + 0 + 0 + + + + + 0 + 24 + + + + + 16777215 + 24 + + + + not available + + + Qt::AlignCenter + + + @@ -8285,205 +8582,6 @@ QComboBox::item:selected { - - - - - - - 0 - 0 - - - - - 200 - 32 - - - - - 200 - 32 - - - - - 12 - 75 - true - - - - QScrollBar { - width: 40px; - background-color: rgba(85, 87, 83, 0.7); -} -QComboBox::item { - padding-top: 6px; - padding-bottom: 6px; - height: 32px; - min-height: 32px; -} -QComboBox::item:selected { - background-color: rgb(78, 154, 6); - padding-top: 6px; - padding-bottom: 6px; - height: 32px; - min-height: 32px; -} - - - - none - - - - - abx80x - - - - - ds1307 - - - - - ds1339 - - - - - ds3231 - - - - - mcp7940x - - - - - mcp7941x - - - - - pcf2127 - - - - - pcf8523 - - - - - pcf8563 - - - - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 100 - 30 - - - - Timezone - - - - - - - - 0 - 0 - - - - - 0 - 32 - - - - - 16777215 - 32 - - - - - 12 - 75 - true - - - - QScrollBar { - width: 40px; - background-color: rgba(85, 87, 83, 0.7); -} -QComboBox::item { - padding-top: 6px; - padding-bottom: 6px; - height: 32px; - min-height: 32px; -} -QComboBox::item:selected { - background-color: rgb(78, 154, 6); - padding-top: 6px; - padding-bottom: 6px; - height: 32px; - min-height: 32px; -} - - - - - - - - @@ -8503,6 +8601,225 @@ QComboBox::item:selected { + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 200 + 32 + + + + + 200 + 32 + + + + + 12 + 75 + true + + + + QScrollBar { + width: 40px; + background-color: rgba(85, 87, 83, 0.7); +} +QComboBox::item { + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} +QComboBox::item:selected { + background-color: rgb(78, 154, 6); + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} + + + + none + + + + + abx80x + + + + + ds1307 + + + + + ds1339 + + + + + ds3231 + + + + + mcp7940x + + + + + mcp7941x + + + + + pcf2127 + + + + + pcf8523 + + + + + pcf8563 + + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 100 + 30 + + + + Timezone + + + + + + + + 0 + 0 + + + + + 0 + 32 + + + + + 16777215 + 32 + + + + + 12 + 75 + true + + + + QScrollBar { + width: 40px; + background-color: rgba(85, 87, 83, 0.7); +} +QComboBox::item { + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} +QComboBox::item:selected { + background-color: rgb(78, 154, 6); + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} + + + + + + + + + @@ -8523,34 +8840,55 @@ QComboBox::item:selected { - + 0 0 - - - 0 - 32 - - - - - 16777215 - 32 - - - - - 12 - 75 - true - - - - QScrollBar { + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 32 + + + + + 16777215 + 32 + + + + + 12 + 75 + true + + + + QScrollBar { width: 40px; background-color: rgba(85, 87, 83, 0.7); } @@ -8567,17 +8905,202 @@ QComboBox::item:selected { height: 32px; min-height: 32px; } - - - - none - - - - - enabled - - + + + + none + + + + + enabled + + + + + + + + + 80 + 30 + + + + FlipX + + + + + + + + 80 + 30 + + + + FlipY + + + + + + + + 0 + 0 + + + + + 70 + 30 + + + + + 70 + 30 + + + + Rotation ° + + + + + + + + 0 + 32 + + + + + 16777215 + 32 + + + + QScrollBar { + width: 40px; + background-color: rgba(85, 87, 83, 0.7); +} +QComboBox::item { + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} +QComboBox::item:selected { + background-color: rgb(78, 154, 6); + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} + + + + 0 + + + + + 90 + + + + + 180 + + + + + 270 + + + + + + + + + 0 + 0 + + + + + 80 + 30 + + + + + 80 + 30 + + + + Resolution + + + + + + + + 0 + 0 + + + + + 0 + 32 + + + + + 16777215 + 32 + + + + QScrollBar { + width: 40px; + background-color: rgba(85, 87, 83, 0.7); +} +QComboBox::item { + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} +QComboBox::item:selected { + background-color: rgb(78, 154, 6); + padding-top: 6px; + padding-bottom: 6px; + height: 32px; + min-height: 32px; +} + + + + 720 + + + + + 1080 + + + + + @@ -8599,6 +9122,32 @@ QComboBox::item:selected { + + + + + 0 + 0 + + + + + 100 + 30 + + + + SDCard OC + + + + + + + Lightsensor + + + @@ -8662,25 +9211,6 @@ QComboBox::item:selected { - - - - - 0 - 0 - - - - - 100 - 30 - - - - SDCard OC - - - @@ -8739,13 +9269,6 @@ QComboBox::item:selected { - - - - Lightsensor - - - diff --git a/src/autoapp/UI/warningdialog.ui b/src/autoapp/UI/warningdialog.ui index 05504e7..c0e53b7 100644 --- a/src/autoapp/UI/warningdialog.ui +++ b/src/autoapp/UI/warningdialog.ui @@ -106,32 +106,36 @@ border-color: rgb(186, 189, 182); - - - - 0 - 40 - - - - - 16777215 - 40 - - - - - 75 - true - - - - background-color: rgb(186, 189, 182); - - - OK - - + + + + + + 0 + 40 + + + + + 16777215 + 40 + + + + + 75 + true + + + + background-color: rgb(186, 189, 182); + + + OK + + + + diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index 6260257..e482f76 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -122,8 +122,9 @@ int main(int argc, char* argv[]) QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { system("touch /tmp/shutdown"); std::exit(0); }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::reboot, []() { system("touch /tmp/reboot"); std::exit(0); }); - QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::loadSystemValues); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::show_tab1); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::loadSystemValues); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectdialog, &autoapp::ui::ConnectDialog::loadClientList); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectdialog, &autoapp::ui::ConnectDialog::exec); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openUpdateDialog, &updatedialog, &autoapp::ui::UpdateDialog::updateCheck); @@ -136,85 +137,69 @@ int main(int argc, char* argv[]) } QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraHide, [&qApplication]() { -#ifdef RASPBERRYPI3 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 + OPENAUTO_LOG(info) << "[Camera] Background."; }); 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 + OPENAUTO_LOG(info) << "[Camera] Foreground."; + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraPosYUp, [&qApplication]() { + system("/opt/crankshaft/cameracontrol.py PosYUp &"); + OPENAUTO_LOG(info) << "[Camera] PosY up."; + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraPosYDown, [&qApplication]() { + system("/opt/crankshaft/cameracontrol.py PosYDown &"); + OPENAUTO_LOG(info) << "[Camera] PosY down."; + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraZoomPlus, [&qApplication]() { + system("/opt/crankshaft/cameracontrol.py ZoomPlus &"); + OPENAUTO_LOG(info) << "[Camera] Zoom plus."; + }); + + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::cameraZoomMinus, [&qApplication]() { + system("/opt/crankshaft/cameracontrol.py ZoomMinus &"); + OPENAUTO_LOG(info) << "[Camera] Zoom minus."; }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::hideRearCam, [&qApplication]() { -#ifdef RASPBERRYPI3 system("/opt/crankshaft/cameracontrol.py DashcamMode &"); system("sudo rm /tmp/rearcam_enabled &"); - 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 + OPENAUTO_LOG(info) << "[Camera] Dashcam mode."; }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::showRearCam, [&qApplication]() { -#ifdef RASPBERRYPI3 system("/opt/crankshaft/cameracontrol.py Rearcam &"); - 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 + OPENAUTO_LOG(info) << "[Camera] Rearcam mode."; }); 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 + OPENAUTO_LOG(info) << "[Camera] Record."; }); 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 + OPENAUTO_LOG(info) << "[Camera] Stop."; }); 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 + OPENAUTO_LOG(info) << "[Camera] Save."; }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerScriptNight, [&qApplication]() { -#ifdef RASPBERRYPI3 system("/opt/crankshaft/service_daynight.sh app night"); - OPENAUTO_LOG(info) << "[CS] Run night script."; -#else - OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Day/Night script."; -#endif + OPENAUTO_LOG(info) << "[MainWindow] Night."; }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerScriptDay, [&qApplication]() { -#ifdef RASPBERRYPI3 system("/opt/crankshaft/service_daynight.sh app day"); - OPENAUTO_LOG(info) << "[CS] Run day script."; -#else - OPENAUTO_LOG(info) << "[CS] You are not running this on a Raspberry Pi, skipping Day/Night script."; -#endif + OPENAUTO_LOG(info) << "[MainWindow] Day."; }); mainWindow.showFullScreen(); @@ -236,36 +221,46 @@ int main(int argc, char* argv[]) }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAppStart, [&app]() { - OPENAUTO_LOG(info) << "[Autoapp] Manual start android auto entity by reset usb."; + OPENAUTO_LOG(info) << "[Autoapp] Manual start android auto."; try { if (std::ifstream("/tmp/android_device")) { - //system("/usr/local/bin/autoapp_helper usbreset"); app->disableAutostartEntity = false; + app->stop(); app->waitForUSBDevice(); } } catch (...) { - OPENAUTO_LOG(info) << "[Autoapp] Exception in Manual start android auto entity by reset usb."; + OPENAUTO_LOG(info) << "[Autoapp] Exception in Manual start android auto."; } }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::TriggerAppStop, [&app]() { - OPENAUTO_LOG(info) << "[Autoapp] Manual stop android auto entity."; try { if (std::ifstream("/tmp/android_device")) { + OPENAUTO_LOG(info) << "[Autoapp] Manual stop usb android auto."; app->disableAutostartEntity = true; system("/usr/local/bin/autoapp_helper usbreset"); - usleep(500000); + usleep(1000000); app->stop(); } else { + OPENAUTO_LOG(info) << "[Autoapp] Manual stop wifi android auto."; app->stop(); - //app->onAndroidAutoQuit(); } } catch (...) { - OPENAUTO_LOG(info) << "[Autoapp] Exception in Manual stop android auto entity."; + OPENAUTO_LOG(info) << "[Autoapp] Exception in manual stop android auto."; } }); - warningdialog.show(); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::CloseAllDialogs, [&settingsWindow, &connectdialog, &updatedialog, &warningdialog]() { + settingsWindow.close(); + connectdialog.close(); + warningdialog.close(); + updatedialog.close(); + OPENAUTO_LOG(info) << "[Autoapp] Close all possible open dialogs."; + }); + + if (configuration->hideWarning() == false) { + warningdialog.show(); + } app->waitForUSBDevice();