[config] added touchscreen auto-detection
This commit is contained in:
parent
16a09529e8
commit
099f14d3de
@ -39,6 +39,8 @@ public:
|
|||||||
void reset() override;
|
void reset() override;
|
||||||
void save() override;
|
void save() override;
|
||||||
|
|
||||||
|
bool hasTouchScreen() const override;
|
||||||
|
|
||||||
void setHandednessOfTrafficType(HandednessOfTrafficType value) override;
|
void setHandednessOfTrafficType(HandednessOfTrafficType value) override;
|
||||||
HandednessOfTrafficType getHandednessOfTrafficType() const override;
|
HandednessOfTrafficType getHandednessOfTrafficType() const override;
|
||||||
void showClock(bool value) override;
|
void showClock(bool value) override;
|
||||||
|
@ -48,6 +48,8 @@ public:
|
|||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
virtual void save() = 0;
|
virtual void save() = 0;
|
||||||
|
|
||||||
|
virtual bool hasTouchScreen() const = 0;
|
||||||
|
|
||||||
virtual void setHandednessOfTrafficType(HandednessOfTrafficType value) = 0;
|
virtual void setHandednessOfTrafficType(HandednessOfTrafficType value) = 0;
|
||||||
virtual HandednessOfTrafficType getHandednessOfTrafficType() const = 0;
|
virtual HandednessOfTrafficType getHandednessOfTrafficType() const = 0;
|
||||||
virtual void showClock(bool value) = 0;
|
virtual void showClock(bool value) = 0;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ class MainWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent = nullptr);
|
||||||
~MainWindow() override;
|
~MainWindow() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
#include <QTouchDevice>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -156,6 +157,17 @@ void Configuration::save()
|
|||||||
boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
|
boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::hasTouchScreen() const
|
||||||
|
{
|
||||||
|
auto touchdevs = QTouchDevice::devices();
|
||||||
|
for (int i = 0; i < touchdevs.length(); i++) {
|
||||||
|
if (touchdevs[i]->type() == QTouchDevice::TouchScreen) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Configuration::setHandednessOfTrafficType(HandednessOfTrafficType value)
|
void Configuration::setHandednessOfTrafficType(HandednessOfTrafficType value)
|
||||||
{
|
{
|
||||||
handednessOfTrafficType_ = value;
|
handednessOfTrafficType_ = value;
|
||||||
|
@ -31,14 +31,14 @@ namespace autoapp
|
|||||||
namespace ui
|
namespace ui
|
||||||
{
|
{
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(configuration::IConfiguration::Pointer configuration, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui_(new Ui::MainWindow)
|
, ui_(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
|
|
||||||
this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);} \
|
this->setStyleSheet("QMainWindow {background-color: rgb(0,0,0);} \
|
||||||
QPushButton { background: url(:/circle.png); border: 0; } \
|
QPushButton { background: url(:/circle.png); border: 0; } \
|
||||||
QPushButton:hover { background: url(:/circle-hot.png); } \
|
QPushButton:hover { background: url(:/circle-hot.png); } \
|
||||||
|
QPushButton:focus { background: url(:/circle-hot.png); } \
|
||||||
QPushButton:pressed { background: url(:/circle-pressed.png); } \
|
QPushButton:pressed { background: url(:/circle-pressed.png); } \
|
||||||
");
|
");
|
||||||
QFileInfo wallpaperFile("wallpaper.png");
|
QFileInfo wallpaperFile("wallpaper.png");
|
||||||
@ -59,7 +59,15 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor);
|
connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor);
|
||||||
connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog);
|
connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog);
|
||||||
connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider);
|
connect(ui_->pushButtonBrightness, &QPushButton::clicked, this, &MainWindow::showBrightnessSlider);
|
||||||
ui_->pushButtonToggleCursor->hide();
|
|
||||||
|
if (configuration->hasTouchScreen()) {
|
||||||
|
ui_->pushButtonToggleCursor->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RASPBERRYPI3
|
||||||
|
ui_->pushButtonWirelessConnection->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
ui_->horizontalSliderBrightness->hide();
|
ui_->horizontalSliderBrightness->hide();
|
||||||
|
|
||||||
QFileInfo brightnessFile(brightnessFilename);
|
QFileInfo brightnessFile(brightnessFilename);
|
||||||
|
@ -78,9 +78,6 @@
|
|||||||
<height>64</height>
|
<height>64</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::ClickFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">display: none;</string>
|
<string notr="true">display: none;</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -84,10 +84,12 @@ int main(int argc, char* argv[])
|
|||||||
startIOServiceWorkers(ioService, threadPool);
|
startIOServiceWorkers(ioService, threadPool);
|
||||||
|
|
||||||
QApplication qApplication(argc, argv);
|
QApplication qApplication(argc, argv);
|
||||||
autoapp::ui::MainWindow mainWindow;
|
|
||||||
mainWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
|
||||||
|
|
||||||
auto configuration = std::make_shared<autoapp::configuration::Configuration>();
|
auto configuration = std::make_shared<autoapp::configuration::Configuration>();
|
||||||
|
|
||||||
|
autoapp::ui::MainWindow mainWindow(configuration);
|
||||||
|
mainWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
autoapp::ui::SettingsWindow settingsWindow(configuration);
|
||||||
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
settingsWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
@ -102,13 +104,13 @@ int main(int argc, char* argv[])
|
|||||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen);
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openSettings, &settingsWindow, &autoapp::ui::SettingsWindow::showFullScreen);
|
||||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectDialog, &autoapp::ui::ConnectDialog::exec);
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::openConnectDialog, &connectDialog, &autoapp::ui::ConnectDialog::exec);
|
||||||
|
|
||||||
#ifdef RPI3_BUILD
|
if (configuration->hasTouchScreen()) {
|
||||||
qApplication.setOverrideCursor(Qt::BlankCursor);
|
qApplication.setOverrideCursor(Qt::BlankCursor);
|
||||||
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&qApplication]() {
|
QObject::connect(&mainWindow, &autoapp::ui::MainWindow::toggleCursor, [&qApplication]() {
|
||||||
const auto cursor = qApplication.overrideCursor()->shape() == Qt::BlankCursor ? Qt::ArrowCursor : Qt::BlankCursor;
|
const auto cursor = qApplication.overrideCursor()->shape() == Qt::BlankCursor ? Qt::ArrowCursor : Qt::BlankCursor;
|
||||||
qApplication.setOverrideCursor(cursor);
|
qApplication.setOverrideCursor(cursor);
|
||||||
});
|
});
|
||||||
#endif
|
}
|
||||||
|
|
||||||
mainWindow.showFullScreen();
|
mainWindow.showFullScreen();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user