@@ -56,9 +56,10 @@ class BatchInputSelectionPanel(QWidget):
5656 def __init__ (self , param , row , col , dialog ):
5757 super (BatchInputSelectionPanel , self ).__init__ (None )
5858 self .param = param
59- self .dialog = dialog
6059 self .row = row
6160 self .col = col
61+ self .dialog = dialog
62+
6263 self .horizontalLayout = QHBoxLayout (self )
6364 self .horizontalLayout .setSpacing (0 )
6465 self .horizontalLayout .setMargin (0 )
@@ -67,8 +68,7 @@ def __init__(self, param, row, col, dialog):
6768 self .text .setMinimumWidth (300 )
6869 self .setValue ('' )
6970 self .text .editingFinished .connect (self .textEditingFinished )
70- self .text .setSizePolicy (QSizePolicy .Expanding ,
71- QSizePolicy .Expanding )
71+ self .text .setSizePolicy (QSizePolicy .Expanding , QSizePolicy .Expanding )
7272 self .horizontalLayout .addWidget (self .text )
7373 self .pushButton = QPushButton ()
7474 self .pushButton .setText ('…' )
@@ -86,14 +86,12 @@ def showPopupMenu(self):
8686 popupmenu = QMenu ()
8787
8888 if not (isinstance (self .param , QgsProcessingParameterMultipleLayers ) and
89- self .param .layerType == dataobjects .TYPE_FILE ):
90- selectLayerAction = QAction (
91- QCoreApplication .translate ('BatchInputSelectionPanel' , 'Select from Open Layers…' ), self .pushButton )
89+ self .param .layerType () == QgsProcessing .TypeFile ):
90+ selectLayerAction = QAction (self .tr ('Select from Open Layers…' ), self .pushButton )
9291 selectLayerAction .triggered .connect (self .showLayerSelectionDialog )
9392 popupmenu .addAction (selectLayerAction )
9493
95- selectFileAction = QAction (
96- QCoreApplication .translate ('BatchInputSelectionPanel' , 'Select from File System…' ), self .pushButton )
94+ selectFileAction = QAction (self .tr ('Select from File System…' ), self .pushButton )
9795 selectFileAction .triggered .connect (self .showFileSelectionDialog )
9896 popupmenu .addAction (selectFileAction )
9997
@@ -151,22 +149,21 @@ def generate_layer_id(layer):
151149
152150 def showFileSelectionDialog (self ):
153151 settings = QgsSettings ()
154- text = str ( self .text .text () )
152+ text = self .text .text ()
155153 if os .path .isdir (text ):
156154 path = text
157155 elif os .path .isdir (os .path .dirname (text )):
158156 path = os .path .dirname (text )
159157 elif settings .contains ('/Processing/LastInputPath' ):
160- path = str ( settings .value ('/Processing/LastInputPath' ) )
158+ path = settings .value ('/Processing/LastInputPath' )
161159 else :
162160 path = ''
163161
164162 ret , selected_filter = QFileDialog .getOpenFileNames (self , self .tr ('Select Files' ), path ,
165163 getFileFilter (self .param ))
166164 if ret :
167165 files = list (ret )
168- settings .setValue ('/Processing/LastInputPath' ,
169- os .path .dirname (str (files [0 ])))
166+ settings .setValue ('/Processing/LastInputPath' , os .path .dirname (files [0 ]))
170167 for i , filename in enumerate (files ):
171168 files [i ] = dataobjects .getRasterSublayer (filename , self .param )
172169 if len (files ) == 1 :
0 commit comments