Skip to content
Permalink
Browse files

Fix messageboxes are shown with wait mouse cursor in style manager im…

…port dialog
  • Loading branch information
nyalldawson committed Aug 31, 2018
1 parent 1f744bd commit 8f1fb1e648ee6433c6351b089db36b03c0dd1a82
@@ -87,7 +87,6 @@ deselectSmartgroup deselects all symbols from a smart group
%End

void importTypeChanged( int );
void browse();

};

@@ -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();
@@ -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:
@@ -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:
@@ -32,6 +32,7 @@

class QgsStyle;
class QgsStyleGroupSelectionDialog;
class QgsTemporaryCursorOverride;

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