Skip to content

Commit

Permalink
[processing] Fix some incorrect formatting of algorithm titles
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 31, 2018
1 parent 4752b99 commit 59d425c
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 12 deletions.
Expand Up @@ -43,6 +43,7 @@ Abstract base class for processing algorithms.
FlagCanCancel,
FlagRequiresMatchingCrs,
FlagNoThreading,
FlagDisplayNameIsLiteral,
FlagDeprecated,
};
typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/OgrToPostGis.py
Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/algs/gdal/buildvrt.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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'))
Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/gdal/fillnodata.py
Expand Up @@ -27,7 +27,8 @@

import os

from qgis.core import (QgsRasterFileWriter,
from qgis.core import (QgsProcessingAlgorithm,
QgsRasterFileWriter,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
Expand Down Expand Up @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/gdal/gdal2tiles.py
Expand Up @@ -26,7 +26,8 @@
__revision__ = '$Format:%H$'


from qgis.core import (QgsProcessingException,
from qgis.core import (QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingParameterDefinition,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterCrs,
Expand Down Expand Up @@ -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 = []

Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/gdal/gdal2xyz.py
Expand Up @@ -25,7 +25,8 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessing,
from qgis.core import (QgsProcessingAlgorithm,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
Expand Down Expand Up @@ -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')
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/gdal/gdaltindex.py
Expand Up @@ -31,6 +31,7 @@

from qgis.core import (QgsMapLayer,
QgsProcessing,
QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingParameterCrs,
QgsProcessingParameterEnum,
Expand Down Expand Up @@ -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')
Expand Down
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -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 == '':
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/menus.py
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/core/processing/qgsprocessingalgorithm.h
Expand Up @@ -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 )
Expand Down
7 changes: 6 additions & 1 deletion src/gui/processing/qgsprocessingalgorithmdialogbase.cpp
Expand Up @@ -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() )
Expand Down

0 comments on commit 59d425c

Please sign in to comment.