Skip to content

Commit

Permalink
[processing] remove similar widgets (use generic one instead)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 17, 2014
1 parent c3d230c commit 28c03a1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 107 deletions.
6 changes: 4 additions & 2 deletions python/plugins/processing/gui/CommanderWindow.py
Expand Up @@ -31,7 +31,7 @@
from PyQt4.QtGui import *
from qgis.utils import iface
from processing.core.Processing import Processing
from processing.gui.MissingDependencyDialog import MissingDependencyDialog
from processing.gui.MessageDialog import MessageDialog
from processing.gui.ParametersDialog import ParametersDialog
from processing.tools import dataobjects
from processing.tools.system import *
Expand Down Expand Up @@ -205,7 +205,9 @@ def runAlgorithm(self, alg):
alg = alg.getCopy()
message = alg.checkBeforeOpeningParametersDialog()
if message:
dlg = MissingDependencyDialog(message)
dlg = MessageDialog()
dlg.setTitle(self.tr('Missing dependency'))
dlg.setMessage(msg)
dlg.exec_()
return
dlg = alg.getCustomParametersDialog()
Expand Down
10 changes: 6 additions & 4 deletions python/plugins/processing/gui/CrsSelectionPanel.py
Expand Up @@ -31,15 +31,17 @@
from qgis.gui import *
from qgis.core import *

from processing.ui.ui_widgetCRSSelector import Ui_widgetCRSSelector
from processing.ui.ui_widgetBaseSelector import Ui_Form

class CrsSelectionPanel(QWidget, Ui_widgetCRSSelector):
class CrsSelectionPanel(QWidget, Ui_Form):

def __init__(self, default):
QWidget.__init__(self)
self.setupUi(self)

self.btnBrowse.clicked.connect(self.browseCRS)
self.leText.setEnabled(False)

self.btnBSelect.clicked.connect(self.browseCRS)
self.authId = QgsCoordinateReferenceSystem(default).authid()
self.updateText()

Expand All @@ -56,7 +58,7 @@ def browseCRS(self):

def updateText(self):
if self.authId is not None:
self.leCRS.setText(self.authId)
self.leText.setText(self.authId)

def getValue(self):
return self.authId
14 changes: 7 additions & 7 deletions python/plugins/processing/gui/ExtentSelectionPanel.py
Expand Up @@ -37,7 +37,7 @@
from processing.core.parameters import ParameterMultipleInput
from processing.tools import dataobjects

from processing.ui.ui_widgetExtentSelector import Ui_Form
from processing.ui.ui_widgetBaseSelector import Ui_Form

class ExtentSelectionPanel(QWidget, Ui_Form):

Expand All @@ -48,8 +48,8 @@ def __init__(self, dialog, alg, default):
self.dialog = dialog
self.params = alg.parameters
if self.canUseAutoExtent():
if hasattr(self.leExtent, 'setPlaceholderText'):
self.leExtent.setPlaceholderText(
if hasattr(self.leText, 'setPlaceholderText'):
self.leText.setPlaceholderText(
self.tr('[Leave blank to use min covering extent]'))

self.btnSelect.clicked.connect(self.selectExtent)
Expand Down Expand Up @@ -92,7 +92,7 @@ def selectExtent(self):
popupmenu.exec_(QCursor.pos())

def useMinCoveringExtent(self):
self.leExtent.setText('')
self.leText.setText('')

def getMinCoveringExtent(self):
first = True
Expand Down Expand Up @@ -165,7 +165,7 @@ def setValueFromRect(self, r):
s = '{},{},{},{}'.format(
r.xMinimum(), r.xMaximum(), r.yMinimum(), r.yMaximum())

self.leExtent.setText(s)
self.leText.setText(s)
self.tool.reset()
canvas = iface.mapCanvas()
canvas.setMapTool(self.prevMapTool)
Expand All @@ -174,7 +174,7 @@ def setValueFromRect(self, r):
self.dialog.activateWindow()

def getValue(self):
if str(self.leExtent.text()).strip() != '':
return str(self.leExtent.text())
if str(self.leText.text()).strip() != '':
return unicode(self.leText.text())
else:
return self.getMinCoveringExtent()
26 changes: 13 additions & 13 deletions python/plugins/processing/gui/OutputSelectionPanel.py
Expand Up @@ -37,9 +37,9 @@
from processing.core.outputs import OutputVector
from processing.core.outputs import OutputDirectory

from processing.ui.ui_widgetOutputSelect import Ui_widgetOutputSelect
from processing.ui.ui_widgetBaseSelector import Ui_Form

class OutputSelectionPanel(QWidget, Ui_widgetOutputSelect):
class OutputSelectionPanel(QWidget, Ui_Form):

SAVE_TO_TEMP_FILE = QCoreApplication.translate(
'OutputSelectionPanel', '[Save to temporary file]')
Expand All @@ -51,10 +51,10 @@ def __init__(self, output, alg):
self.output = output
self.alg = alg

if hasattr(self.text, 'setPlaceholderText'):
self.text.setPlaceholderText(self.SAVE_TO_TEMP_FILE)
if hasattr(self.leText, 'setPlaceholderText'):
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_FILE)

