Skip to content

Commit

Permalink
Use QMessageBox::question instead of information when asking a question
Browse files Browse the repository at this point in the history
And where appropriate use Yes/No choices instead of Ok/Cancel
  • Loading branch information
nyalldawson committed Feb 6, 2018
1 parent aa3a335 commit 9621f38
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 45 deletions.
30 changes: 15 additions & 15 deletions src/app/qgisapp.cpp
Expand Up @@ -8581,10 +8581,10 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
if ( allowCancel )
buttons |= QMessageBox::Cancel;

switch ( QMessageBox::information( nullptr,
tr( "Stop editing" ),
tr( "Do you want to save the changes to layer %1?" ).arg( vlayer->name() ),
buttons ) )
switch ( QMessageBox::question( nullptr,
tr( "Stop editing" ),
tr( "Do you want to save the changes to layer %1?" ).arg( vlayer->name() ),
buttons ) )
{
case QMessageBox::Cancel:
res = false;
Expand Down Expand Up @@ -8692,12 +8692,12 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable, bool triggerR
if ( !vlayer->rollBack( !leaveEditable ) )
{
mSaveRollbackInProgress = false;
QMessageBox::information( nullptr,
tr( "Error" ),
tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" )
.arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ),
vlayer->name(),
vlayer->commitErrors().join( QStringLiteral( "\n " ) ) ) );
QMessageBox::warning( nullptr,
tr( "Error" ),
tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" )
.arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ),
vlayer->name(),
vlayer->commitErrors().join( QStringLiteral( "\n " ) ) ) );
}
freezeCanvases( false );

Expand Down Expand Up @@ -10396,11 +10396,11 @@ bool QgisApp::saveDirty()
// old code: mProjectIsDirtyFlag = true;

