3030import webbrowser
3131
3232from qgis .PyQt import uic
33- from qgis .PyQt .QtCore import QCoreApplication , QByteArray , QUrl
34- from qgis .PyQt .QtWidgets import QApplication , QDialogButtonBox
33+ from qgis .PyQt .QtCore import Qt , QCoreApplication , QByteArray , QUrl
34+ from qgis .PyQt .QtWidgets import QApplication , QDialogButtonBox , QVBoxLayout , QToolButton
3535
3636from qgis .utils import iface
3737from qgis .core import (QgsProject ,
@@ -80,13 +80,29 @@ def __init__(self, alg):
8080 super (AlgorithmDialogBase , self ).__init__ (iface .mainWindow ())
8181 self .setupUi (self )
8282
83+ # don't collapse parameters panel
84+ self .splitter .setCollapsible (0 , False )
85+
86+ # add collapse button to splitter
87+ splitterHandle = self .splitter .handle (1 )
88+ handleLayout = QVBoxLayout ()
89+ handleLayout .setContentsMargins (0 , 0 , 0 , 0 )
90+ self .btnCollapse = QToolButton (splitterHandle )
91+ self .btnCollapse .setAutoRaise (True )
92+ self .btnCollapse .setFixedSize (12 , 12 )
93+ handleLayout .addWidget (self .btnCollapse )
94+ handleLayout .insertStretch (0 )
95+ splitterHandle .setLayout (handleLayout )
96+
8397 self .feedback = AlgorithmDialogFeedback (self )
8498 self .feedback .progressChanged .connect (self .setPercentage )
8599 self .buttonCancel .clicked .connect (self .feedback .cancel )
86100
87101 self .settings = QgsSettings ()
88102 self .splitter .restoreState (self .settings .value ("/Processing/dialogBaseSplitter" , QByteArray ()))
89103 self .restoreGeometry (self .settings .value ("/Processing/dialogBase" , QByteArray ()))
104+ self .splitterState = self .splitter .saveState ()
105+ self .splitterChanged (0 , 0 )
90106
91107 self .setWindowTitle (self .alg .displayName ())
92108
@@ -103,8 +119,8 @@ def __init__(self, alg):
103119 self .btnClose = self .buttonBox .button (QDialogButtonBox .Close )
104120 self .buttonBox .helpRequested .connect (self .openHelp )
105121
106- # don't collapse parameters panel
107- self .splitter .setCollapsible ( 0 , False )
122+ self . btnCollapse . clicked . connect ( self . toggleCollapsed )
123+ self .splitter .splitterMoved . connect ( self . splitterChanged )
108124
109125 # desktop = QDesktopWidget()
110126 # if desktop.physicalDpiX() > 96:
@@ -209,6 +225,24 @@ def reject(self):
209225 def finish (self , context ):
210226 pass
211227
228+ def toggleCollapsed (self ):
229+ if self .helpCollapsed :
230+ self .splitter .restoreState (self .splitterState )
231+ self .btnCollapse .setArrowType (Qt .RightArrow )
232+ else :
233+ self .splitterState = self .splitter .saveState ()
234+ self .splitter .setSizes ([1 , 0 ])
235+ self .btnCollapse .setArrowType (Qt .LeftArrow )
236+ self .helpCollapsed = not self .helpCollapsed
237+
238+ def splitterChanged (self , pos , index ):
239+ if self .splitter .sizes ()[1 ] == 0 :
240+ self .helpCollapsed = True
241+ self .btnCollapse .setArrowType (Qt .LeftArrow )
242+ else :
243+ self .helpCollapsed = False
244+ self .btnCollapse .setArrowType (Qt .RightArrow )
245+
212246 def openHelp (self ):
213247 algHelp = self .alg .helpUrl ()
214248 if algHelp is not None :
0 commit comments