Skip to content

Commit 1fb9ef6

Browse files
committed
[FEATURE] add search bar to the Configure Shortcuts dialog (fix #12681)
Supports search by action name and by shortcut
1 parent 248e7d1 commit 1fb9ef6

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/gui/qgsconfigureshortcutsdialog.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <QFileDialog>
2929
#include <QTextStream>
3030
#include <QSettings>
31+
#include <QDebug>
3132

3233
QgsConfigureShortcutsDialog::QgsConfigureShortcutsDialog( QWidget* parent, QgsShortcutsManager* manager )
3334
: QDialog( parent )
@@ -480,3 +481,19 @@ void QgsConfigureShortcutsDialog::setCurrentActionShortcut( const QKeySequence&
480481

481482
actionChanged( treeActions->currentItem(), nullptr );
482483
}
484+
485+
void QgsConfigureShortcutsDialog::on_mLeFilter_textChanged( const QString& text )
486+
{
487+
for ( int i = 0; i < treeActions->topLevelItemCount(); i++ )
488+
{
489+
QTreeWidgetItem* item = treeActions->topLevelItem( i );
490+
if ( !item->text( 0 ).contains( text, Qt::CaseInsensitive ) && !item->text( 1 ).contains( text, Qt::CaseInsensitive ) )
491+
{
492+
item->setHidden( true );
493+
}
494+
else
495+
{
496+
item->setHidden( false );
497+
}
498+
}
499+
}

src/gui/qgsconfigureshortcutsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class GUI_EXPORT QgsConfigureShortcutsDialog : public QDialog, private Ui::QgsCo
5454
void setNoShortcut();
5555
void saveShortcuts();
5656
void loadShortcuts();
57+
void on_mLeFilter_textChanged( const QString& text );
5758

5859
void actionChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
5960

src/ui/qgsconfigureshortcutsdialog.ui

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
<string>Keyboard shortcuts</string>
1515
</property>
1616
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QgsFilterLineEdit" name="mLeFilter">
19+
<property name="placeholderText">
20+
<string>Search...</string>
21+
</property>
22+
</widget>
23+
</item>
1724
<item>
1825
<widget class="QTreeWidget" name="treeActions">
1926
<property name="rootIsDecorated">
@@ -110,6 +117,13 @@
110117
</item>
111118
</layout>
112119
</widget>
120+
<customwidgets>
121+
<customwidget>
122+
<class>QgsFilterLineEdit</class>
123+
<extends>QLineEdit</extends>
124+
<header>qgsfilterlineedit.h</header>
125+
</customwidget>
126+
</customwidgets>
113127
<tabstops>
114128
<tabstop>treeActions</tabstop>
115129
<tabstop>btnSetNoShortcut</tabstop>

0 commit comments

Comments
 (0)