diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index a32b098..1d74012 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -45,230 +45,231 @@ #include #include -//#include +// #include namespace Ui { -class MainWindow; + class MainWindow; } namespace f1x { -namespace openauto -{ -namespace autoapp -{ -namespace ui -{ + namespace openauto + { + namespace autoapp + { + namespace ui + { -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - explicit MainWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr); - ~MainWindow() override; - QMediaPlayer* player; - QFileSystemWatcher* watcher; - QFileSystemWatcher* watcher_tmp; + class MainWindow : public QMainWindow + { + Q_OBJECT + public: + explicit MainWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr); + ~MainWindow() override; + QMediaPlayer *player; + QFileSystemWatcher *watcher; + QFileSystemWatcher *watcher_tmp; -signals: - void exit(); - void reboot(); - void openSettings(); - void toggleCursor(); - void TriggerScriptDay(); - void TriggerScriptNight(); - void cameraShow(); - void cameraHide(); - void cameraStop(); - void cameraSave(); - void cameraRecord(); - void cameraPosYUp(); - void cameraPosYDown(); - void cameraZoomPlus(); - void cameraZoomMinus(); - void cameraFlipX(); - void cameraFlipY(); - void openConnectDialog(); - void openWifiDialog(); - void openUpdateDialog(); - void showBrightnessSlider(); - void showAlphaSlider(); - void showRearCam(); - void hideRearCam(); - void TriggerAppStart(); - void TriggerAppStop(); - void CloseAllDialogs(); + signals: + void exit(); + void reboot(); + void openSettings(); + void toggleCursor(); + void TriggerScriptDay(); + void TriggerScriptNight(); + void cameraShow(); + void cameraHide(); + void cameraStop(); + void cameraSave(); + void cameraRecord(); + void cameraPosYUp(); + void cameraPosYDown(); + void cameraZoomPlus(); + void cameraZoomMinus(); + void cameraFlipX(); + void cameraFlipY(); + void openConnectDialog(); + void openWifiDialog(); + void openUpdateDialog(); + void showBrightnessSlider(); + void showAlphaSlider(); + void showRearCam(); + void hideRearCam(); + void TriggerAppStart(); + void TriggerAppStop(); + void CloseAllDialogs(); -private slots: - void on_horizontalSliderBrightness_valueChanged(int value); - void updateAlpha(); + private slots: + void on_horizontalSliderBrightness_valueChanged(int value); + void updateAlpha(); -private slots: - void on_pushButtonBrightness_clicked(); - void on_pushButtonBrightness2_clicked(); - void switchGuiToDay(); - void switchGuiToNight(); - void showTime(); - void cameraControlShow(); - void cameraControlHide(); - void toggleExit(); - void createDebuglog(); - void setPairable(); - void toggleGUI(); - void customButtonPressed1(); - void customButtonPressed2(); - void customButtonPressed3(); - void customButtonPressed4(); - void customButtonPressed5(); - void customButtonPressed6(); - void playerShow(); - void playerHide(); - void updateBG(); + private slots: + void on_pushButtonBrightness_clicked(); + void on_pushButtonBrightness2_clicked(); + void switchGuiToDay(); + void switchGuiToNight(); + void showTime(); + void cameraControlShow(); + void cameraControlHide(); + void toggleExit(); + void createDebuglog(); + void setPairable(); + void toggleGUI(); + void customButtonPressed1(); + void customButtonPressed2(); + void customButtonPressed3(); + void customButtonPressed4(); + void customButtonPressed5(); + void customButtonPressed6(); + void playerShow(); + void playerHide(); + void updateBG(); - void on_horizontalSliderProgressPlayer_sliderMoved(int position); - void on_pushButtonList_clicked(); - void on_pushButtonPlayerStop_clicked(); - void on_pushButtonPlayerPause_clicked(); - void on_positionChanged(qint64 position); - void on_durationChanged(qint64 position); - void on_mp3List_itemClicked(QListWidgetItem *item); - void metaDataChanged(); - void on_pushButtonPlayerPlayList_clicked(); - void on_pushButtonPlayerNextBig_clicked(); - void on_pushButtonPlayerPrevBig_clicked(); - void on_pushButtonPlayerPrevAlbum_clicked(); - void on_pushButtonPlayerNextAlbum_clicked(); - void on_pushButtonBackToPlayer_clicked(); - void on_comboBoxAlbum_currentIndexChanged(const QString &arg1); - void on_mp3List_currentRowChanged(int currentRow); - void on_StateChanged(QMediaPlayer::State state); - void scanFolders(); - void scanFiles(); - void tmpChanged(); - void setTrigger(); - void setRetryUSBConnect(); - void resetRetryUSBMessage(); - void updateNetworkInfo(); - bool check_file_exist(const char *filename); - void hostModeStateChanged(QBluetoothLocalDevice::HostMode); + void on_horizontalSliderProgressPlayer_sliderMoved(int position); + void on_pushButtonList_clicked(); + void on_pushButtonPlayerStop_clicked(); + void on_pushButtonPlayerPause_clicked(); + void on_positionChanged(qint64 position); + void on_durationChanged(qint64 position); + void on_mp3List_itemClicked(QListWidgetItem *item); + void metaDataChanged(); + void on_pushButtonPlayerPlayList_clicked(); + void on_pushButtonPlayerNextBig_clicked(); + void on_pushButtonPlayerPrevBig_clicked(); + void on_pushButtonPlayerPrevAlbum_clicked(); + void on_pushButtonPlayerNextAlbum_clicked(); + void on_pushButtonBackToPlayer_clicked(); + void on_comboBoxAlbum_currentIndexChanged(const QString &arg1); + void on_mp3List_currentRowChanged(int currentRow); + void on_StateChanged(QMediaPlayer::State state); + void scanFolders(); + void scanFiles(); + void tmpChanged(); + void setTrigger(); + void setRetryUSBConnect(); + void resetRetryUSBMessage(); + void updateNetworkInfo(); + bool check_file_exist(const char *filename); + void hostModeStateChanged(QBluetoothLocalDevice::HostMode); + void connectWebSocket(); + void handleIncomingMessage(const QString &message); - //void on_AlbumCoverListView_clicked(const QModelIndex &index); - void on_AlbumCoverListView_clicked(const QModelIndex &index); + // void on_AlbumCoverListView_clicked(const QModelIndex &index); + void on_AlbumCoverListView_clicked(const QModelIndex &index); - void on_pushButtonAlbum_clicked(); + void on_pushButtonAlbum_clicked(); -private: - Ui::MainWindow* ui_; - configuration::IConfiguration::Pointer configuration_; + private: + Ui::MainWindow *ui_; + configuration::IConfiguration::Pointer configuration_; - QString brightnessFilename = "/sys/class/backlight/rpi_backlight/brightness"; - QString brightnessFilenameAlt = "/tmp/custombrightness"; - QFile *brightnessFile; - QFile *brightnessFileAlt; - char brightness_str[6]; - int alpha_current_str; - QString bversion; - QString bdate; + QString brightnessFilename = "/sys/class/backlight/rpi_backlight/brightness"; + QString brightnessFilenameAlt = "/tmp/custombrightness"; + QFile *brightnessFile; + QFile *brightnessFileAlt; + char brightness_str[6]; + int alpha_current_str; + QString bversion; + QString bdate; - char nightModeFile[32] = "/tmp/night_mode_enabled"; - char devModeFile[32] = "/tmp/dev_mode_enabled"; - char wifiButtonFile[32] = "/etc/button_wifi_visible"; - char cameraButtonFile[32] = "/etc/button_camera_visible"; - char brightnessButtonFile[32] = "/etc/button_brightness_visible"; - char debugModeFile[32] = "/tmp/usb_debug_mode"; - char lsFile[32] = "/etc/cs_lightsensor"; + char nightModeFile[32] = "/tmp/night_mode_enabled"; + char devModeFile[32] = "/tmp/dev_mode_enabled"; + char wifiButtonFile[32] = "/etc/button_wifi_visible"; + char cameraButtonFile[32] = "/etc/button_camera_visible"; + char brightnessButtonFile[32] = "/etc/button_brightness_visible"; + char debugModeFile[32] = "/tmp/usb_debug_mode"; + char lsFile[32] = "/etc/cs_lightsensor"; - char custom_button_file_c1[26] = "/boot/crankshaft/button_1"; - char custom_button_file_c2[26] = "/boot/crankshaft/button_2"; - char custom_button_file_c3[26] = "/boot/crankshaft/button_3"; - char custom_button_file_c4[26] = "/boot/crankshaft/button_4"; - char custom_button_file_c5[26] = "/boot/crankshaft/button_5"; - char custom_button_file_c6[26] = "/boot/crankshaft/button_6"; + char custom_button_file_c1[26] = "/boot/crankshaft/button_1"; + char custom_button_file_c2[26] = "/boot/crankshaft/button_2"; + char custom_button_file_c3[26] = "/boot/crankshaft/button_3"; + char custom_button_file_c4[26] = "/boot/crankshaft/button_4"; + char custom_button_file_c5[26] = "/boot/crankshaft/button_5"; + char custom_button_file_c6[26] = "/boot/crankshaft/button_6"; - QString custom_button_command_c1; - QString custom_button_command_c2; - QString custom_button_command_c3; - QString custom_button_command_c4; - QString custom_button_command_c5; - QString custom_button_command_c6; + QString custom_button_command_c1; + QString custom_button_command_c2; + QString custom_button_command_c3; + QString custom_button_command_c4; + QString custom_button_command_c5; + QString custom_button_command_c6; - QString custom_button_color_c1 = "186,189,192"; - QString custom_button_color_c2 = "186,189,192"; - QString custom_button_color_c3 = "186,189,192"; - QString custom_button_color_c4 = "186,189,192"; - QString custom_button_color_c5 = "186,189,192"; - QString custom_button_color_c6 = "186,189,192"; + QString custom_button_color_c1 = "186,189,192"; + QString custom_button_color_c2 = "186,189,192"; + QString custom_button_color_c3 = "186,189,192"; + QString custom_button_color_c4 = "186,189,192"; + QString custom_button_color_c5 = "186,189,192"; + QString custom_button_color_c6 = "186,189,192"; - QString selectedMp3file; - QString musicfolder = "/media/CSSTORAGE/Music"; - QString albumfolder = "/"; - QString date_text; + QString selectedMp3file; + QString musicfolder = "/media/CSSTORAGE/Music"; + QString albumfolder = "/"; + QString date_text; - QMediaPlaylist *playlist; + QMediaPlaylist *playlist; - bool customBrightnessControl = false; + bool customBrightnessControl = false; - bool wifiButtonForce = false; - bool cameraButtonForce = false; - bool brightnessButtonForce = false; + bool wifiButtonForce = false; + bool cameraButtonForce = false; + bool brightnessButtonForce = false; - bool nightModeEnabled = false; - bool DayNightModeState = false; + bool nightModeEnabled = false; + bool DayNightModeState = false; - bool devModeEnabled = false; + bool devModeEnabled = false; - bool wallpaperDayFileExists = false; - bool wallpaperNightFileExists = false; - bool wallpaperClassicDayFileExists = false; - bool wallpaperClassicNightFileExists = false; - bool wallpaperEQFileExists = false; + bool wallpaperDayFileExists = false; + bool wallpaperNightFileExists = false; + bool wallpaperClassicDayFileExists = false; + bool wallpaperClassicNightFileExists = false; + bool wallpaperEQFileExists = false; - bool exitMenuVisible = false; + bool exitMenuVisible = false; - bool rearCamEnabled = false; - bool rearCamVisible = false; + bool rearCamEnabled = false; + bool rearCamVisible = false; - bool dashCamRecording = false; - bool systemDebugmode = false; + bool dashCamRecording = false; + bool systemDebugmode = false; - bool bluetoothEnabled = false; + bool bluetoothEnabled = false; - bool oldGUIStyle = false; - bool UseBigClock = false; - bool NoClock = false; + bool oldGUIStyle = false; + bool UseBigClock = false; + bool NoClock = false; - bool c1ButtonForce = false; - bool c2ButtonForce = false; - bool c3ButtonForce = false; - bool c4ButtonForce = false; - bool c5ButtonForce = false; - bool c6ButtonForce = false; + bool c1ButtonForce = false; + bool c2ButtonForce = false; + bool c3ButtonForce = false; + bool c4ButtonForce = false; + bool c5ButtonForce = false; + bool c6ButtonForce = false; - bool hotspotActive = false; - int currentPlaylistIndex = 0; - bool background_set = false; - bool mediacontentchanged = true; + bool hotspotActive = false; + int currentPlaylistIndex = 0; + bool background_set = false; + bool mediacontentchanged = true; - bool lightsensor = false; - bool holidaybg = false; + bool lightsensor = false; + bool holidaybg = false; - bool csmtupdate = false; - bool udevupdate = false; - bool openautoupdate = false; - bool systemupdate = false; + bool csmtupdate = false; + bool udevupdate = false; + bool openautoupdate = false; + bool systemupdate = false; - int camera_ycorection; - int camera_zoom; + int camera_ycorection; + int camera_zoom; - QBluetoothLocalDevice *localDevice; + QBluetoothLocalDevice *localDevice; -protected: - void keyPressEvent(QKeyEvent *event); - -}; + protected: + void keyPressEvent(QKeyEvent *event); + }; -} -} -} + } + } + } } diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index b143740..704a175 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -40,531 +41,661 @@ namespace f1x { -namespace openauto -{ -namespace autoapp -{ -namespace ui -{ + namespace openauto + { + namespace autoapp + { + 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);}"); + MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent) + : QMainWindow(parent), ui_(new Ui::MainWindow), localDevice(new QBluetoothLocalDevice), webSocket(new QWebSocket), + reconnectTimer(new QTimer(this)), + shuttingDown(false) + { + // set default bg color to black + this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);}"); - // Set default font and size - int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); - QString family = QFontDatabase::applicationFontFamilies(id).at(0); - QFont _font(family, 11); - qApp->setFont(_font); + // Set default font and size + int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); + QString family = QFontDatabase::applicationFontFamilies(id).at(0); + QFont _font(family, 11); + qApp->setFont(_font); - this->configuration_ = configuration; + this->configuration_ = configuration; - // trigger files - this->nightModeEnabled = check_file_exist(this->nightModeFile); - this->devModeEnabled = check_file_exist(this->devModeFile); - this->wifiButtonForce = check_file_exist(this->wifiButtonFile); - this->cameraButtonForce = check_file_exist(this->cameraButtonFile); - this->brightnessButtonForce = check_file_exist(this->brightnessButtonFile); - this->systemDebugmode = check_file_exist(this->debugModeFile); - this->lightsensor = check_file_exist(this->lsFile); - this->c1ButtonForce = check_file_exist(this->custom_button_file_c1); - this->c2ButtonForce = check_file_exist(this->custom_button_file_c2); - this->c3ButtonForce = check_file_exist(this->custom_button_file_c3); - this->c4ButtonForce = check_file_exist(this->custom_button_file_c4); - this->c5ButtonForce = check_file_exist(this->custom_button_file_c5); - this->c6ButtonForce = check_file_exist(this->custom_button_file_c6); + // trigger files + this->nightModeEnabled = check_file_exist(this->nightModeFile); + this->devModeEnabled = check_file_exist(this->devModeFile); + this->wifiButtonForce = check_file_exist(this->wifiButtonFile); + this->cameraButtonForce = check_file_exist(this->cameraButtonFile); + this->brightnessButtonForce = check_file_exist(this->brightnessButtonFile); + this->systemDebugmode = check_file_exist(this->debugModeFile); + this->lightsensor = check_file_exist(this->lsFile); + this->c1ButtonForce = check_file_exist(this->custom_button_file_c1); + this->c2ButtonForce = check_file_exist(this->custom_button_file_c2); + this->c3ButtonForce = check_file_exist(this->custom_button_file_c3); + this->c4ButtonForce = check_file_exist(this->custom_button_file_c4); + this->c5ButtonForce = check_file_exist(this->custom_button_file_c5); + this->c6ButtonForce = check_file_exist(this->custom_button_file_c6); - // wallpaper stuff - this->wallpaperDayFileExists = check_file_exist("wallpaper.png"); - this->wallpaperNightFileExists = check_file_exist("wallpaper-night.png"); - this->wallpaperClassicDayFileExists = check_file_exist("wallpaper-classic.png"); - this->wallpaperClassicNightFileExists = check_file_exist("wallpaper-classic-night.png"); - this->wallpaperEQFileExists = check_file_exist("wallpaper-eq.png"); + // wallpaper stuff + this->wallpaperDayFileExists = check_file_exist("wallpaper.png"); + this->wallpaperNightFileExists = check_file_exist("wallpaper-night.png"); + this->wallpaperClassicDayFileExists = check_file_exist("wallpaper-classic.png"); + this->wallpaperClassicNightFileExists = check_file_exist("wallpaper-classic-night.png"); + this->wallpaperEQFileExists = check_file_exist("wallpaper-eq.png"); - ui_->setupUi(this); + ui_->setupUi(this); - connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings); - connect(ui_->pushButtonSettings2, &QPushButton::clicked, this, &MainWindow::openSettings); - connect(ui_->pushButtonUpdate, &QPushButton::clicked, this, &MainWindow::openUpdateDialog); - connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::toggleExit); - connect(ui_->pushButtonExit2, &QPushButton::clicked, this, &MainWindow::toggleExit); - connect(ui_->pushButtonShutdown, &QPushButton::clicked, this, &MainWindow::exit); - connect(ui_->pushButtonShutdown2, &QPushButton::clicked, this, &MainWindow::exit); - connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::reboot); - connect(ui_->pushButtonReboot2, &QPushButton::clicked, this, &MainWindow::reboot); - connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &MainWindow::toggleExit); - connect(ui_->pushButtonCancel2, &QPushButton::clicked, this, &MainWindow::toggleExit); - connect(ui_->pushButtonDay, &QPushButton::clicked, this, &MainWindow::TriggerScriptDay); - connect(ui_->pushButtonDay, &QPushButton::clicked, this, &MainWindow::switchGuiToDay); - connect(ui_->pushButtonDay2, &QPushButton::clicked, this, &MainWindow::TriggerScriptDay); - connect(ui_->pushButtonDay2, &QPushButton::clicked, this, &MainWindow::switchGuiToDay); - connect(ui_->pushButtonNight, &QPushButton::clicked, this, &MainWindow::TriggerScriptNight); - connect(ui_->pushButtonNight, &QPushButton::clicked, this, &MainWindow::switchGuiToNight); - connect(ui_->pushButtonNight2, &QPushButton::clicked, this, &MainWindow::TriggerScriptNight); - connect(ui_->pushButtonNight2, &QPushButton::clicked, this, &MainWindow::switchGuiToNight); - connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider); - connect(ui_->pushButtonBrightness2, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider); - connect(ui_->pushButtonDebug, &QPushButton::clicked, this, &MainWindow::createDebuglog); - connect(ui_->pushButtonDebug2, &QPushButton::clicked, this, &MainWindow::createDebuglog); - connect(ui_->pushButtonBluetooth, &QPushButton::clicked, this, &MainWindow::setPairable); - connect(ui_->pushButtonToggleGUI, &QPushButton::clicked, this, &MainWindow::toggleGUI); - connect(ui_->pushButtonToggleGUI2, &QPushButton::clicked, this, &MainWindow::toggleGUI); - connect(ui_->pushButtonWifi, &QPushButton::clicked, this, &MainWindow::openConnectDialog); - connect(ui_->pushButtonWifi2, &QPushButton::clicked, this, &MainWindow::openConnectDialog); - connect(ui_->pushButtonMusic, &QPushButton::clicked, this, &MainWindow::playerShow); - connect(ui_->pushButtonMusic2, &QPushButton::clicked, this, &MainWindow::playerShow); - connect(ui_->pushButtonBack, &QPushButton::clicked, this, &MainWindow::playerHide); - connect(ui_->pushButtonPlayerBack, &QPushButton::clicked, this, &MainWindow::playerHide); - connect(ui_->pushButtonAndroidAuto, &QPushButton::clicked, this, &MainWindow::TriggerAppStart); - connect(ui_->pushButtonAndroidAuto, &QPushButton::clicked, this, &MainWindow::setRetryUSBConnect); - connect(ui_->pushButtonAndroidAuto2, &QPushButton::clicked, this, &MainWindow::TriggerAppStart); - connect(ui_->pushButtonAndroidAuto2, &QPushButton::clicked, this, &MainWindow::setRetryUSBConnect); + connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings); + connect(ui_->pushButtonSettings2, &QPushButton::clicked, this, &MainWindow::openSettings); + connect(ui_->pushButtonUpdate, &QPushButton::clicked, this, &MainWindow::openUpdateDialog); + connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::toggleExit); + connect(ui_->pushButtonExit2, &QPushButton::clicked, this, &MainWindow::toggleExit); + connect(ui_->pushButtonShutdown, &QPushButton::clicked, this, &MainWindow::exit); + connect(ui_->pushButtonShutdown2, &QPushButton::clicked, this, &MainWindow::exit); + connect(ui_->pushButtonReboot, &QPushButton::clicked, this, &MainWindow::reboot); + connect(ui_->pushButtonReboot2, &QPushButton::clicked, this, &MainWindow::reboot); + connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &MainWindow::toggleExit); + connect(ui_->pushButtonCancel2, &QPushButton::clicked, this, &MainWindow::toggleExit); + connect(ui_->pushButtonDay, &QPushButton::clicked, this, &MainWindow::TriggerScriptDay); + connect(ui_->pushButtonDay, &QPushButton::clicked, this, &MainWindow::switchGuiToDay); + connect(ui_->pushButtonDay2, &QPushButton::clicked, this, &MainWindow::TriggerScriptDay); + connect(ui_->pushButtonDay2, &QPushButton::clicked, this, &MainWindow::switchGuiToDay); + connect(ui_->pushButtonNight, &QPushButton::clicked, this, &MainWindow::TriggerScriptNight); + connect(ui_->pushButtonNight, &QPushButton::clicked, this, &MainWindow::switchGuiToNight); + connect(ui_->pushButtonNight2, &QPushButton::clicked, this, &MainWindow::TriggerScriptNight); + connect(ui_->pushButtonNight2, &QPushButton::clicked, this, &MainWindow::switchGuiToNight); + connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider); + connect(ui_->pushButtonBrightness2, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider); + connect(ui_->pushButtonDebug, &QPushButton::clicked, this, &MainWindow::createDebuglog); + connect(ui_->pushButtonDebug2, &QPushButton::clicked, this, &MainWindow::createDebuglog); + connect(ui_->pushButtonBluetooth, &QPushButton::clicked, this, &MainWindow::setPairable); + connect(ui_->pushButtonToggleGUI, &QPushButton::clicked, this, &MainWindow::toggleGUI); + connect(ui_->pushButtonToggleGUI2, &QPushButton::clicked, this, &MainWindow::toggleGUI); + connect(ui_->pushButtonWifi, &QPushButton::clicked, this, &MainWindow::openConnectDialog); + connect(ui_->pushButtonWifi2, &QPushButton::clicked, this, &MainWindow::openConnectDialog); + connect(ui_->pushButtonMusic, &QPushButton::clicked, this, &MainWindow::playerShow); + connect(ui_->pushButtonMusic2, &QPushButton::clicked, this, &MainWindow::playerShow); + connect(ui_->pushButtonBack, &QPushButton::clicked, this, &MainWindow::playerHide); + connect(ui_->pushButtonPlayerBack, &QPushButton::clicked, this, &MainWindow::playerHide); + connect(ui_->pushButtonAndroidAuto, &QPushButton::clicked, this, &MainWindow::TriggerAppStart); + connect(ui_->pushButtonAndroidAuto, &QPushButton::clicked, this, &MainWindow::setRetryUSBConnect); + connect(ui_->pushButtonAndroidAuto2, &QPushButton::clicked, this, &MainWindow::TriggerAppStart); + connect(ui_->pushButtonAndroidAuto2, &QPushButton::clicked, this, &MainWindow::setRetryUSBConnect); + // RADIO WEBSOCKET STUFF + reconnectTimer->setSingleShot(true); + reconnectTimer->setInterval(3000); // 3 seconds delay before reconnect + connect(reconnectTimer, &QTimer::timeout, this, &MainWindow::connectWebSocket); - ui_->radioView->hide(); + connect(webSocket, &QWebSocket::connected, this, [this]() + { + qDebug() << "WebSocket connected"; + webSocket->sendTextMessage(QStringLiteral("Hello from MainWindow WebSocket!")); }); - ui_->clockOnlyWidget->hide(); + connect(webSocket, &QWebSocket::textMessageReceived, this, [this](const QString &message) + { + qDebug() << "Message received:" << message; + handleIncomingMessage(message); }); - ui_->pushButtonBluetooth->hide(); - ui_->labelBluetoothPairable->hide(); + connect(webSocket, &QWebSocket::disconnected, this, [this]() + { + qDebug() << "WebSocket disconnected"; + if (!shuttingDown) { + qDebug() << "Attempting to reconnect in 3 seconds..."; + reconnectTimer->start(); + } }); - // by default hide media player - ui_->mediaWidget->hide(); + connect(webSocket, QOverload::of(&QWebSocket::error), + this, [this](QAbstractSocket::SocketError) + { qDebug() << "WebSocket error:" << webSocket->errorString(); }); - ui_->SysinfoTopLeft->hide(); + connectWebSocket(); // Initial connection - ui_->ButtonAndroidAuto->hide(); - ui_->pushButtonAndroidAuto2->hide(); + ui_->clockOnlyWidget->hide(); - ui_->SysinfoTopLeft2->hide(); + ui_->pushButtonBluetooth->hide(); + ui_->labelBluetoothPairable->hide(); - ui_->pushButtonUpdate->hide(); - ui_->label_dummy_right->hide(); + // by default hide media player + ui_->mediaWidget->hide(); - ui_->dcRecording->hide(); + ui_->SysinfoTopLeft->hide(); - if (!configuration->showNetworkinfo()) { - ui_->networkInfo->hide(); - } + ui_->ButtonAndroidAuto->hide(); + ui_->pushButtonAndroidAuto2->hide(); - if (!this->devModeEnabled) { - ui_->labelLock->hide(); - ui_->labelLockDummy->hide(); - } + ui_->SysinfoTopLeft2->hide(); + ui_->pushButtonUpdate->hide(); + ui_->label_dummy_right->hide(); + + ui_->dcRecording->hide(); + + if (!configuration->showNetworkinfo()) + { + ui_->networkInfo->hide(); + } + + if (!this->devModeEnabled) + { + ui_->labelLock->hide(); + ui_->labelLockDummy->hide(); + } + + if (std::ifstream("/etc/crankshaft.branch")) + { + QString branch = configuration_->readFileContent("/etc/crankshaft.branch"); + if (branch != "crankshaft-ng") + { + if (branch == "csng-dev") + { + ui_->Header_Label->setText("

