From 69d6cf835ba0959d705aa62904a2acc270848e67 Mon Sep 17 00:00:00 2001 From: "michal.szwaj" Date: Wed, 21 Mar 2018 19:38:20 +0100 Subject: [PATCH] Draft of Connect dialog --- .../f1x/openauto/autoapp/UI/ConnectDialog.hpp | 33 +++++ .../f1x/openauto/autoapp/UI/MainWindow.hpp | 1 + src/autoapp/UI/ConnectDialog.cpp | 28 ++++ src/autoapp/UI/MainWindow.cpp | 1 + src/autoapp/UI/connectdialog.ui | 120 ++++++++++++++++++ src/autoapp/UI/mainwindow.ui | 50 +++++--- src/autoapp/UI/settingswindow.ui | 2 +- src/autoapp/autoapp.cpp | 9 +- 8 files changed, 221 insertions(+), 23 deletions(-) create mode 100644 include/f1x/openauto/autoapp/UI/ConnectDialog.hpp create mode 100644 src/autoapp/UI/ConnectDialog.cpp create mode 100644 src/autoapp/UI/connectdialog.ui diff --git a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp new file mode 100644 index 0000000..db90ca4 --- /dev/null +++ b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include + +namespace Ui { +class ConnectDialog; +} + +namespace f1x +{ +namespace openauto +{ +namespace autoapp +{ +namespace ui +{ + +class ConnectDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ConnectDialog(QWidget *parent = nullptr); + ~ConnectDialog() override; + +private: + Ui::ConnectDialog *ui; +}; + +} +} +} +} diff --git a/include/f1x/openauto/autoapp/UI/MainWindow.hpp b/include/f1x/openauto/autoapp/UI/MainWindow.hpp index 2c82330..b7e2354 100644 --- a/include/f1x/openauto/autoapp/UI/MainWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/MainWindow.hpp @@ -46,6 +46,7 @@ signals: void exit(); void openSettings(); void toggleCursor(); + void openConnectDialog(); private: Ui::MainWindow* ui_; diff --git a/src/autoapp/UI/ConnectDialog.cpp b/src/autoapp/UI/ConnectDialog.cpp new file mode 100644 index 0000000..b663f51 --- /dev/null +++ b/src/autoapp/UI/ConnectDialog.cpp @@ -0,0 +1,28 @@ +#include +#include "ui_connectdialog.h" + +namespace f1x +{ +namespace openauto +{ +namespace autoapp +{ +namespace ui +{ + +ConnectDialog::ConnectDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ConnectDialog) +{ + ui->setupUi(this); +} + +ConnectDialog::~ConnectDialog() +{ + delete ui; +} + +} +} +} +} diff --git a/src/autoapp/UI/MainWindow.cpp b/src/autoapp/UI/MainWindow.cpp index 8569c06..49954f8 100644 --- a/src/autoapp/UI/MainWindow.cpp +++ b/src/autoapp/UI/MainWindow.cpp @@ -37,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui_->pushButtonSettings, &QPushButton::clicked, this, &MainWindow::openSettings); connect(ui_->pushButtonExit, &QPushButton::clicked, this, &MainWindow::exit); connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor); + connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog); } MainWindow::~MainWindow() diff --git a/src/autoapp/UI/connectdialog.ui b/src/autoapp/UI/connectdialog.ui new file mode 100644 index 0000000..ba7b6ee --- /dev/null +++ b/src/autoapp/UI/connectdialog.ui @@ -0,0 +1,120 @@ + + + ConnectDialog + + + + 0 + 0 + 301 + 389 + + + + Connect to device + + + + + 10 + 10 + 281 + 61 + + + + IP Address + + + + + 10 + 30 + 261 + 25 + + + + + + + + 10 + 80 + 281 + 181 + + + + Recent + + + + + 10 + 30 + 261 + 141 + + + + + + + + 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> + + + + + + 100 + 340 + 89 + 41 + + + + Cancel + + + + + + 200 + 340 + 89 + 41 + + + + Connect + + + + + + diff --git a/src/autoapp/UI/mainwindow.ui b/src/autoapp/UI/mainwindow.ui index 8bf5291..7432822 100644 --- a/src/autoapp/UI/mainwindow.ui +++ b/src/autoapp/UI/mainwindow.ui @@ -48,7 +48,7 @@ color: rgb(238, 238, 236); 630 - 340 + 370 161 41 @@ -67,7 +67,7 @@ color: rgb(238, 238, 236); 630 - 390 + 420 161 41 @@ -79,7 +79,7 @@ color: rgb(238, 238, 236); false - + 340 @@ -92,11 +92,11 @@ color: rgb(238, 238, 236); <html><head/><body><p><span style=" font-style:italic; color:#eeeeec;">Plug in your device to start AndroidAuto (tm).</span></p></body></html> - + 10 - 410 + 440 271 21 @@ -167,20 +167,20 @@ color: rgb(238, 238, 236); 220 - 376 + 400 21 - 21 + 31 <html><head/><body><p><img src=":/ico_info.png"/></p></body></html> - + 250 - 370 + 400 361 31 @@ -193,7 +193,7 @@ color: rgb(238, 238, 236); 630 - 290 + 270 161 41 @@ -208,21 +208,31 @@ color: rgb(238, 238, 236); false - - - - - 0 - 0 - 800 - 22 - - + + + + 630 + 320 + 161 + 41 + + + + Wireless connection + + + false + + + false + + pushButtonToggleCursor + pushButtonWirelessConnection pushButtonSettings pushButtonExit diff --git a/src/autoapp/UI/settingswindow.ui b/src/autoapp/UI/settingswindow.ui index 63ad7a2..b066a78 100644 --- a/src/autoapp/UI/settingswindow.ui +++ b/src/autoapp/UI/settingswindow.ui @@ -23,7 +23,7 @@ - Form + Settings background-color: rgb(46, 52, 54); diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index d88863a..f063a2d 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace aasdk = f1x::aasdk; @@ -89,8 +90,12 @@ int main(int argc, char* argv[]) autoapp::ui::SettingsWindow settingsWindow(configuration); settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint); + autoapp::ui::ConnectDialog connectDialog; + connectDialog.setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { std::exit(0); }); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen); + QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectDialog, &autoapp::ui::ConnectDialog::exec); qApplication.setOverrideCursor(Qt::BlankCursor); QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&qApplication]() { @@ -108,8 +113,8 @@ int main(int argc, char* argv[]) autoapp::projection::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory); auto usbHub(std::make_shared(usbWrapper, ioService, queryChainFactory)); - auto ConnectedAccessoriesEnumerator(std::make_shared(usbWrapper, ioService, queryChainFactory)); - auto app = std::make_shared(ioService, usbWrapper, tcpWrapper, androidAutoEntityFactory, std::move(usbHub), std::move(ConnectedAccessoriesEnumerator)); + auto connectedAccessoriesEnumerator(std::make_shared(usbWrapper, ioService, queryChainFactory)); + auto app = std::make_shared(ioService, usbWrapper, tcpWrapper, androidAutoEntityFactory, std::move(usbHub), std::move(connectedAccessoriesEnumerator)); app->waitForUSBDevice(); auto result = qApplication.exec();