<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getSaveFileName(self, *args, **kwargs):
 """ analogue to QtWidgets.QFileDialog.getSaveFileNameAndFilter but returns the filename + chosen file ending even if not typed in gui """

        if 'directory' not in kwargs:
            if self.opts['save']:
                if self.opts['save']:
                    kwargs['directory'] = self.opts['save']
        fname = QtWidgets.QFileDialog.getSaveFileName(**kwargs)
        if fname:
            if type(fname) == tuple:
                #only happened since qt5
                #getSaveFileName returns (path, ftype)
                if not fname[0]:
                    return
                p = PathStr(fname[0])
                if not p.filetype():
                    ftyp = self._extractFtype(fname[1]) 
                    p = p.setFiletype(ftyp)
            else:
                p = PathStr(fname)
            self.opts['save'] = p.dirname()
            if self.opts['open'] is None:
                self.opts['open'] = self.opts['save']
            return p