Skip to content

Commit 59d425c

Browse files
committedMay 31, 2018
[processing] Fix some incorrect formatting of algorithm titles
1 parent 4752b99 commit 59d425c

File tree

12 files changed

+37
-12
lines changed

12 files changed

+37
-12
lines changed
 

‎python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Abstract base class for processing algorithms.
4343
FlagCanCancel,
4444
FlagRequiresMatchingCrs,
4545
FlagNoThreading,
46+
FlagDisplayNameIsLiteral,
4647
FlagDeprecated,
4748
};
4849
typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;

‎python/plugins/processing/algs/gdal/OgrToPostGis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def name(self):
158158
return 'importvectorintopostgisdatabasenewconnection'
159159

160160
def displayName(self):
161-
return self.tr('Import Vector into PostGIS database (new connection)')
161+
return self.tr('Import vector into PostGIS database (new connection)')
162162

163163
def group(self):
164164
return self.tr('Vector miscellaneous')

‎python/plugins/processing/algs/gdal/buildvrt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
from qgis.PyQt.QtCore import QCoreApplication
3131
from qgis.PyQt.QtGui import QIcon
3232

33-
from qgis.core import (QgsProcessing,
33+
from qgis.core import (QgsProcessingAlgorithm,
34+
QgsProcessing,
3435
QgsProperty,
3536
QgsProcessingParameterMultipleLayers,
3637
QgsProcessingParameterEnum,
@@ -93,7 +94,7 @@ def name(self):
9394
return 'buildvirtualraster'
9495

9596
def displayName(self):
96-
return QCoreApplication.translate("buildvrt", 'Build Virtual Raster')
97+
return QCoreApplication.translate("buildvrt", 'Build virtual raster')
9798

9899
def icon(self):
99100
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'vrt.png'))

‎python/plugins/processing/algs/gdal/fillnodata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
import os
2929

