Skip to content

Commit

Permalink
Limit scope of Ctrl+C shortcut for copy features to canvas and for
Browse files Browse the repository at this point in the history
python console to console widget

Avoids ambiguous shortcut warnings/unexpected behavior when pressing
Ctrl+C

Fixes #27035
Fixes #31918
Fixes #31914
Fixes #31392
  • Loading branch information
nyalldawson committed Jun 4, 2020
1 parent 2f4e8c0 commit 873716c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions python/console/console_output.py
Expand Up @@ -168,6 +168,7 @@ def __init__(self, parent=None):
self.runScut.activated.connect(self.enteredSelected)
# Reimplemented copy action to prevent paste prompt (>>>,...) in command view
self.copyShortcut = QShortcut(QKeySequence.Copy, self)
self.copyShortcut.setContext(Qt.WidgetWithChildrenShortcut)
self.copyShortcut.activated.connect(self.copy)
self.selectAllShortcut = QShortcut(QKeySequence.SelectAll, self)
self.selectAllShortcut.activated.connect(self.selectAll)
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -2816,6 +2816,11 @@ void QgisApp::createActions()

connect( mActionDiagramProperties, &QAction::triggered, this, &QgisApp::diagramProperties );

// we can't set the shortcut on the copy action, because we need to restrict it's context to the canvas and it's children..
QShortcut *copyShortcut = new QShortcut( QKeySequence::Copy, mMapCanvas );
copyShortcut->setContext( Qt::WidgetWithChildrenShortcut );
connect( copyShortcut, &QShortcut::activated, this, [ = ] { copySelectionToClipboard(); } );

#ifndef HAVE_POSTGRESQL
delete mActionAddPgLayer;
mActionAddPgLayer = 0;
Expand Down
3 changes: 0 additions & 3 deletions src/ui/qgisapp.ui
Expand Up @@ -894,9 +894,6 @@
<property name="text">
<string>Copy Features</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
<action name="mActionPasteFeatures">
<property name="icon">
Expand Down

0 comments on commit 873716c

Please sign in to comment.