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. 
old-commit-hash: c52e3dfb08
commatwo_master
grekiki 4 years ago committed by GitHub
parent c038a38f88
commit 98a3cabdf2
  1. 1
      .gitignore
  2. 2
      selfdrive/ui/qt/offroad/input_field.cc
  3. 10
      selfdrive/ui/qt/offroad/keyboard.cc
  4. 28
      selfdrive/ui/qt/offroad/settings.cc
  5. 6
      selfdrive/ui/qt/offroad/settings.hpp
  6. 6
      selfdrive/ui/qt/offroad/wifi.cc
  7. 8
      selfdrive/ui/qt/offroad/wifi.hpp
  8. 3
      selfdrive/ui/qt/window.hpp

1
.gitignore vendored

@ -66,3 +66,4 @@ pandaextra
flycheck_* flycheck_*
cppcheck_report.txt cppcheck_report.txt
comma.sh

@ -23,7 +23,7 @@ InputField::InputField(QWidget *parent): QWidget(parent) {
line = new QLineEdit(""); line = new QLineEdit("");
l->addWidget(line); l->addWidget(line);
l->addSpacing(200); l->addSpacing(80);
k = new Keyboard(this); k = new Keyboard(this);
QObject::connect(k, SIGNAL(emitButton(QString)), this, SLOT(getText(QString))); QObject::connect(k, SIGNAL(emitButton(QString)), this, SLOT(getText(QString)));

@ -18,24 +18,24 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, std::vector<QVector<QString>> la
QHBoxLayout *hlayout = new QHBoxLayout; QHBoxLayout *hlayout = new QHBoxLayout;
if (i == 1){ if (i == 1){
hlayout->addSpacing(50); hlayout->addSpacing(90);
} }
for(QString p : s){ for(QString p : s){
QPushButton* btn = new QPushButton(p); QPushButton* btn = new QPushButton(p);
btn->setFixedHeight(100); btn->setFixedHeight(120);
if (p == QString(" ")){ if (p == QString(" ")){
btn->setFixedWidth(1024); btn->setFixedWidth(1024);
} }
btn_group->addButton(btn); btn_group->addButton(btn);
hlayout->addSpacing(5); hlayout->addSpacing(10);
hlayout->addWidget(btn); hlayout->addWidget(btn);
} }
if (i == 1){ if (i == 1){
hlayout->addSpacing(50); hlayout->addSpacing(90);
} }
vlayout->addLayout(hlayout); vlayout->addLayout(hlayout);
@ -88,7 +88,7 @@ Keyboard::Keyboard(QWidget *parent) : QWidget(parent) {
main_layout->setCurrentIndex(0); main_layout->setCurrentIndex(0);
setStyleSheet(R"( setStyleSheet(R"(
QPushButton { font-size: 40px } QPushButton { font-size: 50px }
* { * {
background-color: #99777777; background-color: #99777777;
} }

@ -17,6 +17,7 @@
#include "common/params.h" #include "common/params.h"
#include "common/utilpp.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) { ParamsToggle::ParamsToggle(QString param, QString title, QString description, QString icon_path, QWidget *parent): QFrame(parent) , param(param) {
QHBoxLayout *hlayout = new QHBoxLayout; QHBoxLayout *hlayout = new QHBoxLayout;
@ -195,13 +196,16 @@ QWidget * developer_panel() {
return widget; return widget;
} }
QWidget * network_panel() { QWidget * network_panel(QWidget * parent) {
QVBoxLayout *main_layout = new QVBoxLayout; QVBoxLayout *main_layout = new QVBoxLayout;
WifiUI *w = new WifiUI();
main_layout->addWidget(new WifiUI()); main_layout->addWidget(w);
QWidget *widget = new QWidget; QWidget *widget = new QWidget;
widget->setLayout(main_layout); widget->setLayout(main_layout);
QObject::connect(w, SIGNAL(openKeyboard()), parent, SLOT(closeSidebar()));
QObject::connect(w, SIGNAL(closeKeyboard()), parent, SLOT(openSidebar()));
return widget; return widget;
} }
@ -234,7 +238,7 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) {
{"device", device_panel()}, {"device", device_panel()},
{"toggles", toggles_panel()}, {"toggles", toggles_panel()},
{"developer", developer_panel()}, {"developer", developer_panel()},
{"network", network_panel()}, {"network", network_panel(this)},
}; };
for (auto &panel : panels) { for (auto &panel : panels) {
@ -255,10 +259,15 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QWidget(parent) {
panel_layout->addWidget(panel.second); panel_layout->addWidget(panel.second);
QObject::connect(btn, SIGNAL(released()), this, SLOT(setActivePanel())); QObject::connect(btn, SIGNAL(released()), this, SLOT(setActivePanel()));
} }
QHBoxLayout *settings_layout = new QHBoxLayout(); QHBoxLayout *settings_layout = new QHBoxLayout();
settings_layout->addSpacing(45); 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->addSpacing(45);
settings_layout->addLayout(panel_layout); settings_layout->addLayout(panel_layout);
settings_layout->addSpacing(45); 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);
}

