Skip to content

Commit

Permalink
create toolbox from .ui file
Browse files Browse the repository at this point in the history
add clear button to filter (fix #5695)
  • Loading branch information
alexbruy committed Dec 3, 2012
1 parent 9dd4a92 commit e05519d
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 34 deletions.
4 changes: 4 additions & 0 deletions python/plugins/sextante/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ ADD_SUBDIRECTORY(script)
ADD_SUBDIRECTORY(taudem)
#ADD_SUBDIRECTORY(tests)

FILE(GLOB UI_FILES ui/*.ui)
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})

FILE(GLOB OTHER_FILES metadata.txt)
FILE(GLOB PY_FILES *.py)

PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)

PLUGIN_INSTALL(sextante . ${PY_FILES} ${OTHER_FILES} ${PYRC_FILES})
PLUGIN_INSTALL(sextante ui ${PYUI_FILES} ui/__init__.py)
10 changes: 7 additions & 3 deletions python/plugins/sextante/SextantePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

from sextante.modeler.ModelerDialog import ModelerDialog

import resources_rc
import sextante.resources_rc

cmd_folder = os.path.split(inspect.getfile( inspect.currentframe() ))[0]
if cmd_folder not in sys.path:
Expand All @@ -58,7 +58,8 @@ def __init__(self, iface):

def initGui(self):
self.toolbox = SextanteToolbox(self.iface)
self.toolbox.setVisible(False)
self.iface.addDockWidget(Qt.RightDockWidgetArea, self.toolbox)
self.toolbox.hide()
Sextante.addAlgListListener(self.toolbox)

self.menu = QMenu(self.iface.mainWindow())
Expand Down Expand Up @@ -119,7 +120,10 @@ def unload(self):
pass

def openToolbox(self):
self.toolbox.setVisible(True)
if self.toolbox.isVisible():
self.toolbox.hide()
else:
self.toolbox.show()

def openModeler(self):
dlg = ModelerDialog()
Expand Down
52 changes: 21 additions & 31 deletions python/plugins/sextante/gui/SextanteToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,51 +40,41 @@
from sextante.gui.BatchProcessingDialog import BatchProcessingDialog
from sextante.gui.EditRenderingStylesDialog import EditRenderingStylesDialog

from sextante.ui.ui_SextanteToolbox import Ui_SextanteToolbox

import sextante.resources_rc

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


class SextanteToolbox(QDockWidget):
class SextanteToolbox(QDockWidget, Ui_SextanteToolbox):
def __init__(self, iface):
QDialog.__init__(self)
QDockWidget.__init__(self, None)
self.setupUi(self)
self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)

self.iface=iface
self.setupUi()

self.btnClear.setIcon(QIcon(":/sextante/images/clear.png"))

self.externalAppsButton.clicked.connect(self.configureProviders)
self.searchBox.textChanged.connect(self.fillTree)
self.algorithmTree.customContextMenuRequested.connect(self.showPopupMenu)
self.algorithmTree.doubleClicked.connect(self.executeAlgorithm)
self.btnClear.clicked.connect(self.clearFilter)

self.fillTree()

def algsListHasChanged(self):
self.fillTree()

def updateTree(self):
Sextante.updateAlgsList()

def setupUi(self):
self.setObjectName("SEXTANTE_Toolbox")
self.setFloating(False)
self.resize(400, 500)
self.setWindowTitle(self.tr("SEXTANTE Toolbox"))
self.contents = QWidget()
self.verticalLayout = QVBoxLayout(self.contents)
self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0)
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 = QLineEdit(self.contents)
self.searchBox.textChanged.connect(self.fillTree)
self.verticalLayout.addWidget(self.searchBox)
self.algorithmTree = QTreeWidget(self.contents)
self.algorithmTree.setHeaderHidden(True)
self.algorithmTree.setContextMenuPolicy(Qt.CustomContextMenu)
self.fillTree()
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)
QMetaObject.connectSlotsByName(self)
def clearFilter(self):
self.searchBox.clear()

def configureProviders(self):
webbrowser.open("http://docs.qgis.org/html/en/user_manual/sextante/3rdParty.html")
Expand Down
Binary file added python/plugins/sextante/images/clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/plugins/sextante/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<file>images/script.png</file>
<file>images/tool.png</file>
<file>images/toolbox.png</file>
<file>images/clear.png</file>
<file>images/sextante_logo.png</file>
</qresource>
</RCC>
69 changes: 69 additions & 0 deletions python/plugins/sextante/ui/SextanteToolbox.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SextanteToolbox</class>
<widget class="QDockWidget" name="SextanteToolbox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>444</height>
</rect>
</property>
<property name="windowTitle">
<string>SEXTANTE Toolbox</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="externalAppsButton">
<property name="text">
<string>Click here to configure
additional algorithm providers</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="searchBox"/>
</item>
<item>
<widget class="QToolButton" name="btnClear">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="algorithmTree">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
1 change: 1 addition & 0 deletions python/plugins/sextante/ui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit e05519d

Please sign in to comment.