Skip to content
Permalink
Browse files

[processing] Fix some incorrect formatting of algorithm titles

  • Loading branch information
nyalldawson committed May 30, 2018
1 parent 4752b99 commit 59d425c5b0d6ecadeaa96a78bd7e42c12bea402b
@@ -43,6 +43,7 @@ Abstract base class for processing algorithms.
FlagCanCancel,
FlagRequiresMatchingCrs,
FlagNoThreading,
FlagDisplayNameIsLiteral,
FlagDeprecated,
};
typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;
@@ -158,7 +158,7 @@ def name(self):
return 'importvectorintopostgisdatabasenewconnection'

def displayName(self):
return self.tr('Import Vector into PostGIS database (new connection)')
return self.tr('Import vector into PostGIS database (new connection)')

def group(self):
return self.tr('Vector miscellaneous')
@@ -30,7 +30,8 @@
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtGui import QIcon

from qgis.core import (QgsProcessing,
from qgis.core import (QgsProcessingAlgorithm,
QgsProcessing,
QgsProperty,
QgsProcessingParameterMultipleLayers,
QgsProcessingParameterEnum,
@@ -93,7 +94,7 @@ def name(self):
return 'buildvirtualraster'

def displayName(self):
return QCoreApplication.translate("buildvrt", 'Build Virtual Raster')
return QCoreApplication.translate("buildvrt", 'Build virtual raster')

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'vrt.png'))
@@ -27,7 +27,8 @@

import os

from qgis.core import (QgsRasterFileWriter,
from qgis.core import (QgsProcessingAlgorithm,
QgsRasterFileWriter,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
@@ -93,6 +94,9 @@ def groupId(self):
def commandName(self):
return 'gdal_fillnodata'

def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-md')
@@ -26,7 +26,8 @@
__revision__ = '$Format:%H$'


from qgis.core import (QgsProcessingException,
from qgis.core import (QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingParameterDefinition,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterCrs,
@@ -158,6 +159,9 @@ def groupId(self):
def commandName(self):
return 'gdal2tiles'

def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []

@@ -25,7 +25,8 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessing,
from qgis.core import (QgsProcessingAlgorithm,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
@@ -75,6 +76,9 @@ def groupId(self):
def commandName(self):
return 'gdal2xyz'

def flags(self):
return super().flags() | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-band')
@@ -31,6 +31,7 @@

from qgis.core import (QgsMapLayer,
QgsProcessing,
QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingParameterCrs,
QgsProcessingParameterEnum,
@@ -106,7 +107,7 @@ def name(self):
return 'tileindex'

def displayName(self):
return self.tr('Tile Index')
return self.tr('Tile index')

def group(self):
return self.tr('Raster miscellaneous')
@@ -171,7 +171,7 @@ def name(self):
return 'importvectorintopostgisdatabaseavailableconnections'

def displayName(self):
return self.tr('Import Vector into PostGIS database (available connections)')
return self.tr('Import vector into PostGIS database (available connections)')

def group(self):
return self.tr('Vector miscellaneous')
@@ -160,7 +160,7 @@ def svgIconPath(self):

def flags(self):
# TODO - maybe it's safe to background thread this?
return super().flags() | QgsProcessingAlgorithm.FlagNoThreading
return super().flags() | QgsProcessingAlgorithm.FlagNoThreading | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral

def tr(self, string, context=''):
if context == '':
@@ -32,7 +32,7 @@
from processing.gui.MessageDialog import MessageDialog
from processing.gui.AlgorithmDialog import AlgorithmDialog
from qgis.utils import iface
from qgis.core import QgsApplication, QgsMessageLog, QgsStringUtils
from qgis.core import QgsApplication, QgsMessageLog, QgsStringUtils, QgsProcessingAlgorithm
from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.AlgorithmExecutor import execute
from processing.gui.Postprocessing import handleAlgorithmResults
@@ -183,7 +183,11 @@ def removeMenus():

def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, addButton=False):
if actionText is None:
actionText = QgsStringUtils.capitalize(alg.displayName(), QgsStringUtils.TitleCase) + QCoreApplication.translate('Processing', '…')
if alg.flags() & QgsProcessingAlgorithm.FlagDisplayNameIsLiteral:
alg_title = alg.displayName()
else:
alg_title = QgsStringUtils.capitalize(alg.displayName(), QgsStringUtils.TitleCase)
actionText = alg_title + QCoreApplication.translate('Processing', '…')
action = QAction(icon or alg.icon(), actionText, iface.mainWindow())
action.setData(alg.id())
action.triggered.connect(lambda: _executeAlgorithm(alg))
@@ -73,6 +73,7 @@ class CORE_EXPORT QgsProcessingAlgorithm
FlagCanCancel = 1 << 4, //!< Algorithm can be canceled
FlagRequiresMatchingCrs = 1 << 5, //!< Algorithm requires that all input layers have matching coordinate reference systems
FlagNoThreading = 1 << 6, //!< Algorithm is not thread safe and cannot be run in a background thread, e.g. for algorithms which manipulate the current project, layer selections, or with external dependencies which are not thread-safe.
FlagDisplayNameIsLiteral = 1 << 7, //!< Algorithm's display name is a static literal string, and should not be translated or automatically formatted. For use with algorithms named after commands, e.g. GRASS 'v.in.ogr'.
FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler, //!< Algorithm is deprecated
};
Q_DECLARE_FLAGS( Flags, Flag )
@@ -127,7 +127,12 @@ QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *par
void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *algorithm )
{
mAlgorithm = algorithm;
setWindowTitle( QgsStringUtils::capitalize( mAlgorithm->displayName(), QgsStringUtils::TitleCase ) );
QString title;
if ( algorithm->flags() & QgsProcessingAlgorithm::FlagDisplayNameIsLiteral )
title = mAlgorithm->displayName();
else
title = QgsStringUtils::capitalize( mAlgorithm->displayName(), QgsStringUtils::TitleCase );
setWindowTitle( title );

QString algHelp = formatHelp( algorithm );
if ( algHelp.isEmpty() )

0 comments on commit 59d425c

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