mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 03:22:07 +08:00
remove keyboard deadzone (#21627)
* remove keyboard deadzone * add to height * float old-commit-hash: 3e19c737300310b8493e12448050cd41b14e9dde
This commit is contained in:
@@ -13,17 +13,20 @@ const QString ENTER_KEY = "⏎";
|
||||
|
||||
const QStringList CONTROL_BUTTONS = {"↑", "↓", "ABC", "#+=", "123"};
|
||||
|
||||
const float key_spacing_vertical = 20;
|
||||
const float key_spacing_horizontal = 15;
|
||||
|
||||
KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QString>>& layout) : QWidget(parent) {
|
||||
QVBoxLayout* main_layout = new QVBoxLayout(this);
|
||||
main_layout->setMargin(0);
|
||||
main_layout->setSpacing(20);
|
||||
main_layout->setSpacing(0);
|
||||
|
||||
QButtonGroup* btn_group = new QButtonGroup(this);
|
||||
QObject::connect(btn_group, SIGNAL(buttonClicked(QAbstractButton*)), parent, SLOT(handleButton(QAbstractButton*)));
|
||||
|
||||
for (const auto &s : layout) {
|
||||
QHBoxLayout *hlayout = new QHBoxLayout;
|
||||
hlayout->setSpacing(15);
|
||||
hlayout->setSpacing(0);
|
||||
|
||||
if (main_layout->count() == 1) {
|
||||
hlayout->addSpacing(90);
|
||||
@@ -36,7 +39,7 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QStrin
|
||||
} else if (p == ENTER_KEY) {
|
||||
btn->setStyleSheet("background-color: #465BEA;");
|
||||
}
|
||||
btn->setFixedHeight(135);
|
||||
btn->setFixedHeight(135 + key_spacing_vertical);
|
||||
btn_group->addButton(btn);
|
||||
hlayout->addWidget(btn, p == QString(" ") ? SPACEBAR_STRETCH : DEFAULT_STRETCH);
|
||||
}
|
||||
@@ -48,10 +51,13 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QStrin
|
||||
main_layout->addLayout(hlayout);
|
||||
}
|
||||
|
||||
setStyleSheet(R"(
|
||||
setStyleSheet(QString(R"(
|
||||
QPushButton {
|
||||
font-size: 75px;
|
||||
margin: 0px;
|
||||
margin-left: %1px;
|
||||
margin-right: %1px;
|
||||
margin-top: %2px;
|
||||
margin-bottom: %2px;
|
||||
padding: 0px;
|
||||
border-radius: 10px;
|
||||
color: #dddddd;
|
||||
@@ -60,7 +66,7 @@ KeyboardLayout::KeyboardLayout(QWidget* parent, const std::vector<QVector<QStrin
|
||||
QPushButton:pressed {
|
||||
background-color: #333333;
|
||||
}
|
||||
)");
|
||||
)").arg(key_spacing_vertical / 2).arg(key_spacing_horizontal / 2));
|
||||
}
|
||||
|
||||
Keyboard::Keyboard(QWidget *parent) : QFrame(parent) {
|
||||
|
||||
Reference in New Issue
Block a user