assign numbers 1-9 as shortcuts for the first 9 results of system applications

This commit is contained in:
Albert S. 2019-06-01 13:38:58 +02:00
parent 45abb2bf27
commit 1dc7ef935d
3 changed files with 8 additions and 3 deletions

View File

@ -57,6 +57,7 @@ int EntryPushButton::getRow() const { return config.row; }
int EntryPushButton::getCol() const { return config.col; } int EntryPushButton::getCol() const { return config.col; }
QString EntryPushButton::getName() const { return config.name; } QString EntryPushButton::getName() const { return config.name; }
QString EntryPushButton::getShortcutKey() const { return config.key; } 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::setRow(int row) { this->config.row = row; }
void EntryPushButton::setCol(int col) { this->config.col = col; } void EntryPushButton::setCol(int col) { this->config.col = col; }
QStringList EntryPushButton::getArguments() const { return this->config.arguments; } QStringList EntryPushButton::getArguments() const { return this->config.arguments; }

View File

@ -43,6 +43,7 @@ public:
QString getCommand() const; QString getCommand() const;
void setRow(int row); void setRow(int row);
void setCol(int col); void setCol(int col);
void setShortcutKey(QString key);
}; };

View File

@ -269,8 +269,8 @@ void Window::keyPressEvent(QKeyEvent *event)
QKeySequence seq(event->key()); QKeySequence seq(event->key());
QString key = seq.toString().toLower(); QString key = seq.toString().toLower();
auto it = std::find_if(userEntryButtons.begin(), userEntryButtons.end(), [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; }); auto it = std::find_if(buttonsInGrid.begin(), buttonsInGrid.end(), [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; });
if(it != userEntryButtons.end()) if(it != buttonsInGrid.end())
{ {
buttonClick(**it); buttonClick(**it);
} }
@ -304,7 +304,10 @@ void Window::filterGridFor(QString filter)
if(button->getName().contains(filter, Qt::CaseInsensitive)) if(button->getName().contains(filter, Qt::CaseInsensitive))
{ {
button->setVisible(true); button->setVisible(true);
button->setShortcut(QString::number(i++)); if(i < 10)
{
button->setShortcutKey(QString::number(i++));
}
grid->addWidget(button, currow, curcol++); grid->addWidget(button, currow, curcol++);
this->buttonsInGrid.append(button); this->buttonsInGrid.append(button);
if(curcol == 3) if(curcol == 3)