30-
from qgis.core import (QgsRasterFileWriter,
30+
from qgis.core import (QgsProcessingAlgorithm,
31+
QgsRasterFileWriter,
3132
QgsProcessingException,
3233
QgsProcessingParameterRasterLayer,
3334
QgsProcessingParameterBand,
@@ -93,6 +94,9 @@ def groupId(self):
9394
def commandName(self):
9495
return 'gdal_fillnodata'
9596

97+
def flags(self):
98+
return super().flags() | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral
99+
96100
def getConsoleCommands(self, parameters, context, feedback, executing=True):
97101
arguments = []
98102
arguments.append('-md')

‎python/plugins/processing/algs/gdal/gdal2tiles.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
__revision__ = '$Format:%H$'
2727

2828

29-
from qgis.core import (QgsProcessingException,
29+
from qgis.core import (QgsProcessingAlgorithm,
30+
QgsProcessingException,
3031
QgsProcessingParameterDefinition,
3132
QgsProcessingParameterRasterLayer,
3233
QgsProcessingParameterCrs,
@@ -158,6 +159,9 @@ def groupId(self):
158159
def commandName(self):
159160
return 'gdal2tiles'
160161

162+
def flags(self):
163+
return super().flags() | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral
164+
161165
def getConsoleCommands(self, parameters, context, feedback, executing=True):
162166
arguments = []
163167

‎python/plugins/processing/algs/gdal/gdal2xyz.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28-
from qgis.core import (QgsProcessing,
28+
from qgis.core import (QgsProcessingAlgorithm,
29+
QgsProcessing,
2930
QgsProcessingException,
3031
QgsProcessingParameterRasterLayer,
3132
QgsProcessingParameterBand,
@@ -75,6 +76,9 @@ def groupId(self):
7576
def commandName(self):
7677
return 'gdal2xyz'
7778

79+
def flags(self):
80+
return super().flags() | QgsProcessingAlgorithm.FlagDisplayNameIsLiteral
81+
7882
def getConsoleCommands(self, parameters, context, feedback, executing=True):
7983
arguments = []
8084
arguments.append('-band')

‎python/plugins/processing/algs/gdal/gdaltindex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from qgis.core import (QgsMapLayer,
3333
QgsProcessing,
34+
QgsProcessingAlgorithm,
3435
QgsProcessingException,
3536
QgsProcessingParameterCrs,
3637
QgsProcessingParameterEnum,
@@ -106,7 +107,7 @@ def name(self):
106107
return 'tileindex'
107108

108109
def displayName(self):
109-
return self.tr('Tile Index')
110+
return self.tr('Tile index')
110111

111112
def group(self):
112113
return self.tr('Raster miscellaneous')

‎python/plugins/processing/algs/gdal/ogr2ogrtopostgislist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def name(self):
171171
return 'importvectorintopostgisdatabaseavailableconnections'
172172

173173
def displayName(self):
174-
return self.tr('Import Vector into PostGIS database (available connections)')
174+
return self.tr('Import vector into PostGIS database (available connections)')
175175

176176
def group(self):
177177
return self.tr('Vector miscellaneous')

‎python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def svgIconPath(self):
160160

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

165165
def tr(self, string, context=''):
166166
if context == '':

‎python/plugins/processing/gui/menus.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from processing.gui.MessageDialog import MessageDialog
3333
from processing.gui.AlgorithmDialog import AlgorithmDialog
3434
from qgis.utils import iface
35-
from qgis.core import QgsApplication, QgsMessageLog, QgsStringUtils
35+
from qgis.core import QgsApplication, QgsMessageLog, QgsStringUtils, QgsProcessingAlgorithm
3636
from processing.gui.MessageBarProgress import MessageBarProgress
3737
from processing.gui.AlgorithmExecutor import execute
3838
from processing.gui.Postprocessing import handleAlgorithmResults
@@ -183,7 +183,11 @@ def removeMenus():
183183

184184
def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, addButton=False):
185185
if actionText is None:
186-
actionText = QgsStringUtils.capitalize(alg.displayName(), QgsStringUtils.TitleCase) + QCoreApplication.translate('Processing', '…')
186+
if alg.flags() & QgsProcessingAlgorithm.FlagDisplayNameIsLiteral:
187+
alg_title = alg.displayName()
188+
else:
189+
alg_title = QgsStringUtils.capitalize(alg.displayName(), QgsStringUtils.TitleCase)
190+
actionText = alg_title + QCoreApplication.translate('Processing', '…')
187191
action = QAction(icon or alg.icon(), actionText, iface.mainWindow())
188192
action.setData(alg.id())
189193
action.triggered.connect(lambda: _executeAlgorithm(alg))

‎src/core/processing/qgsprocessingalgorithm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class CORE_EXPORT QgsProcessingAlgorithm
7373
FlagCanCancel = 1 << 4, //!< Algorithm can be canceled
7474
FlagRequiresMatchingCrs = 1 << 5, //!< Algorithm requires that all input layers have matching coordinate reference systems
7575
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.
76+
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'.
7677
FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler, //!< Algorithm is deprecated
7778
};
7879
Q_DECLARE_FLAGS( Flags, Flag )

‎src/gui/processing/qgsprocessingalgorithmdialogbase.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *par
127127
void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *algorithm )
128128
{
129129
mAlgorithm = algorithm;
130-
setWindowTitle( QgsStringUtils::capitalize( mAlgorithm->displayName(), QgsStringUtils::TitleCase ) );
130+
QString title;
131+
if ( algorithm->flags() & QgsProcessingAlgorithm::FlagDisplayNameIsLiteral )
132+
title = mAlgorithm->displayName();
133+
else
134+
title = QgsStringUtils::capitalize( mAlgorithm->displayName(), QgsStringUtils::TitleCase );
135+
setWindowTitle( title );
131136

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

0 commit comments

Comments
 (0)
Please sign in to comment.