Skip to content
Permalink
Browse files

more translatable strings and cleanup

  • Loading branch information
alexbruy committed Oct 4, 2012
1 parent 4e02cfb commit 109525f7a39ade3210735cb355c9fe94bc81d118
Showing with 35 additions and 44 deletions.
  1. +35 −44 python/plugins/sextante/gui/SextanteToolbox.py
@@ -1,26 +1,27 @@
import os
import sys

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui

from sextante.core.Sextante import Sextante
from sextante.gui.ParametersDialog import ParametersDialog
from sextante.gui.BatchProcessingDialog import BatchProcessingDialog
from sextante.gui.EditRenderingStylesDialog import EditRenderingStylesDialog
from sextante.core.SextanteLog import SextanteLog
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.QGisLayers import QGisLayers
import os
import sys
import subprocess

from sextante.gui.ParametersDialog import ParametersDialog
from sextante.gui.BatchProcessingDialog import BatchProcessingDialog
from sextante.gui.EditRenderingStylesDialog import EditRenderingStylesDialog

try:
_fromUtf8 = QtCore.QString.fromUtf8
_fromUtf8 = QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s


class SextanteToolbox(QtGui.QDockWidget):
class SextanteToolbox(QDockWidget):
def __init__(self, iface):
QtGui.QDialog.__init__(self)
QDialog.__init__(self)
self.iface=iface
self.setupUi()

