diff --git a/entrypushbutton.cpp b/entrypushbutton.cpp index 69afda1..b68dc5d 100644 --- a/entrypushbutton.cpp +++ b/entrypushbutton.cpp @@ -57,6 +57,7 @@ int EntryPushButton::getRow() const { return config.row; } int EntryPushButton::getCol() const { return config.col; } QString EntryPushButton::getName() const { return config.name; } QString EntryPushButton::getShortcutKey() const { return config.key; } +void EntryPushButton::setShortcutKey(QString key) { this->config.key = key; } void EntryPushButton::setRow(int row) { this->config.row = row; } void EntryPushButton::setCol(int col) { this->config.col = col; } QStringList EntryPushButton::getArguments() const { return this->config.arguments; } diff --git a/entrypushbutton.h b/entrypushbutton.h index f61c0c9..c697cf9 100644 --- a/entrypushbutton.h +++ b/entrypushbutton.h @@ -43,6 +43,7 @@ public: QString getCommand() const; void setRow(int row); void setCol(int col); + void setShortcutKey(QString key); }; diff --git a/window.cpp b/window.cpp index a2decb9..154efd7 100644 --- a/window.cpp +++ b/window.cpp @@ -269,8 +269,8 @@ void Window::keyPressEvent(QKeyEvent *event) QKeySequence seq(event->key()); QString key = seq.toString().toLower(); - auto it = std::find_if(userEntryButtons.begin(), userEntryButtons.end(), [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; }); - if(it != userEntryButtons.end()) + auto it = std::find_if(buttonsInGrid.begin(), buttonsInGrid.end(), [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; }); + if(it != buttonsInGrid.end()) { buttonClick(**it); } @@ -304,7 +304,10 @@ void Window::filterGridFor(QString filter) if(button->getName().contains(filter, Qt::CaseInsensitive)) { button->setVisible(true); - button->setShortcut(QString::number(i++)); + if(i < 10) + { + button->setShortcutKey(QString::number(i++)); + } grid->addWidget(button, currow, curcol++); this->buttonsInGrid.append(button); if(curcol == 3)