// prompt user to save
answer = QMessageBox::information( this, tr( "Save Project?" ),
tr( "Do you want to save the current project? %1" )
.arg( whyDirty ),
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard,
hasUnsavedEdits ? QMessageBox::Cancel : QMessageBox::Save );
answer = QMessageBox::question( this, tr( "Save Project?" ),
tr( "Do you want to save the current project? %1" )
.arg( whyDirty ),
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard,
hasUnsavedEdits ? QMessageBox::Cancel : QMessageBox::Save );
if ( QMessageBox::Save == answer )
{
if ( !fileSave() )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsbookmarks.cpp
Expand Up @@ -210,9 +210,9 @@ void QgsBookmarks::deleteClicked()
return;

// make sure the user really wants to delete these bookmarks
if ( QMessageBox::Cancel == QMessageBox::information( this, tr( "Delete Bookmarks" ),
if ( QMessageBox::No == QMessageBox::question( this, tr( "Delete Bookmarks" ),
tr( "Are you sure you want to delete %n bookmark(s)?", "number of rows", rows.size() ),
QMessageBox::Ok | QMessageBox::Cancel ) )
QMessageBox::Yes | QMessageBox::No ) )
return;

// Remove in reverse order to keep the merged model indexes
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsguivectorlayertools.cpp
Expand Up @@ -102,10 +102,10 @@ bool QgsGuiVectorLayerTools::stopEditing( QgsVectorLayer *layer, bool allowCance
if ( allowCancel )
buttons |= QMessageBox::Cancel;

switch ( QMessageBox::information( nullptr,
tr( "Stop editing" ),
tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ),
buttons ) )
switch ( QMessageBox::question( nullptr,
tr( "Stop editing" ),
tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ),
buttons ) )
{
case QMessageBox::Cancel:
res = false;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -129,8 +129,8 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
if ( mUnsavedMultiEditChanges )
{
// prompt for save
int res = QMessageBox::information( this, tr( "Multiedit attributes" ),
tr( "Apply changes to edited features?" ), QMessageBox::Yes | QMessageBox::No );
int res = QMessageBox::question( this, tr( "Multiedit attributes" ),
tr( "Apply changes to edited features?" ), QMessageBox::Yes | QMessageBox::No );
if ( res == QMessageBox::Yes )
{
save();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsowssourceselect.cpp
Expand Up @@ -289,8 +289,8 @@ void QgsOWSSourceSelect::mDeleteButton_clicked()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( mConnectionsComboBox->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result == QMessageBox::Yes )
{
QgsOwsConnection::deleteConnection( mService, mConnectionsComboBox->currentText() );
mConnectionsComboBox->removeItem( mConnectionsComboBox->currentIndex() ); // populateConnectionList();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/qgsgeorefplugingui.cpp
Expand Up @@ -1310,7 +1310,7 @@ QgsGeorefPluginGui::SaveGCPs QgsGeorefPluginGui::checkNeedGCPSave()

if ( !equalGCPlists( mInitialPoints, mPoints ) )
{
QMessageBox::StandardButton a = QMessageBox::information( this, tr( "Save GCPs" ),
QMessageBox::StandardButton a = QMessageBox::question( this, tr( "Save GCPs" ),
tr( "Save GCP points?" ),
QMessageBox::Save | QMessageBox::Discard
| QMessageBox::Cancel );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
Expand Up @@ -233,8 +233,8 @@ void QgsArcGisServiceSourceSelect::deleteEntryOfServerList()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result == QMessageBox::Yes )
{
QgsOwsConnection::deleteConnection( mServiceName, cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/db2/qgsdb2sourceselect.cpp
Expand Up @@ -226,7 +226,7 @@ void QgsDb2SourceSelect::btnDelete_clicked()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
return;

QgsDb2SourceSelect::deleteConnection( cmbConnections->currentText() );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlsourceselect.cpp
Expand Up @@ -231,7 +231,7 @@ void QgsMssqlSourceSelect::btnDelete_clicked()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
return;

QgsMssqlSourceSelect::deleteConnection( cmbConnections->currentText() );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/ogr/qgsogrdbsourceselect.cpp
Expand Up @@ -237,8 +237,8 @@ void QgsOgrDbSourceSelect::btnDelete_clicked()

QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ).arg( subKey );
QMessageBox::StandardButton result =
QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result != QMessageBox::Ok )
QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result != QMessageBox::Yes )
return;

QgsOgrDbConnection::deleteConnection( subKey, ogrDriverName() );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/ogr/qgsogrsourceselect.cpp
Expand Up @@ -172,8 +172,8 @@ void QgsOgrSourceSelect::deleteConnection()
QString key = '/' + cmbDatabaseTypes->currentText() + "/connections/" + cmbConnections->currentText();
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result == QMessageBox::Yes )
{
settings.remove( key + "/host" );
settings.remove( key + "/database" );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspgsourceselect.cpp
Expand Up @@ -303,7 +303,7 @@ void QgsPgSourceSelect::btnDelete_clicked()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
return;

QgsPostgresConn::deleteConnection( cmbConnections->currentText() );
Expand Down
8 changes: 4 additions & 4 deletions src/providers/spatialite/qgsspatialitesourceselect.cpp
Expand Up @@ -151,8 +151,8 @@ void QgsSpatiaLiteSourceSelect::updateStatistics()
"This could take a long time (depending on the DB size), "
"but implies better performance thereafter." ).arg( subKey );
QMessageBox::StandardButton result =
QMessageBox::information( this, tr( "Confirm Update Statistics" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result != QMessageBox::Ok )
QMessageBox::question( this, tr( "Confirm Update Statistics" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result != QMessageBox::Yes )
return;

// trying to connect to SpatiaLite DB
Expand Down Expand Up @@ -365,8 +365,8 @@ void QgsSpatiaLiteSourceSelect::btnDelete_clicked()

QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" ).arg( subKey );
QMessageBox::StandardButton result =
QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result != QMessageBox::Ok )
QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result != QMessageBox::Yes )
return;

QgsSpatiaLiteConnection::deleteConnection( subKey );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/wfs/qgswfssourceselect.cpp
Expand Up @@ -318,8 +318,8 @@ void QgsWFSSourceSelect::deleteEntryOfServerList()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result == QMessageBox::Yes )
{
QgsWfsConnection::deleteConnection( cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() );
Expand Down
8 changes: 4 additions & 4 deletions src/providers/wms/qgswmssourceselect.cpp
Expand Up @@ -202,8 +202,8 @@ void QgsWMSSourceSelect::btnDelete_clicked()
{
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result == QMessageBox::Yes )
{
QgsWMSConnection::deleteConnection( cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() );
Expand Down Expand Up @@ -1234,8 +1234,8 @@ void QgsWMSSourceSelect::btnAddWMS_clicked()
if ( settings.contains( QStringLiteral( "qgis/connections-wms/%1/url" ).arg( wmsTitle ) ) )
{
QString msg = tr( "The %1 connection already exists. Do you want to overwrite it?" ).arg( wmsTitle );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Overwrite" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result != QMessageBox::Ok )
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Overwrite" ), msg, QMessageBox::Yes | QMessageBox::No );
if ( result != QMessageBox::Yes )
{
return;
}
Expand Down

0 comments on commit 9621f38

Please sign in to comment.