mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
Avoid temporary no-selection state when selecting a new item
in layouts using mouse interactions
This commit is contained in:
parent
ab4e6c11ed
commit
29dfcc0d7d
@ -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 );
|
||||
@ -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
|
||||
@ -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 );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user