Skip to content

Commit

Permalink
Fix messageboxes are shown with wait mouse cursor in style manager im…
Browse files Browse the repository at this point in the history
…port dialog
  • Loading branch information
nyalldawson committed Aug 31, 2018
1 parent 1f744bd commit 8f1fb1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Expand Up @@ -87,7 +87,6 @@ deselectSmartgroup deselects all symbols from a smart group
%End

void importTypeChanged( int );
void browse();

};

Expand Down
13 changes: 9 additions & 4 deletions src/gui/symbology/qgsstyleexportimportdialog.cpp
Expand Up @@ -154,33 +154,34 @@ void QgsStyleExportImportDialog::doExportImport()

mFileName = fileName;

QgsTemporaryCursorOverride override( Qt::WaitCursor );
mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
moveStyles( &selection, mStyle, mTempStyle );
if ( !mTempStyle->exportXml( mFileName ) )
{
override.release();
mCursorOverride.reset();
QMessageBox::warning( this, tr( "Export Symbols" ),
tr( "Error when saving selected symbols to file:\n%1" )
.arg( mTempStyle->errorString() ) );
return;
}
else
{
override.release();
mCursorOverride.reset();
QMessageBox::information( this, tr( "Export Symbols" ),
tr( "The selected symbols were successfully exported to file:\n%1" )
.arg( mFileName ) );
}
}
else // import
{
QgsTemporaryCursorOverride override( Qt::WaitCursor );
mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
moveStyles( &selection, mTempStyle, mStyle );

// clear model
QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model() );
model->clear();
accept();
mCursorOverride.reset();
}

mFileName.clear();
Expand Down Expand Up @@ -296,10 +297,12 @@ void QgsStyleExportImportDialog::moveStyles( QModelIndexList *selection, QgsStyl
{
if ( dst->symbolNames().contains( symbolName ) && prompt )
{
mCursorOverride.reset();
int res = QMessageBox::warning( this, tr( "Export/import Symbols" ),
tr( "Symbol with name '%1' already exists.\nOverwrite?" )
.arg( symbolName ),
QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
switch ( res )
{
case QMessageBox::Cancel:
Expand Down Expand Up @@ -347,10 +350,12 @@ void QgsStyleExportImportDialog::moveStyles( QModelIndexList *selection, QgsStyl
{
if ( dst->colorRampNames().contains( symbolName ) && prompt )
{
mCursorOverride.reset();
int res = QMessageBox::warning( this, tr( "Export/import Color Ramps" ),
tr( "Color ramp with name '%1' already exists.\nOverwrite?" )
.arg( symbolName ),
QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
mCursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
switch ( res )
{
case QMessageBox::Cancel:
Expand Down
2 changes: 2 additions & 0 deletions src/gui/symbology/qgsstyleexportimportdialog.h
Expand Up @@ -32,6 +32,7 @@

class QgsStyle;
class QgsStyleGroupSelectionDialog;
class QgsTemporaryCursorOverride;

/**
* \ingroup gui
Expand Down Expand Up @@ -144,6 +145,7 @@ class GUI_EXPORT QgsStyleExportImportDialog : public QDialog, private Ui::QgsSty

QgsStyle *mStyle = nullptr;
QgsStyle *mTempStyle = nullptr;
std::unique_ptr< QgsTemporaryCursorOverride > mCursorOverride;
};

#endif // QGSSTYLEV2EXPORTIMPORTDIALOG_H

0 comments on commit 8f1fb1e

Please sign in to comment.