Skip to content

Commit

Permalink
[processing] add button to collapse/expand short help
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jun 6, 2017
1 parent ffac4f9 commit f4853a2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
42 changes: 38 additions & 4 deletions python/plugins/processing/gui/AlgorithmDialogBase.py
Expand Up @@ -30,8 +30,8 @@
import webbrowser

from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication, QByteArray, QUrl
from qgis.PyQt.QtWidgets import QApplication, QDialogButtonBox
from qgis.PyQt.QtCore import Qt, QCoreApplication, QByteArray, QUrl
from qgis.PyQt.QtWidgets import QApplication, QDialogButtonBox, QVBoxLayout, QToolButton

from qgis.utils import iface
from qgis.core import (QgsProject,
Expand Down Expand Up @@ -80,13 +80,29 @@ def __init__(self, alg):
super(AlgorithmDialogBase, self).__init__(iface.mainWindow())
self.setupUi(self)

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

# add collapse button to splitter
splitterHandle = self.splitter.handle(1)
handleLayout = QVBoxLayout()
handleLayout.setContentsMargins(0, 0, 0, 0)
self.btnCollapse = QToolButton(splitterHandle)
self.btnCollapse.setAutoRaise(True)
self.btnCollapse.setFixedSize(12, 12)
handleLayout.addWidget(self.btnCollapse)
handleLayout.insertStretch(0)
splitterHandle.setLayout(handleLayout)

self.feedback = AlgorithmDialogFeedback(self)
self.feedback.progressChanged.connect(self.setPercentage)
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.splitterState = self.splitter.saveState()
self.splitterChanged(0, 0)

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

Expand All @@ -103,8 +119,8 @@ def __init__(self, alg):
self.btnClose = self.buttonBox.button(QDialogButtonBox.Close)
self.buttonBox.helpRequested.connect(self.openHelp)

# don't collapse parameters panel
self.splitter.setCollapsible(0, False)
self.btnCollapse.clicked.connect(self.toggleCollapsed)
self.splitter.splitterMoved.connect(self.splitterChanged)

# desktop = QDesktopWidget()
# if desktop.physicalDpiX() > 96:
Expand Down Expand Up @@ -209,6 +225,24 @@ def reject(self):
def finish(self, context):
pass

def toggleCollapsed(self):
if self.helpCollapsed:
self.splitter.restoreState(self.splitterState)
self.btnCollapse.setArrowType(Qt.RightArrow)
else:
self.splitterState = self.splitter.saveState()
self.splitter.setSizes([1, 0])
self.btnCollapse.setArrowType(Qt.LeftArrow)
self.helpCollapsed = not self.helpCollapsed

def splitterChanged(self, pos, index):
if self.splitter.sizes()[1] == 0:
self.helpCollapsed = True
self.btnCollapse.setArrowType(Qt.LeftArrow)
else:
self.helpCollapsed = False
self.btnCollapse.setArrowType(Qt.RightArrow)

def openHelp(self):
algHelp = self.alg.helpUrl()
if algHelp is not None:
Expand Down
6 changes: 6 additions & 0 deletions python/plugins/processing/ui/DlgAlgorithmBase.ui
Expand Up @@ -25,6 +25,9 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>16</number>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
Expand Down Expand Up @@ -112,6 +115,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="accessibleName">
<string/>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
Expand Down

0 comments on commit f4853a2

Please sign in to comment.