Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[fTools] homogenize UI (contributed by Salvatore Larosa)
  • Loading branch information
alexbruy committed Sep 12, 2013
1 parent 4a95d35 commit e72088c
Show file tree
Hide file tree
Showing 27 changed files with 887 additions and 698 deletions.
13 changes: 6 additions & 7 deletions python/plugins/fTools/tools/doGeometry.py
Expand Up @@ -281,14 +281,13 @@ def runFinishedFromThread( self, success ):
QObject.disconnect( self.cancel_close, SIGNAL( "clicked()" ), self.cancelThread )
if success:
if ( self.myFunction == 5 and self.chkWriteShapefile.isChecked() ) or self.myFunction != 5:
addToTOC = QMessageBox.question( self, self.tr("Geometry"),
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 ),
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
if addToTOC == QMessageBox.Yes:
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
QMessageBox.warning( self, self.tr( "Geometry"),
self.tr( "Error loading output shapefile:\n{0}" ).format( self.shapefileName ) )
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Geometry"),self.tr("Created output shapefile:\n%s\n%s" ) % ( unicode( self.shapefileName ), extra ))
else:
QMessageBox.information( self, self.tr( "Geometry" ),
self.tr( "Layer '{0}' updated" ).format( self.inShape.currentText() ) )
Expand Down
14 changes: 8 additions & 6 deletions python/plugins/fTools/tools/doGeoprocessing.py
Expand Up @@ -247,8 +247,8 @@ def runFinishedFromThread( self, results ):
out_text = self.tr( "\nWarnings:" )
end_text = self.tr( "\nSome output geometries may be missing or invalid.\n\nWould you like to add the new layer anyway?" )
else:
out_text = "\n"
end_text = self.tr( "\n\nWould you like to add the new layer to the TOC?" )
out_text = ""
end_text = ""
if not results[2] is None:
if not results[2]:
out_text = out_text + self.tr( "\nInput CRS error: Different input coordinate reference systems detected, results may not be as expected.")
Expand All @@ -258,11 +258,13 @@ def runFinishedFromThread( self, results ):
out_text = out_text + self.tr( "\nFeature geometry error: One or more output features ignored due to invalid geometry.")
if not results[0]:
out_text = out_text + self.tr( "\nGEOS geoprocessing error: One or more input features have invalid geometry.")
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 )
if addToTOC == QMessageBox.Yes:
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Geoprocessing"),self.tr("Created output shapefile:\n%s\n%s%s" ) % ( unicode( self.shapefileName ), out_text, end_text ))

def runStatusFromThread( self, status ):
self.progressBar.setValue( status )
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/fTools/tools/doIntersectLines.py
Expand Up @@ -95,11 +95,13 @@ def accept(self):
self.outShape.clear()
self.compute(line1, line2, field1, field2, outPath, self.progressBar)
self.progressBar.setValue(100)
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)
if addToTOC == QMessageBox.Yes:
if not ftools_utils.addShapeToCanvas( unicode( outPath ) ):
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Geoprocessing"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Generate Centroids"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down
10 changes: 6 additions & 4 deletions python/plugins/fTools/tools/doMeanCoords.py
Expand Up @@ -90,11 +90,13 @@ def accept(self):
self.compute(inName, outPath, self.weightField.currentText(), self.sizeValue.value(), self.uniqueField.currentText())
self.progressBar.setValue(100)
self.outShape.clear()
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)
if addToTOC == QMessageBox.Yes:
vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([vlayer])
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Coordinate statistics"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Coordinate statistics"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down
15 changes: 6 additions & 9 deletions python/plugins/fTools/tools/doPointsInPolygon.py
Expand Up @@ -112,16 +112,13 @@ def updateProgress(self):

def processFinished(self):
self.stopProcessing()

addToTOC = QMessageBox.question(self, self.tr("Count Points in Polygon"),
self.tr("Created output shapefile:\n%s\n\nWould you like to add the new layer to the TOC?") % (self.outShape.text()),
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton)
if addToTOC == QMessageBox.Yes:
fileInfo = QFileInfo( self.outShape.text() )
layerName = fileInfo.completeBaseName()
layer = QgsVectorLayer(self.outShape.text(), layerName, "ogr")
QgsMapLayerRegistry.instance().addMapLayers([layer])
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.outShape.text()))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Count Points in Polygon"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Count Points in Polygon"),self.tr("Created output shapefile:\n%s" ) % ( unicode( self.outShape.text() )))

self.restoreGui()

