Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[GRASS] accept shortcuts in shell, fixes #18262
  • Loading branch information
blazek committed Feb 28, 2018
1 parent 10c2122 commit f271300
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/plugins/grass/qgsgrassshell.cpp
Expand Up @@ -12,9 +12,11 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QEvent>
#include <QTabWidget>
#include <QVBoxLayout>
#include <QShortcut>
#include <QKeyEvent>
#include <QKeySequence>

#include "qgslogger.h"
Expand Down Expand Up @@ -73,6 +75,27 @@ QgsGrassShell::QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent, const ch
mTerminal->setStyleSheet( QStringLiteral( "font-family: Monospace; font-size: 10pt;" ) );
}

bool QgsGrassShell::event( QEvent *e )
{
// We have to accept simple shortcuts, QGIS defines shortcuts without Ctrl/Shift for map tools,
// for example S for Enable Snapping. See #18262.
// See also QWidgetLineControl::processShortcutOverrideEvent and TerminalDisplay::handleShortcutOverrideEvent
if ( e->type() == QEvent::ShortcutOverride )
{
QKeyEvent *ke = static_cast<QKeyEvent *>( e );
if ( ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier
|| ke->modifiers() == Qt::KeypadModifier )
{
if ( ke->key() < Qt::Key_Escape )
{
ke->accept();
return true;
}
}
}
return QFrame::event( e );
}

void QgsGrassShell::closeShell()
{
int index = mTabWidget->indexOf( this );
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/grass/qgsgrassshell.h
Expand Up @@ -18,13 +18,15 @@
class QgsGrassTools;
class QTabWidget;
class QTermWidget;
class QEvent;

class QgsGrassShell : public QFrame
{
Q_OBJECT

public:
QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent = nullptr, const char *name = nullptr );
bool event( QEvent * ) override;

private slots:
void closeShell();
Expand Down

0 comments on commit f271300

Please sign in to comment.