30
30
import webbrowser
31
31
32
32
from 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
35
35
36
36
from qgis .utils import iface
37
37
from qgis .core import (QgsProject ,
@@ -80,13 +80,29 @@ def __init__(self, alg):
80
80
super (AlgorithmDialogBase , self ).__init__ (iface .mainWindow ())
81
81
self .setupUi (self )
82
82
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
+
83
97
self .feedback = AlgorithmDialogFeedback (self )
84
98
self .feedback .progressChanged .connect (self .setPercentage )
85
99
self .buttonCancel .clicked .connect (self .feedback .cancel )
86
100
87
101
self .settings = QgsSettings ()
88
102
self .splitter .restoreState (self .settings .value ("/Processing/dialogBaseSplitter" , QByteArray ()))
89
103
self .restoreGeometry (self .settings .value ("/Processing/dialogBase" , QByteArray ()))
104
+ self .splitterState = self .splitter .saveState ()
105
+ self .splitterChanged (0 , 0 )
90
106
91
107
self .setWindowTitle (self .alg .displayName ())
92
108
@@ -103,8 +119,8 @@ def __init__(self, alg):
103
119
self .btnClose = self .buttonBox .button (QDialogButtonBox .Close )
104
120
self .buttonBox .helpRequested .connect (self .openHelp )
105
121
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 )
108
124
109
125
# desktop = QDesktopWidget()
110
126
# if desktop.physicalDpiX() > 96:
@@ -209,6 +225,24 @@ def reject(self):
209
225
def finish (self , context ):
210
226
pass
211
227
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
+
212
246
def openHelp (self ):
213
247
algHelp = self .alg .helpUrl ()
214
248
if algHelp is not None :
0 commit comments