Expand Down
13 changes: 7 additions & 6 deletions python/plugins/fTools/tools/doRandPoints.py
Expand Up @@ -119,12 +119,13 @@ def accept(self):
if self.randomize(inLayer, outPath, minimum, design, value):
self.progressBar.setValue(100)
self.outShape.clear()
addToTOC = QMessageBox.question(self, self.tr("Random 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)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
self.populateLayers()
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Random Points"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Random Points"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down
10 changes: 6 additions & 4 deletions python/plugins/fTools/tools/doRegPoints.py
Expand Up @@ -84,11 +84,13 @@ def accept(self):
print crs.isValid()
if not crs.isValid(): crs = None
self.regularize(boundBox, outPath, offset, value, self.rdoSpacing.isChecked(), self.spnInset.value(), crs)
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)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Generate Regular Points"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Generate Regular Points"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down
10 changes: 6 additions & 4 deletions python/plugins/fTools/tools/doSumLines.py
Expand Up @@ -73,11 +73,13 @@ def accept(self):
outName = ftools_utils.getShapefileName( outPath )
self.compute(inPoly, inLns, inField, outPath, self.progressBar)
self.outShape.clear()
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)
if addToTOC == QMessageBox.Yes:
self.vlayer = QgsVectorLayer(outPath, unicode(outName), "ogr")
QgsMapLayerRegistry.instance().addMapLayers([self.vlayer])
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(outPath))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Sum line lengths"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( outPath ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Sum line lengths"),self.tr("Created output shapefile:\n%s" ) % ( unicode( outPath )))
self.progressBar.setValue(0)
self.buttonOk.setEnabled( True )

Expand Down
15 changes: 8 additions & 7 deletions python/plugins/fTools/tools/doValidate.py
Expand Up @@ -135,6 +135,7 @@ def updateGui( self ):
if self.ckBoxShpError.isChecked():
self.lineEditShpError.setEnabled( True )
self.browseShpError.setEnabled( True )
self.addToCanvasCheck.setEnabled(True)
self.tblUnique.setEnabled( False )
self.lstCount.setEnabled( False )
self.label_2.setEnabled( False )
Expand All @@ -143,6 +144,7 @@ def updateGui( self ):
else:
self.lineEditShpError.setEnabled( False )
self.browseShpError.setEnabled( False )
self.addToCanvasCheck.setEnabled(False)
self.tblUnique.setEnabled( True )
self.lstCount.setEnabled( True )
self.label_2.setEnabled( True )
Expand Down Expand Up @@ -227,13 +229,12 @@ def runFinishedFromThread( self, success ):
self.buttonOk.setEnabled( True )
if success == "writeShape":
extra = ""
addToTOC = QMessageBox.question( self, self.tr("Geometry"),
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 ),
QMessageBox.Yes, QMessageBox.No, QMessageBox.NoButton )
if addToTOC == QMessageBox.Yes:
if not ftools_utils.addShapeToCanvas( unicode( self.shapefileName ) ):
QMessageBox.warning( self, self.tr( "Geometry"),
self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ) )
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Geometry"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
else:
QMessageBox.information(self, self.tr("Geometry"),self.tr("Created output shapefile:\n%s\n%s" ) % ( unicode( self.shapefileName ), extra))
else:
self.tblUnique.setColumnCount( 2 )
count = 0
Expand Down
9 changes: 6 additions & 3 deletions python/plugins/fTools/tools/doVectorGrid.py
Expand Up @@ -146,10 +146,13 @@ def accept(self):
QApplication.setOverrideCursor(Qt.WaitCursor)
self.compute( boundBox, xSpace, ySpace, polygon )
QApplication.restoreOverrideCursor()
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)
if addToTOC == QMessageBox.Yes:
ftools_utils.addShapeToCanvas( self.shapefileName )
if self.addToCanvasCheck.isChecked():
addCanvasCheck = ftools_utils.addShapeToCanvas(unicode(self.shapefileName))
if not addCanvasCheck:
QMessageBox.warning( self, self.tr("Generate Vector Grid"), self.tr( "Error loading output shapefile:\n%s" ) % ( unicode( self.shapefileName ) ))
self.populateLayers()
else:
QMessageBox.information(self, self.tr("Generate Vector Grid"),self.tr("Created output shapefile:\n%s" ) % ( unicode( self.shapefileName )))
self.progressBar.setValue( 0 )
self.buttonOk.setEnabled( True )

Expand Down
1 change: 1 addition & 0 deletions python/plugins/fTools/tools/doVisual.py
Expand Up @@ -48,6 +48,7 @@ def __init__( self, iface, function ):
self.lineEditShpError.hide()
self.label_6.hide()
self.line.hide()
self.addToCanvasCheck.hide()
self.buttonBox_2.setOrientation(Qt.Horizontal)

if self.myFunction == 2 or self.myFunction == 3:
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/fTools/tools/frmEliminate.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>436</width>
<height>218</height>
<height>242</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -38,7 +38,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="toolOut">
<widget class="QPushButton" name="toolOut">
<property name="text">
<string>Browse</string>
</property>
Expand Down

0 comments on commit e72088c

Please sign in to comment.