From 06430e29bfeaa3dd3a8d7f8911e0f0ba17d35d7b Mon Sep 17 00:00:00 2001 From: ShaneSmiskol Date: Fri, 16 Jul 2021 15:01:12 -0700 Subject: [PATCH] clean up clean up clean up --- selfdrive/ui/qt/widgets/input.cc | 1 - selfdrive/ui/qt/widgets/keyboard.cc | 33 +++++++++++++---------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/selfdrive/ui/qt/widgets/input.cc b/selfdrive/ui/qt/widgets/input.cc index 440958b261..b44a057a95 100644 --- a/selfdrive/ui/qt/widgets/input.cc +++ b/selfdrive/ui/qt/widgets/input.cc @@ -4,7 +4,6 @@ #include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/hardware/hw.h" -#include QDialogBase::QDialogBase(QWidget *parent) : QDialog(parent) { diff --git a/selfdrive/ui/qt/widgets/keyboard.cc b/selfdrive/ui/qt/widgets/keyboard.cc index c75986e85b..f85d37f6f0 100644 --- a/selfdrive/ui/qt/widgets/keyboard.cc +++ b/selfdrive/ui/qt/widgets/keyboard.cc @@ -5,13 +5,15 @@ #include #include #include +#include const QString BACKSPACE_KEY = "⌫"; const QString ENTER_KEY = "→"; const QMap KEY_STRETCH = {{" ", 5}, {ENTER_KEY, 2}}; -const QStringList CONTROL_BUTTONS = {"↑", "↓", "ABC", "#+=", "123", BACKSPACE_KEY, ENTER_KEY}; +const QMap 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); } }