Skip to content
Permalink
Browse files
Save as image cleanup:
* message bar go away after 5sec
* make a couple of strings translatable in settings dialog
* nicer initialization of members
  • Loading branch information
nirvn committed Apr 24, 2017
1 parent 858129d commit 7b3859bdea735177e10669ae5bbc693987e9ec36
Showing with 9 additions and 19 deletions.
  1. +3 −12 src/app/qgisapp.cpp
  2. +6 −7 src/app/qgsmapsavedialog.cpp
@@ -5835,26 +5835,17 @@ void QgisApp::saveMapAsImage()

connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, this, [ = ]
{
QgsMessageBarItem *successMsg = new QgsMessageBarItem(
tr( "Successfully saved canvas to image" ),
QgsMessageBar::SUCCESS );
messageBar()->pushItem( successMsg );
messageBar()->pushSuccess( tr( "Save as image" ), tr( "Successfully saved canvas to image" ) );
} );
connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, this, [ = ]( int error )
{
if ( error == QgsMapRendererTask::ImageAllocationFail )
{
QgsMessageBarItem *errorMsg = new QgsMessageBarItem(
tr( "Could not allocate required memory for image" ),
QgsMessageBar::WARNING );
messageBar()->pushItem( errorMsg );
messageBar()->pushWarning( tr( "Save as image" ), tr( "Could not allocate required memory for image" ) );
}
else if ( error == QgsMapRendererTask::ImageAllocationFail )
{
QgsMessageBarItem *errorMsg = new QgsMessageBarItem(
tr( "Could not save the image to file" ),
QgsMessageBar::WARNING );
messageBar()->pushItem( errorMsg );
messageBar()->pushWarning( tr( "Save as image" ), tr( "Could not save the image to file" ) );
}
} );

@@ -31,24 +31,23 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();

QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, const QString &decorations )
: QDialog( parent )
, mExtent( mapCanvas->mapSettings().visibleExtent() )
, mDpi( mapCanvas->mapSettings().outputDpi() )
, mSize( mapCanvas->mapSettings().outputSize() )
{
setupUi( this );

mExtent = mapCanvas->mapSettings().visibleExtent();
mDpi = mapCanvas->mapSettings().outputDpi();
mSize = mapCanvas->mapSettings().outputSize();

mResolutionSpinBox->setValue( qt_defaultDpiX() );

mExtentGroupBox->setOutputCrs( mapCanvas->mapSettings().destinationCrs() );
mExtentGroupBox->setCurrentExtent( mapCanvas->mapSettings().visibleExtent(), mapCanvas->mapSettings().destinationCrs() );
mExtentGroupBox->setCurrentExtent( mExtent, mapCanvas->mapSettings().destinationCrs() );
mExtentGroupBox->setOutputExtentFromCurrent();

mScaleWidget->setScale( 1 / mapCanvas->mapSettings().scale() );
mScaleWidget->setMapCanvas( mapCanvas );
mScaleWidget->setShowCurrentScaleButton( true );

mDrawDecorations->setText( QString( "Draw active decorations: %1" ).arg( !decorations.isEmpty() ? decorations : tr( "none" ) ) );
mDrawDecorations->setText( tr( "Draw active decorations: %1" ).arg( !decorations.isEmpty() ? decorations : tr( "none" ) ) );

connect( mResolutionSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsMapSaveDialog::updateDpi );
connect( mExtentGroupBox, &QgsExtentGroupBox::extentChanged, this, &QgsMapSaveDialog::updateExtent );
@@ -88,7 +87,7 @@ void QgsMapSaveDialog::updateScale( double scale )

void QgsMapSaveDialog::updateOutputSize()
{
mOutputSize->setText( QString( "Output size: %1 x %2 pixels" ).arg( mSize.width() ).arg( mSize.height() ) );
mOutputSize->setText( tr( "Output size: %1 x %2 pixels" ).arg( mSize.width() ).arg( mSize.height() ) );
}

QgsRectangle QgsMapSaveDialog::extent() const

0 comments on commit 7b3859b

Please sign in to comment.