From c52e3dfb0887358faee5cb37f0eefc77767fd71d Mon Sep 17 00:00:00 2001 From: grekiki Date: Thu, 26 Nov 2020 16:22:14 +0100 Subject: [PATCH] wider keyboard (#2629) The keyboard now signals when it wants to open. By subscribing to this signal we can close the sidebar to make the keyboard larger. We also increase the key size to make it easier to type on. --- .gitignore | 1 + selfdrive/ui/qt/offroad/input_field.cc | 2 +- selfdrive/ui/qt/offroad/keyboard.cc | 10 ++++----- selfdrive/ui/qt/offroad/settings.cc | 28 ++++++++++++++++++++------ selfdrive/ui/qt/offroad/settings.hpp | 6 ++++++ selfdrive/ui/qt/offroad/wifi.cc | 6 ++++-- selfdrive/ui/qt/offroad/wifi.hpp | 8 ++++++-- selfdrive/ui/qt/window.hpp | 3 ++- 8 files changed, 47 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index b8d9a39b4a..262fa9fa76 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ pandaextra flycheck_* cppcheck_report.txt +comma.sh diff --git a/selfdrive/ui/qt/offroad/input_field.cc b/selfdrive/ui/qt/offroad/input_field.cc index 4696416eaf..8409b18048 100644 --- a/selfdrive/ui/qt/offroad/input_field.cc +++ b/selfdrive/ui/qt/offroad/input_field.cc @@ -23,7 +23,7 @@ InputField::InputField(QWidget *parent): QWidget(parent) { line = new QLineEdit(""); l->addWidget(line); - l->addSpacing(200); + l->addSpacing(80); k = new Keyboard(this); QObject::connect(k, SIGNAL(emitButton(QString)), this, SLOT(getText(QString))); diff --git a/selfdrive/ui/qt/offroad/keyboard.cc b/selfdrive/ui/qt/offroad/keyboard.cc index 0cdc38c562..8f94348cb6 100644 --- a/selfdrive/ui/qt/offroad/keyboard.cc +++ b/selfdrive/ui/qt/offroad/keyboard.cc @@ -18,24 +18,24 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, std::vector> la QHBoxLayout *hlayout = new QHBoxLayout; if (i == 1){ - hlayout->addSpacing(50); + hlayout->addSpacing(90); } for(QString p : s){ QPushButton* btn = new QPushButton(p); - btn->setFixedHeight(100); + btn->setFixedHeight(120); if (p == QString(" ")){ btn->setFixedWidth(1024); } btn_group->addButton(btn); - hlayout->addSpacing(5); + hlayout->addSpacing(10); hlayout->addWidget(btn); } if (i == 1){ - hlayout->addSpacing(50); + hlayout->addSpacing(90); } vlayout->addLayout(hlayout); @@ -88,7 +88,7 @@ Keyboard::Keyboard(QWidget *parent) : QWidget(parent) { main_layout->setCurrentIndex(0); setStyleSheet(R"( - QPushButton { font-size: 40px } + QPushButton { font-size: 50px } * { background-color: #99777777; } diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index eb2424082f..c0dba8f247 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -17,6 +17,7 @@ #include "common/params.h" #include "common/utilpp.h" +const int SIDEBAR_WIDTH = 400; ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) { QHBoxLayout *hlayout = new QHBoxLayout; @@ -195,13 +196,16 @@ QWidget * developer_panel() { return widget; } -QWidget * network_panel() { +QWidget * network_panel(QWidget * parent) { QVBoxLayout *main_layout = new QVBoxLayout; - - main_layout->addWidget(new WifiUI()); + WifiUI *w = new WifiUI(); + main_layout->addWidget(w); QWidget *widget = new QWidget; widget->setLayout(main_layout); + + QObject::connect(w, SIGNAL(openKeyboard()), parent, SLOT(closeSidebar())); + QObject::connect(w, SIGNAL(closeKeyboard()), parent, SLOT(openSidebar())); return widget; } @@ -234,7 +238,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) { {"device", device_panel()}, {"toggles", toggles_panel()}, {"developer", developer_panel()}, - {"network", network_panel()}, + {"network", network_panel(this)}, }; for (auto &panel : panels) { @@ -255,10 +259,15 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) { panel_layout->addWidget(panel.second); QObject::connect(btn, SIGNAL(released()), this, SLOT(setActivePanel())); } - QHBoxLayout *settings_layout = new QHBoxLayout(); settings_layout->addSpacing(45); - settings_layout->addLayout(sidebar_layout); + + // settings_layout->addLayout(sidebar_layout); + sidebar_widget = new QWidget; + sidebar_widget->setLayout(sidebar_layout); + sidebar_widget->setFixedWidth(SIDEBAR_WIDTH); + settings_layout->addWidget(sidebar_widget); + settings_layout->addSpacing(45); settings_layout->addLayout(panel_layout); settings_layout->addSpacing(45); @@ -271,3 +280,10 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) { } )"); } + +void SettingsWindow::closeSidebar(){ + sidebar_widget->setFixedWidth(0); +} +void SettingsWindow::openSidebar(){ + sidebar_widget->setFixedWidth(SIDEBAR_WIDTH); +} diff --git a/selfdrive/ui/qt/offroad/settings.hpp b/selfdrive/ui/qt/offroad/settings.hpp index e4f65a6944..81d127aea1 100644 --- a/selfdrive/ui/qt/offroad/settings.hpp +++ b/selfdrive/ui/qt/offroad/settings.hpp @@ -1,11 +1,14 @@ #pragma once + #include #include #include #include #include +#include "wifi.hpp" + class ParamsToggle : public QFrame { Q_OBJECT @@ -31,9 +34,12 @@ signals: void closeSettings(); private: + QWidget *sidebar_widget; std::map panels; QStackedLayout *panel_layout; private slots: void setActivePanel(); + void closeSidebar(); + void openSidebar(); }; diff --git a/selfdrive/ui/qt/offroad/wifi.cc b/selfdrive/ui/qt/offroad/wifi.cc index 525a023a78..2b99443a52 100644 --- a/selfdrive/ui/qt/offroad/wifi.cc +++ b/selfdrive/ui/qt/offroad/wifi.cc @@ -106,7 +106,7 @@ void WifiUI::refresh() { vlayout->addWidget(w); w->setStyleSheet(R"( QLabel { - font-size: 40px; + font-size: 50px; } QPushButton:enabled { background-color: #114265; @@ -124,7 +124,7 @@ void WifiUI::refresh() { } //Pad vlayout to prevert oversized network widgets in case of low visible network count - for(int i=countWidgets;iaddWidget(w); } @@ -186,8 +186,10 @@ void WifiUI::connectToNetwork(Network n){ } QString WifiUI::getStringFromUser(){ + emit openKeyboard(); swidget->setCurrentIndex(1); loop.exec(); + emit closeKeyboard(); swidget->setCurrentIndex(0); return text; } diff --git a/selfdrive/ui/qt/offroad/wifi.hpp b/selfdrive/ui/qt/offroad/wifi.hpp index df6cd233dc..bbda7a1450 100644 --- a/selfdrive/ui/qt/offroad/wifi.hpp +++ b/selfdrive/ui/qt/offroad/wifi.hpp @@ -15,8 +15,7 @@ class WifiUI : public QWidget { private: WifiManager* wifi; - int page; - const int networks_per_page = 10; + const int networks_per_page = 8; QStackedWidget* swidget; QVBoxLayout* vlayout; @@ -32,6 +31,7 @@ private: QString getStringFromUser(); public: + int page; explicit WifiUI(QWidget *parent = 0); private slots: @@ -42,4 +42,8 @@ private slots: void prevPage(); void nextPage(); + +signals: + void openKeyboard(); + void closeKeyboard(); }; diff --git a/selfdrive/ui/qt/window.hpp b/selfdrive/ui/qt/window.hpp index d0854ba127..d97572b5b5 100644 --- a/selfdrive/ui/qt/window.hpp +++ b/selfdrive/ui/qt/window.hpp @@ -9,9 +9,10 @@ #include #include "qt/qt_sound.hpp" -#include "ui/ui.hpp" #include "offroad/settings.hpp" #include "offroad/onboarding.hpp" +#include "ui/ui.hpp" + class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions { Q_OBJECT