Skip to content

Commit 9621f38

Browse files
committed
Use QMessageBox::question instead of information when asking a question
And where appropriate use Yes/No choices instead of Ok/Cancel
1 parent aa3a335 commit 9621f38

15 files changed

+45
-45
lines changed

src/app/qgisapp.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -8581,10 +8581,10 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
85818581
if ( allowCancel )
85828582
buttons |= QMessageBox::Cancel;
85838583

8584-
switch ( QMessageBox::information( nullptr,
8585-
tr( "Stop editing" ),
8586-
tr( "Do you want to save the changes to layer %1?" ).arg( vlayer->name() ),
8587-
buttons ) )
8584+
switch ( QMessageBox::question( nullptr,
8585+
tr( "Stop editing" ),
8586+
tr( "Do you want to save the changes to layer %1?" ).arg( vlayer->name() ),
8587+
buttons ) )
85888588
{
85898589
case QMessageBox::Cancel:
85908590
res = false;
@@ -8692,12 +8692,12 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable, bool triggerR
86928692
if ( !vlayer->rollBack( !leaveEditable ) )
86938693
{
86948694
mSaveRollbackInProgress = false;
8695-
QMessageBox::information( nullptr,
8696-
tr( "Error" ),
8697-
tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" )
8698-
.arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ),
8699-
vlayer->name(),
8700-
vlayer->commitErrors().join( QStringLiteral( "\n " ) ) ) );
8695+
QMessageBox::warning( nullptr,
8696+
tr( "Error" ),
8697+
tr( "Could not %1 changes to layer %2\n\nErrors: %3\n" )
8698+
.arg( leaveEditable ? tr( "rollback" ) : tr( "cancel" ),
8699+
vlayer->name(),
8700+
vlayer->commitErrors().join( QStringLiteral( "\n " ) ) ) );
87018701
}
87028702
freezeCanvases( false );
87038703

@@ -10396,11 +10396,11 @@ bool QgisApp::saveDirty()
1039610396
// old code: mProjectIsDirtyFlag = true;
1039710397

