Skip to content

Commit

Permalink
[processing] Move some SVG icons out of plugin to themes
Browse files Browse the repository at this point in the history
...and swap to using QgsApplication methods for retrieving cached icons,
implement svgIconPath for providers with SVG icons
  • Loading branch information
nyalldawson committed Jan 11, 2017
1 parent bf484da commit 04eb293
Show file tree
Hide file tree
Showing 43 changed files with 148 additions and 137 deletions.
8 changes: 8 additions & 0 deletions images/images.qrc
Expand Up @@ -550,6 +550,14 @@
<file>themes/default/mTaskRunning.svg</file>
<file>themes/default/mTaskTerminated.svg</file>
<file>themes/default/mTaskCancel.svg</file>
<file>themes/default/providerGdal.svg</file>
<file>themes/default/providerGrass.svg</file>
<file>themes/default/providerQgis.svg</file>
<file>themes/default/providerR.svg</file>
<file>themes/default/providerTaudem.svg</file>
<file>themes/default/processingModel.svg</file>
<file>themes/default/processingScript.svg</file>
<file>themes/default/processingAlgorithm.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions python/plugins/processing/ProcessingPlugin.py
Expand Up @@ -72,13 +72,13 @@ def initGui(self):
self.toolboxAction = self.toolbox.toggleViewAction()
self.toolboxAction.setObjectName('toolboxAction')
self.toolboxAction.setIcon(
QIcon(os.path.join(cmd_folder, 'images', 'alg.svg')))
QgsApplication.getThemeIcon("/processingAlgorithm.svg"))
self.toolboxAction.setText(self.tr('&Toolbox'))
self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T')
self.menu.addAction(self.toolboxAction)

self.modelerAction = QAction(
QIcon(os.path.join(cmd_folder, 'images', 'model.svg')),
QgsApplication.getThemeIcon("/processingModel.svg"),
self.tr('Graphical &Modeler...'), self.iface.mainWindow())
self.modelerAction.setObjectName('modelerAction')
self.modelerAction.triggered.connect(self.openModeler)
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/algs/gdal/GdalAlgorithm.py
Expand Up @@ -31,6 +31,8 @@
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QUrl

from qgis.core import QgsApplication

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithmDialog import GdalAlgorithmDialog
from processing.algs.gdal.GdalUtils import GdalUtils
Expand All @@ -48,7 +50,7 @@ def __init__(self):

def getIcon(self):
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
self._icon = QgsApplication.getThemeIcon("/providerGdal.svg")
return self._icon

def getCustomParametersDialog(self):
Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py
Expand Up @@ -28,6 +28,7 @@
import os
from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsApplication
from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from .GdalUtils import GdalUtils
Expand Down Expand Up @@ -120,7 +121,10 @@ def id(self):
return 'gdal'

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
return QgsApplication.getThemeIcon("/providerGdal.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerGdal.svg")

def _loadAlgorithms(self):
self.algs = self.preloadedAlgs
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -35,7 +35,8 @@
from qgis.PyQt.QtCore import QCoreApplication, QUrl
from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsRasterLayer
from qgis.core import (QgsRasterLayer,
QgsApplication)
from qgis.utils import iface

from processing.core.GeoAlgorithm import GeoAlgorithm
Expand Down Expand Up @@ -102,7 +103,7 @@ def getCopy(self):

def getIcon(self):
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))
self._icon = QgsApplication.getThemeIcon("/providerGrass.svg")
return self._icon

def help(self):
Expand Down
Expand Up @@ -28,6 +28,7 @@

import os
from qgis.PyQt.QtGui import QIcon
from qgis.core import QgsApplication
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingLog import ProcessingLog
Expand Down Expand Up @@ -105,7 +106,10 @@ def id(self):
return 'grass7'

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))
return QgsApplication.getThemeIcon("/providerGrass.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerGrass.svg")

