Skip to content
Permalink
Browse files

[GRASS] accept shortcuts in shell, fixes #18262

  • Loading branch information
blazek committed Feb 28, 2018
1 parent 10c2122 commit f27130016e28a44323a2505a63dfdde6dca763ac
Showing with 25 additions and 0 deletions.
  1. +23 −0 src/plugins/grass/qgsgrassshell.cpp
  2. +2 −0 src/plugins/grass/qgsgrassshell.h
@@ -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"
@@ -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 );
@@ -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();

0 comments on commit f271300

Please sign in to comment.
You can’t perform that action at this time.