1039810398
// prompt user to save
10399-
answer = QMessageBox::information( this, tr( "Save Project?" ),
10400-
tr( "Do you want to save the current project? %1" )
10401-
.arg( whyDirty ),
10402-
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard,
10403-
hasUnsavedEdits ? QMessageBox::Cancel : QMessageBox::Save );
10399+
answer = QMessageBox::question( this, tr( "Save Project?" ),
10400+
tr( "Do you want to save the current project? %1" )
10401+
.arg( whyDirty ),
10402+
QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard,
10403+
hasUnsavedEdits ? QMessageBox::Cancel : QMessageBox::Save );
1040410404
if ( QMessageBox::Save == answer )
1040510405
{
1040610406
if ( !fileSave() )

src/app/qgsbookmarks.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ void QgsBookmarks::deleteClicked()
210210
return;
211211

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

218218
// Remove in reverse order to keep the merged model indexes

src/app/qgsguivectorlayertools.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ bool QgsGuiVectorLayerTools::stopEditing( QgsVectorLayer *layer, bool allowCance
102102
if ( allowCancel )
103103
buttons |= QMessageBox::Cancel;
104104

105-
switch ( QMessageBox::information( nullptr,
106-
tr( "Stop editing" ),
107-
tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ),
108-
buttons ) )
105+
switch ( QMessageBox::question( nullptr,
106+
tr( "Stop editing" ),
107+
tr( "Do you want to save the changes to layer %1?" ).arg( layer->name() ),
108+
buttons ) )
109109
{
110110
case QMessageBox::Cancel:
111111
res = false;

src/gui/qgsattributeform.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
129129
if ( mUnsavedMultiEditChanges )
130130
{
131131
// prompt for save
132-
int res = QMessageBox::information( this, tr( "Multiedit attributes" ),
133-
tr( "Apply changes to edited features?" ), QMessageBox::Yes | QMessageBox::No );
132+
int res = QMessageBox::question( this, tr( "Multiedit attributes" ),
133+
tr( "Apply changes to edited features?" ), QMessageBox::Yes | QMessageBox::No );
134134
if ( res == QMessageBox::Yes )
135135
{
136136
save();

src/gui/qgsowssourceselect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ void QgsOWSSourceSelect::mDeleteButton_clicked()
289289
{
290290
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
291291
.arg( mConnectionsComboBox->currentText() );
292-
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
293-
if ( result == QMessageBox::Ok )
292+
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
293+
if ( result == QMessageBox::Yes )
294294
{
295295
QgsOwsConnection::deleteConnection( mService, mConnectionsComboBox->currentText() );
296296
mConnectionsComboBox->removeItem( mConnectionsComboBox->currentIndex() ); // populateConnectionList();

src/plugins/georeferencer/qgsgeorefplugingui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ QgsGeorefPluginGui::SaveGCPs QgsGeorefPluginGui::checkNeedGCPSave()
13101310

13111311
if ( !equalGCPlists( mInitialPoints, mPoints ) )
13121312
{
1313-
QMessageBox::StandardButton a = QMessageBox::information( this, tr( "Save GCPs" ),
1313+
QMessageBox::StandardButton a = QMessageBox::question( this, tr( "Save GCPs" ),
13141314
tr( "Save GCP points?" ),
13151315
QMessageBox::Save | QMessageBox::Discard
13161316
| QMessageBox::Cancel );

src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ void QgsArcGisServiceSourceSelect::deleteEntryOfServerList()
233233
{
234234
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
235235
.arg( cmbConnections->currentText() );
236-
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
237-
if ( result == QMessageBox::Ok )
236+
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
237+
if ( result == QMessageBox::Yes )
238238
{
239239
QgsOwsConnection::deleteConnection( mServiceName, cmbConnections->currentText() );
240240
cmbConnections->removeItem( cmbConnections->currentIndex() );

src/providers/db2/qgsdb2sourceselect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void QgsDb2SourceSelect::btnDelete_clicked()
226226
{
227227
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
228228
.arg( cmbConnections->currentText() );
229-
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
229+
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
230230
return;
231231

232232
QgsDb2SourceSelect::deleteConnection( cmbConnections->currentText() );

src/providers/mssql/qgsmssqlsourceselect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void QgsMssqlSourceSelect::btnDelete_clicked()
231231
{
232232
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
233233
.arg( cmbConnections->currentText() );
234-
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
234+
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
235235
return;
236236

237237
QgsMssqlSourceSelect::deleteConnection( cmbConnections->currentText() );

src/providers/ogr/qgsogrdbsourceselect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ void QgsOgrDbSourceSelect::btnDelete_clicked()
237237

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

244244
QgsOgrDbConnection::deleteConnection( subKey, ogrDriverName() );

src/providers/ogr/qgsogrsourceselect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ void QgsOgrSourceSelect::deleteConnection()
172172
QString key = '/' + cmbDatabaseTypes->currentText() + "/connections/" + cmbConnections->currentText();
173173
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
174174
.arg( cmbConnections->currentText() );
175-
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
176-
if ( result == QMessageBox::Ok )
175+
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
176+
if ( result == QMessageBox::Yes )
177177
{
178178
settings.remove( key + "/host" );
179179
settings.remove( key + "/database" );

src/providers/postgres/qgspgsourceselect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void QgsPgSourceSelect::btnDelete_clicked()
303303
{
304304
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
305305
.arg( cmbConnections->currentText() );
306-
if ( QMessageBox::Ok != QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel ) )
306+
if ( QMessageBox::Yes != QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
307307
return;
308308

309309
QgsPostgresConn::deleteConnection( cmbConnections->currentText() );

src/providers/spatialite/qgsspatialitesourceselect.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ void QgsSpatiaLiteSourceSelect::updateStatistics()
151151
"This could take a long time (depending on the DB size), "
152152
"but implies better performance thereafter." ).arg( subKey );
153153
QMessageBox::StandardButton result =
154-
QMessageBox::information( this, tr( "Confirm Update Statistics" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
155-
if ( result != QMessageBox::Ok )
154+
QMessageBox::question( this, tr( "Confirm Update Statistics" ), msg, QMessageBox::Yes | QMessageBox::No );
155+
if ( result != QMessageBox::Yes )
156156
return;
157157

158158
// trying to connect to SpatiaLite DB
@@ -365,8 +365,8 @@ void QgsSpatiaLiteSourceSelect::btnDelete_clicked()
365365

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

372372
QgsSpatiaLiteConnection::deleteConnection( subKey );

src/providers/wfs/qgswfssourceselect.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ void QgsWFSSourceSelect::deleteEntryOfServerList()
318318
{
319319
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
320320
.arg( cmbConnections->currentText() );
321-
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
322-
if ( result == QMessageBox::Ok )
321+
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
322+
if ( result == QMessageBox::Yes )
323323
{
324324
QgsWfsConnection::deleteConnection( cmbConnections->currentText() );
325325
cmbConnections->removeItem( cmbConnections->currentIndex() );

src/providers/wms/qgswmssourceselect.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ void QgsWMSSourceSelect::btnDelete_clicked()
202202
{
203203
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
204204
.arg( cmbConnections->currentText() );
205-
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
206-
if ( result == QMessageBox::Ok )
205+
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No );
206+
if ( result == QMessageBox::Yes )
207207
{
208208
QgsWMSConnection::deleteConnection( cmbConnections->currentText() );
209209
cmbConnections->removeItem( cmbConnections->currentIndex() );
@@ -1234,8 +1234,8 @@ void QgsWMSSourceSelect::btnAddWMS_clicked()
12341234
if ( settings.contains( QStringLiteral( "qgis/connections-wms/%1/url" ).arg( wmsTitle ) ) )
12351235
{
12361236
QString msg = tr( "The %1 connection already exists. Do you want to overwrite it?" ).arg( wmsTitle );
1237-
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Overwrite" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
1238-
if ( result != QMessageBox::Ok )
1237+
QMessageBox::StandardButton result = QMessageBox::question( this, tr( "Confirm Overwrite" ), msg, QMessageBox::Yes | QMessageBox::No );
1238+
if ( result != QMessageBox::Yes )
12391239
{
12401240
return;
12411241
}

0 commit comments

Comments
 (0)