@ -1,11 +1,14 @@
#pragma once #pragma once
#include <QWidget> #include <QWidget>
#include <QFrame> #include <QFrame>
#include <QTimer> #include <QTimer>
#include <QCheckBox> #include <QCheckBox>
#include <QStackedLayout> #include <QStackedLayout>
#include "wifi.hpp"
class ParamsToggle : public QFrame { class ParamsToggle : public QFrame {
Q_OBJECT Q_OBJECT
@ -31,9 +34,12 @@ signals:
void closeSettings(); void closeSettings();
private: private:
QWidget *sidebar_widget;
std::map<QString, QWidget *> panels; std::map<QString, QWidget *> panels;
QStackedLayout *panel_layout; QStackedLayout *panel_layout;
private slots: private slots:
void setActivePanel(); void setActivePanel();
void closeSidebar();
void openSidebar();
}; };

@ -106,7 +106,7 @@ void WifiUI::refresh() {
vlayout->addWidget(w); vlayout->addWidget(w);
w->setStyleSheet(R"( w->setStyleSheet(R"(
QLabel { QLabel {
font-size: 40px; font-size: 50px;
} }
QPushButton:enabled { QPushButton:enabled {
background-color: #114265; background-color: #114265;
@ -124,7 +124,7 @@ void WifiUI::refresh() {
} }
//Pad vlayout to prevert oversized network widgets in case of low visible network count //Pad vlayout to prevert oversized network widgets in case of low visible network count
for(int i=countWidgets;i<networks_per_page;i++){ for(int i = countWidgets ; i < networks_per_page ; i++){
QWidget * w = new QWidget; QWidget * w = new QWidget;
vlayout->addWidget(w); vlayout->addWidget(w);
} }
@ -186,8 +186,10 @@ void WifiUI::connectToNetwork(Network n){
} }
QString WifiUI::getStringFromUser(){ QString WifiUI::getStringFromUser(){
emit openKeyboard();
swidget->setCurrentIndex(1); swidget->setCurrentIndex(1);
loop.exec(); loop.exec();
emit closeKeyboard();
swidget->setCurrentIndex(0); swidget->setCurrentIndex(0);
return text; return text;
} }

@ -15,8 +15,7 @@ class WifiUI : public QWidget {
private: private:
WifiManager* wifi; WifiManager* wifi;
int page; const int networks_per_page = 8;
const int networks_per_page = 10;
QStackedWidget* swidget; QStackedWidget* swidget;
QVBoxLayout* vlayout; QVBoxLayout* vlayout;
@ -32,6 +31,7 @@ private:
QString getStringFromUser(); QString getStringFromUser();
public: public:
int page;
explicit WifiUI(QWidget *parent = 0); explicit WifiUI(QWidget *parent = 0);
private slots: private slots:
@ -42,4 +42,8 @@ private slots:
void prevPage(); void prevPage();
void nextPage(); void nextPage();
signals:
void openKeyboard();
void closeKeyboard();
}; };

@ -9,9 +9,10 @@
#include <QStackedLayout> #include <QStackedLayout>
#include "qt/qt_sound.hpp" #include "qt/qt_sound.hpp"
#include "ui/ui.hpp"
#include "offroad/settings.hpp" #include "offroad/settings.hpp"
#include "offroad/onboarding.hpp" #include "offroad/onboarding.hpp"
#include "ui/ui.hpp"
class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions { class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions {
Q_OBJECT Q_OBJECT

Loading…
Cancel
Save