crankshaft NG - Dev-Build

"); + } + else + { + ui_->Header_Label->setText("

crankshaft NG - Custom-Build

"); + } + } + } + + QTimer *timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(showTime())); + timer->start(1000); + + // enable connects while cam is enabled + if (this->cameraButtonForce) + { + connect(ui_->pushButtonCameraShow, &QPushButton::clicked, this, &MainWindow::cameraShow); + connect(ui_->pushButtonCameraShow, &QPushButton::clicked, this, &MainWindow::cameraControlShow); + connect(ui_->pushButtonCameraShow2, &QPushButton::clicked, this, &MainWindow::cameraShow); + connect(ui_->pushButtonCameraShow2, &QPushButton::clicked, this, &MainWindow::cameraControlShow); + connect(ui_->pushButtonCameraHide, &QPushButton::clicked, this, &MainWindow::cameraHide); + connect(ui_->pushButtonCameraHide, &QPushButton::clicked, this, &MainWindow::cameraControlHide); + connect(ui_->pushButtonStop, &QPushButton::clicked, this, &MainWindow::cameraStop); + connect(ui_->pushButtonRecord, &QPushButton::clicked, this, &MainWindow::cameraRecord); + connect(ui_->pushButtonSave, &QPushButton::clicked, this, &MainWindow::cameraSave); + connect(ui_->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(); + } + + // show debug button if enabled + if (!this->systemDebugmode) + { + ui_->pushButtonDebug->hide(); + ui_->pushButtonDebug2->hide(); + } + + ui_->pushButtonLock->hide(); + ui_->pushButtonLock2->hide(); + + ui_->btDevice->hide(); + + // check if a device is connected via bluetooth + if (std::ifstream("/tmp/btdevice")) + { + if (ui_->btDevice->isVisible() == false || ui_->btDevice->text().simplified() == "") + { + QString btdevicename = configuration_->readFileContent("/tmp/btdevice"); + ui_->btDevice->setText(btdevicename); + ui_->btDevice->show(); + } + } + else + { + if (ui_->btDevice->isVisible() == true) + { + ui_->btDevice->hide(); + } + } + + // hide brightness slider of control file is not existing + QFileInfo brightnessFile(brightnessFilename); + if (!brightnessFile.exists() && !this->brightnessButtonForce) + { + ui_->pushButtonBrightness->hide(); + ui_->pushButtonBrightness2->hide(); + } + + // as default hide brightness slider + ui_->BrightnessSliderControl->hide(); + + // as default hide power buttons + ui_->exitWidget->hide(); + ui_->horizontalWidgetPower->hide(); + + // hide wifi if not forced + if (!this->wifiButtonForce && !std::ifstream("/tmp/mobile_hotspot_detected")) + { + ui_->AAWIFIWidget->hide(); + ui_->AAWIFIWidget2->hide(); + } + else + { + ui_->AAUSBWidget->hide(); + ui_->AAUSBWidget2->hide(); + } + + if (std::ifstream("/tmp/temp_recent_list") || std::ifstream("/tmp/mobile_hotspot_detected")) + { + ui_->pushButtonWifi->show(); + ui_->pushButtonWifi->setFocus(); + ui_->pushButtonNoWiFiDevice->hide(); + ui_->pushButtonWifi2->show(); + ui_->pushButtonWifi2->setFocus(); + ui_->pushButtonNoWiFiDevice2->hide(); + } + else + { + ui_->pushButtonWifi->hide(); + ui_->pushButtonNoWiFiDevice->show(); + ui_->pushButtonWifi2->hide(); + ui_->pushButtonNoWiFiDevice2->show(); + } + + // set custom buttons if file enabled by trigger file + if (!this->c1ButtonForce) + { + ui_->pushButton_c1->hide(); + } + else + { + // read button config 1 + QFile paramFile(this->custom_button_file_c1); + paramFile.open(QIODevice::ReadOnly); + QTextStream data(¶mFile); + QStringList params = data.readAll().split("#"); + paramFile.close(); + ui_->pushButton_c1->setText(params[0].simplified()); + this->custom_button_command_c1 = params[1].simplified(); + if (params[2] != "") + { + this->custom_button_color_c1 = params[2].simplified(); + } + connect(ui_->pushButton_c1, &QPushButton::clicked, this, &MainWindow::customButtonPressed1); + } + + if (!this->c2ButtonForce) + { + ui_->pushButton_c2->hide(); + } + else + { + // read button config 2 + QFile paramFile(this->custom_button_file_c2); + paramFile.open(QIODevice::ReadOnly); + QTextStream data(¶mFile); + QStringList params = data.readAll().split("#"); + paramFile.close(); + ui_->pushButton_c2->setText(params[0].simplified()); + this->custom_button_command_c2 = params[1].simplified(); + if (params[2] != "") + { + this->custom_button_color_c2 = params[2].simplified(); + } + connect(ui_->pushButton_c2, &QPushButton::clicked, this, &MainWindow::customButtonPressed2); + } + + if (!this->c3ButtonForce) + { + ui_->pushButton_c3->hide(); + } + else + { + // read button config 3 + QFile paramFile(this->custom_button_file_c3); + paramFile.open(QIODevice::ReadOnly); + QTextStream data(¶mFile); + QStringList params = data.readAll().split("#"); + paramFile.close(); + ui_->pushButton_c3->setText(params[0].simplified()); + this->custom_button_command_c3 = params[1].simplified(); + if (params[2] != "") + { + this->custom_button_color_c3 = params[2].simplified(); + } + connect(ui_->pushButton_c3, &QPushButton::clicked, this, &MainWindow::customButtonPressed3); + } + + if (!this->c4ButtonForce) + { + ui_->pushButton_c4->hide(); + } + else + { + // read button config 4 + QFile paramFile(this->custom_button_file_c4); + paramFile.open(QIODevice::ReadOnly); + QTextStream data(¶mFile); + QStringList params = data.readAll().split("#"); + paramFile.close(); + ui_->pushButton_c4->setText(params[0].simplified()); + this->custom_button_command_c4 = params[1].simplified(); + if (params[2] != "") + { + this->custom_button_color_c4 = params[2].simplified(); + } + connect(ui_->pushButton_c4, &QPushButton::clicked, this, &MainWindow::customButtonPressed4); + } + + if (!this->c5ButtonForce) + { + ui_->pushButton_c5->hide(); + } + else + { + // read button config 5 + QFile paramFile(this->custom_button_file_c5); + paramFile.open(QIODevice::ReadOnly); + QTextStream data(¶mFile); + QStringList params = data.readAll().split("#"); + paramFile.close(); + ui_->pushButton_c5->setText(params[0].simplified()); + this->custom_button_command_c5 = params[1].simplified(); + if (params[2] != "") + { + this->custom_button_color_c5 = params[2].simplified(); + } + connect(ui_->pushButton_c5, &QPushButton::clicked, this, &MainWindow::customButtonPressed5); + } + + if (!this->c6ButtonForce) + { + ui_->pushButton_c6->hide(); + } + else + { + // read button config 6 + QFile paramFile(this->custom_button_file_c6); + paramFile.open(QIODevice::ReadOnly); + QTextStream data(¶mFile); + QStringList params = data.readAll().split("#"); + paramFile.close(); + ui_->pushButton_c6->setText(params[0].simplified()); + this->custom_button_command_c6 = params[1].simplified(); + if (params[2] != "") + { + this->custom_button_color_c6 = params[2].simplified(); + } + connect(ui_->pushButton_c6, &QPushButton::clicked, this, &MainWindow::customButtonPressed6); + } + + // as default hide camera controls + ui_->cameraWidget->hide(); + ui_->pushButtonRecordActive->hide(); + + // fill gui with dummys if needed + if (this->c1ButtonForce || this->c2ButtonForce || this->c3ButtonForce || this->c4ButtonForce || this->c5ButtonForce || this->c6ButtonForce) + { + if (!this->c1ButtonForce && !this->c2ButtonForce) + { + ui_->pushButtonDummy1->show(); + } + else + { + ui_->pushButtonDummy1->hide(); + } + if (!this->c3ButtonForce && !this->c4ButtonForce) + { + ui_->pushButtonDummy2->show(); + } + else + { + ui_->pushButtonDummy2->hide(); + } + if (!this->c5ButtonForce && !this->c6ButtonForce) + { + ui_->pushButtonDummy3->show(); + } + else + { + ui_->pushButtonDummy3->hide(); + } + } + else + { + ui_->pushButtonDummy1->hide(); + ui_->pushButtonDummy2->hide(); + ui_->pushButtonDummy3->hide(); + } + + // show dev labels if dev mode activated + if (!this->devModeEnabled) + { + ui_->devlabel_left->hide(); + ui_->devlabel_right->hide(); + } + + // 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")) + { + if (!configuration->hideBrightnessControl()) + { + ui_->pushButtonBrightness->show(); + ui_->pushButtonBrightness2->show(); + } + this->customBrightnessControl = true; + } + + // switch to old menu if set in settings + if (!configuration->oldGUI()) + { + this->oldGUIStyle = false; + ui_->menuWidget->show(); + ui_->oldmenuWidget->hide(); + } + else + { + this->oldGUIStyle = true; + ui_->oldmenuWidget->show(); + ui_->menuWidget->hide(); + } + + // set bg's on startup + MainWindow::updateBG(); + if (!this->nightModeEnabled) + { + ui_->pushButtonDay->hide(); + ui_->pushButtonDay2->hide(); + ui_->pushButtonNight->show(); + ui_->pushButtonNight2->show(); + } + else + { + ui_->pushButtonNight->hide(); + ui_->pushButtonNight2->hide(); + ui_->pushButtonDay->show(); + ui_->pushButtonDay2->show(); + } + + // use big clock in classic gui? + if (configuration->showBigClock()) + { + this->UseBigClock = true; + } + else + { + this->UseBigClock = false; + } + + // clock viibility by settings + if (!configuration->showClock()) + { + ui_->Digital_clock->hide(); + this->NoClock = true; + } + else + { + this->NoClock = false; + if (this->UseBigClock) + { + // ui_->oldmenuDummy->hide(); + if (oldGUIStyle) + { + ui_->Digital_clock->hide(); + } + } + else + { + // ui_->oldmenuDummy->show(); + ui_->Digital_clock->show(); + } + } + + // hide gui toggle if enabled in settings + if (configuration->hideMenuToggle()) + { + ui_->pushButtonToggleGUI->hide(); + ui_->pushButtonToggleGUI2->hide(); + } + + // hide brightness button if eanbled in settings + if (configuration->hideBrightnessControl()) + { + ui_->pushButtonBrightness->hide(); + ui_->pushButtonBrightness2->hide(); + ui_->BrightnessSliderControl->hide(); + } + + // init alpha values + MainWindow::updateAlpha(); + + // Hide auto day/night if needed + if (this->lightsensor) + { + ui_->pushButtonDay->hide(); + ui_->pushButtonNight->hide(); + ui_->pushButtonDay2->hide(); + ui_->pushButtonNight2->hide(); + ui_->pushButtonBrightness->hide(); + ui_->pushButtonBrightness2->hide(); + } + + // Hide recordings button + ui_->pushButtonRecordings->hide(); + + player = new QMediaPlayer(this); + playlist = new QMediaPlaylist(this); + connect(player, &QMediaPlayer::positionChanged, this, &MainWindow::on_positionChanged); + connect(player, &QMediaPlayer::durationChanged, this, &MainWindow::on_durationChanged); + connect(player, &QMediaPlayer::metaDataAvailableChanged, this, &MainWindow::metaDataChanged); + connect(player, &QMediaPlayer::stateChanged, this, &MainWindow::on_StateChanged); + + ui_->pushButtonList->hide(); + ui_->pushButtonBackToPlayer->hide(); + ui_->PlayerPlayingWidget->hide(); + ui_->pushButtonPlayerStop->hide(); + ui_->pushButtonPlayerPause->hide(); + + this->musicfolder = QString::fromStdString(configuration->getMp3MasterPath()); + this->albumfolder = QString::fromStdString(configuration->getMp3SubFolder()); + + ui_->labelFolderpath->setText(this->musicfolder); + ui_->labelAlbumpath->setText(this->albumfolder); + + ui_->labelFolderpath->hide(); + ui_->labelAlbumpath->hide(); + ui_->comboBoxAlbum->hide(); + ui_->pushButtonAlbum->hide(); + + MainWindow::scanFolders(); + ui_->comboBoxAlbum->setCurrentText(QString::fromStdString(configuration->getMp3SubFolder())); + MainWindow::scanFiles(); + player->setPlaylist(this->playlist); + ui_->mp3List->setCurrentRow(configuration->getMp3Track()); + this->currentPlaylistIndex = configuration->getMp3Track(); + + if (configuration->mp3AutoPlay()) + { + MainWindow::playerShow(); + MainWindow::playerHide(); + MainWindow::on_pushButtonPlayerPlayList_clicked(); + if (configuration->showAutoPlay()) + { + MainWindow::playerShow(); + } + } + + watcher = new QFileSystemWatcher(this); + watcher->addPath("/media/USBDRIVES"); + connect(watcher, &QFileSystemWatcher::directoryChanged, this, &MainWindow::setTrigger); + + watcher_tmp = new QFileSystemWatcher(this); + 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(); + } + + MainWindow::~MainWindow() + { + shuttingDown = true; + webSocket->abort(); // Immediately disconnect without waiting + webSocket->deleteLater(); + delete ui_; + } - if (std::ifstream("/etc/crankshaft.branch")) { - QString branch = configuration_->readFileContent("/etc/crankshaft.branch"); - if (branch != "crankshaft-ng") { - if (branch == "csng-dev") { - ui_->Header_Label->setText("

