mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-02 17:44:46 -05:00
Implement search auto-clear and goto group
* Search clears if the search box does not have focus for 5 minutes (fixes #2178) * Goto group from search results after double clicking the group name (fixes #2043)
This commit is contained in:
parent
4b983251cb
commit
d6ffee5e99
@ -893,6 +893,14 @@ void DatabaseWidget::entryActivationSignalReceived(Entry* entry, EntryModel::Mod
|
||||
setupTotp();
|
||||
}
|
||||
break;
|
||||
case EntryModel::ParentGroup:
|
||||
// Call this first to clear out of search mode, otherwise
|
||||
// the desired entry is not properly selected
|
||||
endSearch();
|
||||
emit clearSearch();
|
||||
m_groupView->setCurrentGroup(entry->group());
|
||||
m_entryView->setCurrentEntry(entry);
|
||||
break;
|
||||
// TODO: switch to 'Notes' tab in details view/pane
|
||||
// case EntryModel::Notes:
|
||||
// break;
|
||||
|
@ -30,15 +30,18 @@
|
||||
SearchWidget::SearchWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::SearchWidget())
|
||||
, m_searchTimer(new QTimer(this))
|
||||
, m_clearSearchTimer(new QTimer(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_searchTimer = new QTimer(this);
|
||||
m_searchTimer->setSingleShot(true);
|
||||
m_clearSearchTimer->setSingleShot(true);
|
||||
|
||||
connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), SLOT(startSearchTimer()));
|
||||
connect(m_ui->clearIcon, SIGNAL(triggered(bool)), m_ui->searchEdit, SLOT(clear()));
|
||||
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(startSearch()));
|
||||
connect(m_clearSearchTimer, SIGNAL(timeout()), m_ui->searchEdit, SLOT(clear()));
|
||||
connect(this, SIGNAL(escapePressed()), m_ui->searchEdit, SLOT(clear()));
|
||||
|
||||
new QShortcut(QKeySequence::Find, this, SLOT(searchFocus()), nullptr, Qt::ApplicationShortcut);
|
||||
@ -101,6 +104,11 @@ bool SearchWidget::eventFilter(QObject* obj, QEvent* event)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (event->type() == QEvent::FocusOut) {
|
||||
// Auto-clear search after 5 minutes
|
||||
m_clearSearchTimer->start(300000);
|
||||
} else if (event->type() == QEvent::FocusIn) {
|
||||
m_clearSearchTimer->stop();
|
||||
}
|
||||
|
||||
return QObject::eventFilter(obj, event);
|
||||
|
@ -69,6 +69,7 @@ private slots:
|
||||
private:
|
||||
const QScopedPointer<Ui::SearchWidget> m_ui;
|
||||
QTimer* m_searchTimer;
|
||||
QTimer* m_clearSearchTimer;
|
||||
QAction* m_actionCaseSensitive;
|
||||
QAction* m_actionLimitGroup;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user