self.btnBrowse.clicked.connect(self.selectOutput)
self.btnSelect.clicked.connect(self.selectOutput)

def selectOutput(self):
if isinstance(self.output, OutputDirectory):
Expand All @@ -63,29 +63,29 @@ def selectOutput(self):
popupMenu = QMenu()

actionSaveToTempFile = QAction(
self.tr('Save to a temporary file'), self.btnBrowse)
self.tr('Save to a temporary file'), self.btnSelect)
actionSaveToTempFile.triggered.connect(self.saveToTemporaryFile)
popupMenu.addAction(actionSaveToTempFile)

actionSaveToFile = QAction(
self.tr('Save to file...'), self.btnBrowse)
self.tr('Save to file...'), self.btnSelect)
actionSaveToFile.triggered.connect(self.selectFile)
popupMenu.addAction(actionSaveToFile)

if isinstance(self.output, OutputVector) \
and self.alg.provider.supportsNonFileBasedOutput():
actionSaveToMemory = QAction(
self.tr('Save to memory layer'), self.btnBrowse)
self.tr('Save to memory layer'), self.btnSelect)
actionSaveToMemory.triggered.connect(self.saveToMemory)
popupMenu.addAction(actionSaveToMemory)

popupMenu.exec_(QCursor.pos())

def saveToTemporaryFile(self):
self.text.setText('')
self.leText.setText('')

def saveToMemory(self):
self.text.setText('memory:')
self.leText.setText('memory:')

def selectFile(self):
fileFilter = self.output.getFileFilter(self.alg)
Expand Down Expand Up @@ -114,7 +114,7 @@ def selectFile(self):
ext = re.search("\*(\.[a-z]{1,5})", selectedFileFilter)
if ext:
fileName += ext.group(1)
self.text.setText(fileName)
self.leText.setText(fileName)
settings.setValue('/Processing/LastOutputPath',
os.path.dirname(fileName))
settings.setValue('/Processing/encoding', encoding)
Expand All @@ -125,10 +125,10 @@ def selectDirectory(self):
dirName = QFileDialog.getExistingDirectory(self,
self.tr('Select directory'), lastDir, QFileDialog.ShowDirsOnly)

self.text.setText(dirName)
self.leText.setText(dirName)

def getValue(self):
fileName = unicode(self.text.text())
fileName = unicode(self.leText.text())
if fileName.strip() in ['', self.SAVE_TO_TEMP_FILE]:
value = None
elif fileName.startswith('memory:'):
Expand Down
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>249</width>
<height>23</height>
</rect>
</property>
Expand All @@ -21,7 +21,7 @@
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="leExtent"/>
<widget class="QLineEdit" name="leText"/>
</item>
<item>
<widget class="QToolButton" name="btnSelect">
Expand Down
41 changes: 0 additions & 41 deletions python/plugins/processing/ui/widgetCRSSelector.ui

This file was deleted.

5 changes: 4 additions & 1 deletion python/plugins/processing/ui/widgetNumberInput.ui
Expand Up @@ -7,13 +7,16 @@
<x>0</x>
<y>0</y>
<width>251</width>
<height>24</height>
<height>23</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
Expand Down
37 changes: 0 additions & 37 deletions python/plugins/processing/ui/widgetOutputSelect.ui

This file was deleted.

0 comments on commit 28c03a1

Please sign in to comment.