Skip to content

Commit 4475854

Browse files
committed
use resource file for images
1 parent fbb4af7 commit 4475854

7 files changed

Lines changed: 41 additions & 45 deletions

File tree

‎python/plugins/sextante/CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ ADD_SUBDIRECTORY(script)
2424
FILE(GLOB OTHER_FILES metadata.txt)
2525
FILE(GLOB PY_FILES *.py)
2626

27+
PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)
28+
29+
ADD_CUSTOM_TARGET(sextante ALL DEPENDS ${PYRC_FILES})
30+
2731
INSTALL(FILES ${PY_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR})
2832
INSTALL(FILES ${OTHER_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR})
33+
INSTALL(FILES ${PYRC_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR})

‎python/plugins/sextante/SextantePlugin.py‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
from sextante.about.AboutDialog import AboutDialog
2222

23+
import resources_rc
24+
2325
cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
2426
if cmd_folder not in sys.path:
2527
sys.path.insert(0, cmd_folder)
@@ -40,50 +42,43 @@ def initGui(self):
4042
self.menu = QMenu(self.iface.mainWindow())
4143
self.menu.setTitle(QCoreApplication.translate("SEXTANTE", "Analysis"))
4244

43-
icon = QIcon(os.path.dirname(__file__) + "/images/toolbox.png")
44-
self.toolboxAction = QAction(icon, \
45+
self.toolboxAction = QAction(QIcon(":/sextante/images/toolbox.png"),
4546
QCoreApplication.translate("SEXTANTE", "&SEXTANTE Toolbox"),
4647
self.iface.mainWindow())
4748
QObject.connect(self.toolboxAction, SIGNAL("triggered()"), self.openToolbox)
4849
self.menu.addAction(self.toolboxAction)
4950

50-
icon = QIcon(os.path.dirname(__file__) + "/images/model.png")
51-
self.modelerAction = QAction(icon, \
51+
self.modelerAction = QAction(QIcon(":/sextante/images/model.png"),
5252
QCoreApplication.translate("SEXTANTE", "&SEXTANTE Modeler"),
5353
self.iface.mainWindow())
5454
QObject.connect(self.modelerAction, SIGNAL("triggered()"), self.openModeler)
5555
self.menu.addAction(self.modelerAction)
5656

57-
icon = QIcon(os.path.dirname(__file__) + "/images/history.gif")
58-
self.historyAction = QAction(icon, \
57+
self.historyAction = QAction(QIcon(":/sextante/images/history.gif"),
5958
QCoreApplication.translate("SEXTANTE", "&SEXTANTE History and log"),
6059
self.iface.mainWindow())
6160
QObject.connect(self.historyAction, SIGNAL("triggered()"), self.openHistory)
6261
self.menu.addAction(self.historyAction)
6362

64-
icon = QIcon(os.path.dirname(__file__) + "/images/config.png")
65-
self.configAction = QAction(icon, \
63+
self.configAction = QAction(QIcon(":/sextante/images/config.png"),
6664
QCoreApplication.translate("SEXTANTE", "&SEXTANTE options and configuration"),
6765
self.iface.mainWindow())
6866
QObject.connect(self.configAction, SIGNAL("triggered()"), self.openConfig)
6967
self.menu.addAction(self.configAction)
7068

71-
icon = QIcon(os.path.dirname(__file__) + "/images/results.png")
72-
self.resultsAction = QAction(icon, \
69+
self.resultsAction = QAction(QIcon(":/sextante/images/results.png"),
7370
QCoreApplication.translate("SEXTANTE", "&SEXTANTE results viewer"),
7471
self.iface.mainWindow())
7572
QObject.connect(self.resultsAction, SIGNAL("triggered()"), self.openResults)
7673
self.menu.addAction(self.resultsAction)
7774

78-
icon = QIcon(os.path.dirname(__file__) + "/images/help.png")
79-
self.helpAction = QAction(icon, \
75+
self.helpAction = QAction(QIcon(":/sextante/images/help.png"),
8076
QCoreApplication.translate("SEXTANTE", "&SEXTANTE help"),
8177
self.iface.mainWindow())
8278
QObject.connect(self.helpAction, SIGNAL("triggered()"), self.openHelp)
8379
self.menu.addAction(self.helpAction)
8480

85-
icon = QIcon(os.path.dirname(__file__) + "/images/info.png")
86-
self.aboutAction = QAction(icon, \
81+
self.aboutAction = QAction(QIcon(":/sextante/images/info.png"),
8782
QCoreApplication.translate("SEXTANTE", "&About SEXTANTE"),
8883
self.iface.mainWindow())
8984
QObject.connect(self.aboutAction, SIGNAL("triggered()"), self.openAbout)

‎python/plugins/sextante/about/AboutDialog.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from sextante.__init__ import version
77
from ui_aboutdialogbase import Ui_DlgAbout
88

9+
import sextante.resources_rc
10+
911
class AboutDialog(QDialog, Ui_DlgAbout):
1012

1113
def __init__(self, parent):
@@ -15,9 +17,8 @@ def __init__(self, parent):
1517
self.setAboutText()
1618

1719
def setAboutText(self):
18-
imgPath = QDir(os.path.join(os.path.dirname(__file__), "sextante_logo.png")).absolutePath()
1920
strAbout = self.tr("""
20-
<img src="%1" />
21+
<img src="qrc:/sextante/images/sextante_logo.png" />
2122
<h2>SEXTANTE for QGIS</h2>
2223
<p>SEXTANTE, a geoprocessing platform for QGIS</p>
2324
<p>A development by Victor Olaya (volayaf@gmail.com).</p>
@@ -31,8 +32,8 @@ def setAboutText(self):
3132
<li>Camilo Polymeris (Threading). Developed as part of Google Summer of Code 2012</li>
3233
</ul>
3334
</p>
34-
<p>You are currently using SEXTANTE v%2</p>
35+
<p>You are currently using SEXTANTE v%1</p>
3536
<p>This software is distributed under the terms of the GNU GPL License v2.
3637
<p>For more information, please visit our website at <a href="http://sextantegis.com">http://sextantegis.com</a></p>
37-
""").arg(imgPath).arg(version())
38-
self.webView.setHtml(strAbout, QUrl.fromLocalFile(QDir(os.path.join(os.path.dirname(__file__), "sextante_logo.png")).absolutePath()))
38+
""").arg(version())
39+
self.webView.setHtml(strAbout)
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
FILE(GLOB PY_FILES *.py)
2-
FILE(GLOB OTHER_FILES *.htm *.png)
32

43
FILE(GLOB UI_FILES *.ui)
54
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
65

76
ADD_CUSTOM_TARGET(sextante_about ALL DEPENDS ${PYUI_FILES})
87

98
INSTALL(FILES ${PY_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR}/about)
10-
INSTALL(FILES ${OTHER_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR}/about)
119
INSTALL(FILES ${PYUI_FILES} DESTINATION ${SEXTANTE_PLUGIN_DIR}/about)

‎python/plugins/sextante/about/about.htm‎

Lines changed: 0 additions & 24 deletions
This file was deleted.
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<RCC>
2+
<qresource prefix="/sextante">
3+
<file>images/alg.png</file>
4+
<file>images/config.png</file>
5+
<file>images/grass.png</file>
6+
<file>images/help.png</file>
7+
<file>images/history.gif</file>
8+
<file>images/info.png</file>
9+
<file>images/input.png</file>
10+
<file>images/iterate.png</file>
11+
<file>images/model.png</file>
12+
<file>images/otb.png</file>
13+
<file>images/r.png</file>
14+
<file>images/results.png</file>
15+
<file>images/saga.png</file>
16+
<file>images/script.png</file>
17+
<file>images/tool.png</file>
18+
<file>images/toolbox.png</file>
19+
<file>images/sextante_logo.png</file>
20+
</qresource>
21+
</RCC>

0 commit comments

Comments
 (0)