Skip to content

Commit e72088c

Browse files
committedSep 12, 2013
[fTools] homogenize UI (contributed by Salvatore Larosa)
1 parent 4a95d35 commit e72088c

27 files changed

+887
-698
lines changed
 

‎python/plugins/fTools/tools/doGeometry.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,13 @@ def runFinishedFromThread( self, success ):
281281
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
282282
if success:
283283
if ( self.myFunction == 5 and self.chkWriteShapefile.isChecked() ) or self.myFunction != 5:
284-
addToTOC = QMessageBox.question( self, self.tr("Geometry"),
285-
self.tr( "Created output shapefile:\n{0}\n{1}\n\nWould you like to add the new layer to the TOC?" ).format( self.shapefileName, extra ),
286-
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
287-
if addToTOC == QMessageBox.Yes:
288-
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
289-
QMessageBox.warning( self, self.tr( "Geometry"),
290-
self.tr( "Error loading output shapefile:\n{0}" ).format( self.shapefileName ) )
284+
if self.addToCanvasCheck.isChecked():
285+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
286+
if not addCanvasCheck:
287+
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
291288
self.populateLayers()
289+
else:
290+
QMessageBox.information(self, self.tr("Geometry"),self.tr("Created output shapefile:\n%s\n%s" ) % ( unicode( self.shapefileName ), extra ))
292291
else:
293292
QMessageBox.information( self, self.tr( "Geometry" ),
294293
self.tr( "Layer '{0}' updated" ).format( self.inShape.currentText() ) )

‎python/plugins/fTools/tools/doGeoprocessing.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ def runFinishedFromThread( self, results ):
247247
out_text = self.tr( "\nWarnings:" )
248248
end_text = self.tr( "\nSome output geometries may be missing or invalid.\n\nWould you like to add the new layer anyway?" )
249249
else:
250-
out_text = "\n"
251-
end_text = self.tr( "\n\nWould you like to add the new layer to the TOC?" )
250+
out_text = ""
251+
end_text = ""
252252
if not results[2] is None:
253253
if not results[2]:
254254
out_text = out_text + self.tr( "\nInput CRS error: Different input coordinate reference systems detected, results may not be as expected.")
@@ -258,11 +258,13 @@ def runFinishedFromThread( self, results ):
258258
out_text = out_text + self.tr( "\nFeature geometry error: One or more output features ignored due to invalid geometry.")
259259
if not results[0]:
260260
out_text = out_text + self.tr( "\nGEOS geoprocessing error: One or more input features have invalid geometry.")
261-
addToTOC = QMessageBox.question( self, self.tr("Geoprocessing"), self.tr( "Created output shapefile:\n%s\n%s%s" ) % ( unicode( self.shapefileName ), out_text, end_text ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
262-
if addToTOC == QMessageBox.Yes:
263-
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
264-
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
261+
if self.addToCanvasCheck.isChecked():
262+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
263+
if not addCanvasCheck:
264+
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
265265
self.populateLayers()
266+
else:
267+
QMessageBox.information(self, self.tr("Geoprocessing"),self.tr("Created output shapefile:\n%s\n%s%s" ) % ( unicode( self.shapefileName ), out_text, end_text ))
266268

267269
def runStatusFromThread( self, status ):
268270
self.progressBar.setValue( status )

‎python/plugins/fTools/tools/doIntersectLines.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ def accept(self):
9595
self.outShape.clear()
9696
self.compute(line1, line2, field1, field2, outPath, self.progressBar)
9797
self.progressBar.setValue(100)
98-
addToTOC = QMessageBox.question(self, self.tr("Generate Centroids"), self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % ( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
99-
if addToTOC == QMessageBox.Yes:
100-
if not ftools_utils.addShapeToCanvas( unicode( outPath ) ):
98+
if self.addToCanvasCheck.isChecked():
99+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
100+
if not addCanvasCheck:
101101
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
102102
self.populateLayers()
103+
else:
104+
QMessageBox.information(self, self.tr("Generate Centroids"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
103105
self.progressBar.setValue(0)
104106
self.buttonOk.setEnabled( True )
105107

‎python/plugins/fTools/tools/doMeanCoords.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ def accept(self):
9090
self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
9191
self.progressBar.setValue(100)
9292
self.outShape.clear()
93-
addToTOC = QMessageBox.question(self, self.tr("Coordinate statistics"), self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % ( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
94-
if addToTOC == QMessageBox.Yes:
95-
vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
96-
QgsMapLayerRegistry.instance().addMapLayers([vlayer])
93+
if self.addToCanvasCheck.isChecked():
94+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
95+
if not addCanvasCheck:
96+
QMessageBox.warning( self, self.tr("Coordinate statistics"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
9797
self.populateLayers()
98+
else:
99+
QMessageBox.information(self, self.tr("Coordinate statistics"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
98100
self.progressBar.setValue(0)
99101
self.buttonOk.setEnabled( True )
100102

‎python/plugins/fTools/tools/doPointsInPolygon.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,13 @@ def updateProgress(self):
112112

113113
def processFinished(self):
114114
self.stopProcessing()
115-
116-
addToTOC = QMessageBox.question(self, self.tr("Count Points in Polygon"),
117-
self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (self.outShape.text()),
118-
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
119-
if addToTOC == QMessageBox.Yes:
120-
fileInfo = QFileInfo( self.outShape.text() )
121-
layerName = fileInfo.completeBaseName()
122-
layer = QgsVectorLayer(self.outShape.text(), layerName, "ogr")
123-
QgsMapLayerRegistry.instance().addMapLayers([layer])
115+
if self.addToCanvasCheck.isChecked():
116+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.outShape.text()))
117+
if not addCanvasCheck:
118+
QMessageBox.warning( self, self.tr("Count Points in Polygon"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
124119
self.populateLayers()
120+
else:
121+
QMessageBox.information(self, self.tr("Count Points in Polygon"),self.tr("Created output shapefile:\n%s" ) % ( unicode( self.outShape.text() )))
125122

126123
self.restoreGui()
127124

‎python/plugins/fTools/tools/doRandPoints.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ def accept(self):
119119
if self.randomize(inLayer, outPath, minimum, design, value):
120120
self.progressBar.setValue(100)
121121
self.outShape.clear()
122-
addToTOC = QMessageBox.question(self, self.tr("Random Points"),
123-
self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (outPath), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
124-
if addToTOC == QMessageBox.Yes:
125-
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
126-
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
127-
self.populateLayers()
122+
if self.addToCanvasCheck.isChecked():
123+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
124+
if not addCanvasCheck:
125+
QMessageBox.warning( self, self.tr("Random Points"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
126+
self.populateLayers()
127+
else:
128+
QMessageBox.information(self, self.tr("Random Points"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
128129
self.progressBar.setValue(0)
129130
self.buttonOk.setEnabled( True )
130131

‎python/plugins/fTools/tools/doRegPoints.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ def accept(self):
8484
print crs.isValid()
8585
if not crs.isValid(): crs = None
8686
self.regularize(boundBox, outPath, offset, value, self.rdoSpacing.isChecked(), self.spnInset.value(), crs)
87-
addToTOC = QMessageBox.question(self, self.tr("Generate Regular Points"), self.tr("Created output point shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % ( outPath ), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
88-
if addToTOC == QMessageBox.Yes:
89-
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
90-
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
87+
if self.addToCanvasCheck.isChecked():
88+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
89+
if not addCanvasCheck:
90+
QMessageBox.warning( self, self.tr("Generate Regular Points"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
9191
self.populateLayers()
92+
else:
93+
QMessageBox.information(self, self.tr("Generate Regular Points"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
9294
self.progressBar.setValue(0)
9395
self.buttonOk.setEnabled( True )
9496

‎python/plugins/fTools/tools/doSumLines.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ def accept(self):
7373
outName = ftools_utils.getShapefileName( outPath )
7474
self.compute(inPoly, inLns, inField, outPath, self.progressBar)
7575
self.outShape.clear()
76-
addToTOC = QMessageBox.question(self, self.tr("Sum line lengths"), self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (unicode(outPath)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
77-
if addToTOC == QMessageBox.Yes:
78-
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
79-
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
76+
if self.addToCanvasCheck.isChecked():
77+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
78+
if not addCanvasCheck:
79+
QMessageBox.warning( self, self.tr("Sum line lengths"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
8080
self.populateLayers()
81+
else:
82+
QMessageBox.information(self, self.tr("Sum line lengths"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
8183
self.progressBar.setValue(0)
8284
self.buttonOk.setEnabled( True )
8385

‎python/plugins/fTools/tools/doValidate.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def updateGui( self ):
135135
if self.ckBoxShpError.isChecked():
136136
self.lineEditShpError.setEnabled( True )
137137
self.browseShpError.setEnabled( True )
138+
self.addToCanvasCheck.setEnabled(True)
138139
self.tblUnique.setEnabled( False )
139140
self.lstCount.setEnabled( False )
140141
self.label_2.setEnabled( False )
@@ -143,6 +144,7 @@ def updateGui( self ):
143144
else:
144145
self.lineEditShpError.setEnabled( False )
145146
self.browseShpError.setEnabled( False )
147+
self.addToCanvasCheck.setEnabled(False)
146148
self.tblUnique.setEnabled( True )
147149
self.lstCount.setEnabled( True )
148150
self.label_2.setEnabled( True )
@@ -227,13 +229,12 @@ def runFinishedFromThread( self, success ):
227229
self.buttonOk.setEnabled( True )
228230
if success == "writeShape":
229231
extra = ""
230-
addToTOC = QMessageBox.question( self, self.tr("Geometry"),
231-
self.tr( "Created output shapefile:\n%s\n%s\n\nWould you like to add the new layer to the TOC?" ) % ( unicode( self.shapefileName ), extra ),
232-
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
233-
if addToTOC == QMessageBox.Yes:
234-
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
235-
QMessageBox.warning( self, self.tr( "Geometry"),
236-
self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ) )
232+
if self.addToCanvasCheck.isChecked():
233+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
234+
if not addCanvasCheck:
235+
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
236+
else:
237+
QMessageBox.information(self, self.tr("Geometry"),self.tr("Created output shapefile:\n%s\n%s" ) % ( unicode( self.shapefileName ), extra))
237238
else:
238239
self.tblUnique.setColumnCount( 2 )
239240
count = 0

‎python/plugins/fTools/tools/doVectorGrid.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,13 @@ def accept(self):
146146
QApplication.setOverrideCursor(Qt.WaitCursor)
147147
self.compute( boundBox, xSpace, ySpace, polygon )
148148
QApplication.restoreOverrideCursor()
149-
addToTOC = QMessageBox.question(self, self.tr("Generate Vector Grid"), self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (unicode(self.shapefileName)), QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
150-
if addToTOC == QMessageBox.Yes:
151-
ftools_utils.addShapeToCanvas( self.shapefileName )
149+
if self.addToCanvasCheck.isChecked():
150+
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
151+
if not addCanvasCheck:
152+
QMessageBox.warning( self, self.tr("Generate Vector Grid"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
152153
self.populateLayers()
154+
else:
155+
QMessageBox.information(self, self.tr("Generate Vector Grid"),self.tr("Created output shapefile:\n%s" ) % ( unicode( self.shapefileName )))
153156
self.progressBar.setValue( 0 )
154157
self.buttonOk.setEnabled( True )
155158

‎python/plugins/fTools/tools/doVisual.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__( self, iface, function ):
4848
self.lineEditShpError.hide()
4949
self.label_6.hide()
5050
self.line.hide()
51+
self.addToCanvasCheck.hide()
5152
self.buttonBox_2.setOrientation(Qt.Horizontal)
5253

5354
if self.myFunction == 2 or self.myFunction == 3:

‎python/plugins/fTools/tools/frmEliminate.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>436</width>
10-
<height>218</height>
10+
<height>242</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -38,7 +38,7 @@
3838
</widget>
3939
</item>
4040
<item>
41-
<widget class="QToolButton" name="toolOut">
41+
<widget class="QPushButton" name="toolOut">
4242
<property name="text">
4343
<string>Browse</string>
4444
</property>

0 commit comments

Comments
 (0)
Please sign in to comment.