Skip to content

Commit

Permalink
After creating an item with the add item tool, switch immediately to …
Browse files Browse the repository at this point in the history
…select tool
  • Loading branch information
nyalldawson committed Nov 7, 2017
1 parent 3678f01 commit c0b63a6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/gui/layout/qgslayoutviewtooladditem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class QgsLayoutViewToolAddItem : QgsLayoutViewTool
virtual void deactivate();


signals:

void createdItem();
%Docstring
Emitted when an item has been created using the tool.
%End

};

/************************************************************************
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
mSelectTool->setAction( mActionSelectMoveItem );
mToolsActionGroup->addAction( mActionSelectMoveItem );
connect( mActionSelectMoveItem, &QAction::triggered, mSelectTool, [ = ] { mView->setTool( mSelectTool ); } );
// after creating an item with the add item tool, switch immediately to select tool
connect( mAddItemTool, &QgsLayoutViewToolAddItem::createdItem, this, [ = ] { mView->setTool( mSelectTool ); } );

//Ctrl+= should also trigger zoom in
QShortcut *ctrlEquals = new QShortcut( QKeySequence( QStringLiteral( "Ctrl+=" ) ), this );
Expand Down
1 change: 1 addition & 0 deletions src/gui/layout/qgslayoutviewtooladditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void QgsLayoutViewToolAddItem::layoutReleaseEvent( QgsLayoutViewMouseEvent *even

layout()->addLayoutItem( item );
layout()->setSelectedItem( item );
emit createdItem();
}

void QgsLayoutViewToolAddItem::deactivate()
Expand Down
7 changes: 7 additions & 0 deletions src/gui/layout/qgslayoutviewtooladditem.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class GUI_EXPORT QgsLayoutViewToolAddItem : public QgsLayoutViewTool
void layoutReleaseEvent( QgsLayoutViewMouseEvent *event ) override;
void deactivate() override;

signals:

/**
* Emitted when an item has been created using the tool.
*/
void createdItem();

private:

bool mDrawing = false;
Expand Down

0 comments on commit c0b63a6

Please sign in to comment.