overrirde accept

This commit is contained in:
viperminiq 2025-04-30 07:35:35 +02:00 committed by Nyall Dawson
parent 032f8ff70c
commit 7d453b4d19
2 changed files with 11 additions and 2 deletions

View File

@ -449,13 +449,20 @@ void QgsMapSaveDialog::copyToClipboard()
QgsApplication::taskManager()->addTask( mapRendererTask );
}
void QgsMapSaveDialog::accept()
{
// prevent the dialog from closing before saving the image/pdf
QgsMapSaveDialog::onAccepted();
QDialog::accept();
}
void QgsMapSaveDialog::onAccepted()
{
switch ( mDialogType )
{
case Image:
{
const QPair<QString, QString> fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( QgisApp::instance(), tr( "Choose a file name to save the map image as" ) );
const QPair<QString, QString> fileNameAndFilter = QgsGuiUtils::getSaveAsImageName( this, tr( "Choose a file name to save the map image as" ) );
if ( !fileNameAndFilter.first.isEmpty() )
{
QgsMapSettings ms = QgsMapSettings();
@ -503,7 +510,7 @@ void QgsMapSaveDialog::onAccepted()
{
QgsSettings settings;
const QString lastUsedDir = settings.value( QStringLiteral( "UI/lastSaveAsImageDir" ), QDir::homePath() ).toString();
QString fileName = QFileDialog::getSaveFileName( QgisApp::instance(), tr( "Save Map As" ), lastUsedDir, tr( "PDF Format" ) + " (*.pdf *.PDF)" );
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save Map As" ), lastUsedDir, tr( "PDF Format" ) + " (*.pdf *.PDF)" );
// return dialog focus on Mac
activateWindow();
raise();

View File

@ -78,6 +78,8 @@ class APP_EXPORT QgsMapSaveDialog : public QDialog, private Ui::QgsMapSaveDialog
//! configure a map settings object
void applyMapSettings( QgsMapSettings &mapSettings );
void accept() override;
private slots:
void onAccepted();