Skip to content

Commit

Permalink
Show section name in layout designer title
Browse files Browse the repository at this point in the history
To make it clearer which section is currently being edited
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent 612969c commit d9fe0d4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,16 +733,16 @@ void QgsLayoutDesignerDialog::setMasterLayout( QgsMasterLayoutInterface *layout
if ( obj )
connect( obj, &QObject::destroyed, this, &QgsLayoutDesignerDialog::close );

setWindowTitle( mMasterLayout->name() );
setTitle( mMasterLayout->name() );

if ( QgsPrintLayout *l = dynamic_cast< QgsPrintLayout * >( layout ) )
{
connect( l, &QgsPrintLayout::nameChanged, this, &QgsLayoutDesignerDialog::setWindowTitle );
connect( l, &QgsPrintLayout::nameChanged, this, &QgsLayoutDesignerDialog::setTitle );
setCurrentLayout( l );
}
else if ( QgsReport *r = dynamic_cast< QgsReport * >( layout ) )
{
connect( r, &QgsReport::nameChanged, this, &QgsLayoutDesignerDialog::setWindowTitle );
connect( r, &QgsReport::nameChanged, this, &QgsLayoutDesignerDialog::setTitle );
}

if ( dynamic_cast< QgsPrintLayout * >( layout ) )
Expand Down Expand Up @@ -1205,6 +1205,12 @@ void QgsLayoutDesignerDialog::dragEnterEvent( QDragEnterEvent *event )
}
}

void QgsLayoutDesignerDialog::setTitle( const QString &title )
{
mTitle = title;
updateWindowTitle();
}

void QgsLayoutDesignerDialog::itemTypeAdded( int id )
{
if ( QgsGui::layoutItemGuiRegistry()->itemMetadata( id )->flags() & QgsLayoutItemAbstractGuiMetadata::FlagNoCreationTools )
Expand Down Expand Up @@ -3995,6 +4001,14 @@ void QgsLayoutDesignerDialog::updateActionNames( QgsMasterLayoutInterface::Type
}
}

void QgsLayoutDesignerDialog::updateWindowTitle()
{
if ( mSectionTitle.isEmpty() )
setWindowTitle( mTitle );
else
setWindowTitle( QStringLiteral( "%1 - %2" ).arg( mTitle, mSectionTitle ) );
}

void QgsLayoutDesignerDialog::selectItems( const QList<QgsLayoutItem *> items )
{
for ( QGraphicsItem *item : items )
Expand Down Expand Up @@ -4045,4 +4059,10 @@ void QgsLayoutDesignerDialog::setAtlasFeature( QgsMapLayer *layer, const QgsFeat
activate();
}

void QgsLayoutDesignerDialog::setSectionTitle( const QString &title )
{
mSectionTitle = title;
updateWindowTitle();
}


12 changes: 12 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
*/
void setAtlasFeature( QgsMapLayer *layer, const QgsFeature &feat );

/**
* Sets a section \a title, to use to update the dialog title to display
* the currently edited section.
*/
void setSectionTitle( const QString &title );

public slots:

/**
Expand Down Expand Up @@ -280,6 +286,8 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner

private slots:

void setTitle( const QString &title );

void itemTypeAdded( int id );
void statusZoomCombo_currentIndexChanged( int index );
void statusZoomCombo_zoomEntered();
Expand Down Expand Up @@ -419,6 +427,9 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
std::unique_ptr< QPrinter > mPrinter;
bool mSetPageOrientation = false;

QString mTitle;
QString mSectionTitle;

//! Save window state
void saveWindowState();

Expand Down Expand Up @@ -480,6 +491,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
QPrinter *printer();
QString reportTypeString();
void updateActionNames( QgsMasterLayoutInterface::Type type );
void updateWindowTitle();
};

#endif // QGSLAYOUTDESIGNERDIALOG_H
Expand Down
3 changes: 3 additions & 0 deletions src/app/layout/qgsreportfieldgroupsectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void QgsReportSectionFieldGroupWidget::editHeader()
{
mSection->header()->reportContext().setLayer( mSection->layer() );
mDesigner->setCurrentLayout( mSection->header() );
mDesigner->setSectionTitle( tr( "%1 Header" ).arg( mSection->description() ) );
}
}

Expand All @@ -87,6 +88,7 @@ void QgsReportSectionFieldGroupWidget::editFooter()
{
mSection->footer()->reportContext().setLayer( mSection->layer() );
mDesigner->setCurrentLayout( mSection->footer() );
mDesigner->setSectionTitle( tr( "%1 Footer" ).arg( mSection->description() ) );
}
}

Expand All @@ -108,6 +110,7 @@ void QgsReportSectionFieldGroupWidget::editBody()
{
mSection->body()->reportContext().setLayer( mSection->layer() );
mDesigner->setCurrentLayout( mSection->body() );
mDesigner->setSectionTitle( tr( "%1 Body" ).arg( mSection->description() ) );
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/app/layout/qgsreportlayoutsectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void QgsReportLayoutSectionWidget::editHeader()
if ( mSection->header() )
{
mDesigner->setCurrentLayout( mSection->header() );
mDesigner->setSectionTitle( tr( "%1 Header" ).arg( mSection->description() ) );
}
}

Expand All @@ -76,6 +77,7 @@ void QgsReportLayoutSectionWidget::editFooter()
if ( mSection->footer() )
{
mDesigner->setCurrentLayout( mSection->footer() );
mDesigner->setSectionTitle( tr( "%1 Footer" ).arg( mSection->description() ) );
}
}

Expand All @@ -94,4 +96,5 @@ void QgsReportLayoutSectionWidget::editBody()
}

mDesigner->setCurrentLayout( mSection->body() );
mDesigner->setSectionTitle( tr( "%1 Body" ).arg( mSection->description() ) );
}
2 changes: 2 additions & 0 deletions src/app/layout/qgsreportsectionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void QgsReportSectionWidget::editHeader()
if ( mSection->header() )
{
mDesigner->setCurrentLayout( mSection->header() );
mDesigner->setSectionTitle( tr( "Report Header" ) );
}
}

Expand All @@ -73,6 +74,7 @@ void QgsReportSectionWidget::editFooter()
if ( mSection->footer() )
{
mDesigner->setCurrentLayout( mSection->footer() );
mDesigner->setSectionTitle( tr( "Report Footer" ) );
}
}

0 comments on commit d9fe0d4

Please sign in to comment.