Skip to content

Commit

Permalink
[processing] save and restore geometry of the algorithm dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jun 6, 2017
1 parent dec9ecf commit 77fa177
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
6 changes: 3 additions & 3 deletions python/plugins/processing/gui/AlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def checkExtentCRS(self):
return hasExtent and unmatchingCRS

def accept(self):
self.settings.setValue("/Processing/dialogBase", self.saveGeometry())
super(AlgorithmDialog, self)._saveGeometry()

context = dataobjects.createContext()

Expand Down Expand Up @@ -273,7 +273,7 @@ def finish(self, result, context):
self.tr('HTML output has been generated by this algorithm.'
'\nOpen the results dialog to check it.'))

def closeEvent(self, evt):
def closeEvent(self, event):
QgsProject.instance().layerWasAdded.disconnect(self.mainWidget.layerRegistryChanged)
QgsProject.instance().layersWillBeRemoved.disconnect(self.mainWidget.layerRegistryChanged)
super(AlgorithmDialog, self).closeEvent(evt)
super(AlgorithmDialog, self).closeEvent(event)
24 changes: 17 additions & 7 deletions python/plugins/processing/gui/AlgorithmDialogBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ def __init__(self, alg):
self.buttonCancel.clicked.connect(self.feedback.cancel)

self.settings = QgsSettings()
self.splitter.restoreState(self.settings.value("/Processing/dialogBaseSplitter", QByteArray()))
self.restoreGeometry(self.settings.value("/Processing/dialogBase", QByteArray()))

self.setWindowTitle(self.alg.displayName())

self.executed = False
self.mainWidget = None
self.alg = alg
Expand All @@ -101,15 +104,16 @@ def __init__(self, alg):

self.btnClose = self.buttonBox.button(QDialogButtonBox.Close)

self.setWindowTitle(self.alg.displayName())
# don't collapse parameters panel
self.splitter.setCollapsible(0, False)

# desktop = QDesktopWidget()
# if desktop.physicalDpiX() > 96:
# self.txtHelp.setZoomFactor(desktop.physicalDpiX() / 96)

algHelp = self.formatHelp(self.alg)
if algHelp is None:
self.textShortHelp.setVisible(False)
self.textShortHelp.hide()
else:
self.textShortHelp.document().setDefaultStyleSheet('''.summary { margin-left: 10px; margin-right: 10px; }
h2 { color: #555555; padding-bottom: 15px; }
Expand All @@ -119,8 +123,6 @@ def __init__(self, alg):
dl dd { margin-bottom: 5px; }''')
self.textShortHelp.setHtml(algHelp)

self.textShortHelp.setOpenLinks(False)

def linkClicked(url):
webbrowser.open(url.toString())

Expand Down Expand Up @@ -162,9 +164,9 @@ def requestFinished(self):
reply.deleteLater()
self.txtHelp.setHtml(html)

def closeEvent(self, evt):
self.settings.setValue("/Processing/dialogBase", self.saveGeometry())
super(AlgorithmDialogBase, self).closeEvent(evt)
def closeEvent(self, event):
self._saveGeometry()
super(AlgorithmDialogBase, self).closeEvent(event)

def setMainWidget(self, widget):
if self.mainWidget is not None:
Expand Down Expand Up @@ -228,9 +230,17 @@ def getParamValues(self):
def accept(self):
pass

def reject(self):
self._saveGeometry()
super(AlgorithmDialogBase, self).reject()

def finish(self, context):
pass

def _saveGeometry(self):
self.settings.setValue("/Processing/dialogBaseSplitter", self.splitter.saveState())
self.settings.setValue("/Processing/dialogBase", self.saveGeometry())

class InvalidParameterValue(Exception):

def __init__(self, param, widget):
Expand Down
18 changes: 17 additions & 1 deletion python/plugins/processing/ui/DlgAlgorithmBase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
Expand Down Expand Up @@ -99,7 +105,17 @@
</layout>
</widget>
</widget>
<widget class="QTextBrowser" name="textShortHelp"/>
<widget class="QTextBrowser" name="textShortHelp">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</widget>
</item>
<item>
Expand Down

0 comments on commit 77fa177

Please sign in to comment.