From 3a7e7593ffe7ab0176fbdad9935b122f3b194d20 Mon Sep 17 00:00:00 2001 From: hawkeyexp Date: Thu, 13 Sep 2018 14:57:07 +0200 Subject: [PATCH] latest dev --- .../f1x/openauto/autoapp/UI/ConnectDialog.hpp | 2 + .../f1x/openauto/autoapp/UI/MainWindow.hpp | 3 +- .../openauto/autoapp/UI/SettingsWindow.hpp | 2 + src/autoapp/UI/ConnectDialog.cpp | 34 +- src/autoapp/UI/MainWindow.cpp | 72 ++- src/autoapp/UI/SettingsWindow.cpp | 14 + src/autoapp/UI/connectdialog.ui | 434 ++++++++++++------ src/autoapp/UI/mainwindow.ui | 157 ++----- src/autoapp/UI/settingswindow.ui | 87 +++- src/autoapp/autoapp.cpp | 4 +- 10 files changed, 513 insertions(+), 296 deletions(-) diff --git a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp index 9e944aa..c272247 100644 --- a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp +++ b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp @@ -37,10 +37,12 @@ private slots: void onConnectionFailed(const QString& message); void onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer socket, const std::string& ipAddress); void onRecentAddressClicked(const QModelIndex& index); + void onUpdateButtonClicked(); private: void insertIpAddress(const std::string& ipAddress); void loadRecentList(); + void loadTempRecentList(); void setControlsEnabledStatus(bool status); void connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket); diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index 2c25157..dccaeb5 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -174,8 +174,7 @@ private: bool c7ButtonForce = false; bool c8ButtonForce = false; - //int screen_width = 800; - //int screen_height = 480; + bool hotspotActive = false; }; } diff --git a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp index 0a136a6..a0514ef 100644 --- a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp @@ -56,6 +56,8 @@ private slots: void onUpdateSystemVolume(int value); void onUpdateSystemCapture(int value); void setTime(); + void onStartHotspot(); + void onStopHotspot(); private slots: void show_tab1(); diff --git a/src/autoapp/UI/ConnectDialog.cpp b/src/autoapp/UI/ConnectDialog.cpp index 127e216..88ea194 100644 --- a/src/autoapp/UI/ConnectDialog.cpp +++ b/src/autoapp/UI/ConnectDialog.cpp @@ -1,6 +1,8 @@ #include #include #include "ui_connectdialog.h" +#include +#include namespace f1x { @@ -27,9 +29,14 @@ ConnectDialog::ConnectDialog(boost::asio::io_service& ioService, aasdk::tcp::ITC connect(ui_->listViewRecent, &QListView::clicked, this, &ConnectDialog::onRecentAddressClicked); connect(this, &ConnectDialog::connectionSucceed, this, &ConnectDialog::onConnectionSucceed); connect(this, &ConnectDialog::connectionFailed, this, &ConnectDialog::onConnectionFailed); + connect(ui_->pushButtonUpdate, &QPushButton::clicked, this, &ConnectDialog::onUpdateButtonClicked); ui_->listViewRecent->setModel(&recentAddressesModel_); this->loadRecentList(); + loadTempRecentList(); + + ui_->progressBarConnect->hide(); + ui_->lineEditIPAddress->setFocus(); } ConnectDialog::~ConnectDialog() @@ -43,7 +50,7 @@ void ConnectDialog::onConnectButtonClicked() const auto& ipAddress = ui_->lineEditIPAddress->text().toStdString(); auto socket = std::make_shared(ioService_); - + ui_->progressBarConnect->show(); try { tcpWrapper_.asyncConnect(*socket, ipAddress, 5277, std::bind(&ConnectDialog::connectHandler, this, std::placeholders::_1, ipAddress, socket)); @@ -52,6 +59,13 @@ void ConnectDialog::onConnectButtonClicked() { emit connectionFailed(QString(se.what())); } + loadTempRecentList(); +} + +void ConnectDialog::onUpdateButtonClicked() +{ + system("/usr/local/bin/autoapp_helper updaterecent"); + loadTempRecentList(); } void ConnectDialog::connectHandler(const boost::system::error_code& ec, const std::string& ipAddress, aasdk::tcp::ITCPEndpoint::SocketPointer socket) @@ -69,6 +83,7 @@ void ConnectDialog::connectHandler(const boost::system::error_code& ec, const st void ConnectDialog::onConnectionSucceed(aasdk::tcp::ITCPEndpoint::SocketPointer, const std::string& ipAddress) { + ui_->progressBarConnect->hide(); this->insertIpAddress(ipAddress); this->setControlsEnabledStatus(true); } @@ -77,6 +92,7 @@ void ConnectDialog::onConnectionFailed(const QString& message) { this->setControlsEnabledStatus(true); + ui_->progressBarConnect->hide(); QMessageBox errorMessage(QMessageBox::Critical, "Connect error", message, QMessageBox::Ok); errorMessage.setWindowFlags(Qt::WindowStaysOnTopHint); errorMessage.exec(); @@ -113,6 +129,22 @@ void ConnectDialog::loadRecentList() recentAddressesModel_.setStringList(stringList); } +void ConnectDialog::loadTempRecentList() +{ + QFileInfo recentFile("/tmp/temp_recent_list"); + if (recentFile.exists()) { + QFile versionFile(QString("/tmp/temp_recent_list")); + versionFile.open(QIODevice::ReadOnly); + QTextStream data(&versionFile); + while (!data.atEnd()) + { + QString ip = data.readLine(); + ConnectDialog::insertIpAddress(ip.toStdString()); + } + versionFile.close(); + } +} + void ConnectDialog::insertIpAddress(const std::string& ipAddress) { recentAddressesList_.insertAddress(ipAddress); diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index 3b1374c..b1e8bcd 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -167,6 +167,9 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonWifi, &QPushButton::clicked, this, &MainWindow::openConnectDialog); connect(ui_->pushButtonWifi2, &QPushButton::clicked, this, &MainWindow::openConnectDialog); + // by default hide bluetooth button on init + ui_->pushButtonBluetooth->hide(); + QTimer *timer=new QTimer(this); connect(timer, SIGNAL(timeout()),this,SLOT(showTime())); timer->start(); @@ -213,24 +216,15 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi connect(ui_->pushButtonRecord, &QPushButton::clicked, this, &MainWindow::cameraRecord); connect(ui_->pushButtonSave, &QPushButton::clicked, this, &MainWindow::cameraSave); ui_->pushButtonDummyCamWifi->hide(); - ui_->pushButtonDummyCamWifi2->hide(); } else { ui_->pushButtonCameraShow->hide(); ui_->pushButtonCameraShow2->hide(); - if (this->wifiButtonForce) { - ui_->pushButtonDummyCamWifi2->hide(); - } } // show debug button if enabled if (!this->systemDebugmode) { ui_->pushButtonDebug->hide(); ui_->pushButtonDebug2->hide(); - if (this->cameraButtonForce && this->wifiButtonForce) { - ui_->pushButtonDummyDebug->hide(); - } - } else { - ui_->pushButtonDummyDebug->hide(); } ui_->systemConfigInProgress->hide(); @@ -569,9 +563,6 @@ MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWi // init alpha values ui_->horizontalSliderAlpha->setValue(int(configuration->getAlphaTrans())); MainWindow::on_horizontalSliderAlpha_valueChanged(int(configuration->getAlphaTrans())); - - // bt media controls - ui_->btControlWidget->hide(); } MainWindow::~MainWindow() @@ -1058,7 +1049,6 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() ui_->pushButtonDebug2->hide(); ui_->pushButtonLock->show(); ui_->pushButtonLock2->show(); - ui_->pushButtonDummyDebug->show(); ui_->systemConfigInProgress->show(); } if (enablePairingFile.exists()) { @@ -1078,7 +1068,6 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() if (this->systemDebugmode) { ui_->pushButtonDebug->show(); ui_->pushButtonDebug2->show(); - ui_->pushButtonDummyDebug->hide(); } } } @@ -1143,6 +1132,61 @@ void f1x::openauto::autoapp::ui::MainWindow::showTime() if (externalExitFile.exists()) { f1x::openauto::autoapp::ui::MainWindow::MainWindow::exit(); } + + QFileInfo hotspotFile("/tmp/hotspot_active"); + this->hotspotActive = hotspotFile.exists(); + + // hide wifi if not forced + if (!this->hotspotActive) { + if ((ui_->pushButtonWifi->isVisible() == true) || (ui_->pushButtonWifi2->isVisible() == true)){ + ui_->pushButtonWifi->hide(); + ui_->pushButtonWifi2->hide(); + if (!this->cameraButtonForce) { + ui_->pushButtonDummyCamWifi->show(); + } + } + } else { + if ((ui_->pushButtonWifi->isVisible() == false) || (ui_->pushButtonWifi2->isVisible() == false)) { + ui_->pushButtonWifi->show(); + ui_->pushButtonWifi2->show(); + ui_->pushButtonDummyCamWifi->hide(); + } + } + + // handle dummys in classic menu + int button_count = 0; + if (ui_->pushButtonCameraShow2->isVisible() == true) { + button_count = button_count + 1; + } + if (ui_->pushButtonToggleGUI2->isVisible() == true) { + button_count = button_count + 1; + } + if (ui_->pushButtonWifi2->isVisible() == true) { + button_count = button_count + 1; + } + if (ui_->pushButtonDebug2->isVisible() == true) { + button_count = button_count + 1; + } + if (button_count >= 3) { + ui_->pushButtonDummyClassic1->hide(); + ui_->pushButtonDummyClassic2->hide(); + ui_->pushButtonDummyClassic3->hide(); + } + if (button_count == 2) { + ui_->pushButtonDummyClassic1->show(); + ui_->pushButtonDummyClassic2->hide(); + ui_->pushButtonDummyClassic3->hide(); + } + if (button_count == 1) { + ui_->pushButtonDummyClassic1->show(); + ui_->pushButtonDummyClassic2->show(); + ui_->pushButtonDummyClassic3->hide(); + } + if (button_count == 0) { + ui_->pushButtonDummyClassic1->show(); + ui_->pushButtonDummyClassic2->show(); + ui_->pushButtonDummyClassic3->show(); + } } ui_->Digital_clock->setText(time_text); ui_->bigClock->setText(time_text); diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index 876750f..e57398c 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -55,6 +55,10 @@ 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); + connect(ui_->pushButtonHotspotStart, &QPushButton::clicked, this, &SettingsWindow::onStartHotspot); + connect(ui_->pushButtonHotspotStart , &QPushButton::clicked, this, &SettingsWindow::close); + connect(ui_->pushButtonHotspotStop, &QPushButton::clicked, this, &SettingsWindow::onStopHotspot); + connect(ui_->pushButtonHotspotStop , &QPushButton::clicked, this, &SettingsWindow::close); connect(ui_->pushButtonSetTime, &QPushButton::clicked, this, &SettingsWindow::setTime); // menu ui_->tab1->show(); @@ -697,6 +701,16 @@ void SettingsWindow::onShowBindings() confirmationMessage.exec(); } +void SettingsWindow::onStartHotspot() +{ + system("sudo systemctl start hotspot &"); +} + +void SettingsWindow::onStopHotspot() +{ + system("sudo systemctl stop hotspot &"); +} + void SettingsWindow::show_tab1() { ui_->tab2->hide(); diff --git a/src/autoapp/UI/connectdialog.ui b/src/autoapp/UI/connectdialog.ui index 445e962..106f67e 100644 --- a/src/autoapp/UI/connectdialog.ui +++ b/src/autoapp/UI/connectdialog.ui @@ -6,154 +6,302 @@ 0 0 - 301 - 389 + 500 + 431 + + + 0 + 0 + + + + + 500 + 360 + + Connect to device - - - - 10 - 10 - 281 - 61 - - - - IP Address - - - - - 10 - 30 - 261 - 25 - - - - - - - - 10 - 80 - 281 - 181 - - - - Recent - - - - - 10 - 30 - 261 - 141 - - - - QAbstractItemView::NoEditTriggers - - - - - - - 60 - 260 - 221 - 81 - - - - <html><head/><body><p><span style=" font-style:italic;">In order to use wireless mode you must enable head unit server in developer settings.</span></p></body></html> - - - true - - - - - - 20 - 290 - 21 - 21 - - - - <html><head/><body><p><img src=":/ico_info.png"/></p></body></html> - - - - - - 40 - 340 - 121 - 41 - - - - Cancel - - - - - - 170 - 340 - 121 - 41 - - - - Connect - - - - - - 170 - 340 - 121 - 41 - - - - 0 - - - 0 - - - - - - 188 - 350 - 91 - 20 - - - - Connecting... - - - groupBoxIPAddress - groupBoxRecent - labelHeadUnitServerInfo - labelCopyrightsInfoIcon - pushButtonCancel - progressBarConnect - labelConnecting - pushButtonConnect + + background-color: rgb(46, 52, 54); +color: rgb(255, 255, 255); + + + + + + + 0 + 0 + + + + IP Address + + + + + + + 75 + true + + + + background-color: rgb(85, 87, 83); +color: rgb(255, 255, 255); + + + Qt::AlignCenter + + + false + + + + + + + + + + + 0 + 0 + + + + + 0 + 100 + + + + Recent + + + + 9 + + + + + + 0 + 0 + + + + + 0 + 100 + + + + + 75 + true + + + + background-color: rgb(85, 87, 83); +color: rgb(255, 255, 255); + + + QAbstractItemView::NoEditTriggers + + + 100 + + + + + + + + + + + 0 + 0 + + + + + + + <html><head/><body><p><img src=":/ico_info.png"/></p></body></html> + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-style:italic;">In order to use wireless mode you must enable head unit server in developer settings.</span></p></body></html> + + + true + + + + + + + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + 75 + true + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + Update + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + 75 + true + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + Cancel + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + 75 + true + PreferDefault + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + Connect + + + + + + + + 0 + 0 + + + + + 120 + 30 + + + + + true + + + + background-color: rgba(186, 189, 182, 0.5); +border-radius: 4px; +border: 2px solid rgba(255,255,255,0.5); +color: rgb(255, 255, 255); + + + 0 + + + 0 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index 4367e40..4e954ba 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 823 - 840 + 800 + 865 @@ -1133,133 +1133,6 @@ color: rgb(255, 255, 255); - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 75 - true - - - - background-color: rgba(114, 159, 207, 0.01); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Play - - - - - - - - 0 - 0 - - - - - 75 - true - - - - background-color: rgba(114, 159, 207, 0.01); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Pause - - - - - - - - 0 - 0 - - - - - 75 - true - - - - background-color: rgba(114, 159, 207, 0.01); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Prev - - - - - - - - 0 - 0 - - - - - 75 - true - - - - background-color: rgba(114, 159, 207, 0.01); -border-radius: 4px; -border: 2px solid rgba(255,255,255,0.5); -color: rgb(255, 255, 255); - - - Next - - - - - - @@ -1837,7 +1710,7 @@ border: 2px solid rgba(255,255,255,0.5); - + 0 @@ -1865,7 +1738,7 @@ border: 2px solid rgba(255,255,255,0.5); - + 0 @@ -1892,6 +1765,28 @@ border: 2px solid rgba(255,255,255,0.5); + + + + + 0 + 0 + + + + + 62 + 0 + + + + background-color: rgba(136, 138, 133, 0.5); + + + + + + diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index ee42d00..7f76a47 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -7,7 +7,7 @@ 0 0 800 - 2925 + 2976 @@ -1896,7 +1896,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} background-color: rgb(164, 0, 0); - Remove all paired devices + Remove all paired devices now! @@ -2115,7 +2115,7 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} - Enable + Enabled @@ -2128,6 +2128,9 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} + + 2 + @@ -2144,13 +2147,71 @@ QSlider::groove:horizontal { background: #6d6d6d; height: 32px;} - The Hotspot is only available in dev mode and overrides client mode! SSID is fixed. + If enabled Hotspot will start on boot and Start/Stop buttons will work. + + + + + 100 + 20 + + + + background-color: rgb(78, 154, 6); + + + Start + + + + + + + + 100 + 20 + + + + background-color: rgb(164, 0, 0); + + + Stop + + + + + + + + 0 + 0 + + + + Start hotspot mode now. This will exit client mode. + + + + + + + + 0 + 0 + + + + Stop hotspot mode now. This will exit hotspot and reenable wifi client mode. + + + @@ -2926,6 +2987,12 @@ subcontrol-position: center left; + + + 0 + 32 + + Disable @@ -3053,6 +3120,12 @@ subcontrol-position: center left; + + + 0 + 32 + + Disable @@ -4659,9 +4732,15 @@ subcontrol-origin: margin; subcontrol-position: center left; } + + false + 23 + + 10 + diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index ac1d558..ca6f173 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -106,6 +106,8 @@ int main(int argc, char* argv[]) aasdk::tcp::TCPWrapper tcpWrapper; autoapp::ui::ConnectDialog connectDialog(ioService, tcpWrapper, recentAddressesList); connectDialog.setWindowFlags(Qt::WindowStaysOnTopHint); + // center dialog + connectDialog.move((width - 500)/2,(height-440)/2); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { system("touch /tmp/shutdown"); std::exit(0); }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::reboot, []() { system("touch /tmp/reboot"); std::exit(0); }); @@ -203,7 +205,7 @@ int main(int argc, char* argv[]) mainWindow.showFullScreen(); mainWindow.setFixedSize(width, height); - //mainWindow.adjustSize(); + mainWindow.adjustSize(); aasdk::usb::USBWrapper usbWrapper(usbContext); aasdk::usb::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);