StringsWidget: add shortcuts for QuickFilter (#973)

This commit is contained in:
Paul I 2018-11-30 00:59:34 +03:00 committed by Itay Cohen
parent 3c78586438
commit 3fa101d9ee
3 changed files with 32 additions and 0 deletions

View File

@ -26,3 +26,21 @@ QComboBox *ComboQuickFilterView::comboBox()
{
return ui->comboBox;
}
void ComboQuickFilterView::showFilter()
{
show();
ui->lineEdit->setFocus();
}
void ComboQuickFilterView::clearFilter()
{
ui->lineEdit->setText("");
}
void ComboQuickFilterView::closeFilter()
{
ui->lineEdit->setText("");
hide();
emit filterClosed();
}

View File

@ -19,8 +19,14 @@ public:
void setLabelText(const QString &text);
QComboBox *comboBox();
public slots:
void showFilter();
void closeFilter();
void clearFilter();
signals:
void filterTextChanged(const QString &text);
void filterClosed();
private:
Ui::ComboQuickFilterView *ui;

View File

@ -178,6 +178,14 @@ StringsWidget::StringsWidget(MainWindow *main, QAction *action) :
tree->showItemsNumber(proxyModel->rowCount());
});
QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this);
connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &ComboQuickFilterView::showFilter);
searchShortcut->setContext(Qt::WidgetWithChildrenShortcut);
QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(clearShortcut, &QShortcut::activated, ui->quickFilterView, &ComboQuickFilterView::clearFilter);
clearShortcut->setContext(Qt::WidgetWithChildrenShortcut);
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshStrings()));
connect(