Skip to content

Commit

Permalink
[ui] Fix unmet expectation: when navigating the processing toolbox pa…
Browse files Browse the repository at this point in the history
…nel via keyboard, hitting return/enter should launch focused algorithm
  • Loading branch information
nirvn committed Oct 11, 2021
1 parent f774de9 commit 7a0fb2a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Expand Up @@ -97,6 +97,11 @@ Sets a ``filter`` string, used to filter out the contents of the view
to matching algorithms.
%End

protected:

virtual void keyPressEvent( QKeyEvent *event );


};

/************************************************************************
Expand Down
10 changes: 10 additions & 0 deletions src/gui/processing/qgsprocessingtoolboxtreeview.cpp
Expand Up @@ -16,6 +16,8 @@
#include "qgsprocessingtoolboxtreeview.h"
#include "qgsprocessingtoolboxmodel.h"

#include <QKeyEvent>

///@cond PRIVATE

QgsProcessingToolboxTreeView::QgsProcessingToolboxTreeView( QWidget *parent,
Expand Down Expand Up @@ -119,4 +121,12 @@ QModelIndex QgsProcessingToolboxTreeView::findFirstVisibleAlgorithm( const QMode
return QModelIndex();
}

void QgsProcessingToolboxTreeView::keyPressEvent( QKeyEvent *event )
{
if ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter )
emit doubleClicked( currentIndex() );
else
QTreeView::keyPressEvent( event );
}

///@endcond
4 changes: 4 additions & 0 deletions src/gui/processing/qgsprocessingtoolboxtreeview.h
Expand Up @@ -106,6 +106,10 @@ class GUI_EXPORT QgsProcessingToolboxTreeView : public QTreeView
*/
void setFilterString( const QString &filter );

protected:

void keyPressEvent( QKeyEvent *event ) override;

private:

QgsProcessingToolboxProxyModel *mModel = nullptr;
Expand Down

0 comments on commit 7a0fb2a

Please sign in to comment.