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
This commit is contained in:
grekiki 2020-11-26 16:22:14 +01:00 committed by GitHub
parent c038a38f88
commit 98a3cabdf2
8 changed files with 47 additions and 17 deletions

1
.gitignore vendored
View File

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

View File

@ -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)));

View File

@ -18,24 +18,24 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, std::vector<QVector<QString>> 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;
}

View File

@ -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);
}

View File

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

View File

@ -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;i<networks_per_page;i++){
for(int i = countWidgets ; i < networks_per_page ; i++){
QWidget * w = new QWidget;
vlayout->addWidget(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;
}

View File

@ -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();
};

View File

@ -9,9 +9,10 @@
#include <QStackedLayout>
#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