clean up

clean up
pull/21629/head
ShaneSmiskol 4 years ago
parent 77ca8e3d17
commit 06430e29bf
  1. 1
      selfdrive/ui/qt/widgets/input.cc
  2. 33
      selfdrive/ui/qt/widgets/keyboard.cc

@ -4,7 +4,6 @@
#include "selfdrive/ui/qt/qt_window.h"
#include "selfdrive/hardware/hw.h"
#include <QDebug>
QDialogBase::QDialogBase(QWidget *parent) : QDialog(parent) {

@ -5,13 +5,15 @@
#include <QMap>
#include <QPushButton>
#include <QVBoxLayout>
#include <QMap>
const QString BACKSPACE_KEY = "";
const QString ENTER_KEY = "";
const QMap<QString, int> KEY_STRETCH = {{" ", 5}, {ENTER_KEY, 2}};
const QStringList CONTROL_BUTTONS = {"", "", "ABC", "#+=", "123", BACKSPACE_KEY, ENTER_KEY};
const QMap<QString, int> CONTROL_BUTTONS = {{"", 1}, {"", 0}, {"ABC", 0}, {"#+=", 3},
{"123", 2}, {BACKSPACE_KEY, -1}, {ENTER_KEY, 0}};
const float key_spacing_vertical = 20;
const float key_spacing_horizontal = 15;
@ -114,24 +116,19 @@ Keyboard::Keyboard(QWidget *parent) : QFrame(parent) {
void Keyboard::handleButton(QAbstractButton* btn) {
const QString &key = btn->text();
if (key == "" || key == "ABC") {
main_layout->setCurrentIndex(0);
} else if (key == "") {
main_layout->setCurrentIndex(1);
} else if (key == "123") {
main_layout->setCurrentIndex(2);
} else if (key == "#+=") {
main_layout->setCurrentIndex(3);
} else if ("A" <= key && key <= "Z") {
main_layout->setCurrentIndex(0);
} else if (key == ENTER_KEY) {
main_layout->setCurrentIndex(0);
emit emitEnter();
} else if (key == BACKSPACE_KEY) {
emit emitBackspace();
}
if (!CONTROL_BUTTONS.contains(key)) {
if (CONTROL_BUTTONS.contains(key)) {
const int index = CONTROL_BUTTONS.value(key);
if (index != -1) {
main_layout->setCurrentIndex(index);
}
if (key == ENTER_KEY) emit emitEnter();
if (key == BACKSPACE_KEY) emit emitBackspace();
} else {
if ("A" <= key && key <= "Z") {
main_layout->setCurrentIndex(0);
}
emit emitKey(key);
}
}

Loading…
Cancel
Save