mirror of https://github.com/f1xpl/openauto.git
Remove Main class
parent
68bf0e3990
commit
21ff97fe8a
|
@ -38,7 +38,7 @@ public:
|
|||
App(boost::asio::io_service& ioService, projection::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
||||
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);
|
||||
|
||||
void start();
|
||||
void waitForUSBDevice();
|
||||
void stop();
|
||||
void onAndroidAutoQuit() override;
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <f1x/aasdk/USB/USBWrapper.hpp>
|
||||
#include <f1x/aasdk/USB/AccessoryModeQueryChain.hpp>
|
||||
#include <f1x/aasdk/USB/AccessoryModeQueryChainFactory.hpp>
|
||||
#include <f1x/aasdk/USB/AccessoryModeQueryFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/App.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
|
||||
class Main
|
||||
{
|
||||
public:
|
||||
Main(aasdk::usb::IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration);
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
aasdk::usb::IUSBWrapper& usbWrapper_;
|
||||
boost::asio::io_service& ioService_;
|
||||
aasdk::usb::AccessoryModeQueryFactory queryFactory_;
|
||||
aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory_;
|
||||
projection::ServiceFactory serviceFactory_;
|
||||
projection::AndroidAutoEntityFactory androidAutoEntityFactory_;
|
||||
autoapp::App::Pointer app_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ App::App(boost::asio::io_service& ioService, projection::IAndroidAutoEntityFacto
|
|||
|
||||
}
|
||||
|
||||
void App::start()
|
||||
void App::waitForUSBDevice()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
this->waitForDevice();
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <f1x/aasdk/USB/USBHub.hpp>
|
||||
#include <f1x/aasdk/USB/ConnectedAccessoriesEnumerator.hpp>
|
||||
#include <f1x/openauto/autoapp/Main.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
|
||||
Main::Main(aasdk::usb::IUSBWrapper& usbWrapper, boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration)
|
||||
: usbWrapper_(usbWrapper)
|
||||
, ioService_(ioService)
|
||||
, queryFactory_(usbWrapper_, ioService_)
|
||||
, queryChainFactory_(usbWrapper_, ioService_, queryFactory_)
|
||||
, serviceFactory_(ioService_, configuration)
|
||||
, androidAutoEntityFactory_(usbWrapper_, ioService_, configuration, serviceFactory_)
|
||||
{
|
||||
auto usbHub(std::make_shared<aasdk::usb::USBHub>(usbWrapper_, ioService_, queryChainFactory_));
|
||||
auto ConnectedAccessoriesEnumerator(std::make_shared<aasdk::usb::ConnectedAccessoriesEnumerator>(usbWrapper_, ioService_, queryChainFactory_));
|
||||
|
||||
app_ = std::make_shared<autoapp::App>(ioService_, androidAutoEntityFactory_,
|
||||
std::move(usbHub), std::move(ConnectedAccessoriesEnumerator));
|
||||
}
|
||||
|
||||
void Main::start()
|
||||
{
|
||||
app_->start();
|
||||
}
|
||||
|
||||
void Main::stop()
|
||||
{
|
||||
app_->stop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,10 +18,18 @@
|
|||
|
||||
#include <thread>
|
||||
#include <QApplication>
|
||||
#include <f1x/aasdk/USB/USBHub.hpp>
|
||||
#include <f1x/aasdk/USB/ConnectedAccessoriesEnumerator.hpp>
|
||||
#include <f1x/aasdk/USB/AccessoryModeQueryChain.hpp>
|
||||
#include <f1x/aasdk/USB/AccessoryModeQueryChainFactory.hpp>
|
||||
#include <f1x/aasdk/USB/AccessoryModeQueryFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/App.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/MainWindow.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
|
||||
#include <f1x/openauto/autoapp/Main.hpp>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
|
||||
namespace aasdk = f1x::aasdk;
|
||||
|
@ -66,35 +74,41 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
QApplication qApplication(argc, argv);
|
||||
boost::asio::io_service ioService;
|
||||
boost::asio::io_service::work work(ioService);
|
||||
std::vector<std::thread> threadPool;
|
||||
startUSBWorkers(ioService, usbContext, threadPool);
|
||||
startIOServiceWorkers(ioService, threadPool);
|
||||
|
||||
QApplication qApplication(argc, argv);
|
||||
autoapp::ui::MainWindow mainWindow;
|
||||
mainWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
mainWindow.showFullScreen();
|
||||
|
||||
auto configuration = std::make_shared<autoapp::configuration::Configuration>();
|
||||
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
||||
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
|
||||
qApplication.setOverrideCursor(Qt::BlankCursor);
|
||||
bool cursorVisible = false;
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&cursorVisible, &qApplication]() {
|
||||
cursorVisible = !cursorVisible;
|
||||
qApplication.setOverrideCursor(cursorVisible ? Qt::ArrowCursor : Qt::BlankCursor);
|
||||
});
|
||||
|
||||
aasdk::usb::USBWrapper usbWrapper(usbContext);
|
||||
autoapp::Main main(usbWrapper, ioService, configuration);
|
||||
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::exit, []() { std::exit(0); });
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen);
|
||||
|
||||
std::vector<std::thread> threadPool;
|
||||
startUSBWorkers(ioService, usbContext, threadPool);
|
||||
startIOServiceWorkers(ioService, threadPool);
|
||||
main.start();
|
||||
qApplication.setOverrideCursor(Qt::BlankCursor);
|
||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&qApplication]() {
|
||||
const auto cursor = qApplication.overrideCursor()->shape() == Qt::BlankCursor ? Qt::ArrowCursor : Qt::BlankCursor;
|
||||
qApplication.setOverrideCursor(cursor);
|
||||
});
|
||||
|
||||
mainWindow.showFullScreen();
|
||||
|
||||
aasdk::usb::USBWrapper usbWrapper(usbContext);
|
||||
aasdk::usb::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);
|
||||
aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory(usbWrapper, ioService, queryFactory);
|
||||
autoapp::projection::ServiceFactory serviceFactory(ioService, configuration);
|
||||
autoapp::projection::AndroidAutoEntityFactory androidAutoEntityFactory(usbWrapper, ioService, configuration, serviceFactory);
|
||||
|
||||
auto usbHub(std::make_shared<aasdk::usb::USBHub>(usbWrapper, ioService, queryChainFactory));
|
||||
auto ConnectedAccessoriesEnumerator(std::make_shared<aasdk::usb::ConnectedAccessoriesEnumerator>(usbWrapper, ioService, queryChainFactory));
|
||||
auto app = std::make_shared<autoapp::App>(ioService, androidAutoEntityFactory, std::move(usbHub), std::move(ConnectedAccessoriesEnumerator));
|
||||
app->waitForUSBDevice();
|
||||
|
||||
auto result = qApplication.exec();
|
||||
std::for_each(threadPool.begin(), threadPool.end(), std::bind(&std::thread::join, std::placeholders::_1));
|
||||
|
|
Loading…
Reference in New Issue