crankshaft NG - Dev-Build

"); - } else { - ui_->Header_Label->setText("

crankshaft NG - Custom-Build

"); } } } - - QTimer *timer=new QTimer(this); - connect(timer, SIGNAL(timeout()),this,SLOT(showTime())); - timer->start(1000); - - // enable connects while cam is enabled - if (this->cameraButtonForce) { - connect(ui_->pushButtonCameraShow, &QPushButton::clicked, this, &MainWindow::cameraShow); - connect(ui_->pushButtonCameraShow, &QPushButton::clicked, this, &MainWindow::cameraControlShow); - connect(ui_->pushButtonCameraShow2, &QPushButton::clicked, this, &MainWindow::cameraShow); - connect(ui_->pushButtonCameraShow2, &QPushButton::clicked, this, &MainWindow::cameraControlShow); - connect(ui_->pushButtonCameraHide, &QPushButton::clicked, this, &MainWindow::cameraHide); - connect(ui_->pushButtonCameraHide, &QPushButton::clicked, this, &MainWindow::cameraControlHide); - connect(ui_->pushButtonStop, &QPushButton::clicked, this, &MainWindow::cameraStop); - connect(ui_->pushButtonRecord, &QPushButton::clicked, this, &MainWindow::cameraRecord); - connect(ui_->pushButtonSave, &QPushButton::clicked, this, &MainWindow::cameraSave); - connect(ui_->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(); - } - - // show debug button if enabled - if (!this->systemDebugmode) { - ui_->pushButtonDebug->hide(); - ui_->pushButtonDebug2->hide(); - } - - ui_->pushButtonLock->hide(); - ui_->pushButtonLock2->hide(); - - ui_->btDevice->hide(); - - // check if a device is connected via bluetooth - if (std::ifstream("/tmp/btdevice")) { - if (ui_->btDevice->isVisible() == false || ui_->btDevice->text().simplified() == "") { - QString btdevicename = configuration_->readFileContent("/tmp/btdevice"); - ui_->btDevice->setText(btdevicename); - ui_->btDevice->show(); - } - } else { - if (ui_->btDevice->isVisible() == true) { - ui_->btDevice->hide(); - } - } - - // hide brightness slider of control file is not existing - QFileInfo brightnessFile(brightnessFilename); - if (!brightnessFile.exists() && !this->brightnessButtonForce) { - ui_->pushButtonBrightness->hide(); - ui_->pushButtonBrightness2->hide(); - } - - // as default hide brightness slider - ui_->BrightnessSliderControl->hide(); - - // as default hide power buttons - ui_->exitWidget->hide(); - ui_->horizontalWidgetPower->hide(); - - // hide wifi if not forced - if (!this->wifiButtonForce && !std::ifstream("/tmp/mobile_hotspot_detected")) { - ui_->AAWIFIWidget->hide(); - ui_->AAWIFIWidget2->hide(); - } else { - ui_->AAUSBWidget->hide(); - ui_->AAUSBWidget2->hide(); - } - - if (std::ifstream("/tmp/temp_recent_list") || std::ifstream("/tmp/mobile_hotspot_detected")) { - ui_->pushButtonWifi->show(); - ui_->pushButtonWifi->setFocus(); - ui_->pushButtonNoWiFiDevice->hide(); - ui_->pushButtonWifi2->show(); - ui_->pushButtonWifi2->setFocus(); - ui_->pushButtonNoWiFiDevice2->hide(); - } else { - ui_->pushButtonWifi->hide(); - ui_->pushButtonNoWiFiDevice->show(); - ui_->pushButtonWifi2->hide(); - ui_->pushButtonNoWiFiDevice2->show(); - } - - // set custom buttons if file enabled by trigger file - if (!this->c1ButtonForce) { - ui_->pushButton_c1->hide(); - } else { - // read button config 1 - QFile paramFile(this->custom_button_file_c1); - paramFile.open(QIODevice::ReadOnly); - QTextStream data(¶mFile); - QStringList params = data.readAll().split("#"); - paramFile.close(); - ui_->pushButton_c1->setText(params[0].simplified()); - this->custom_button_command_c1 = params[1].simplified(); - if (params[2] != "") { - this->custom_button_color_c1 = params[2].simplified(); - } - connect(ui_->pushButton_c1, &QPushButton::clicked, this, &MainWindow::customButtonPressed1); - } - - if (!this->c2ButtonForce) { - ui_->pushButton_c2->hide(); - } else { - // read button config 2 - QFile paramFile(this->custom_button_file_c2); - paramFile.open(QIODevice::ReadOnly); - QTextStream data(¶mFile); - QStringList params = data.readAll().split("#"); - paramFile.close(); - ui_->pushButton_c2->setText(params[0].simplified()); - this->custom_button_command_c2 = params[1].simplified(); - if (params[2] != "") { - this->custom_button_color_c2 = params[2].simplified(); - } - connect(ui_->pushButton_c2, &QPushButton::clicked, this, &MainWindow::customButtonPressed2); - } - - if (!this->c3ButtonForce) { - ui_->pushButton_c3->hide(); - } else { - // read button config 3 - QFile paramFile(this->custom_button_file_c3); - paramFile.open(QIODevice::ReadOnly); - QTextStream data(¶mFile); - QStringList params = data.readAll().split("#"); - paramFile.close(); - ui_->pushButton_c3->setText(params[0].simplified()); - this->custom_button_command_c3 = params[1].simplified(); - if (params[2] != "") { - this->custom_button_color_c3 = params[2].simplified(); - } - connect(ui_->pushButton_c3, &QPushButton::clicked, this, &MainWindow::customButtonPressed3); - } - - if (!this->c4ButtonForce) { - ui_->pushButton_c4->hide(); - } else { - // read button config 4 - QFile paramFile(this->custom_button_file_c4); - paramFile.open(QIODevice::ReadOnly); - QTextStream data(¶mFile); - QStringList params = data.readAll().split("#"); - paramFile.close(); - ui_->pushButton_c4->setText(params[0].simplified()); - this->custom_button_command_c4 = params[1].simplified(); - if (params[2] != "") { - this->custom_button_color_c4 = params[2].simplified(); - } - connect(ui_->pushButton_c4, &QPushButton::clicked, this, &MainWindow::customButtonPressed4); - } - - if (!this->c5ButtonForce) { - ui_->pushButton_c5->hide(); - } else { - // read button config 5 - QFile paramFile(this->custom_button_file_c5); - paramFile.open(QIODevice::ReadOnly); - QTextStream data(¶mFile); - QStringList params = data.readAll().split("#"); - paramFile.close(); - ui_->pushButton_c5->setText(params[0].simplified()); - this->custom_button_command_c5 = params[1].simplified(); - if (params[2] != "") { - this->custom_button_color_c5 = params[2].simplified(); - } - connect(ui_->pushButton_c5, &QPushButton::clicked, this, &MainWindow::customButtonPressed5); - } - - if (!this->c6ButtonForce) { - ui_->pushButton_c6->hide(); - } else { - // read button config 6 - QFile paramFile(this->custom_button_file_c6); - paramFile.open(QIODevice::ReadOnly); - QTextStream data(¶mFile); - QStringList params = data.readAll().split("#"); - paramFile.close(); - ui_->pushButton_c6->setText(params[0].simplified()); - this->custom_button_command_c6 = params[1].simplified(); - if (params[2] != "") { - this->custom_button_color_c6 = params[2].simplified(); - } - connect(ui_->pushButton_c6, &QPushButton::clicked, this, &MainWindow::customButtonPressed6); - } - - // as default hide camera controls - ui_->cameraWidget->hide(); - ui_->pushButtonRecordActive->hide(); - - // fill gui with dummys if needed - if (this->c1ButtonForce || this->c2ButtonForce || this->c3ButtonForce || this->c4ButtonForce || this->c5ButtonForce || this->c6ButtonForce) { - if (!this->c1ButtonForce && !this->c2ButtonForce) { - ui_->pushButtonDummy1->show(); - } else { - ui_->pushButtonDummy1->hide(); - } - if (!this->c3ButtonForce && !this->c4ButtonForce) { - ui_->pushButtonDummy2->show(); - } else { - ui_->pushButtonDummy2->hide(); - } - if (!this->c5ButtonForce && !this->c6ButtonForce) { - ui_->pushButtonDummy3->show(); - } else { - ui_->pushButtonDummy3->hide(); - } - } else { - ui_->pushButtonDummy1->hide(); - ui_->pushButtonDummy2->hide(); - ui_->pushButtonDummy3->hide(); - } - - // show dev labels if dev mode activated - if (!this->devModeEnabled) { - ui_->devlabel_left->hide(); - ui_->devlabel_right->hide(); - } - - // 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")) { - if (!configuration->hideBrightnessControl()) { - ui_->pushButtonBrightness->show(); - ui_->pushButtonBrightness2->show(); - } - this->customBrightnessControl = true; - } - - // switch to old menu if set in settings - if (!configuration->oldGUI()) { - this->oldGUIStyle = false; - ui_->menuWidget->show(); - ui_->oldmenuWidget->hide(); - } else { - this->oldGUIStyle = true; - ui_->oldmenuWidget->show(); - ui_->menuWidget->hide(); - } - - // set bg's on startup - MainWindow::updateBG(); - if (!this->nightModeEnabled) { - ui_->pushButtonDay->hide(); - ui_->pushButtonDay2->hide(); - ui_->pushButtonNight->show(); - ui_->pushButtonNight2->show(); - } else { - ui_->pushButtonNight->hide(); - ui_->pushButtonNight2->hide(); - ui_->pushButtonDay->show(); - ui_->pushButtonDay2->show(); - } - - // use big clock in classic gui? - if (configuration->showBigClock()) { - this->UseBigClock = true; - } else { - this->UseBigClock = false; - } - - // clock viibility by settings - if (!configuration->showClock()) { - ui_->Digital_clock->hide(); - this->NoClock = true; - } else { - this->NoClock = false; - if (this->UseBigClock) { - //ui_->oldmenuDummy->hide(); - if (oldGUIStyle) { - ui_->Digital_clock->hide(); - } - } else { - //ui_->oldmenuDummy->show(); - ui_->Digital_clock->show(); - } - } - - // hide gui toggle if enabled in settings - if (configuration->hideMenuToggle()) { - ui_->pushButtonToggleGUI->hide(); - ui_->pushButtonToggleGUI2->hide(); - } - - // hide brightness button if eanbled in settings - if (configuration->hideBrightnessControl()) { - ui_->pushButtonBrightness->hide(); - ui_->pushButtonBrightness2->hide(); - ui_->BrightnessSliderControl->hide(); - } - - // init alpha values - MainWindow::updateAlpha(); - - // Hide auto day/night if needed - if (this->lightsensor) { - ui_->pushButtonDay->hide(); - ui_->pushButtonNight->hide(); - ui_->pushButtonDay2->hide(); - ui_->pushButtonNight2->hide(); - ui_->pushButtonBrightness->hide(); - ui_->pushButtonBrightness2->hide(); - } - - // Hide recordings button - ui_->pushButtonRecordings->hide(); - - player = new QMediaPlayer(this); - playlist = new QMediaPlaylist(this); - connect(player, &QMediaPlayer::positionChanged, this, &MainWindow::on_positionChanged); - connect(player, &QMediaPlayer::durationChanged, this, &MainWindow::on_durationChanged); - connect(player, &QMediaPlayer::metaDataAvailableChanged, this, &MainWindow::metaDataChanged); - connect(player, &QMediaPlayer::stateChanged, this, &MainWindow::on_StateChanged); - - ui_->pushButtonList->hide(); - ui_->pushButtonBackToPlayer->hide(); - ui_->PlayerPlayingWidget->hide(); - ui_->pushButtonPlayerStop->hide(); - ui_->pushButtonPlayerPause->hide(); - - this->musicfolder = QString::fromStdString(configuration->getMp3MasterPath()); - this->albumfolder = QString::fromStdString(configuration->getMp3SubFolder()); - - ui_->labelFolderpath->setText(this->musicfolder); - ui_->labelAlbumpath->setText(this->albumfolder); - - ui_->labelFolderpath->hide(); - ui_->labelAlbumpath->hide(); - ui_->comboBoxAlbum->hide(); - ui_->pushButtonAlbum->hide(); - - MainWindow::scanFolders(); - ui_->comboBoxAlbum->setCurrentText(QString::fromStdString(configuration->getMp3SubFolder())); - MainWindow::scanFiles(); - player->setPlaylist(this->playlist); - ui_->mp3List->setCurrentRow(configuration->getMp3Track()); - this->currentPlaylistIndex = configuration->getMp3Track(); - - if (configuration->mp3AutoPlay()) { - MainWindow::playerShow(); - MainWindow::playerHide(); - MainWindow::on_pushButtonPlayerPlayList_clicked(); - if (configuration->showAutoPlay()) { - MainWindow::playerShow(); - } - } - - watcher = new QFileSystemWatcher(this); - watcher->addPath("/media/USBDRIVES"); - connect(watcher, &QFileSystemWatcher::directoryChanged, this, &MainWindow::setTrigger); - - watcher_tmp = new QFileSystemWatcher(this); - 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(); } -MainWindow::~MainWindow() +void f1x::openauto::autoapp::ui::MainWindow::connectWebSocket() { - delete ui_; + QUrl url(QStringLiteral("ws://127.0.0.1:5000")); // Change to your real server + qDebug() << "Connecting to WebSocket:" << url; + webSocket->open(url); } -} -} -} +void f1x::openauto::autoapp::ui::MainWindow::handleIncomingMessage(const QString &message) +{ + // Your custom message processing logic here + qDebug() << "[Handler] Processing message:" << message; } void f1x::openauto::autoapp::ui::MainWindow::hostModeStateChanged(QBluetoothLocalDevice::HostMode mode) { - if (mode != QBluetoothLocalDevice::HostPoweredOff) { + if (mode != QBluetoothLocalDevice::HostPoweredOff) + { this->bluetoothEnabled = true; ui_->pushButtonBluetooth->show(); - if (std::ifstream("/tmp/bluetooth_pairable")) { + if (std::ifstream("/tmp/bluetooth_pairable")) + { ui_->labelBluetoothPairable->show(); ui_->pushButtonBluetooth->hide(); - } else { + } + else + { ui_->labelBluetoothPairable->hide(); } - } else { + } + else + { this->bluetoothEnabled = false; ui_->pushButtonBluetooth->hide(); ui_->labelBluetoothPairable->hide(); @@ -574,22 +705,29 @@ void f1x::openauto::autoapp::ui::MainWindow::hostModeStateChanged(QBluetoothLoca void f1x::openauto::autoapp::ui::MainWindow::updateNetworkInfo() { QNetworkInterface wlan0if = QNetworkInterface::interfaceFromName("wlan0"); - if (wlan0if.flags().testFlag(QNetworkInterface::IsUp)) { + if (wlan0if.flags().testFlag(QNetworkInterface::IsUp)) + { QList entrieswlan0 = wlan0if.addressEntries(); - if (!entrieswlan0.isEmpty()) { + if (!entrieswlan0.isEmpty()) + { QNetworkAddressEntry wlan0 = entrieswlan0.first(); - //qDebug() << "wlan0: " << wlan0.ip(); + // qDebug() << "wlan0: " << wlan0.ip(); ui_->value_ip->setText(wlan0.ip().toString().simplified()); ui_->value_mask->setText(wlan0.netmask().toString().simplified()); - if (std::ifstream("/tmp/hotspot_active")) { - ui_->value_ssid->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid")); - } else { + if (std::ifstream("/tmp/hotspot_active")) + { + ui_->value_ssid->setText(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf", "ssid")); + } + else + { ui_->value_ssid->setText(configuration_->readFileContent("/tmp/wifi_ssid")); } ui_->value_gw->setText(configuration_->readFileContent("/tmp/gateway_wlan0")); } - } else { - //qDebug() << "wlan0: down"; + } + else + { + // qDebug() << "wlan0: down"; ui_->value_ip->setText(""); ui_->value_mask->setText(""); ui_->value_gw->setText(""); @@ -627,30 +765,34 @@ void f1x::openauto::autoapp::ui::MainWindow::customButtonPressed6() system(qPrintable(this->custom_button_command_c6 + " &")); } - void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBrightness_clicked() { this->brightnessFile = new QFile(this->brightnessFilename); this->brightnessFileAlt = new QFile(this->brightnessFilenameAlt); // Get the current brightness value - if (!this->customBrightnessControl) { - if (this->brightnessFile->open(QIODevice::ReadOnly)) { + if (!this->customBrightnessControl) + { + if (this->brightnessFile->open(QIODevice::ReadOnly)) + { QByteArray data = this->brightnessFile->readAll(); std::string::size_type sz; int brightness_val = std::stoi(data.toStdString(), &sz); ui_->horizontalSliderBrightness->setValue(brightness_val); - QString bri=QString::number(brightness_val); + QString bri = QString::number(brightness_val); ui_->brightnessValueLabel->setText(bri); this->brightnessFile->close(); } - } else { - if (this->brightnessFileAlt->open(QIODevice::ReadOnly)) { + } + else + { + if (this->brightnessFileAlt->open(QIODevice::ReadOnly)) + { QByteArray data = this->brightnessFileAlt->readAll(); std::string::size_type sz; int brightness_val = std::stoi(data.toStdString(), &sz); ui_->horizontalSliderBrightness->setValue(brightness_val); - QString bri=QString::number(brightness_val); + QString bri = QString::number(brightness_val); ui_->brightnessValueLabel->setText(bri); this->brightnessFileAlt->close(); } @@ -664,23 +806,28 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBrightness2_clicked() this->brightnessFileAlt = new QFile(this->brightnessFilenameAlt); // Get the current brightness value - if (!this->customBrightnessControl) { - if (this->brightnessFile->open(QIODevice::ReadOnly)) { + if (!this->customBrightnessControl) + { + if (this->brightnessFile->open(QIODevice::ReadOnly)) + { QByteArray data = this->brightnessFile->readAll(); std::string::size_type sz; int brightness_val = std::stoi(data.toStdString(), &sz); ui_->horizontalSliderBrightness->setValue(brightness_val); - QString bri=QString::number(brightness_val); + QString bri = QString::number(brightness_val); ui_->brightnessValueLabel->setText(bri); this->brightnessFile->close(); } - } else { - if (this->brightnessFileAlt->open(QIODevice::ReadOnly)) { + } + else + { + if (this->brightnessFileAlt->open(QIODevice::ReadOnly)) + { QByteArray data = this->brightnessFileAlt->readAll(); std::string::size_type sz; int brightness_val = std::stoi(data.toStdString(), &sz); ui_->horizontalSliderBrightness->setValue(brightness_val); - QString bri=QString::number(brightness_val); + QString bri = QString::number(brightness_val); ui_->brightnessValueLabel->setText(bri); this->brightnessFileAlt->close(); } @@ -694,80 +841,86 @@ void f1x::openauto::autoapp::ui::MainWindow::on_horizontalSliderBrightness_value this->brightnessFile = new QFile(this->brightnessFilename); this->brightnessFileAlt = new QFile(this->brightnessFilenameAlt); - if (!this->customBrightnessControl) { - if (this->brightnessFile->open(QIODevice::WriteOnly)) { + if (!this->customBrightnessControl) + { + if (this->brightnessFile->open(QIODevice::WriteOnly)) + { this->brightness_str[n] = '\n'; - this->brightness_str[n+1] = '\0'; + this->brightness_str[n + 1] = '\0'; this->brightnessFile->write(this->brightness_str); this->brightnessFile->close(); } - } else { - if (this->brightnessFileAlt->open(QIODevice::WriteOnly)) { + } + else + { + if (this->brightnessFileAlt->open(QIODevice::WriteOnly)) + { this->brightness_str[n] = '\n'; - this->brightness_str[n+1] = '\0'; + this->brightness_str[n + 1] = '\0'; this->brightnessFileAlt->write(this->brightness_str); this->brightnessFileAlt->close(); } } - QString bri=QString::number(value); + QString bri = QString::number(value); ui_->brightnessValueLabel->setText(bri); } void f1x::openauto::autoapp::ui::MainWindow::updateAlpha() { int value = configuration_->getAlphaTrans(); - //int n = snprintf(this->alpha_str, 5, "%d", value); + // int n = snprintf(this->alpha_str, 5, "%d", value); - if (value != this->alpha_current_str) { + if (value != this->alpha_current_str) + { this->alpha_current_str = value; - double alpha = value/100.0; - QString alp=QString::number(alpha); - ui_->pushButtonExit->setStyleSheet( "QPushButton{background-color: rgba(164, 0, 0, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonShutdown->setStyleSheet( "QPushButton{background-color: rgba(239, 41, 41, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonReboot->setStyleSheet( "QPushButton{background-color: rgba(252, 175, 62, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonCancel->setStyleSheet( "QPushButton{background-color: rgba(32, 74, 135, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonBrightness->setStyleSheet( "QPushButton{background-color: rgba(245, 121, 0, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonLock->setStyleSheet( "QPushButton{background-color: rgba(15, 54, 5, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonSettings->setStyleSheet( "QPushButton{background-color: rgba(138, 226, 52, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonDay->setStyleSheet( "QPushButton{background: rgba(252, 233, 79, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonNight->setStyleSheet( "QPushButton{background-color: rgba(114, 159, 207, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonCameraShow->setStyleSheet( "QPushButton{background-color: rgba(100, 62, 4, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonWifi->setStyleSheet( "QPushButton{background-color: rgba(252, 175, 62, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonToggleGUI->setStyleSheet( "QPushButton{background-color: rgba(237, 164, 255, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButton_c1->setStyleSheet( "QPushButton{background-color: rgba(" + this->custom_button_color_c1 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButton_c2->setStyleSheet( "QPushButton{background-color: rgba(" + this->custom_button_color_c2 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButton_c3->setStyleSheet( "QPushButton{background-color: rgba(" + this->custom_button_color_c3 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButton_c4->setStyleSheet( "QPushButton{background-color: rgba(" + this->custom_button_color_c4 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButton_c5->setStyleSheet( "QPushButton{background-color: rgba(" + this->custom_button_color_c5 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButton_c6->setStyleSheet( "QPushButton{background-color: rgba(" + this->custom_button_color_c6 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonDummy1->setStyleSheet( "QPushButton{background-color: rgba(186, 189, 182, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonDummy2->setStyleSheet( "QPushButton{background-color: rgba(186, 189, 182, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonDummy3->setStyleSheet( "QPushButton{background-color: rgba(186, 189, 182, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonDebug->setStyleSheet( "QPushButton{background-color: rgba(85, 87, 83, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonMusic->setStyleSheet( "QPushButton{background-color: rgba(78, 154, 6, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->pushButtonAndroidAuto->setStyleSheet( "QPushButton{background-color: rgba(48, 140, 198, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px; border-top: 0px;} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); - ui_->labelAndroidAutoBottom->setStyleSheet( "background-color: rgba(48, 140, 198, " + alp + " ); border-bottom-left-radius: 4px; border-bottom-right-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-top-left-radius: 4px; border-top-right-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);"); + double alpha = value / 100.0; + QString alp = QString::number(alpha); + ui_->pushButtonExit->setStyleSheet("QPushButton{background-color: rgba(164, 0, 0, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonShutdown->setStyleSheet("QPushButton{background-color: rgba(239, 41, 41, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonReboot->setStyleSheet("QPushButton{background-color: rgba(252, 175, 62, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonCancel->setStyleSheet("QPushButton{background-color: rgba(32, 74, 135, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonBrightness->setStyleSheet("QPushButton{background-color: rgba(245, 121, 0, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonLock->setStyleSheet("QPushButton{background-color: rgba(15, 54, 5, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonSettings->setStyleSheet("QPushButton{background-color: rgba(138, 226, 52, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonDay->setStyleSheet("QPushButton{background: rgba(252, 233, 79, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonNight->setStyleSheet("QPushButton{background-color: rgba(114, 159, 207, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonCameraShow->setStyleSheet("QPushButton{background-color: rgba(100, 62, 4, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonWifi->setStyleSheet("QPushButton{background-color: rgba(252, 175, 62, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonToggleGUI->setStyleSheet("QPushButton{background-color: rgba(237, 164, 255, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButton_c1->setStyleSheet("QPushButton{background-color: rgba(" + this->custom_button_color_c1 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButton_c2->setStyleSheet("QPushButton{background-color: rgba(" + this->custom_button_color_c2 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButton_c3->setStyleSheet("QPushButton{background-color: rgba(" + this->custom_button_color_c3 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButton_c4->setStyleSheet("QPushButton{background-color: rgba(" + this->custom_button_color_c4 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButton_c5->setStyleSheet("QPushButton{background-color: rgba(" + this->custom_button_color_c5 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButton_c6->setStyleSheet("QPushButton{background-color: rgba(" + this->custom_button_color_c6 + ", " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonDummy1->setStyleSheet("QPushButton{background-color: rgba(186, 189, 182, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonDummy2->setStyleSheet("QPushButton{background-color: rgba(186, 189, 182, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonDummy3->setStyleSheet("QPushButton{background-color: rgba(186, 189, 182, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonDebug->setStyleSheet("QPushButton{background-color: rgba(85, 87, 83, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonMusic->setStyleSheet("QPushButton{background-color: rgba(78, 154, 6, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255);} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->pushButtonAndroidAuto->setStyleSheet("QPushButton{background-color: rgba(48, 140, 198, " + alp + " ); outline-style: dotted; outline-color: #92a8d1; border: 2px solid rgba(255,255,255,0.5); color: rgb(255,255,255); border-bottom: 0px; border-top: 0px;} QPushButton:focus {border: 2px solid rgba(125,125,125,0.5);}"); + ui_->labelAndroidAutoBottom->setStyleSheet("background-color: rgba(48, 140, 198, " + alp + " ); border-bottom-left-radius: 4px; border-bottom-right-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-top-left-radius: 4px; border-top-right-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 - ui_->pushButtonSettings2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonLock2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonMusic2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonBrightness2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonToggleGUI2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonExit2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonShutdown2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonReboot2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonCancel2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonAndroidAuto2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonNoDevice2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonWifi2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonNoWiFiDevice2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonDay2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonNight2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonCameraShow2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); - ui_->pushButtonDebug2->setStyleSheet( "background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonSettings2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonLock2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonMusic2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonBrightness2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonToggleGUI2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonExit2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonShutdown2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonReboot2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonCancel2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonAndroidAuto2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonNoDevice2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonWifi2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonNoWiFiDevice2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonDay2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonNight2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonCameraShow2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); + ui_->pushButtonDebug2->setStyleSheet("background-color: rgba(136, 138, 133, " + alp + " ); color: rgb(255, 255, 255); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5);"); } } @@ -793,11 +946,15 @@ void f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay() void f1x::openauto::autoapp::ui::MainWindow::cameraControlHide() { - if (this->cameraButtonForce) { + if (this->cameraButtonForce) + { ui_->cameraWidget->hide(); - if (!this->oldGUIStyle) { + if (!this->oldGUIStyle) + { ui_->menuWidget->show(); - } else { + } + else + { ui_->oldmenuWidget->show(); } } @@ -805,22 +962,31 @@ void f1x::openauto::autoapp::ui::MainWindow::cameraControlHide() void f1x::openauto::autoapp::ui::MainWindow::cameraControlShow() { - if (this->cameraButtonForce) { - if (!this->oldGUIStyle) { + if (this->cameraButtonForce) + { + if (!this->oldGUIStyle) + { ui_->menuWidget->hide(); - } else { + } + else + { ui_->oldmenuWidget->hide(); } ui_->cameraWidget->show(); // check if dashcam is recording - if (std::ifstream("/tmp/dashcam_is_recording")) { - if (ui_->pushButtonRecordActive->isVisible() == false) { + if (std::ifstream("/tmp/dashcam_is_recording")) + { + if (ui_->pushButtonRecordActive->isVisible() == false) + { ui_->pushButtonRecordActive->show(); ui_->pushButtonRecord->hide(); } - } else { - if (ui_->pushButtonRecordActive->isVisible() == true) { + } + else + { + if (ui_->pushButtonRecordActive->isVisible() == true) + { ui_->pushButtonRecordActive->hide(); ui_->pushButtonRecord->show(); } @@ -830,15 +996,21 @@ void f1x::openauto::autoapp::ui::MainWindow::cameraControlShow() void f1x::openauto::autoapp::ui::MainWindow::playerShow() { - if (this->wallpaperEQFileExists) { + if (this->wallpaperEQFileExists) + { this->setStyleSheet("QMainWindow { background: url(wallpaper-eq.png); background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: no-repeat; background-position: center; }"); } - if (!this->oldGUIStyle) { + if (!this->oldGUIStyle) + { ui_->menuWidget->hide(); - } else { + } + else + { ui_->oldmenuWidget->hide(); } ui_->mediaWidget->show(); @@ -846,29 +1018,37 @@ void f1x::openauto::autoapp::ui::MainWindow::playerShow() ui_->networkInfo->hide(); ui_->Info->hide(); ui_->horizontalSliderProgressPlayer->hide(); - if (player->state() == QMediaPlayer::PlayingState) { + if (player->state() == QMediaPlayer::PlayingState) + { on_pushButtonBackToPlayer_clicked(); ui_->Info->show(); ui_->horizontalSliderProgressPlayer->show(); ui_->pushButtonPlayerPlayList->hide(); } - if (ui_->mp3List->isVisible() == true) { + if (ui_->mp3List->isVisible() == true) + { ui_->pushButtonPlayerPlayList->show(); - } else { + } + else + { ui_->pushButtonPlayerPlayList->hide(); } } void f1x::openauto::autoapp::ui::MainWindow::playerHide() { - if (!this->oldGUIStyle) { + if (!this->oldGUIStyle) + { ui_->menuWidget->show(); - } else { + } + else + { ui_->oldmenuWidget->show(); } ui_->mediaWidget->hide(); ui_->BrightnessSliderControl->hide(); - if (configuration_->showNetworkinfo()) { + if (configuration_->showNetworkinfo()) + { ui_->networkInfo->hide(); } f1x::openauto::autoapp::ui::MainWindow::updateBG(); @@ -877,13 +1057,16 @@ void f1x::openauto::autoapp::ui::MainWindow::playerHide() void f1x::openauto::autoapp::ui::MainWindow::toggleExit() { - if (!this->exitMenuVisible) { + if (!this->exitMenuVisible) + { ui_->exitWidget->show(); ui_->buttonWidget->hide(); ui_->horizontalWidgetButtons->hide(); ui_->horizontalWidgetPower->show(); this->exitMenuVisible = true; - } else { + } + else + { ui_->buttonWidget->show(); ui_->exitWidget->hide(); ui_->horizontalWidgetButtons->show(); @@ -894,22 +1077,30 @@ void f1x::openauto::autoapp::ui::MainWindow::toggleExit() void f1x::openauto::autoapp::ui::MainWindow::toggleGUI() { - if (!this->oldGUIStyle) { + if (!this->oldGUIStyle) + { ui_->oldmenuWidget->show(); ui_->menuWidget->hide(); this->oldGUIStyle = true; - if (!this->NoClock) { - if (UseBigClock) { + if (!this->NoClock) + { + if (UseBigClock) + { ui_->Digital_clock->hide(); - } else { + } + else + { ui_->Digital_clock->show(); } } - } else { + } + else + { ui_->menuWidget->show(); ui_->oldmenuWidget->hide(); this->oldGUIStyle = false; - if (!this->NoClock) { + if (!this->NoClock) + { ui_->Digital_clock->show(); } } @@ -919,54 +1110,89 @@ void f1x::openauto::autoapp::ui::MainWindow::toggleGUI() void f1x::openauto::autoapp::ui::MainWindow::updateBG() { - if (this->date_text == "12/24") { + if (this->date_text == "12/24") + { this->setStyleSheet("QMainWindow { background: url(:/wallpaper-christmas.png); background-repeat: no-repeat; background-position: center; }"); this->holidaybg = true; } - else if (this->date_text == "12/31") { + else if (this->date_text == "12/31") + { this->setStyleSheet("QMainWindow { background: url(:/wallpaper-firework.png); background-repeat: no-repeat; background-position: center; }"); this->holidaybg = true; } - if (!this->nightModeEnabled) { - if (ui_->mediaWidget->isVisible() == true) { - if (this->wallpaperEQFileExists) { + if (!this->nightModeEnabled) + { + if (ui_->mediaWidget->isVisible() == true) + { + if (this->wallpaperEQFileExists) + { this->setStyleSheet("QMainWindow { background: url(wallpaper-eq.png); background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: repeat; background-position: center; }"); } - } else { - if (this->oldGUIStyle) { - if (this->wallpaperClassicDayFileExists) { + } + else + { + if (this->oldGUIStyle) + { + if (this->wallpaperClassicDayFileExists) + { this->setStyleSheet("QMainWindow { background: url(wallpaper-classic.png); background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: repeat; background-position: center; }"); } - } else { - if (this->wallpaperDayFileExists) { + } + else + { + if (this->wallpaperDayFileExists) + { this->setStyleSheet("QMainWindow { background: url(wallpaper.png); background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: repeat; background-position: center; }"); } } } - } else { - if (ui_->mediaWidget->isVisible() == true) { - if (this->wallpaperEQFileExists) { + } + else + { + if (ui_->mediaWidget->isVisible() == true) + { + if (this->wallpaperEQFileExists) + { this->setStyleSheet("QMainWindow { background: url(wallpaper-eq.png); background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: repeat; background-position: center; }"); } - } else { - if (this->oldGUIStyle) { - if (this->wallpaperClassicNightFileExists) { - this->setStyleSheet( "QMainWindow { background: url(wallpaper-classic-night.png); background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { + if (this->oldGUIStyle) + { + if (this->wallpaperClassicNightFileExists) + { + this->setStyleSheet("QMainWindow { background: url(wallpaper-classic-night.png); background-repeat: no-repeat; background-position: center; }"); + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: repeat; background-position: center; }"); } - } else { - if (this->wallpaperNightFileExists) { + } + else + { + if (this->wallpaperNightFileExists) + { this->setStyleSheet("QMainWindow { background: url(wallpaper-night.png) stretch stretch; background-repeat: no-repeat; background-position: center; }"); - } else { + } + else + { this->setStyleSheet("QMainWindow { background: url(:/black.png); background-repeat: repeat; background-position: center; }"); } } @@ -986,44 +1212,52 @@ void f1x::openauto::autoapp::ui::MainWindow::setPairable() void f1x::openauto::autoapp::ui::MainWindow::showTime() { - QTime time=QTime::currentTime(); - QDate date=QDate::currentDate(); - QString time_text=time.toString("hh : mm"); - this->date_text=date.toString("MM/dd"); + QTime time = QTime::currentTime(); + QDate date = QDate::currentDate(); + QString time_text = time.toString("hh : mm"); + this->date_text = date.toString("MM/dd"); ui_->Digital_clock->setText(time_text); - if (!this->holidaybg) { - if (this->date_text == "12/24") { + if (!this->holidaybg) + { + if (this->date_text == "12/24") + { MainWindow::updateBG(); } - else if (this->date_text == "12/31") { + else if (this->date_text == "12/31") + { MainWindow::updateBG(); } } // check connected devices - if (localDevice->isValid()) { + if (localDevice->isValid()) + { QString localDeviceName = localDevice->name(); QString 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_->btDeviceCount->setText(QString::number(count)); - if (ui_->btDevice->isVisible() == false) { + if (count > 0) + { + // QBluetoothAddress btdevice = btdevices[0]; + // QString btmac = btdevice.toString(); + // ui_->btDeviceCount->setText(QString::number(count)); + if (ui_->btDevice->isVisible() == false) + { ui_->btDevice->show(); } - if (std::ifstream("/tmp/btnowplaying")) { + if (std::ifstream("/tmp/btnowplaying")) + { ui_->stackedWidget->setCurrentIndex(0); using namespace std; ifstream inFile; string line; inFile.open("/tmp/btnowplaying"); - if(inFile) { + if (inFile) + { getline(inFile, line); ui_->btSongName->setText(QString::fromStdString(line)); getline(inFile, line); @@ -1032,17 +1266,22 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() ui_->btAlbumName->setText(QString::fromStdString(line)); } } - else { + else + { ui_->stackedWidget->setCurrentIndex(1); ui_->btSongName->setText(""); ui_->btArtistName->setText(""); ui_->btAlbumName->setText(""); } - if (std::ifstream("/tmp/btdevice")) { + if (std::ifstream("/tmp/btdevice")) + { ui_->btDevice->setText(configuration_->readFileContent("/tmp/btdevice")); } - } else { - if (ui_->btDevice->isVisible() == true) { + } + else + { + if (ui_->btDevice->isVisible() == true) + { ui_->btDevice->hide(); ui_->btDevice->setText("BT-Device"); } @@ -1067,11 +1306,14 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonList_clicked() ui_->mp3List->show(); ui_->AlbumCoverListView->hide(); - if (playlist->currentIndex() == -1) { + if (playlist->currentIndex() == -1) + { ui_->pushButtonPlayerStop->hide(); ui_->pushButtonPlayerPause->hide(); ui_->pushButtonBackToPlayer->hide(); - } else { + } + else + { ui_->pushButtonBackToPlayer->show(); } } @@ -1081,7 +1323,7 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerStop_clicked() ui_->mp3List->setCurrentRow(playlist->currentIndex()); player->stop(); ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png")); - ui_->pushButtonPlayerPause->setStyleSheet( "background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); + ui_->pushButtonPlayerPause->setStyleSheet("background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); ui_->mp3selectWidget->show(); ui_->PlayerPlayingWidget->hide(); ui_->pushButtonBackToPlayer->hide(); @@ -1103,15 +1345,17 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerStop_clicked() void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPause_clicked() { { - if(player->state() == QMediaPlayer::PlayingState){ + if (player->state() == QMediaPlayer::PlayingState) + { player->pause(); - ui_->pushButtonPlayerPause->setStyleSheet( "background-color: rgb(218, 143, 143); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); - }else{ - ui_->pushButtonPlayerPause->setStyleSheet( "background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); + ui_->pushButtonPlayerPause->setStyleSheet("background-color: rgb(218, 143, 143); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); + } + else + { + ui_->pushButtonPlayerPause->setStyleSheet("background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); player->play(); player->setPosition(player->position()); } - } } @@ -1119,37 +1363,41 @@ void f1x::openauto::autoapp::ui::MainWindow::on_positionChanged(qint64 position) { ui_->horizontalSliderProgressPlayer->setValue(position); - //Setting the time + // Setting the time QString time_elapsed, time_total; int total_seconds, total_minutes; - total_seconds = (player->duration()/1000) % 60; - total_minutes = (player->duration()/1000) / 60; - - if(total_minutes >= 60){ - int total_hours = (total_minutes/60); - total_minutes = total_minutes - (total_hours*60); - time_total = QString("%1").arg(total_hours, 2,10,QChar('0')) + ':' + QString("%1").arg(total_minutes, 2,10,QChar('0')) + ':' + QString("%1").arg(total_seconds, 2,10,QChar('0')); - - }else{ - time_total = QString("%1").arg(total_minutes, 2,10,QChar('0')) + ':' + QString("%1").arg(total_seconds, 2,10,QChar('0')); + total_seconds = (player->duration() / 1000) % 60; + total_minutes = (player->duration() / 1000) / 60; + if (total_minutes >= 60) + { + int total_hours = (total_minutes / 60); + total_minutes = total_minutes - (total_hours * 60); + time_total = QString("%1").arg(total_hours, 2, 10, QChar('0')) + ':' + QString("%1").arg(total_minutes, 2, 10, QChar('0')) + ':' + QString("%1").arg(total_seconds, 2, 10, QChar('0')); + } + else + { + time_total = QString("%1").arg(total_minutes, 2, 10, QChar('0')) + ':' + QString("%1").arg(total_seconds, 2, 10, QChar('0')); } - //calculate time elapsed + // calculate time elapsed int seconds, minutes; - seconds = (position/1000) % 60; - minutes = (position/1000) / 60; + seconds = (position / 1000) % 60; + minutes = (position / 1000) / 60; - //if minutes is over 60 then we should really display hours - if(minutes >= 60){ - int hours = (minutes/60); - minutes = minutes - (hours*60); - time_elapsed = QString("%1").arg(hours, 2,10,QChar('0')) + ':' + QString("%1").arg(minutes, 2,10,QChar('0')) + ':' + QString("%1").arg(seconds, 2,10,QChar('0')); - }else{ - time_elapsed = QString("%1").arg(minutes, 2,10,QChar('0')) + ':' + QString("%1").arg(seconds, 2,10,QChar('0')); + // if minutes is over 60 then we should really display hours + if (minutes >= 60) + { + int hours = (minutes / 60); + minutes = minutes - (hours * 60); + time_elapsed = QString("%1").arg(hours, 2, 10, QChar('0')) + ':' + QString("%1").arg(minutes, 2, 10, QChar('0')) + ':' + QString("%1").arg(seconds, 2, 10, QChar('0')); + } + else + { + time_elapsed = QString("%1").arg(minutes, 2, 10, QChar('0')) + ':' + QString("%1").arg(seconds, 2, 10, QChar('0')); } ui_->playerPositionTime->setText(time_elapsed + " / " + time_total); } @@ -1170,36 +1418,50 @@ void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged() QString filename = QFileInfo(fullpathplaying).fileName(); QImage img = player->metaData(QMediaMetaData::CoverArtImage).value(); - QImage imgscaled = img.scaled(270,270,Qt::IgnoreAspectRatio); - if (!imgscaled.isNull()) { + QImage imgscaled = img.scaled(270, 270, Qt::IgnoreAspectRatio); + if (!imgscaled.isNull()) + { ui_->pushButtonBack->setIcon(QPixmap::fromImage(imgscaled)); - } else { - if (playlist->currentIndex() != -1 && fullpathplaying != "") { + } + else + { + if (playlist->currentIndex() != -1 && fullpathplaying != "") + { QString filename = ui_->mp3List->item(playlist->currentIndex())->text(); QString cover = this->musicfolder + "/" + this->albumfolder + "/" + filename + ".png"; - if (check_file_exist(cover.toStdString().c_str())) { + if (check_file_exist(cover.toStdString().c_str())) + { QPixmap img = cover; - ui_->pushButtonBack->setIcon(img.scaled(270,270,Qt::KeepAspectRatio)); - } else { + ui_->pushButtonBack->setIcon(img.scaled(270, 270, Qt::KeepAspectRatio)); + } + else + { ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png")); } - } else { + } + else + { ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png")); } } - try { + try + { // use metadata from mp3list widget (prescanned id3 by taglib) - if (playlist->currentIndex() != -1 && fullpathplaying != "") { + if (playlist->currentIndex() != -1 && fullpathplaying != "") + { QString currentsong = ui_->mp3List->item(playlist->currentIndex())->text(); ui_->labelCurrentPlaying->setText(currentsong); - if (currentsong.length() > 48) { + if (currentsong.length() > 48) + { int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); QFont _font(family, 12, QFont::Bold); _font.setItalic(true); ui_->labelCurrentPlaying->setFont(_font); - } else { + } + else + { int id = QFontDatabase::addApplicationFont(":/Roboto-Regular.ttf"); QString family = QFontDatabase::applicationFontFamilies(id).at(0); QFont _font(family, 16, QFont::Bold); @@ -1207,50 +1469,66 @@ void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged() ui_->labelCurrentPlaying->setFont(_font); } } - } catch (...) { + } + catch (...) + { // use metadata from player QString AlbumInterpret = player->metaData(QMediaMetaData::AlbumArtist).toString(); QString Title = player->metaData(QMediaMetaData::Title).toString(); - if (AlbumInterpret == "" && ui_->comboBoxAlbum->currentText() != ".") { + if (AlbumInterpret == "" && ui_->comboBoxAlbum->currentText() != ".") + { AlbumInterpret = ui_->comboBoxAlbum->currentText(); } QString currentPlaying; - if (AlbumInterpret != "") { + if (AlbumInterpret != "") + { currentPlaying.append(AlbumInterpret); } - if (Title != "" && AlbumInterpret != "") { + if (Title != "" && AlbumInterpret != "") + { currentPlaying.append(" - "); } - if (Title != "") { + if (Title != "") + { currentPlaying.append(Title); } ui_->labelCurrentPlaying->setText(currentPlaying); } - ui_->labelTrack->setText(QString::number(playlist->currentIndex()+1)); + ui_->labelTrack->setText(QString::number(playlist->currentIndex() + 1)); ui_->labelTrackCount->setText(QString::number(playlist->mediaCount())); - if (playlist->currentIndex() == -1) { + if (playlist->currentIndex() == -1) + { // check for folder icon QString coverpng = this->musicfolder + "/" + this->albumfolder + "/folder.png"; QString coverjpg = this->musicfolder + "/" + this->albumfolder + "/folder.jpg"; QString coverpngcs = "/media/USBDRIVES/CSSTORAGE/COVERCACHE/" + this->albumfolder + ".png"; QString coverjpgcs = "/media/USBDRIVES/CSSTORAGE/COVERCACHE/" + this->albumfolder + ".jpg"; - if (check_file_exist(coverpng.toStdString().c_str())) { + if (check_file_exist(coverpng.toStdString().c_str())) + { QPixmap img = coverpng; - ui_->pushButtonBack->setIcon(img.scaled(270,270,Qt::KeepAspectRatio)); - } else if (check_file_exist(coverjpg.toStdString().c_str())) { + ui_->pushButtonBack->setIcon(img.scaled(270, 270, Qt::KeepAspectRatio)); + } + else if (check_file_exist(coverjpg.toStdString().c_str())) + { QPixmap img = coverjpg; - ui_->pushButtonBack->setIcon(img.scaled(270,270,Qt::KeepAspectRatio)); - } else if (check_file_exist(coverpngcs.toStdString().c_str())) { + ui_->pushButtonBack->setIcon(img.scaled(270, 270, Qt::KeepAspectRatio)); + } + else if (check_file_exist(coverpngcs.toStdString().c_str())) + { QPixmap img = coverpngcs; - ui_->pushButtonBack->setIcon(img.scaled(270,270,Qt::KeepAspectRatio)); - } else if (check_file_exist(coverjpgcs.toStdString().c_str())) { + ui_->pushButtonBack->setIcon(img.scaled(270, 270, Qt::KeepAspectRatio)); + } + else if (check_file_exist(coverjpgcs.toStdString().c_str())) + { QPixmap img = coverjpgcs; - ui_->pushButtonBack->setIcon(img.scaled(270,270,Qt::KeepAspectRatio)); - } else { + ui_->pushButtonBack->setIcon(img.scaled(270, 270, Qt::KeepAspectRatio)); + } + else + { ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png")); } ui_->labelCurrentPlaying->setText(ui_->comboBoxAlbum->currentText()); @@ -1277,10 +1555,10 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPlayList_clicked ui_->pushButtonList->show(); ui_->pushButtonBackToPlayer->hide(); ui_->pushButtonPlayerStop->show(); - ui_->pushButtonPlayerPause->setStyleSheet( "background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); + ui_->pushButtonPlayerPause->setStyleSheet("background-color: rgb(233, 185, 110); border-radius: 4px; border: 2px solid rgba(255,255,255,0.5); color: rgb(0,0,0);"); ui_->pushButtonPlayerPause->show(); int currentalbum = ui_->comboBoxAlbum->currentIndex(); - ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum + 1)); ui_->Info->show(); ui_->horizontalSliderProgressPlayer->show(); ui_->pushButtonAlbum->hide(); @@ -1308,9 +1586,12 @@ void f1x::openauto::autoapp::ui::MainWindow::on_comboBoxAlbum_currentIndexChange ui_->labelCurrentPlaying->setText(""); ui_->playerPositionTime->setText(""); - if (this->playlist->mediaCount() < 2) { + if (this->playlist->mediaCount() < 2) + { ui_->pushButtonPlayerPlayList->hide(); - } else { + } + else + { ui_->pushButtonPlayerPlayList->show(); } } @@ -1341,46 +1622,60 @@ void f1x::openauto::autoapp::ui::MainWindow::resetRetryUSBMessage() void f1x::openauto::autoapp::ui::MainWindow::scanFolders() { - try { - if (this->mediacontentchanged == true) { + try + { + if (this->mediacontentchanged == true) + { this->mediacontentchanged = false; int cleaner = ui_->comboBoxAlbum->count(); - while (cleaner > -1) { + while (cleaner > -1) + { ui_->comboBoxAlbum->removeItem(cleaner); cleaner--; } QDir directory(this->musicfolder); QStringList folders = directory.entryList(QStringList() << "*", QDir::AllDirs, QDir::Name); QStandardItemModel *model = new QStandardItemModel(this); - foreach (QString foldername, folders) { - if (foldername != ".." and foldername != ".") { + foreach (QString foldername, folders) + { + if (foldername != ".." and foldername != ".") + { ui_->comboBoxAlbum->addItem(foldername); - ui_->labelAlbumCount->setText(QString::number(ui_->comboBoxAlbum->count())); + ui_->labelAlbumCount->setText(QString::number(ui_->comboBoxAlbum->count())); QString coverpng = this->musicfolder + "/" + foldername + "/folder.png"; QString coverjpg = this->musicfolder + "/" + foldername + "/folder.jpg"; QString coverpngcs = "/media/USBDRIVES/CSSTORAGE/COVERCACHE/" + foldername + ".png"; QString coverjpgcs = "/media/USBDRIVES/CSSTORAGE/COVERCACHE/" + foldername + ".jpg"; - if (check_file_exist(coverpng.toStdString().c_str())) { + if (check_file_exist(coverpng.toStdString().c_str())) + { QPixmap img = coverpng; - QStandardItem *item = new QStandardItem(QIcon(img.scaled(270,270,Qt::KeepAspectRatio)),foldername); - model->setItem(ui_->comboBoxAlbum->count(),0,item); - } else if (check_file_exist(coverjpg.toStdString().c_str())) { + QStandardItem *item = new QStandardItem(QIcon(img.scaled(270, 270, Qt::KeepAspectRatio)), foldername); + model->setItem(ui_->comboBoxAlbum->count(), 0, item); + } + else if (check_file_exist(coverjpg.toStdString().c_str())) + { QPixmap img = coverjpg; - QStandardItem *item = new QStandardItem(QIcon(img.scaled(270,270,Qt::KeepAspectRatio)),foldername); - model->setItem(ui_->comboBoxAlbum->count(),0,item); - } else if (check_file_exist(coverpngcs.toStdString().c_str())) { + QStandardItem *item = new QStandardItem(QIcon(img.scaled(270, 270, Qt::KeepAspectRatio)), foldername); + model->setItem(ui_->comboBoxAlbum->count(), 0, item); + } + else if (check_file_exist(coverpngcs.toStdString().c_str())) + { QPixmap img = coverpngcs; - QStandardItem *item = new QStandardItem(QIcon(img.scaled(270,270,Qt::KeepAspectRatio)),foldername); - model->setItem(ui_->comboBoxAlbum->count(),0,item); - } else if (check_file_exist(coverjpgcs.toStdString().c_str())) { + QStandardItem *item = new QStandardItem(QIcon(img.scaled(270, 270, Qt::KeepAspectRatio)), foldername); + model->setItem(ui_->comboBoxAlbum->count(), 0, item); + } + else if (check_file_exist(coverjpgcs.toStdString().c_str())) + { QPixmap img = coverjpgcs; - QStandardItem *item = new QStandardItem(QIcon(img.scaled(270,270,Qt::KeepAspectRatio)),foldername); - model->setItem(ui_->comboBoxAlbum->count(),0,item); - } else { - QStandardItem *item = new QStandardItem(QIcon(":/coverlogo.png"),foldername); - model->setItem(ui_->comboBoxAlbum->count(),0,item); + QStandardItem *item = new QStandardItem(QIcon(img.scaled(270, 270, Qt::KeepAspectRatio)), foldername); + model->setItem(ui_->comboBoxAlbum->count(), 0, item); + } + else + { + QStandardItem *item = new QStandardItem(QIcon(":/coverlogo.png"), foldername); + model->setItem(ui_->comboBoxAlbum->count(), 0, item); } } } @@ -1389,7 +1684,8 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFolders() ui_->SysinfoTopLeft->hide(); } } - catch(...) { + catch (...) + { ui_->SysinfoTopLeft->hide(); } ui_->mp3List->hide(); @@ -1397,9 +1693,11 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFolders() void f1x::openauto::autoapp::ui::MainWindow::scanFiles() { - if (this->mediacontentchanged == false) { + if (this->mediacontentchanged == false) + { int cleaner = ui_->mp3List->count(); - while (cleaner > -1) { + while (cleaner > -1) + { ui_->mp3List->takeItem(cleaner); cleaner--; } @@ -1407,19 +1705,24 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFiles() QList content; QDir directory(this->musicfolder + "/" + this->albumfolder); - QStringList mp3s = directory.entryList(QStringList() << "*.mp3" << "*.flac" << "*.aac" << "*.ogg" << "*.mp4" << "*.mp4a" << "*.wma" << "*.strm",QDir::Files, QDir::Name); - foreach (QString filename, mp3s) { + QStringList mp3s = directory.entryList(QStringList() << "*.mp3" << "*.flac" << "*.aac" << "*.ogg" << "*.mp4" << "*.mp4a" << "*.wma" << "*.strm", QDir::Files, QDir::Name); + foreach (QString filename, mp3s) + { // add to mediacontent - if (filename.endsWith(".strm")) { - QString url=configuration_->readFileContent(this->musicfolder + "/" + this->albumfolder + "/" + filename); + if (filename.endsWith(".strm")) + { + QString url = configuration_->readFileContent(this->musicfolder + "/" + this->albumfolder + "/" + filename); content.push_back(QMediaContent(QUrl(url))); - ui_->mp3List->addItem(filename.replace(".strm","")); - } else { + ui_->mp3List->addItem(filename.replace(".strm", "")); + } + else + { // add items to gui content.push_back(QMediaContent(QUrl::fromLocalFile(this->musicfolder + "/" + this->albumfolder + "/" + filename))); // read metadata using taglib - try { - TagLib::FileRef file((this->musicfolder + "/" + this->albumfolder + "/" + filename).toUtf8(),true); + try + { + TagLib::FileRef file((this->musicfolder + "/" + this->albumfolder + "/" + filename).toUtf8(), true); TagLib::String artist_string = file.tag()->artist(); TagLib::String title_string = file.tag()->title(); TagLib::uint track_string = file.tag()->track(); @@ -1427,12 +1730,15 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFiles() QString titleid3 = QString::fromStdWString(title_string.toCWString()); QString trackid3 = QString::number(track_string); int tracklength = trackid3.length(); - if (tracklength < 2) { + if (tracklength < 2) + { trackid3 = "0" + trackid3; } QString ID3Entry = trackid3 + ": " + artistid3 + " - " + titleid3; ui_->mp3List->addItem(ID3Entry); - } catch (...) { + } + catch (...) + { // old way only adding filename to list ui_->mp3List->addItem(filename); } @@ -1448,7 +1754,8 @@ void f1x::openauto::autoapp::ui::MainWindow::on_mp3List_currentRowChanged(int cu ui_->labelFolderpath->setText(QString::number(currentRow)); this->currentPlaylistIndex = currentRow; - if (configuration_->instantPlay()) { + if (configuration_->instantPlay()) + { MainWindow::on_pushButtonPlayerPlayList_clicked(); } } @@ -1456,7 +1763,8 @@ void f1x::openauto::autoapp::ui::MainWindow::on_mp3List_currentRowChanged(int cu void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextBig_clicked() { playlist->next(); - if (playlist->currentIndex() != -1) { + if (playlist->currentIndex() != -1) + { player->play(); ui_->pushButtonPlayerStop->show(); ui_->pushButtonPlayerPause->show(); @@ -1467,7 +1775,8 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextBig_clicked( void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPrevBig_clicked() { playlist->previous(); - if (playlist->currentIndex() != -1) { + if (playlist->currentIndex() != -1) + { player->play(); ui_->pushButtonPlayerStop->show(); ui_->pushButtonPlayerPause->show(); @@ -1479,18 +1788,22 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerPrevAlbum_clicke { int albumcount = ui_->comboBoxAlbum->count(); int currentalbum = ui_->comboBoxAlbum->currentIndex(); - if (currentalbum >= 1) { - currentalbum = currentalbum-1; + if (currentalbum >= 1) + { + currentalbum = currentalbum - 1; ui_->comboBoxAlbum->setCurrentIndex(currentalbum); - ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); - player->play(); - } else { - currentalbum = albumcount-1; - ui_->comboBoxAlbum->setCurrentIndex(currentalbum); - ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum + 1)); player->play(); } - if (ui_->mp3selectWidget->isVisible() == false) { + else + { + currentalbum = albumcount - 1; + ui_->comboBoxAlbum->setCurrentIndex(currentalbum); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum + 1)); + player->play(); + } + if (ui_->mp3selectWidget->isVisible() == false) + { ui_->pushButtonPlayerBack->show(); ui_->pushButtonList->show(); ui_->pushButtonPlayerPause->show(); @@ -1503,18 +1816,22 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonPlayerNextAlbum_clicke { int albumcount = ui_->comboBoxAlbum->count(); int currentalbum = ui_->comboBoxAlbum->currentIndex(); - if (currentalbum < albumcount-1) { + if (currentalbum < albumcount - 1) + { currentalbum = currentalbum + 1; ui_->comboBoxAlbum->setCurrentIndex(currentalbum); - ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); - player->play(); - } else { - currentalbum = 0; - ui_->comboBoxAlbum->setCurrentIndex(currentalbum); - ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum+1)); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum + 1)); player->play(); } - if (ui_->mp3selectWidget->isVisible() == false) { + else + { + currentalbum = 0; + ui_->comboBoxAlbum->setCurrentIndex(currentalbum); + ui_->labelCurrentAlbumIndex->setText(QString::number(currentalbum + 1)); + player->play(); + } + if (ui_->mp3selectWidget->isVisible() == false) + { ui_->pushButtonPlayerBack->show(); ui_->pushButtonList->show(); ui_->pushButtonPlayerPause->show(); @@ -1538,83 +1855,111 @@ void f1x::openauto::autoapp::ui::MainWindow::on_pushButtonBackToPlayer_clicked() void f1x::openauto::autoapp::ui::MainWindow::on_StateChanged(QMediaPlayer::State state) { - if (state == QMediaPlayer::StoppedState || state == QMediaPlayer::PausedState) { + if (state == QMediaPlayer::StoppedState || state == QMediaPlayer::PausedState) + { std::remove("/tmp/media_playing"); - } else { + } + else + { std::ofstream("/tmp/media_playing"); } } - bool f1x::openauto::autoapp::ui::MainWindow::check_file_exist(const char *fileName) { std::ifstream ifile(fileName, std::ios::in); // file not ok - checking if symlink - if (!ifile.good()) { + if (!ifile.good()) + { QFileInfo linkFile = QString(fileName); - if (linkFile.isSymLink()) { + if (linkFile.isSymLink()) + { QFileInfo linkTarget(linkFile.symLinkTarget()); return linkTarget.exists(); - } else { + } + else + { return ifile.good(); } - } else { + } + else + { return ifile.good(); } } void f1x::openauto::autoapp::ui::MainWindow::keyPressEvent(QKeyEvent *event) { - if (configuration_->playerButtonControl()) { - if (event->key() == Qt::Key_C) { + if (configuration_->playerButtonControl()) + { + if (event->key() == Qt::Key_C) + { on_pushButtonPlayerPause_clicked(); } - if (event->key() == Qt::Key_X) { + if (event->key() == Qt::Key_X) + { on_pushButtonPlayerPlayList_clicked(); } - if (event->key() == Qt::Key_V) { + if (event->key() == Qt::Key_V) + { on_pushButtonPlayerPrevBig_clicked(); } - if (event->key() == Qt::Key_N) { + if (event->key() == Qt::Key_N) + { on_pushButtonPlayerNextBig_clicked(); } - if (event->key() == Qt::Key_B) { + if (event->key() == Qt::Key_B) + { on_pushButtonPlayerPause_clicked(); } - if (event->key() == Qt::Key_H) { - if (ui_->mediaWidget->isVisible() == false) { + if (event->key() == Qt::Key_H) + { + if (ui_->mediaWidget->isVisible() == false) + { playerShow(); - } else { + } + else + { playerHide(); } } - if (event->key() == Qt::Key_A) { + if (event->key() == Qt::Key_A) + { on_pushButtonPlayerPrevAlbum_clicked(); } - if (event->key() == Qt::Key_L) { + if (event->key() == Qt::Key_L) + { on_pushButtonPlayerNextAlbum_clicked(); } } - if (event->key() == Qt::Key_Return) { - QApplication::postEvent (QApplication::focusWidget(), new QKeyEvent ( QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier)); - QApplication::postEvent (QApplication::focusWidget(), new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier)); - } - if (event->key() == Qt::Key_1) { - QApplication::postEvent (QApplication::focusWidget(), new QKeyEvent ( QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier)); - } - if (event->key() == Qt::Key_2) { - QApplication::postEvent (QApplication::focusWidget(), new QKeyEvent ( QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier)); - } - if(event->key() == Qt::Key_Escape) + if (event->key() == Qt::Key_Return) { - if (ui_->mediaWidget->isVisible() == true) { + QApplication::postEvent(QApplication::focusWidget(), new QKeyEvent(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier)); + QApplication::postEvent(QApplication::focusWidget(), new QKeyEvent(QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier)); + } + if (event->key() == Qt::Key_1) + { + QApplication::postEvent(QApplication::focusWidget(), new QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier)); + } + if (event->key() == Qt::Key_2) + { + QApplication::postEvent(QApplication::focusWidget(), new QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier)); + } + if (event->key() == Qt::Key_Escape) + { + if (ui_->mediaWidget->isVisible() == true) + { playerHide(); - } else if (this->oldGUIStyle == true) { - toggleGUI(); - } else { + } + else if (this->oldGUIStyle == true) + { + toggleGUI(); + } + else + { toggleExit(); } - } + } } void f1x::openauto::autoapp::ui::MainWindow::on_AlbumCoverListView_clicked(const QModelIndex &index) @@ -1629,64 +1974,86 @@ void f1x::openauto::autoapp::ui::MainWindow::on_AlbumCoverListView_clicked(const ui_->pushButtonAlbum->show(); ui_->pushButtonPlayerPlayList->show(); - if (ui_->mp3selectWidget->isVisible() == false) { + if (ui_->mp3selectWidget->isVisible() == false) + { MainWindow::on_pushButtonPlayerPlayList_clicked(); } } void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() { - try { - if (std::ifstream("/tmp/entityexit")) { + try + { + if (std::ifstream("/tmp/entityexit")) + { MainWindow::TriggerAppStop(); std::remove("/tmp/entityexit"); } - } catch (...) { + } + catch (...) + { OPENAUTO_LOG(error) << "[OpenAuto] Error in entityexit"; } // check if system is in display off mode (tap2wake) - if (std::ifstream("/tmp/blankscreen")) { - if (ui_->centralWidget->isVisible() == true) { + if (std::ifstream("/tmp/blankscreen")) + { + if (ui_->centralWidget->isVisible() == true) + { CloseAllDialogs(); ui_->centralWidget->hide(); } - } else { - if (ui_->centralWidget->isVisible() == false) { + } + else + { + if (ui_->centralWidget->isVisible() == false) + { ui_->centralWidget->show(); } } // check if system is in display off mode (tap2wake/screensaver) - if (std::ifstream("/tmp/screensaver")) { - if (ui_->menuWidget->isVisible() == true) { + if (std::ifstream("/tmp/screensaver")) + { + if (ui_->menuWidget->isVisible() == true) + { ui_->menuWidget->hide(); } - if (ui_->oldmenuWidget->isVisible() == true) { + if (ui_->oldmenuWidget->isVisible() == true) + { ui_->oldmenuWidget->hide(); } - if (ui_->headerWidget->isVisible() == true) { + if (ui_->headerWidget->isVisible() == true) + { ui_->headerWidget->hide(); CloseAllDialogs(); } - if (ui_->mediaWidget->isVisible() == true) { + if (ui_->mediaWidget->isVisible() == true) + { ui_->mediaWidget->hide(); } - if (ui_->cameraWidget->isVisible() == true) { + if (ui_->cameraWidget->isVisible() == true) + { ui_->cameraWidget->hide(); } - if (ui_->BrightnessSliderControl->isVisible() == true) { + if (ui_->BrightnessSliderControl->isVisible() == true) + { ui_->BrightnessSliderControl->hide(); } cameraHide(); - if (ui_->clockOnlyWidget->isVisible() == false) { + if (ui_->clockOnlyWidget->isVisible() == false) + { ui_->clockOnlyWidget->show(); } - } else { - if (ui_->headerWidget->isVisible() == false) { + } + else + { + if (ui_->headerWidget->isVisible() == false) + { ui_->headerWidget->show(); } - if (ui_->clockOnlyWidget->isVisible() == true) { + if (ui_->clockOnlyWidget->isVisible() == true) + { ui_->clockOnlyWidget->hide(); toggleGUI(); toggleGUI(); @@ -1695,50 +2062,66 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if custom command needs black background - if (std::ifstream("/tmp/blackscreen")) { - if (ui_->centralWidget->isVisible() == true) { + if (std::ifstream("/tmp/blackscreen")) + { + if (ui_->centralWidget->isVisible() == true) + { ui_->centralWidget->hide(); this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);}"); this->background_set = false; } - } else { - if (this->background_set == false) { + } + else + { + if (this->background_set == false) + { f1x::openauto::autoapp::ui::MainWindow::updateBG(); this->background_set = true; } } // check if phone is conencted to usb - if (std::ifstream("/tmp/android_device")) { - if (ui_->ButtonAndroidAuto->isVisible() == false) { + if (std::ifstream("/tmp/android_device")) + { + if (ui_->ButtonAndroidAuto->isVisible() == false) + { ui_->ButtonAndroidAuto->show(); ui_->pushButtonNoDevice->hide(); } - if (ui_->pushButtonAndroidAuto2->isVisible() == false) { + if (ui_->pushButtonAndroidAuto2->isVisible() == false) + { ui_->pushButtonAndroidAuto2->show(); ui_->pushButtonNoDevice2->hide(); } - try { + try + { QFile deviceData(QString("/tmp/android_device")); deviceData.open(QIODevice::ReadOnly); QTextStream data_date(&deviceData); data_date.readLine(); // wait for second line to be written QString linedate; - while (linedate.isNull()) { + while (linedate.isNull()) + { linedate = data_date.readLine(); } deviceData.close(); - ui_->labelAndroidAutoBottom->setText(linedate.simplified().replace("_"," ")); - } catch (...) { + ui_->labelAndroidAutoBottom->setText(linedate.simplified().replace("_", " ")); + } + catch (...) + { ui_->labelAndroidAutoBottom->setText(""); } - } else { - if (ui_->ButtonAndroidAuto->isVisible() == true) { + } + else + { + if (ui_->ButtonAndroidAuto->isVisible() == true) + { ui_->pushButtonNoDevice->show(); ui_->ButtonAndroidAuto->hide(); } - if (ui_->pushButtonAndroidAuto2->isVisible() == true) { + if (ui_->pushButtonAndroidAuto2->isVisible() == true) + { ui_->pushButtonNoDevice2->show(); ui_->pushButtonAndroidAuto2->hide(); } @@ -1746,34 +2129,49 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if bluetooth pairable - if (this->bluetoothEnabled) { - if (std::ifstream("/tmp/bluetooth_pairable")) { - if (ui_->labelBluetoothPairable->isVisible() == false) { + if (this->bluetoothEnabled) + { + if (std::ifstream("/tmp/bluetooth_pairable")) + { + if (ui_->labelBluetoothPairable->isVisible() == false) + { ui_->labelBluetoothPairable->show(); } - if (ui_->pushButtonBluetooth->isVisible() == true) { + if (ui_->pushButtonBluetooth->isVisible() == true) + { ui_->pushButtonBluetooth->hide(); } - } else { - if (ui_->labelBluetoothPairable->isVisible() == true) { + } + else + { + if (ui_->labelBluetoothPairable->isVisible() == true) + { ui_->labelBluetoothPairable->hide(); } - if (ui_->pushButtonBluetooth->isVisible() == false) { + if (ui_->pushButtonBluetooth->isVisible() == false) + { ui_->pushButtonBluetooth->show(); } } - } else { - if (ui_->labelBluetoothPairable->isVisible() == true) { + } + else + { + if (ui_->labelBluetoothPairable->isVisible() == true) + { ui_->labelBluetoothPairable->hide(); } - if (ui_->pushButtonBluetooth->isVisible() == true) { + if (ui_->pushButtonBluetooth->isVisible() == true) + { ui_->pushButtonBluetooth->hide(); } } - if (std::ifstream("/tmp/config_in_progress") || std::ifstream("/tmp/debug_in_progress") || std::ifstream("/tmp/enable_pairing")) { - if (ui_->SysinfoTopLeft2->isVisible() == false) { - if (std::ifstream("/tmp/config_in_progress")) { + if (std::ifstream("/tmp/config_in_progress") || std::ifstream("/tmp/debug_in_progress") || std::ifstream("/tmp/enable_pairing")) + { + if (ui_->SysinfoTopLeft2->isVisible() == false) + { + if (std::ifstream("/tmp/config_in_progress")) + { ui_->pushButtonSettings->hide(); ui_->pushButtonSettings2->hide(); ui_->pushButtonLock->show(); @@ -1781,7 +2179,8 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() ui_->SysinfoTopLeft2->setText("Config in progress ..."); ui_->SysinfoTopLeft2->show(); } - if (std::ifstream("/tmp/debug_in_progress")) { + if (std::ifstream("/tmp/debug_in_progress")) + { ui_->pushButtonSettings->hide(); ui_->pushButtonSettings2->hide(); ui_->pushButtonDebug->hide(); @@ -1791,22 +2190,27 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() ui_->SysinfoTopLeft2->setText("Creating debug.zip ..."); ui_->SysinfoTopLeft2->show(); } - if (std::ifstream("/tmp/enable_pairing")) { + if (std::ifstream("/tmp/enable_pairing")) + { ui_->pushButtonDebug->hide(); ui_->pushButtonDebug2->hide(); ui_->SysinfoTopLeft2->setText("Pairing enabled for 120 seconds!"); ui_->SysinfoTopLeft2->show(); } } - } else { - if (ui_->SysinfoTopLeft2->isVisible() == true) { + } + else + { + if (ui_->SysinfoTopLeft2->isVisible() == true) + { ui_->SysinfoTopLeft2->setText(""); ui_->SysinfoTopLeft2->hide(); ui_->pushButtonSettings->show(); ui_->pushButtonSettings2->show(); ui_->pushButtonLock->hide(); ui_->pushButtonLock2->hide(); - if (this->systemDebugmode) { + if (this->systemDebugmode) + { ui_->pushButtonDebug->show(); ui_->pushButtonDebug2->show(); } @@ -1816,43 +2220,60 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() // update day/night state this->nightModeEnabled = check_file_exist("/tmp/night_mode_enabled"); - if (this->nightModeEnabled) { - if (!this->DayNightModeState) { + if (this->nightModeEnabled) + { + if (!this->DayNightModeState) + { this->DayNightModeState = true; f1x::openauto::autoapp::ui::MainWindow::switchGuiToNight(); } - } else { - if (this->DayNightModeState) { + } + else + { + if (this->DayNightModeState) + { this->DayNightModeState = false; f1x::openauto::autoapp::ui::MainWindow::switchGuiToDay(); } } // camera stuff - if (this->cameraButtonForce) { + if (this->cameraButtonForce) + { // check if dashcam is recording this->dashCamRecording = check_file_exist("/tmp/dashcam_is_recording"); - if (this->dashCamRecording) { - if (ui_->dcRecording->isVisible() == false) { + if (this->dashCamRecording) + { + if (ui_->dcRecording->isVisible() == false) + { ui_->dcRecording->show(); } - } else { - if (ui_->dcRecording->isVisible() == true) { + } + else + { + if (ui_->dcRecording->isVisible() == true) + { ui_->dcRecording->hide(); } } // show recording state if dashcam is visible - if (ui_->cameraWidget->isVisible() == true) { - if (this->dashCamRecording) { - if (ui_->pushButtonRecord->isVisible() == true) { + if (ui_->cameraWidget->isVisible() == true) + { + if (this->dashCamRecording) + { + if (ui_->pushButtonRecord->isVisible() == true) + { ui_->pushButtonRecordActive->show(); ui_->pushButtonRecord->hide(); } - } else { - if (ui_->pushButtonRecordActive->isVisible() == true) { + } + else + { + if (ui_->pushButtonRecordActive->isVisible() == true) + { ui_->pushButtonRecord->show(); ui_->pushButtonRecordActive->hide(); } @@ -1861,22 +2282,28 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // check if shutdown is external triggered and init clean app exit - if (std::ifstream("/tmp/external_exit")) { + if (std::ifstream("/tmp/external_exit")) + { f1x::openauto::autoapp::ui::MainWindow::MainWindow::exit(); } this->hotspotActive = check_file_exist("/tmp/hotspot_active"); // hide wifi if hotspot disabled and force wifi unselected - if (!this->hotspotActive && !std::ifstream("/tmp/mobile_hotspot_detected")) { - if ((ui_->AAWIFIWidget->isVisible() == true) || (ui_->AAWIFIWidget2->isVisible() == true)){ + if (!this->hotspotActive && !std::ifstream("/tmp/mobile_hotspot_detected")) + { + if ((ui_->AAWIFIWidget->isVisible() == true) || (ui_->AAWIFIWidget2->isVisible() == true)) + { ui_->AAWIFIWidget->hide(); ui_->AAWIFIWidget2->hide(); ui_->AAUSBWidget->show(); ui_->AAUSBWidget2->show(); } - } else { - if ((ui_->AAWIFIWidget->isVisible() == false) || (ui_->AAWIFIWidget2->isVisible() == false)) { + } + else + { + if ((ui_->AAWIFIWidget->isVisible() == false) || (ui_->AAWIFIWidget2->isVisible() == false)) + { ui_->AAWIFIWidget->show(); ui_->AAWIFIWidget2->show(); ui_->AAUSBWidget->hide(); @@ -1884,50 +2311,65 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } } - if (std::ifstream("/tmp/temp_recent_list") || std::ifstream("/tmp/mobile_hotspot_detected")) { - if (ui_->pushButtonWifi->isVisible() == false) { + if (std::ifstream("/tmp/temp_recent_list") || std::ifstream("/tmp/mobile_hotspot_detected")) + { + if (ui_->pushButtonWifi->isVisible() == false) + { ui_->pushButtonWifi->show(); ui_->pushButtonWifi->setFocus(); } - if (ui_->pushButtonNoWiFiDevice->isVisible() == true) { + if (ui_->pushButtonNoWiFiDevice->isVisible() == true) + { ui_->pushButtonNoWiFiDevice->hide(); } - if (ui_->pushButtonWifi2->isVisible() == false) { + if (ui_->pushButtonWifi2->isVisible() == false) + { ui_->pushButtonWifi2->show(); ui_->pushButtonWifi2->setFocus(); } - if (ui_->pushButtonNoWiFiDevice2->isVisible() == true) { + if (ui_->pushButtonNoWiFiDevice2->isVisible() == true) + { ui_->pushButtonNoWiFiDevice2->hide(); } - } else { - if (ui_->pushButtonWifi->isVisible() == true) { + } + else + { + if (ui_->pushButtonWifi->isVisible() == true) + { ui_->pushButtonWifi->hide(); } - if (ui_->pushButtonNoWiFiDevice->isVisible() == false) { + if (ui_->pushButtonNoWiFiDevice->isVisible() == false) + { ui_->pushButtonNoWiFiDevice->show(); } - if (ui_->pushButtonWifi2->isVisible() == true) { + if (ui_->pushButtonWifi2->isVisible() == true) + { ui_->pushButtonWifi2->hide(); } - if (ui_->pushButtonNoWiFiDevice2->isVisible() == false) { + if (ui_->pushButtonNoWiFiDevice2->isVisible() == false) + { ui_->pushButtonNoWiFiDevice2->show(); } } // handle dummys in classic menu int button_count = 0; - if (ui_->pushButtonCameraShow2->isVisible() == true) { + if (ui_->pushButtonCameraShow2->isVisible() == true) + { button_count = button_count + 1; } - if (ui_->AAWIFIWidget2->isVisible() == true) { + if (ui_->AAWIFIWidget2->isVisible() == true) + { button_count = button_count + 1; } - if (ui_->pushButtonDebug2->isVisible() == true) { + if (ui_->pushButtonDebug2->isVisible() == true) + { button_count = button_count + 1; } // Hide auto day/night if needed - if (this->lightsensor || std::ifstream("/tmp/daynight_gpio")) { + if (this->lightsensor || std::ifstream("/tmp/daynight_gpio")) + { ui_->pushButtonDay->hide(); ui_->pushButtonNight->hide(); ui_->pushButtonDay2->hide(); @@ -1937,61 +2379,86 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // use big clock in classic gui? - if (this->configuration_->showBigClock()) { + if (this->configuration_->showBigClock()) + { this->UseBigClock = true; - } else { + } + else + { this->UseBigClock = false; } // clock viibility by settings - if (!this->configuration_->showClock()) { + if (!this->configuration_->showClock()) + { ui_->Digital_clock->hide(); - //ui_->oldmenuDummy->show(); + // ui_->oldmenuDummy->show(); this->NoClock = true; - } else { + } + else + { this->NoClock = false; - if (this->UseBigClock && ui_->oldmenuWidget->isVisible() == true) { - //ui_->oldmenuDummy->hide(); - if (oldGUIStyle) { + if (this->UseBigClock && ui_->oldmenuWidget->isVisible() == true) + { + // ui_->oldmenuDummy->hide(); + if (oldGUIStyle) + { ui_->Digital_clock->hide(); } - } else { - //ui_->oldmenuDummy->show(); + } + else + { + // ui_->oldmenuDummy->show(); ui_->Digital_clock->show(); } } - if (!this->configuration_->showNetworkinfo()) { - if (ui_->networkInfo->isVisible() == true) { + if (!this->configuration_->showNetworkinfo()) + { + if (ui_->networkInfo->isVisible() == true) + { ui_->networkInfo->hide(); } - } else { - if (ui_->networkInfo->isVisible() == false) { - if (ui_->mediaWidget->isVisible() == false) { + } + else + { + if (ui_->networkInfo->isVisible() == false) + { + if (ui_->mediaWidget->isVisible() == false) + { ui_->networkInfo->show(); } } } // hide gui toggle if enabled in settings - if (this->configuration_->hideMenuToggle()) { + if (this->configuration_->hideMenuToggle()) + { ui_->pushButtonToggleGUI->hide(); ui_->pushButtonToggleGUI2->hide(); - } else { + } + else + { ui_->pushButtonToggleGUI->show(); ui_->pushButtonToggleGUI2->show(); } // hide brightness button if eanbled in settings - if (configuration_->hideBrightnessControl()) { - if ((ui_->pushButtonBrightness->isVisible() == true) || (ui_->pushButtonBrightness->isVisible() == true) || (ui_->BrightnessSliderControl->isVisible() == true)) { + if (configuration_->hideBrightnessControl()) + { + if ((ui_->pushButtonBrightness->isVisible() == true) || (ui_->pushButtonBrightness->isVisible() == true) || (ui_->BrightnessSliderControl->isVisible() == true)) + { ui_->pushButtonBrightness->hide(); ui_->pushButtonBrightness2->hide(); ui_->BrightnessSliderControl->hide(); } - } else { - if (!this->lightsensor) { - if ((ui_->pushButtonBrightness->isVisible() == false) || (ui_->pushButtonBrightness->isVisible() == false)) { + } + else + { + if (!this->lightsensor) + { + if ((ui_->pushButtonBrightness->isVisible() == false) || (ui_->pushButtonBrightness->isVisible() == false)) + { ui_->pushButtonBrightness->show(); ui_->pushButtonBrightness2->show(); ui_->BrightnessSliderControl->hide(); @@ -2000,14 +2467,19 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() } // read value from tsl2561 - if (std::ifstream("/tmp/tsl2561") && this->configuration_->showLux()) { - if (ui_->label_left->isVisible() == false) { + if (std::ifstream("/tmp/tsl2561") && this->configuration_->showLux()) + { + if (ui_->label_left->isVisible() == false) + { ui_->label_left->show(); ui_->label_right->show(); } ui_->label_left->setText("Lux: " + configuration_->readFileContent("/tmp/tsl2561")); - } else { - if (ui_->label_left->isVisible() == true) { + } + else + { + if (ui_->label_left->isVisible() == true) + { ui_->label_left->hide(); ui_->label_right->hide(); ui_->label_left->setText(""); @@ -2022,36 +2494,50 @@ void f1x::openauto::autoapp::ui::MainWindow::tmpChanged() this->openautoupdate = check_file_exist("/tmp/openauto_update_available"); this->systemupdate = check_file_exist("/tmp/system_update_available"); - if (this->csmtupdate || this->udevupdate || this->openautoupdate || this->systemupdate) { - if (ui_->pushButtonUpdate->isVisible() == false) { + if (this->csmtupdate || this->udevupdate || this->openautoupdate || this->systemupdate) + { + if (ui_->pushButtonUpdate->isVisible() == false) + { ui_->pushButtonUpdate->show(); ui_->label_left->show(); ui_->label_right->show(); - if (this->devModeEnabled) { + if (this->devModeEnabled) + { ui_->devlabel_right->hide(); - } else { + } + else + { ui_->label_dummy_right->show(); } } - } else { - if (ui_->pushButtonUpdate->isVisible() == true) { + } + else + { + if (ui_->pushButtonUpdate->isVisible() == true) + { ui_->pushButtonUpdate->hide(); ui_->label_left->hide(); ui_->label_right->hide(); ui_->label_dummy_right->hide(); - if (this->devModeEnabled) { + if (this->devModeEnabled) + { ui_->devlabel_right->show(); } } - } + } - 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) { + 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) { + } + else + { + if (ui_->labelLock->isVisible() == true) + { ui_->labelLock->hide(); ui_->labelLockDummy->hide(); }