Skip to content
Permalink
Browse files

Show section name in layout designer title

To make it clearer which section is currently being edited
  • Loading branch information
nyalldawson committed Jan 5, 2018
1 parent 612969c commit d9fe0d44076c44e9ac0ab7da31b6392d2dc9ef53
@@ -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 ) )
@@ -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 )
@@ -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 )
@@ -4045,4 +4059,10 @@ void QgsLayoutDesignerDialog::setAtlasFeature( QgsMapLayer *layer, const QgsFeat
activate();
}

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


@@ -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:

/**
@@ -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();
@@ -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();

@@ -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
@@ -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() ) );
}
}

@@ -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() ) );
}
}

@@ -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() ) );
}
}

@@ -61,6 +61,7 @@ void QgsReportLayoutSectionWidget::editHeader()
if ( mSection->header() )
{
mDesigner->setCurrentLayout( mSection->header() );
mDesigner->setSectionTitle( tr( "%1 Header" ).arg( mSection->description() ) );
}
}

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

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

mDesigner->setCurrentLayout( mSection->body() );
mDesigner->setSectionTitle( tr( "%1 Body" ).arg( mSection->description() ) );
}
@@ -58,6 +58,7 @@ void QgsReportSectionWidget::editHeader()
if ( mSection->header() )
{
mDesigner->setCurrentLayout( mSection->header() );
mDesigner->setSectionTitle( tr( "Report Header" ) );
}
}

@@ -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.
You can’t perform that action at this time.