Skip to content

Commit

Permalink
Add method to push messages to layout designer status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 6, 2017
1 parent fac2d7f commit b9ecb4f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/gui/layout/qgslayoutview.sip
Expand Up @@ -179,6 +179,14 @@ class QgsLayoutView: QGraphicsView
i.e. QGraphicsView.fitInView().
%End

void pushStatusMessage( const QString &message );
%Docstring
Pushes a new status bar ``message`` to the view. This causes statusMessage()
to be emitted, which should cause the message to appear in the status bar
for the parent window.
.. seealso:: statusMessage()
%End

signals:

void layoutSet( QgsLayout *layout );
Expand Down Expand Up @@ -212,6 +220,13 @@ class QgsLayoutView: QGraphicsView
considers the page at the center of the view as the current visible
page.
.. seealso:: currentPage()
%End

void statusMessage( const QString &message );
%Docstring
Emitted when the view has a ``message`` for display in a parent window's
status bar.
.. seealso:: pushStatusMessage()
%End

protected:
Expand Down
8 changes: 8 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -312,6 +312,9 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
tabifyDockWidget( mGeneralDock, mItemDock );

restoreWindowState();

//listen out to status bar updates from the view
connect( mView, &QgsLayoutView::statusMessage, this, &QgsLayoutDesignerDialog::statusMessageReceived );
}

QgsAppLayoutDesignerInterface *QgsLayoutDesignerDialog::iface()
Expand Down Expand Up @@ -652,6 +655,11 @@ void QgsLayoutDesignerDialog::addPages()
}
}

void QgsLayoutDesignerDialog::statusMessageReceived( const QString &message )
{
mStatusBar->showMessage( message );
}

QgsLayoutView *QgsLayoutDesignerDialog::view()
{
return mView;
Expand Down
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Expand Up @@ -163,6 +163,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
void toggleFullScreen( bool enabled );

void addPages();
void statusMessageReceived( const QString &message );

private:

Expand Down
5 changes: 5 additions & 0 deletions src/gui/layout/qgslayoutview.cpp
Expand Up @@ -445,6 +445,11 @@ void QgsLayoutView::viewChanged()
}
}

void QgsLayoutView::pushStatusMessage( const QString &message )
{
emit statusMessage( message );
}

void QgsLayoutView::wheelZoom( QWheelEvent *event )
{
//get mouse wheel zoom behavior settings
Expand Down
15 changes: 15 additions & 0 deletions src/gui/layout/qgslayoutview.h
Expand Up @@ -218,6 +218,14 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView
*/
void viewChanged();

/**
* Pushes a new status bar \a message to the view. This causes statusMessage()
* to be emitted, which should cause the message to appear in the status bar
* for the parent window.
* \see statusMessage()
*/
void pushStatusMessage( const QString &message );

signals:

/**
Expand Down Expand Up @@ -253,6 +261,13 @@ class GUI_EXPORT QgsLayoutView: public QGraphicsView
*/
void pageChanged( int page );

/**
* Emitted when the view has a \a message for display in a parent window's
* status bar.
* \see pushStatusMessage()
*/
void statusMessage( const QString &message );

protected:
void mousePressEvent( QMouseEvent *event ) override;
void mouseReleaseEvent( QMouseEvent *event ) override;
Expand Down

0 comments on commit b9ecb4f

Please sign in to comment.