Skip to content

Commit

Permalink
Limit scope of Ctrl+{A,X,C,V} shortcut for attribue table
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jun 4, 2020
1 parent 82199f1 commit b923b3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
17 changes: 9 additions & 8 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -114,6 +114,15 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mActionExpressionSelect, &QAction::triggered, this, &QgsAttributeTableDialog::mActionExpressionSelect_triggered );
connect( mMainView, &QgsDualView::showContextMenuExternally, this, &QgsAttributeTableDialog::showContextMenu );

mActionSelectAll->setShortcuts( QKeySequence::SelectAll );
mActionSelectAll->setShortcutContext( Qt::WidgetWithChildrenShortcut );
mActionCopySelectedRows->setShortcuts( QKeySequence::Copy );
mActionCopySelectedRows->setShortcutContext( Qt::WidgetWithChildrenShortcut );
mActionCutSelectedRows->setShortcuts( QKeySequence::Cut );
mActionCutSelectedRows->setShortcutContext( Qt::WidgetWithChildrenShortcut );
mActionPasteFeatures->setShortcuts( QKeySequence::Paste );
mActionPasteFeatures->setShortcutContext( Qt::WidgetWithChildrenShortcut );

const QgsFields fields = mLayer->fields();
for ( const QgsField &field : fields )
{
Expand Down Expand Up @@ -933,12 +942,8 @@ void QgsAttributeTableDialog::toggleDockMode( bool docked )

// To prevent "QAction::event: Ambiguous shortcut overload"
QgsDebugMsgLevel( QStringLiteral( "Remove shortcuts from attribute table already defined in main window" ), 2 );
mActionCopySelectedRows->setShortcut( QKeySequence() );
mActionPasteFeatures->setShortcut( QKeySequence() );
mActionCutSelectedRows->setShortcut( QKeySequence() );
mActionZoomMapToSelectedRows->setShortcut( QKeySequence() );
mActionRemoveSelection->setShortcut( QKeySequence() );
mActionSelectAll->setShortcut( QKeySequence() );
// duplicated on Main Window, with different semantics
mActionPanMapToSelectedRows->setShortcut( QKeySequence() );
mActionSearchForm->setShortcut( QKeySequence() );
Expand Down Expand Up @@ -974,12 +979,8 @@ void QgsAttributeTableDialog::toggleDockMode( bool docked )
// restore attribute table shortcuts in window mode
QgsDebugMsgLevel( QStringLiteral( "Restore attribute table dialog shortcuts in window mode" ), 2 );
// duplicated on Main Window
mActionCopySelectedRows->setShortcut( QKeySequence( QKeySequence::Copy ) );
mActionPasteFeatures->setShortcut( QKeySequence( QKeySequence::Paste ) );
mActionCutSelectedRows->setShortcut( QKeySequence( QKeySequence::Cut ) );
mActionZoomMapToSelectedRows->setShortcut( QStringLiteral( "Ctrl+J" ) );
mActionRemoveSelection->setShortcut( QStringLiteral( "Ctrl+Shift+A" ) );
mActionSelectAll->setShortcut( QStringLiteral( "Ctrl+A" ) );
// duplicated on Main Window, with different semantics
mActionPanMapToSelectedRows->setShortcut( QStringLiteral( "Ctrl+P" ) );
mActionSearchForm->setShortcut( QStringLiteral( "Ctrl+F" ) );
Expand Down
12 changes: 0 additions & 12 deletions src/ui/qgsattributetabledialog.ui
Expand Up @@ -339,9 +339,6 @@
<property name="toolTip">
<string>Select all (Ctrl+A)</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action>
<action name="mActionInvertSelection">
<property name="icon">
Expand Down Expand Up @@ -429,9 +426,6 @@
<property name="toolTip">
<string>Cut selected rows to clipboard (Ctrl+X)</string>
</property>
<property name="shortcut">
<string>Ctrl+X</string>
</property>
</action>
<action name="mActionCopySelectedRows">
<property name="icon">
Expand All @@ -444,9 +438,6 @@
<property name="toolTip">
<string>Copy selected rows to clipboard (Ctrl+C)</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
<action name="mActionPasteFeatures">
<property name="icon">
Expand All @@ -459,9 +450,6 @@
<property name="toolTip">
<string>Paste features from clipboard (Ctrl+V)</string>
</property>
<property name="shortcut">
<string>Ctrl+V</string>
</property>
</action>
<action name="mActionRemoveAttribute">
<property name="icon">
Expand Down

0 comments on commit b923b3d

Please sign in to comment.