@@ -34,58 +35,52 @@ def setupUi(self):
self.setObjectName("SEXTANTE_Toolbox")
self.setFloating(False)
self.resize(400, 500)
self.setWindowTitle("SEXTANTE Toolbox")
self.contents = QtGui.QWidget()
self.verticalLayout = QtGui.QVBoxLayout(self.contents)
self.setWindowTitle(self.tr("SEXTANTE Toolbox"))
self.contents = QWidget()
self.verticalLayout = QVBoxLayout(self.contents)
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
self.externalAppsButton = QtGui.QPushButton()
self.externalAppsButton.setText("Click here to configure\nadditional algorithm providers")
QObject.connect(self.externalAppsButton, QtCore.SIGNAL("clicked()"), self.configureProviders)
self.externalAppsButton = QPushButton()
self.externalAppsButton.setText(self.tr("Click here to configure\nadditional algorithm providers"))
QObject.connect(self.externalAppsButton, SIGNAL("clicked()"), self.configureProviders)
self.verticalLayout.addWidget(self.externalAppsButton)
self.searchBox = QtGui.QLineEdit(self.contents)
self.searchBox = QLineEdit(self.contents)
self.searchBox.textChanged.connect(self.fillTree)
self.verticalLayout.addWidget(self.searchBox)
self.algorithmTree = QtGui.QTreeWidget(self.contents)
self.algorithmTree = QTreeWidget(self.contents)
self.algorithmTree.setHeaderHidden(True)
self.algorithmTree.setContextMenuPolicy(Qt.CustomContextMenu)
self.fillTree()
self.connect(self.algorithmTree,SIGNAL('customContextMenuRequested(QPoint)'),
self.connect(self.algorithmTree, SIGNAL('customContextMenuRequested(QPoint)'),
self.showPopupMenu)
self.verticalLayout.addWidget(self.algorithmTree)
self.algorithmTree.doubleClicked.connect(self.executeAlgorithm)
self.setWidget(self.contents)
self.iface.addDockWidget(Qt.RightDockWidgetArea, self)
QtCore.QMetaObject.connectSlotsByName(self)
QMetaObject.connectSlotsByName(self)

def configureProviders(self):
filename = os.path.join(os.path.dirname(__file__), "..", "help", "3rdParty.html")
if os.name == "nt":
os.startfile(filename)
elif sys.platform == "darwin":
subprocess.Popen(('open', filename))
else:
subprocess.call(('xdg-open', filename))
QDesktopServices.openUrl(QUrl(os.path.join(os.path.dirname(__file__), os.path.pardir) + "/help/3rdParty.html"))

def showPopupMenu(self,point):
item = self.algorithmTree.itemAt(point)
if isinstance(item, TreeAlgorithmItem):
alg = item.alg
popupmenu = QMenu()
executeAction = QtGui.QAction("Execute", self.algorithmTree)
executeAction = QAction(self.tr("Execute"), self.algorithmTree)
executeAction.triggered.connect(self.executeAlgorithm)
popupmenu.addAction(executeAction)
executeBatchAction = QtGui.QAction("Execute as batch process", self.algorithmTree)
executeBatchAction = QAction(self.tr("Execute as batch process"), self.algorithmTree)
executeBatchAction.triggered.connect(self.executeAlgorithmAsBatchProcess)
popupmenu.addAction(executeBatchAction)
editRenderingStylesAction = QtGui.QAction("Edit rendering styles for outputs", self.algorithmTree)
editRenderingStylesAction = QAction(self.tr("Edit rendering styles for outputs"), self.algorithmTree)
editRenderingStylesAction.triggered.connect(self.editRenderingStyles)
popupmenu.addAction(editRenderingStylesAction)
actions = Sextante.contextMenuActions
for action in actions:
action.setData(alg,self)
if action.isEnabled():
contextMenuAction = QtGui.QAction(action.name, self.algorithmTree)
contextMenuAction = QAction(action.name, self.algorithmTree)
contextMenuAction.triggered.connect(action.execute)
popupmenu.addAction(contextMenuAction)

@@ -111,7 +106,7 @@ def executeAlgorithm(self):
alg = Sextante.getAlgorithm(item.alg.commandLineName())
message = alg.checkBeforeOpeningParametersDialog()
if message:
QtGui.QMessageBox.warning(self, "Warning", message)
QMessageBox.warning(self, self.tr("Warning"), message)
return
alg = alg.getCopy()#copy.deepcopy(alg)
dlg = alg.getCustomParametersDialog()
@@ -154,7 +149,7 @@ def fillTree(self):
if alg.group in groups:
groupItem = groups[alg.group]
else:
groupItem = QtGui.QTreeWidgetItem()
groupItem = QTreeWidgetItem()
groupItem.setText(0,alg.group)
groups[alg.group] = groupItem
algItem = TreeAlgorithmItem(alg)
@@ -166,15 +161,15 @@ def fillTree(self):
if action.group in groups:
groupItem = groups[action.group]
else:
groupItem = QtGui.QTreeWidgetItem()
groupItem = QTreeWidgetItem()
groupItem.setText(0,action.group)
groups[action.group] = groupItem
algItem = TreeActionItem(action)
groupItem.addChild(algItem)


if len(groups)>0:
providerItem = QtGui.QTreeWidgetItem()
if len(groups) > 0:
providerItem = QTreeWidgetItem()
providerItem.setText(0, Sextante.getProviderFromName(providerName).getDescription()
+ " [" + str(len(provider)) + " geoalgorithms]")
providerItem.setIcon(0, Sextante.getProviderFromName(providerName).getIcon())
@@ -193,8 +188,8 @@ def fillTree(self):
recent = SextanteLog.getRecentAlgorithms()
if len(recent) != 0:
found = False
recentItem = QtGui.QTreeWidgetItem()
recentItem.setText(0,"Recently used algorithms")
recentItem = QTreeWidgetItem()
recentItem.setText(0, self.tr("Recently used algorithms"))
for algname in recent:
alg = Sextante.getAlgorithm(algname)
if alg is not None:
@@ -207,9 +202,7 @@ def fillTree(self):

self.algorithmTree.setWordWrap(True)



class TreeAlgorithmItem(QtGui.QTreeWidgetItem):
class TreeAlgorithmItem(QTreeWidgetItem):

def __init__(self, alg):
QTreeWidgetItem.__init__(self)
@@ -218,12 +211,10 @@ def __init__(self, alg):
self.setIcon(0, alg.getIcon())
self.setToolTip(0, alg.name)


class TreeActionItem(QtGui.QTreeWidgetItem):
class TreeActionItem(QTreeWidgetItem):

def __init__(self, action):
QTreeWidgetItem.__init__(self)
self.action = action
self.setText(0, action.name)
self.setIcon(0, action.getIcon())

0 comments on commit 109525f

Please sign in to comment.
You can’t perform that action at this time.