Skip to content

Commit

Permalink
[processing] cache icons to speed up toolbox rendering
Browse files Browse the repository at this point in the history
fixes #15550
  • Loading branch information
volaya committed Sep 13, 2016
1 parent f55d7d3 commit d265f33
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
15 changes: 8 additions & 7 deletions python/plugins/processing/algs/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))

_icon = QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))

class GrassAlgorithm(GeoAlgorithm):

Expand All @@ -89,9 +90,10 @@ def getCopy(self):
newone = GrassAlgorithm(self.descriptionFile)
newone.provider = self.provider
return newone

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))
return _icon


def help(self):
return False, 'http://grass.osgeo.org/grass64/manuals/' + self.grassName + '.html'
Expand Down Expand Up @@ -121,11 +123,10 @@ def defineCharacteristicsFromFile(self):
line = lines.readline().strip('\n').strip()
self.grassName = line
line = lines.readline().strip('\n').strip()
self.name = line
self.i18n_name = QCoreApplication.translate("GrassAlgorithm", line)
if " - " not in self.name:
self.name = self.grassName + " - " + self.name
self.i18n_name = self.grassName + " - " + self.i18n_name
self.name = line.split("-")[0]
#self.i18n_name = QCoreApplication.translate("GrassAlgorithm", self.name)
self.name = self.grassName
self.i18n_name = self.grassName
line = lines.readline().strip('\n').strip()
self.group = line
self.i18n_group = QCoreApplication.translate("GrassAlgorithm", line)
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))

_icon = QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))

class Grass7Algorithm(GeoAlgorithm):

Expand Down Expand Up @@ -98,8 +99,8 @@ def getCopy(self):
return newone

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))

return _icon
def help(self):
localDoc = None
html = self.grass7Name + '.html'
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/otb/OTBAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))

_icon = QIcon(os.path.join(pluginPath, 'images', 'otb.png'))

class OTBAlgorithm(GeoAlgorithm):

Expand All @@ -73,7 +74,7 @@ def getCopy(self):
return newone

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
return _icon

def help(self):
version = OTBUtils.getInstalledVersion()
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/algs/saga/SagaAlgorithm212.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

sessionExportedLayers = {}

_icon = QIcon(os.path.join(pluginPath, 'images', 'saga.png'))

class SagaAlgorithm212(GeoAlgorithm):

Expand All @@ -75,8 +76,8 @@ def getCopy(self):
return newone

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'saga.png'))

return _icon
def defineCharacteristicsFromFile(self):
lines = open(self.descriptionFile)
line = lines.readline().strip('\n').strip()
Expand Down

1 comment on commit d265f33

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@volaya I've had to revert this change - it broke all the processing tests on Travis. Can you rework and push again?

Please sign in to comment.