From baae26932c24b19f6cb0be9f3421197596f5a91d Mon Sep 17 00:00:00 2001 From: hawkeyexp Date: Fri, 17 Aug 2018 16:13:44 +0200 Subject: [PATCH] Add bluetooth pair button --- assets/ico_bluetooth.png | Bin 0 -> 5819 bytes assets/resources.qrc | 1 + .../f1x/openauto/autoapp/UI/MainWindow.hpp | 1 + .../openauto/autoapp/UI/SettingsWindow.hpp | 1 + src/autoapp/UI/MainWindow.cpp | 21 +- src/autoapp/UI/SettingsWindow.cpp | 28 +- src/autoapp/UI/mainwindow.ui | 27 +- src/autoapp/UI/settingswindow.ui | 292 ++++++++++-------- 8 files changed, 239 insertions(+), 132 deletions(-) create mode 100644 assets/ico_bluetooth.png diff --git a/assets/ico_bluetooth.png b/assets/ico_bluetooth.png new file mode 100644 index 0000000000000000000000000000000000000000..b8d6c950bba31df95801c0023f9b7e54c858e354 GIT binary patch literal 5819 zcmV;s7DVZZP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ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2DAXr+MN6IA#*6)n?QzxSG3(B%z?T_~^;aHOEzq1@K znj|=^G^a{Z$^dDxJo&Ao)85#+Iz&>EuOVu$>SOLXx2>RVPZLFB%d__s8O(yGoux7D zKM~hyFFy$-kWd^i;Xd4{B7H-?_`!8-TK6e|NmbdMo@bo@0-kClYW=73K)GoFlX3^5 z-GP|Mz*WXActctF>$dI+FQ0t*FD!fh1Du*Fl*wm5h0=oSc|VnCENn-@SdmC7_E3Ib z*D?n$mb^o0_Y$R?id-yQx^_6Xs+3RnH*@dL*Td++_-viK;fX>yag0~I%!?0MiQmnL zGi(6Qt4mp_r`m{>&UON7J9y;c3I|ja^Y({zJn_rTFfc%{v>&WCw1xzZlD}#vjKH^M7(VEq@v?3l(5VJLfWr6&F5m0KiaSNt{GRh}l`M`2g{p^{G zAWA+Jv8oWY9wj|rPb(as4U+re(b@IgBGx>VbV)pqbgN4#;sUcUY9^wZ`u@BWFxK1R zS(U(2m1fqxt9vLA!v;iEqVzmqTOZKI5q={u0i&<$6i9YY$jico_warning.png ico_setting.png ico_info.png + ico_bluetooth.png connect.png cursor-hot.png power-hot.png diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index 61bd07a..13c65b2 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -76,6 +76,7 @@ private slots: void showRearCamBG(); void hideRearCamBG(); void createDebuglog(); + void setPairable(); private: Ui::MainWindow* ui_; diff --git a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp index 9d37d8d..3e06ddd 100644 --- a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp @@ -47,6 +47,7 @@ public: void loadSystemValues(); private slots: + void unpairAll(); void onSave(); void onResetToDefaults(); void onUpdateScreenDPI(int value); diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index a4c6f0b..9500d42 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -47,7 +47,7 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);} \ QPushButton { background: url(:/circle.png); border: 0; } \ QPushButton:hover { background: url(:/circle.png); } \ - QPushButton:focus { background: url(:/circle.png); } \ + QPushButton:focus { background: url(:/circle.png); border: none; outline: none;} \ QPushButton:pressed { background: url(:/circle-pressed.png); } \ QSlider:horizontal { background: url(:/slider.png); border: 1px solid #ffffff; border-radius: 2px; min-height: 32px;} \ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} \ @@ -120,11 +120,17 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonKodi, &QPushButton::clicked, this, &MainWindow::startKodi); connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider); connect(ui_->systemDebugging, &QPushButton::clicked, this, &MainWindow::createDebuglog); + connect(ui_->pushButtonBluetooth, &QPushButton::clicked, this, &MainWindow::setPairable); QTimer *timer=new QTimer(this); connect(timer, SIGNAL(timeout()),this,SLOT(showTime())); timer->start(); + QFileInfo bluetoothButtonFile("/tmp/button_bluetooth_visible"); + if (! bluetoothButtonFile.exists()) { + ui_->pushButtonBluetooth->hide(); + } + // Get version string QFileInfo vFile("/etc/crankshaft.build"); if (vFile.exists()) { @@ -498,6 +504,11 @@ void f1x::openauto::autoapp::ui::MainWindow::createDebuglog() system("/usr/local/bin/crankshaft debuglog &"); } +void f1x::openauto::autoapp::ui::MainWindow::setPairable() +{ + system("/usr/local/bin/autoapp_helper enablepairing &"); +} + void f1x::openauto::autoapp::ui::MainWindow::showTime() { using namespace std::this_thread; // sleep_for @@ -540,8 +551,9 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() QFileInfo configInProgressFile("/tmp/config_in_progress"); QFileInfo debugInProgressFile("/tmp/debug_in_progress"); + QFileInfo enablePairingFile("/tmp/enable_pairing"); - if (configInProgressFile.exists() || debugInProgressFile.exists()) { + if (configInProgressFile.exists() || debugInProgressFile.exists() || enablePairingFile.exists()) { if (ui_->systemConfigInProgress->isVisible() == false) { if (configInProgressFile.exists()) { ui_->systemConfigInProgress->setText("System config in progress - please wait ..."); @@ -554,6 +566,11 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() ui_->systemDebugging->hide(); ui_->systemConfigInProgress->show(); } + if (enablePairingFile.exists()) { + ui_->systemConfigInProgress->setText("Bluetooth Pairing enabled! "); + ui_->systemDebugging->hide(); + ui_->systemConfigInProgress->show(); + } } } else { if (ui_->systemConfigInProgress->isVisible() == true) { diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index 726edd4..88f86af 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -41,6 +41,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat ui_->setupUi(this); connect(ui_->pushButtonCancel, &QPushButton::clicked, this, &SettingsWindow::close); connect(ui_->pushButtonSave, &QPushButton::clicked, this, &SettingsWindow::onSave); + connect(ui_->pushButtonUnpair , &QPushButton::clicked, this, &SettingsWindow::unpairAll); connect(ui_->horizontalSliderScreenDPI, &QSlider::valueChanged, this, &SettingsWindow::onUpdateScreenDPI); connect(ui_->radioButtonUseExternalBluetoothAdapter, &QRadioButton::clicked, [&](bool checked) { ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(checked); }); connect(ui_->radioButtonDisableBluetooth, &QRadioButton::clicked, [&]() { ui_->lineEditExternalBluetoothAdapterAddress->setEnabled(false); }); @@ -51,6 +52,7 @@ SettingsWindow::SettingsWindow(configuration::IConfiguration::Pointer configurat connect(ui_->pushButtonShowBindings, &QPushButton::clicked, this, &SettingsWindow::onShowBindings); connect(ui_->horizontalSliderSystemVolume, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemVolume); connect(ui_->horizontalSliderSystemCapture, &QSlider::valueChanged, this, &SettingsWindow::onUpdateSystemCapture); + } SettingsWindow::~SettingsWindow() @@ -195,6 +197,8 @@ void SettingsWindow::onSave() params.append("0"); } params.append("#"); + params.append( std::string(ui_->comboBoxBluetooth->currentText().toStdString()) ); + params.append("#"); if (ui_->checkBoxHardwareSave->isChecked()) { params.append("1"); } else { @@ -258,6 +262,8 @@ void SettingsWindow::load() const auto& audioOutputBackendType = configuration_->getAudioOutputBackendType(); ui_->radioButtonRtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::RTAUDIO); ui_->radioButtonQtAudio->setChecked(audioOutputBackendType == configuration::AudioOutputBackendType::QT); + + ui_->checkBoxHardwareSave->setChecked(false); } void SettingsWindow::loadButtonCheckBoxes() @@ -346,6 +352,11 @@ void SettingsWindow::onUpdateSystemCapture(int value) ui_->labelSystemCaptureValue->setText(QString::number(value)); } +void SettingsWindow::unpairAll() +{ + system("/usr/local/bin/crankshaft bluetooth unpair &"); +} + void SettingsWindow::loadSystemValues() { // Generate param file @@ -580,12 +591,27 @@ void SettingsWindow::loadSystemValues() // set cam ui_->comboBoxCam->setCurrentText(getparams[33]); - // set cs bluetooth + // set bluetooth if (getparams[34] == "1") { + // check external bluetooth enabled + if (getparams[36] == "1") { + ui_->radioButtonUseExternalBluetoothAdapter->setChecked(true); + } else { + ui_->radioButtonUseLocalBluetoothAdapter->setChecked(true); + } + // mac + ui_->lineEditExternalBluetoothAdapterAddress->setText(getparams[37]); + } else { + ui_->radioButtonDisableBluetooth->setChecked(true); + ui_->lineEditExternalBluetoothAdapterAddress->setText(""); + } + if (getparams[35] == "1") { ui_->checkBoxBluetoothAutoPair->setChecked(true); } else { ui_->checkBoxBluetoothAutoPair->setChecked(false); } + // set timezone + ui_->comboBoxBluetooth->setCurrentText(getparams[38]); } } diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index d22be2a..35bf719 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -51,6 +51,30 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + 618 + -8 + 64 + 64 + + + + + :/ico_bluetooth.png + + + + + 24 + 24 + + + + background: rgba(255,255,255,0); + + @@ -75,7 +99,7 @@ - color: #00CCFF; + color: #0000FF; Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -815,6 +839,7 @@ QPushButton:pressed { background: orange; border: none; } pushButtonLock pushButtonWirelessConnection pushButtonKodi + pushButtonBluetooth pushButtonToggleCursor pushButtonDay pushButtonNight diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index b358f57..c3896c3 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -1104,106 +1104,68 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} 0 10 646 - 101 + 111 - Bluetooth adapter + Bluetooth settings - - - - 20 - 30 - 171 - 23 - - - - Disable bluetooth - - - - - - 210 - 30 - 171 - 23 - - - - Use external adapter - - 410 - 66 + 26 231 31 + + true + - 340 - 66 - 67 + 290 + 26 + 111 31 - Address: + Used Address: - - - - 440 - 20 - 181 - 41 - - - - - true - - - - Provide address in format AA:BB:CC:DD:EE:FF. - - - true - - - - - - 410 - 30 - 21 - 21 - - - - <html><head/><body><p><img src=":/ico_info.png"/></p></body></html> - - - + 20 - 60 - 151 + 30 + 261 23 - Use local adapter + Set pairable on startup (120 secs) + + + + + + 20 + 70 + 191 + 30 + + + + Remove all paired devices + + + false + + + false @@ -1211,7 +1173,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} 0 - 190 + 160 646 111 @@ -1259,6 +1221,9 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} 31 + + true + @@ -1291,7 +1256,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} 0 - 310 + 280 646 141 @@ -1386,66 +1351,93 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} - + - 0 - 120 - 646 - 61 + 330 + 60 + 171 + 23 - - Bluetooth Pairing / Connect + + Use external adapter - - - - 20 - 26 - 250 - 23 - - - - Enable Autopairing / Autoconnect - - - - - - 360 - 20 - 281 - 31 - - - - - true - - - - Experimental and only using local adapter! Needs a reboot after changing! - - - true - - - - - - 320 - 20 - 31 - 31 - - - - <html><head/><body><p><img src=":/ico_warning.png"/></p></body></html> - - + + + true + + + + 170 + 60 + 151 + 23 + + + + Use local adapter + + + + + + 10 + 60 + 171 + 23 + + + + Disable bluetooth + + + + + + 80 + 422 + 31 + 31 + + + + <html><head/><body><p align="justify"><img src=":/ico_warning.png"/></p></body></html> + + + + + + 2 + 425 + 644 + 26 + + + + + true + + + + To activate this settings you have to reboot after changing! + + + Qt::AlignCenter + + + true + + + radioButtonDisableBluetooth + radioButtonUseExternalBluetoothAdapter + radioButtonUseLocalBluetoothAdapter + groupBoxWifiClient + groupBoxWifiHotspot + groupBoxBluetoothAdapter + labelSettingsInfo_5 + labelSettingsInfo_Icon_5 @@ -3265,7 +3257,7 @@ subcontrol-position: center left; 0 10 646 - 241 + 291 @@ -3572,6 +3564,50 @@ subcontrol-position: center left; + + + + 10 + 240 + 80 + 30 + + + + Bluetooth + + + + + + 90 + 240 + 300 + 30 + + + + false + + + none + + + + none + + + + + builtin + + + + + external + + +