Skip to content
Permalink
Browse files

Use QMessageBox::question instead of information when asking a question

And where appropriate use Yes/No choices instead of Ok/Cancel
  • Loading branch information
nyalldawson committed Feb 6, 2018
1 parent aa3a335 commit 9621f38330d3f5c7727665b621865736e4d77538
@@ -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;
@@ -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 );

@@ -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() )
@@ -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
@@ -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;
@@ -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();
@@ -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();
@@ -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 );
@@ -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() );
@@ -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() );
@@ -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() );
@@ -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() );
@@ -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" );
@@ -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() );
@@ -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
@@ -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 );
@@ -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() );
@@ -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() );
@@ -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;
}

0 comments on commit 9621f38

Please sign in to comment.
You can’t perform that action at this time.