Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle no file selected
  • Loading branch information
YoannQDQ authored and nyalldawson committed May 12, 2023
1 parent ccc17b9 commit e61f355
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/app/qgsformannotationdialog.cpp
Expand Up @@ -70,9 +70,12 @@ void QgsFormAnnotationDialog::applySettingsToItem()

if ( mItem && mItem->annotation() )
{
QgsFormAnnotation *annotation = static_cast< QgsFormAnnotation * >( mItem->annotation() );
annotation->setDesignerForm( mFileLineEdit->text() );
mItem->update();
if ( !mFileLineEdit->text().isEmpty() )
{
QgsFormAnnotation *annotation = static_cast< QgsFormAnnotation * >( mItem->annotation() );
annotation->setDesignerForm( mFileLineEdit->text() );
mItem->update();
}
}
}

Expand All @@ -85,6 +88,10 @@ void QgsFormAnnotationDialog::mBrowseToolButton_clicked()
directory = fi.absolutePath();
}
const QString filename = QFileDialog::getOpenFileName( nullptr, tr( "Qt designer file" ), directory, QStringLiteral( "*.ui" ) );
if ( filename.isEmpty() )
{
return;
}
mFileLineEdit->setText( filename );
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/qgshtmlannotationdialog.cpp
Expand Up @@ -104,6 +104,10 @@ void QgsHtmlAnnotationDialog::mBrowseToolButton_clicked()
directory = QDir::homePath();
}
const QString filename = QFileDialog::getOpenFileName( nullptr, tr( "html" ), directory, QStringLiteral( "HTML (*.html *.htm);;All files (*.*)" ) );
if ( filename.isEmpty() )
{
return;
}
mFileLineEdit->setText( filename );
}

Expand Down
13 changes: 10 additions & 3 deletions src/app/qgssvgannotationdialog.cpp
Expand Up @@ -72,6 +72,10 @@ void QgsSvgAnnotationDialog::mBrowseToolButton_clicked()
directory = fi.absolutePath();
}
const QString filename = QFileDialog::getOpenFileName( nullptr, tr( "Select SVG file" ), directory, tr( "SVG files" ) + " (*.svg)" );
if ( filename.isEmpty() )
{
return;
}
mFileLineEdit->setText( filename );
}

Expand All @@ -84,9 +88,12 @@ void QgsSvgAnnotationDialog::applySettingsToItem()

if ( mItem && mItem->annotation() )
{
QgsSvgAnnotation *annotation = static_cast< QgsSvgAnnotation * >( mItem->annotation() );
annotation->setFilePath( mFileLineEdit->text() );
mItem->update();
if ( !mFileLineEdit->text().isEmpty() )
{
QgsSvgAnnotation *annotation = static_cast< QgsSvgAnnotation * >( mItem->annotation() );
annotation->setFilePath( mFileLineEdit->text() );
mItem->update();
}
}

}
Expand Down

0 comments on commit e61f355

Please sign in to comment.