Navigation Menu

Skip to content

Commit

Permalink
Avoid temporary no-selection state when selecting a new item
Browse files Browse the repository at this point in the history
in layouts using mouse interactions
  • Loading branch information
nyalldawson committed Nov 7, 2017
1 parent ab4e6c1 commit 29dfcc0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/gui/layout/qgslayoutviewtoolselect.cpp
Expand Up @@ -62,11 +62,12 @@ void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
QgsLayoutItem *selectedItem = nullptr;
QgsLayoutItem *previousSelectedItem = nullptr;

QList<QgsLayoutItem *> selectedItems = layout()->selectedLayoutItems();

if ( event->modifiers() & Qt::ControlModifier )
{
//CTRL modifier, so we are trying to select the next item below the current one
//first, find currently selected item
QList<QgsLayoutItem *> selectedItems = layout()->selectedLayoutItems();
if ( !selectedItems.isEmpty() )
{
previousSelectedItem = selectedItems.at( 0 );
Expand Down Expand Up @@ -100,12 +101,6 @@ void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
return;
}

if ( ( !selectedItem->isSelected() ) && //keep selection if an already selected item pressed
!( event->modifiers() & Qt::ShiftModifier ) ) //keep selection if shift key pressed
{
layout()->deselectAll();
}

if ( ( event->modifiers() & Qt::ShiftModifier ) && ( selectedItem->isSelected() ) )
{
//SHIFT-clicking a selected item deselects it
Expand All @@ -120,7 +115,15 @@ void QgsLayoutViewToolSelect::layoutPressEvent( QgsLayoutViewMouseEvent *event )
}
else
{
selectedItem->setSelected( true );
if ( ( !selectedItem->isSelected() ) && //keep selection if an already selected item pressed
!( event->modifiers() & Qt::ShiftModifier ) ) //keep selection if shift key pressed
{
layout()->setSelectedItem( selectedItem ); // clears existing selection
}
else
{
selectedItem->setSelected( true );
}
event->ignore();
emit itemFocused( selectedItem );
}
Expand Down

0 comments on commit 29dfcc0

Please sign in to comment.