def getSupportedOutputVectorLayerExtensions(self):
return ['shp']
Expand Down
11 changes: 8 additions & 3 deletions python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
Expand Up @@ -43,7 +43,9 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import Qgis, QgsWkbTypes
from qgis.core import (Qgis,
QgsWkbTypes,
QgsApplication)

from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.script.ScriptUtils import ScriptUtils
Expand Down Expand Up @@ -197,7 +199,7 @@ class QGISAlgorithmProvider(AlgorithmProvider):

def __init__(self):
super().__init__()
self._icon = QIcon(os.path.join(pluginPath, 'images', 'qgis.svg'))
self._icon = QgsApplication.getThemeIcon("/providerQgis.svg")

self.alglist = [SumLines(), PointsInPolygon(),
PointsInPolygonWeighted(), PointsInPolygonUnique(),
Expand Down Expand Up @@ -304,7 +306,10 @@ def name(self):
return 'QGIS'

def icon(self):
return self._icon
return QgsApplication.getThemeIcon("/providerQgis.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerQgis.svg")

def _loadAlgorithms(self):
self.algs = list(self.alglist) + self.externalAlgs
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/algs/r/RAlgorithm.py
Expand Up @@ -33,6 +33,8 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsApplication

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.ProcessingLog import ProcessingLog
Expand Down Expand Up @@ -88,7 +90,7 @@ def __init__(self, descriptionFile, script=None):

def getIcon(self):
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'r.svg'))
self._icon = QgsApplication.getThemeIcon("/providerR.svg")
return self._icon

def defineCharacteristicsFromScript(self):
Expand Down
7 changes: 5 additions & 2 deletions python/plugins/processing/algs/r/RAlgorithmProvider.py
Expand Up @@ -29,7 +29,7 @@
import os

from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsApplication
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.ProcessingLog import ProcessingLog
from processing.core.AlgorithmProvider import AlgorithmProvider
Expand Down Expand Up @@ -87,7 +87,10 @@ def unload(self):
ProcessingConfig.removeSetting(RUtils.R_USE64)

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'r.svg'))
return QgsApplication.getThemeIcon("/providerR.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerR.svg")

def name(self):
return 'R scripts'
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/taudem/TauDEMAlgorithm.py
Expand Up @@ -31,7 +31,7 @@
import os
import codecs

from qgis.PyQt.QtGui import QIcon
from qgis.core import QgsApplication

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.ProcessingLog import ProcessingLog
Expand Down Expand Up @@ -68,7 +68,7 @@ def getCopy(self):

def getIcon(self):
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'taudem.svg'))
self._icon = QgsApplication.getThemeIcon("/providerTaudem.svg")
return self._icon

def defineCharacteristicsFromFile(self):
Expand Down
Expand Up @@ -30,6 +30,8 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsApplication

from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.ProcessingLog import ProcessingLog
Expand Down Expand Up @@ -64,7 +66,10 @@ def id(self):
return 'taudem'

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'taudem.svg'))
return QgsApplication.getThemeIcon("/providerTaudem.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerTaudem.svg")

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/algs/taudem/dinfdistdown.py
Expand Up @@ -32,6 +32,8 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsApplication

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
Expand Down Expand Up @@ -68,7 +70,7 @@ class DinfDistDown(GeoAlgorithm):
}

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../../images/taudem.svg')
return QgsApplication.getThemeIcon("/providerTaudem.svg")

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('D-Infinity Distance Down')
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/algs/taudem/dinfdistup.py
Expand Up @@ -32,6 +32,8 @@

from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsApplication

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
Expand Down Expand Up @@ -69,7 +71,7 @@ class DinfDistUp(GeoAlgorithm):
}

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../../images/taudem.svg')
return QgsApplication.getThemeIcon("/providerTaudem.svg")

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('D-Infinity Distance Up')
Expand Down

0 comments on commit 04eb293

Please sign in to comment.