QFileDialog Wizard: without_py2_and_pyqt4

Tue, 03 Sep 2019 19:31:20 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 03 Sep 2019 19:31:20 +0200
branch
without_py2_and_pyqt4
changeset 7207
4ba7a9b26020
parent 7206
74666c6679af
child 7209
ad27005f08ac

QFileDialog Wizard:
- added support for the QFileDialog.get...Url() methods
- added support for E5FileDialog

docs/changelog file | annotate | diff | comparison | revisions
eric6/E5Gui/E5FileDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/PluginWizardQFileDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.py file | annotate | diff | comparison | revisions
eric6/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.ui file | annotate | diff | comparison | revisions
--- a/docs/changelog	Tue Sep 03 19:27:46 2019 +0200
+++ b/docs/changelog	Tue Sep 03 19:31:20 2019 +0200
@@ -1,5 +1,13 @@
 Change Log
 ----------
+Version 19.10:
+- bug fixes
+- removed runtime support for Python2 and PyQt4
+- changed minimum Qt/PyQt version required to 5.9.0
+- QFileDialog Wizard:
+  -- added support for the QFileDialog.get...Url() methods
+  -- added support for E5FileDialog
+
 Version 19.9:
 - bug fixes
 - added widgets to support development for embedded controllers with
--- a/eric6/E5Gui/E5FileDialog.py	Tue Sep 03 19:27:46 2019 +0200
+++ b/eric6/E5Gui/E5FileDialog.py	Tue Sep 03 19:31:20 2019 +0200
@@ -24,6 +24,7 @@
 ReadOnly = QFileDialog.ReadOnly
 HideNameFilterDetails = QFileDialog.HideNameFilterDetails
 DontUseSheet = QFileDialog.DontUseSheet
+DontUseCustomDirectoryIcons = QFileDialog.DontUseCustomDirectoryIcons
 
 
 def __reorderFilter(filterStr, initialFilter=""):
--- a/eric6/Plugins/PluginWizardQFileDialog.py	Tue Sep 03 19:27:46 2019 +0200
+++ b/eric6/Plugins/PluginWizardQFileDialog.py	Tue Sep 03 19:31:20 2019 +0200
@@ -49,6 +49,7 @@
         super(FileDialogWizard, self).__init__(ui)
         self.__ui = ui
         
+        # PyQt4 or PyQt5
         self.__pyqtRe = re.compile(r"(?:import|from)\s+PyQt([45])")
 
     def activate(self):
@@ -57,7 +58,7 @@
         
         @return tuple of None and activation status (boolean)
         """
-        self.__initAction()
+        self.__initActions()
         self.__initMenu()
         
         return None, True
@@ -68,27 +69,45 @@
         """
         menu = self.__ui.getMenu("wizards")
         if menu:
-            menu.removeAction(self.action)
-        self.__ui.removeE5Actions([self.action], 'wizards')
+            menu.removeAction(self.qFileDialogAction)
+            menu.removeAction(self.e5FileDialogAction)
+        self.__ui.removeE5Actions(
+            [self.qFileDialogAction, self.e5FileDialogAction],
+            'wizards')
     
-    def __initAction(self):
+    def __initActions(self):
         """
-        Private method to initialize the action.
+        Private method to initialize the actions.
         """
-        self.action = E5Action(
+        self.qFileDialogAction = E5Action(
             self.tr('QFileDialog Wizard'),
             self.tr('Q&FileDialog Wizard...'), 0, 0, self,
             'wizards_qfiledialog')
-        self.action.setStatusTip(self.tr('QFileDialog Wizard'))
-        self.action.setWhatsThis(self.tr(
+        self.qFileDialogAction.setStatusTip(self.tr('QFileDialog Wizard'))
+        self.qFileDialogAction.setWhatsThis(self.tr(
             """<b>QFileDialog Wizard</b>"""
             """<p>This wizard opens a dialog for entering all the parameters"""
             """ needed to create a QFileDialog. The generated code is"""
             """ inserted at the current cursor position.</p>"""
         ))
-        self.action.triggered.connect(self.__handle)
+        self.qFileDialogAction.triggered.connect(self.__handleQFileDialog)
         
-        self.__ui.addE5Actions([self.action], 'wizards')
+        self.e5FileDialogAction = E5Action(
+            self.tr('E5FileDialog Wizard'),
+            self.tr('E&5ileDialog Wizard...'), 0, 0, self,
+            'wizards_e5filedialog')
+        self.e5FileDialogAction.setStatusTip(self.tr('E5FileDialog Wizard'))
+        self.e5FileDialogAction.setWhatsThis(self.tr(
+            """<b>E5FileDialog Wizard</b>"""
+            """<p>This wizard opens a dialog for entering all the parameters"""
+            """ needed to create an E5FileDialog. The generated code is"""
+            """ inserted at the current cursor position.</p>"""
+        ))
+        self.e5FileDialogAction.triggered.connect(self.__handleE5FileDialog)
+        
+        self.__ui.addE5Actions(
+            [self.qFileDialogAction, self.e5FileDialogAction],
+            'wizards')
 
     def __initMenu(self):
         """
@@ -96,24 +115,23 @@
         """
         menu = self.__ui.getMenu("wizards")
         if menu:
-            menu.addAction(self.action)
+            menu.addAction(self.e5FileDialogAction)
+            menu.addAction(self.qFileDialogAction)
     
-    def __callForm(self, editor):
+    def __callForm(self, editor, variant):
         """
         Private method to display a dialog and get the code.
         
         @param editor reference to the current editor
+        @type Editor
+        @param variant variant of code to be generated
+            (-1 = E5FileDialog, 0 = unknown, 4 = PyQt4, 5 = PyQt5)
+        @type int
         @return the generated code (string)
         """
-        match = self.__pyqtRe.search(editor.text())
-        if match is None:
-            pyqtVariant = 0    # unknown
-        else:
-            pyqtVariant = int(match.group(1))   # 4 or 5
-        
         from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import \
             FileDialogWizardDialog
-        dlg = FileDialogWizardDialog(pyqtVariant, None)
+        dlg = FileDialogWizardDialog(variant, None)
         if dlg.exec_() == QDialog.Accepted:
             line, index = editor.getCursorPosition()
             indLevel = editor.indentation(line) // editor.indentationWidth()
@@ -125,9 +143,14 @@
         else:
             return (None, 0)
         
-    def __handle(self):
+    def __handle(self, variant):
         """
         Private method to handle the wizards action.
+        
+        @param variant dialog variant to be generated
+            (E5FileDialog or QFileDialog)
+        @type str
+        @exception ValueError raised to indicate an illegal file dialog variant
         """
         editor = e5App().getObject("ViewManager").activeWindow()
         
@@ -137,10 +160,36 @@
                 self.tr('No current editor'),
                 self.tr('Please open or create a file first.'))
         else:
-            code, ok = self.__callForm(editor)
+            if variant == "QFileDialog":
+                match = self.__pyqtRe.search(editor.text())
+                if match is None:
+                    # unknown
+                    dialogVariant = 0
+                else:
+                    # PyQt4 or PyQt5
+                    dialogVariant = int(match.group(1))
+            elif variant == "E5FileDialog":
+                # E5FileDialog
+                dialogVariant = -1
+            else:
+                raise ValueError("Illegal dialog variant given")
+            
+            code, ok = self.__callForm(editor, dialogVariant)
             if ok:
                 line, index = editor.getCursorPosition()
                 # It should be done on this way to allow undo
                 editor.beginUndoAction()
                 editor.insertAt(code, line, index)
                 editor.endUndoAction()
+    
+    def __handleQFileDialog(self):
+        """
+        Private slot to handle the wizard QFileDialog action.
+        """
+        self.__handle("QFileDialog")
+    
+    def __handleE5FileDialog(self):
+        """
+        Private slot to handle the wizard E5FileDialog action.
+        """
+        self.__handle("E5FileDialog")
--- a/eric6/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.py	Tue Sep 03 19:27:46 2019 +0200
+++ b/eric6/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.py	Tue Sep 03 19:31:20 2019 +0200
@@ -11,7 +11,7 @@
 
 import os
 
-from PyQt5.QtCore import pyqtSlot
+from PyQt5.QtCore import pyqtSlot, QUrl
 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFileDialog, \
     QButtonGroup
 
@@ -22,20 +22,22 @@
 import Globals
 
 
-# TODO: adjust this to Qt5 QFileDialog and Eric E5FileDialog
 class FileDialogWizardDialog(QDialog, Ui_FileDialogWizardDialog):
     """
     Class implementing the color dialog wizard dialog.
     
-    It displays a dialog for entering the parameters
-    for the QFileDialog code generator.
+    It displays a dialog for entering the parameters for the
+    E5FileDialog or QFileDialog code generator.
     """
-    def __init__(self, pyqtVariant, parent=None):
+    def __init__(self, dialogVariant, parent=None):
         """
         Constructor
         
-        @param pyqtVariant variant of PyQt (integer; 0, 4 or 5)
-        @param parent parent widget (QWidget)
+        @param dialogVariant variant of the file dialog to be generated
+            (-1 = E5FileDialog, 0 = unknown, 4 = PyQt4, 5 = PyQt5)
+        @type int
+        @param parent parent widget
+        @type QWidget
         """
         super(FileDialogWizardDialog, self).__init__(parent)
         self.setupUi(self)
@@ -43,7 +45,7 @@
         self.eStartWithCompleter = E5FileCompleter(self.eStartWith)
         self.eWorkDirCompleter = E5DirCompleter(self.eWorkDir)
         
-        self.__pyqtVariant = pyqtVariant
+        self.__dialogVariant = dialogVariant
         
         self.__typeButtonsGroup = QButtonGroup(self)
         self.__typeButtonsGroup.setExclusive(True)
@@ -53,21 +55,36 @@
         self.__typeButtonsGroup.addButton(self.rfOpenFile, 11)
         self.__typeButtonsGroup.addButton(self.rfOpenFiles, 12)
         self.__typeButtonsGroup.addButton(self.rfSaveFile, 13)
-        self.__typeButtonsGroup.addButton(self.rDirectory, 20)
+        self.__typeButtonsGroup.addButton(self.rOpenFileUrl, 21)
+        self.__typeButtonsGroup.addButton(self.rOpenFileUrls, 22)
+        self.__typeButtonsGroup.addButton(self.rSaveFileUrl, 23)
+        self.__typeButtonsGroup.addButton(self.rDirectory, 30)
+        self.__typeButtonsGroup.addButton(self.rDirectoryUrl, 31)
         self.__typeButtonsGroup.buttonClicked[int].connect(
             self.__toggleInitialFilterAndResult)
         self.__toggleInitialFilterAndResult(1)
         
-        self.pyqtComboBox.addItems(["PyQt4", "PyQt5"])
-        self.__pyqtVariant = pyqtVariant
-        if self.__pyqtVariant == 5:
-            self.pyqtComboBox.setCurrentIndex(1)
+        self.__dialogVariant = dialogVariant
+        if self.__dialogVariant == -1:
+            self.pyqtComboBox.addItems(["eric"])
+            self.setWindowTitle(self.tr("E5FileDialog Wizard"))
+            self.pyqtComboBox.setCurrentIndex(0)
+            self.pyqtComboBox.setEnabled(False)
         else:
-            self.pyqtComboBox.setCurrentIndex(0)
+            self.pyqtComboBox.addItems(["PyQt5", "PyQt4"])
+            self.setWindowTitle(self.tr("QFileDialog Wizard"))
+            if self.__dialogVariant == 5:
+                self.pyqtComboBox.setCurrentIndex(0)
+            elif self.__dialogVariant == 4:
+                self.pyqtComboBox.setCurrentIndex(1)
+            else:
+                self.pyqtComboBox.setCurrentIndex(0)
         
         self.rSaveFile.toggled[bool].connect(self.__toggleConfirmCheckBox)
         self.rfSaveFile.toggled[bool].connect(self.__toggleConfirmCheckBox)
+        self.rSaveFileUrl.toggled[bool].connect(self.__toggleConfirmCheckBox)
         self.rDirectory.toggled[bool].connect(self.__toggleGroupsAndTest)
+        self.rDirectoryUrl.toggled[bool].connect(self.__toggleGroupsAndTest)
         self.cStartWith.toggled[bool].connect(self.__toggleGroupsAndTest)
         self.cWorkDir.toggled[bool].connect(self.__toggleGroupsAndTest)
         self.cFilters.toggled[bool].connect(self.__toggleGroupsAndTest)
@@ -96,9 +113,14 @@
         
         @param txt text of the selected combo box entry (string)
         """
-        self.rfOpenFile.setEnabled(txt == "PyQt4")
-        self.rfOpenFiles.setEnabled(txt == "PyQt4")
-        self.rfSaveFile.setEnabled(txt == "PyQt4")
+        self.rfOpenFile.setEnabled(txt in ("eric", "PyQt4"))
+        self.rfOpenFiles.setEnabled(txt in ("eric", "PyQt4"))
+        self.rfSaveFile.setEnabled(txt in ("eric", "PyQt4"))
+        
+        self.rOpenFileUrl.setEnabled(txt == "PyQt5")
+        self.rOpenFileUrls.setEnabled(txt == "PyQt5")
+        self.rSaveFileUrl.setEnabled(txt == "PyQt5")
+        self.rDirectoryUrl.setEnabled(txt == "PyQt5")
         
         if txt == "PyQt5":
             if self.rfOpenFile.isChecked():
@@ -107,8 +129,25 @@
                 self.rOpenFiles.setChecked(True)
             elif self.rfSaveFile.isChecked():
                 self.rSaveFile.setChecked(True)
+        else:
+            if self.rOpenFileUrl.isChecked():
+                self.rOpenFile.setChecked(True)
+            if self.rOpenFileUrls.isChecked():
+                self.rOpenFiles.setChecked(True)
+            if self.rSaveFileUrl.isChecked():
+                self.rSaveFile.setChecked(True)
+            if self.rDirectoryUrl.isChecked():
+                self.rDirectory.setChecked(True)
         
-        self.__pyqtVariant = 5 if txt == "PyQt5" else 4
+        if txt == "eric":
+            self.__dialogVariant = -1
+        elif txt == "PyQt5":
+            self.__dialogVariant = 5
+        elif txt == "PyQt4":
+            self.__dialogVariant = 4
+        else:
+            # default is PyQt5
+            self.__dialogVariant = 5
         
         self.__toggleInitialFilterAndResult(
             self.__typeButtonsGroup.checkedId())
@@ -133,117 +172,114 @@
             else:
                 options = QFileDialog.Options()
             options = self.__adjustOptions(options)
-            if self.rOpenFile.isChecked() and self.__pyqtVariant == 4:
-                try:
-                    QFileDialog.getOpenFileName(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        options)
-                except TypeError:
-                    QFileDialog.getOpenFileName(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
+            QFileDialog.getOpenFileName(
+                None,
+                self.eCaption.text(),
+                self.eStartWith.text(),
+                self.eFilters.text(),
+                self.eInitialFilter.text(),
+                options)
+        elif self.rOpenFileUrl.isChecked():
+            if not self.cSymlinks.isChecked():
+                options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
             else:
-                try:
-                    QFileDialog.getOpenFileNameAndFilter(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
-                except AttributeError:
-                    QFileDialog.getOpenFileName(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
+                options = QFileDialog.Options()
+            options = self.__adjustOptions(options)
+            try:
+                QFileDialog.getOpenFileUrl(
+                    None,
+                    self.eCaption.text(),
+                    QUrl(self.eStartWith.text()),
+                    self.eFilters.text(),
+                    self.eInitialFilter.text(),
+                    options,
+                    self.schemesEdit.text().split())
+            except TypeError:
+                # PyQt5 < 5.13.0 contains an error
+                QFileDialog.getOpenFileUrl(
+                    None,
+                    self.eCaption.text(),
+                    self.eStartWith.text(),
+                    self.eFilters.text(),
+                    self.eInitialFilter.text(),
+                    options,
+                    self.schemesEdit.text().split())
         elif self.rOpenFiles.isChecked() or self.rfOpenFiles.isChecked():
             if not self.cSymlinks.isChecked():
                 options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
             else:
                 options = QFileDialog.Options()
             options = self.__adjustOptions(options)
-            if self.rOpenFiles.isChecked() and self.__pyqtVariant == 4:
-                try:
-                    QFileDialog.getOpenFileNames(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        options)
-                except TypeError:
-                    QFileDialog.getOpenFileNames(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
+            QFileDialog.getOpenFileNames(
+                None,
+                self.eCaption.text(),
+                self.eStartWith.text(),
+                self.eFilters.text(),
+                self.eInitialFilter.text(),
+                options)
+        elif self.rOpenFileUrls.isChecked():
+            if not self.cSymlinks.isChecked():
+                options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
             else:
-                try:
-                    QFileDialog.getOpenFileNamesAndFilter(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
-                except AttributeError:
-                    QFileDialog.getOpenFileNames(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
+                options = QFileDialog.Options()
+            options = self.__adjustOptions(options)
+            try:
+                QFileDialog.getOpenFileUrls(
+                    None,
+                    self.eCaption.text(),
+                    QUrl(self.eStartWith.text()),
+                    self.eFilters.text(),
+                    self.eInitialFilter.text(),
+                    options,
+                    self.schemesEdit.text().split())
+            except TypeError:
+                # PyQt5 < 5.13.0 contains an error
+                QFileDialog.getOpenFileUrls(
+                    None,
+                    self.eCaption.text(),
+                    self.eStartWith.text(),
+                    self.eFilters.text(),
+                    self.eInitialFilter.text(),
+                    options,
+                    self.schemesEdit.text().split())
         elif self.rSaveFile.isChecked() or self.rfSaveFile.isChecked():
             if not self.cSymlinks.isChecked():
                 options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
             else:
                 options = QFileDialog.Options()
             options = self.__adjustOptions(options)
-            if self.rSaveFile.isChecked() and self.__pyqtVariant == 4:
-                try:
-                    QFileDialog.getSaveFileName(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        options)
-                except TypeError:
-                    QFileDialog.getSaveFileName(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
+            QFileDialog.getSaveFileName(
+                None,
+                self.eCaption.text(),
+                self.eStartWith.text(),
+                self.eFilters.text(),
+                self.eInitialFilter.text(),
+                options)
+        elif self.rSaveFileUrl.isChecked():
+            if not self.cSymlinks.isChecked():
+                options = QFileDialog.Options(QFileDialog.DontResolveSymlinks)
             else:
-                try:
-                    QFileDialog.getSaveFileNameAndFilter(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
-                except AttributeError:
-                    QFileDialog.getSaveFileName(
-                        None,
-                        self.eCaption.text(),
-                        self.eStartWith.text(),
-                        self.eFilters.text(),
-                        self.eInitialFilter.text(),
-                        options)
+                options = QFileDialog.Options()
+            options = self.__adjustOptions(options)
+            try:
+                QFileDialog.getSaveFileUrl(
+                    None,
+                    self.eCaption.text(),
+                    QUrl(self.eStartWith.text()),
+                    self.eFilters.text(),
+                    self.eInitialFilter.text(),
+                    options,
+                    self.schemesEdit.text().split())
+            except TypeError:
+                # PyQt5 < 5.13.0 contains an error
+                QFileDialog.getSaveFileUrl(
+                    None,
+                    self.eCaption.text(),
+                    self.eStartWith.text(),
+                    self.eFilters.text(),
+                    self.eInitialFilter.text(),
+                    options,
+                    self.schemesEdit.text().split())
         elif self.rDirectory.isChecked():
             options = QFileDialog.Options()
             if not self.cSymlinks.isChecked():
@@ -258,19 +294,44 @@
                 self.eCaption.text(),
                 self.eWorkDir.text(),
                 options)
+        elif self.rDirectoryUrl.isChecked():
+            options = QFileDialog.Options()
+            if not self.cSymlinks.isChecked():
+                options |= QFileDialog.Options(QFileDialog.DontResolveSymlinks)
+            if self.cDirOnly.isChecked():
+                options |= QFileDialog.Options(QFileDialog.ShowDirsOnly)
+            else:
+                options |= QFileDialog.Options(QFileDialog.Option(0))
+            options = self.__adjustOptions(options)
+            try:
+                QFileDialog.getExistingDirectoryUrl(
+                    None,
+                    self.eCaption.text(),
+                    QUrl(self.eWorkDir.text()),
+                    options,
+                    self.schemesEdit.text().split())
+            except TypeError:
+                # PyQt5 < 5.13.0 contains an error
+                QFileDialog.getExistingDirectoryUrl(
+                    None,
+                    self.eCaption.text(),
+                    self.eWorkDir.text(),
+                    options,
+                    self.schemesEdit.text().split())
     
     def __toggleConfirmCheckBox(self):
         """
         Private slot to enable/disable the confirmation check box.
         """
         self.cConfirmOverwrite.setEnabled(
-            self.rSaveFile.isChecked() or self.rfSaveFile.isChecked())
+            self.rSaveFile.isChecked() or self.rfSaveFile.isChecked() or
+            self.rSaveFileUrl.isChecked())
     
     def __toggleGroupsAndTest(self):
         """
         Private slot to enable/disable certain groups and the test button.
         """
-        if self.rDirectory.isChecked():
+        if self.rDirectory.isChecked() or self.rDirectoryUrl.isChecked():
             self.filePropertiesGroup.setEnabled(False)
             self.dirPropertiesGroup.setEnabled(True)
             self.bTest.setDisabled(self.cWorkDir.isChecked())
@@ -287,17 +348,19 @@
         
         @param checkedId id of the clicked button (integer)
         """
-        if (self.__pyqtVariant == 4 and checkedId in [11, 12, 13]) or \
-                (self.__pyqtVariant == 5 and checkedId in [1, 2, 3]):
-            enable = True
-        else:
-            enable = False
+        enable = (
+            (self.__dialogVariant in (-1, 4) and checkedId in [11, 12, 13]) or
+            (self.__dialogVariant == 5 and checkedId in [1, 2, 3, 21, 22, 23])
+        )
+        
         self.lInitialFilter.setEnabled(enable)
         self.eInitialFilter.setEnabled(enable)
         self.cInitialFilter.setEnabled(enable)
         
         self.lFilterVariable.setEnabled(enable)
         self.eFilterVariable.setEnabled(enable)
+        
+        self.urlPropertiesGroup.setEnabled(checkedId in (21, 22, 23, 31))
     
     def getCode(self, indLevel, indString):
         """
@@ -338,10 +401,10 @@
                 nameVariable = "res"
         filterVariable = self.eFilterVariable.text()
         if not filterVariable:
-            if (self.__pyqtVariant == 4 and
+            if (self.__dialogVariant in (-1, 4) and
                 self.__typeButtonsGroup.checkedButton() in [
                     self.rfOpenFile, self.rfOpenFiles, self.rfSaveFile]) or \
-                    (self.__pyqtVariant == 5 and
+                    (self.__dialogVariant == 5 and
                         self.__typeButtonsGroup.checkedButton() in [
                             self.rOpenFile, self.rOpenFiles, self.rSaveFile]):
                 filterVariable = ", selectedFilter"
@@ -350,10 +413,18 @@
         else:
             filterVariable = ", " + filterVariable
         
-        code = '{0}{1} = QFileDialog.'.format(nameVariable, filterVariable)
-        if self.rOpenFile.isChecked() or self.rfOpenFile.isChecked():
+        if self.__dialogVariant == -1:
+            dialogType = "E5FileDialog"
+        else:
+            dialogType = "QFileDialog"
+        
+        code = '{0}{1} = {2}.'.format(nameVariable, filterVariable, dialogType)
+        if self.rOpenFile.isChecked() or self.rfOpenFile.isChecked() or \
+           self.rOpenFileUrl.isChecked():
             if self.rOpenFile.isChecked():
                 code += 'getOpenFileName({0}{1}'.format(os.linesep, istring)
+            elif self.rOpenFileUrl.isChecked():
+                code += 'getOpenFileUrl({0}{1}'.format(os.linesep, istring)
             else:
                 code += 'getOpenFileNameAndFilter({0}{1}'.format(
                     os.linesep, istring)
@@ -363,14 +434,26 @@
             else:
                 code += 'self.tr("{0}"),{1}{2}'.format(
                     self.eCaption.text(), os.linesep, istring)
-            if not self.eStartWith.text():
-                code += '"",{0}{1}'.format(os.linesep, istring)
+            if self.rOpenFileUrl.isChecked():
+                if not self.eStartWith.text():
+                    code += 'QUrl(),{0}{1}'.format(os.linesep, istring)
+                else:
+                    if self.cStartWith.isChecked():
+                        fmt = '{0},{1}{2}'
+                    else:
+                        fmt = 'QUrl("{0}"),{1}{2}'
+                    code += fmt.format(self.eStartWith.text(), os.linesep,
+                                       istring)
             else:
-                if self.cStartWith.isChecked():
-                    fmt = '{0},{1}{2}'
+                if not self.eStartWith.text():
+                    code += '"",{0}{1}'.format(os.linesep, istring)
                 else:
-                    fmt = 'self.tr("{0}"),{1}{2}'
-                code += fmt.format(self.eStartWith.text(), os.linesep, istring)
+                    if self.cStartWith.isChecked():
+                        fmt = '{0},{1}{2}'
+                    else:
+                        fmt = '"{0}",{1}{2}'
+                    code += fmt.format(self.eStartWith.text(), os.linesep,
+                                       istring)
             if self.eFilters.text() == "":
                 code += '""'
             else:
@@ -379,7 +462,70 @@
                 else:
                     fmt = 'self.tr("{0}")'
                 code += fmt.format(self.eFilters.text())
-            if self.rfOpenFile.isChecked() or self.__pyqtVariant == 5:
+            if self.rfOpenFile.isChecked() or self.__dialogVariant == 5:
+                if self.eInitialFilter.text() == "":
+                    initialFilter = "None"
+                else:
+                    if self.cInitialFilter.isChecked():
+                        fmt = '{0}'
+                    else:
+                        fmt = 'self.tr("{0}")'
+                    initialFilter = fmt.format(self.eInitialFilter.text())
+                code += ',{0}{1}{2}'.format(os.linesep, istring, initialFilter)
+            if not self.cSymlinks.isChecked():
+                code += \
+                    ',{0}{1}{2}.Options(' \
+                    '{2}.DontResolveSymlinks)' \
+                    .format(os.linesep, istring, dialogType)
+            if self.rOpenFileUrl.isChecked() and bool(self.schemesEdit.text()):
+                code += \
+                    ',{0}{1}{2}'.format(os.linesep, istring,
+                                        self.__prepareSchemesList())
+            code += '){0}'.format(estring)
+        elif self.rOpenFiles.isChecked() or self.rfOpenFiles.isChecked() or \
+                self.rOpenFileUrls.isChecked():
+            if self.rOpenFiles.isChecked():
+                code += 'getOpenFileNames({0}{1}'.format(os.linesep, istring)
+            elif self.rOpenFileUrls.isChecked():
+                code += 'getOpenFileUrls({0}{1}'.format(os.linesep, istring)
+            else:
+                code += 'getOpenFileNamesAndFilter({0}{1}'.format(
+                    os.linesep, istring)
+            code += '{0},{1}{2}'.format(parent, os.linesep, istring)
+            if not self.eCaption.text():
+                code += '"",{0}{1}'.format(os.linesep, istring)
+            else:
+                code += 'self.tr("{0}"),{1}{2}'.format(
+                    self.eCaption.text(), os.linesep, istring)
+            if self.rOpenFileUrls.isChecked():
+                if not self.eStartWith.text():
+                    code += 'QUrl(),{0}{1}'.format(os.linesep, istring)
+                else:
+                    if self.cStartWith.isChecked():
+                        fmt = '{0},{1}{2}'
+                    else:
+                        fmt = 'QUrl("{0}"),{1}{2}'
+                    code += fmt.format(self.eStartWith.text(), os.linesep,
+                                       istring)
+            else:
+                if not self.eStartWith.text():
+                    code += '"",{0}{1}'.format(os.linesep, istring)
+                else:
+                    if self.cStartWith.isChecked():
+                        fmt = '{0},{1}{2}'
+                    else:
+                        fmt = '"{0}",{1}{2}'
+                    code += fmt.format(self.eStartWith.text(), os.linesep,
+                                       istring)
+            if not self.eFilters.text():
+                code += '""'
+            else:
+                if self.cFilters.isChecked():
+                    fmt = '{0}'
+                else:
+                    fmt = 'self.tr("{0}")'
+                code += fmt.format(self.eFilters.text())
+            if self.rfOpenFiles.isChecked() or self.__dialogVariant == 5:
                 if self.eInitialFilter.text() == "":
                     initialFilter = "None"
                 else:
@@ -391,57 +537,21 @@
                 code += ',{0}{1}{2}'.format(os.linesep, istring, initialFilter)
             if not self.cSymlinks.isChecked():
                 code += \
-                    ',{0}{1}QFileDialog.Options(' \
-                    'QFileDialog.DontResolveSymlinks)' \
-                    .format(os.linesep, istring)
+                    ',{0}{1}{2}.Options(' \
+                    '{2}.DontResolveSymlinks)' \
+                    .format(os.linesep, istring, dialogType)
+            if self.rOpenFileUrls.isChecked() and \
+               bool(self.schemesEdit.text()):
+                code += \
+                    ',{0}{1}{2}'.format(os.linesep, istring,
+                                        self.__prepareSchemesList())
             code += '){0}'.format(estring)
-        elif self.rOpenFiles.isChecked() or self.rfOpenFiles.isChecked():
-            if self.rOpenFiles.isChecked():
-                code += 'getOpenFileNames({0}{1}'.format(os.linesep, istring)
-            else:
-                code += 'getOpenFileNamesAndFilter({0}{1}'.format(
-                    os.linesep, istring)
-            code += '{0},{1}{2}'.format(parent, os.linesep, istring)
-            if not self.eCaption.text():
-                code += '"",{0}{1}'.format(os.linesep, istring)
-            else:
-                code += 'self.tr("{0}"),{1}{2}'.format(
-                    self.eCaption.text(), os.linesep, istring)
-            if not self.eStartWith.text():
-                code += '"",{0}{1}'.format(os.linesep, istring)
-            else:
-                if self.cStartWith.isChecked():
-                    fmt = '{0},{1}{2}'
-                else:
-                    fmt = 'self.tr("{0}"),{1}{2}'
-                code += fmt.format(self.eStartWith.text(), os.linesep, istring)
-            if not self.eFilters.text():
-                code += '""'
-            else:
-                if self.cFilters.isChecked():
-                    fmt = '{0}'
-                else:
-                    fmt = 'self.tr("{0}")'
-                code += fmt.format(self.eFilters.text())
-            if self.rfOpenFiles.isChecked() or self.__pyqtVariant == 5:
-                if self.eInitialFilter.text() == "":
-                    initialFilter = "None"
-                else:
-                    if self.cInitialFilter.isChecked():
-                        fmt = '{0}'
-                    else:
-                        fmt = 'self.tr("{0}")'
-                    initialFilter = fmt.format(self.eInitialFilter.text())
-                code += ',{0}{1}{2}'.format(os.linesep, istring, initialFilter)
-            if not self.cSymlinks.isChecked():
-                code += \
-                    ',{0}{1}QFileDialog.Options(' \
-                    'QFileDialog.DontResolveSymlinks)' \
-                    .format(os.linesep, istring)
-            code += '){0}'.format(estring)
-        elif self.rSaveFile.isChecked() or self.rfSaveFile.isChecked():
+        elif self.rSaveFile.isChecked() or self.rfSaveFile.isChecked() or \
+                self.rSaveFileUrl.isChecked():
             if self.rSaveFile.isChecked():
                 code += 'getSaveFileName({0}{1}'.format(os.linesep, istring)
+            elif self.rSaveFileUrl.isChecked():
+                code += 'getSaveFileUrl({0}{1}'.format(os.linesep, istring)
             else:
                 code += 'getSaveFileNameAndFilter({0}{1}'.format(
                     os.linesep, istring)
@@ -451,14 +561,26 @@
             else:
                 code += 'self.tr("{0}"),{1}{2}'.format(
                     self.eCaption.text(), os.linesep, istring)
-            if not self.eStartWith.text():
-                code += '"",{0}{1}'.format(os.linesep, istring)
+            if self.rSaveFileUrl.isChecked():
+                if not self.eStartWith.text():
+                    code += 'QUrl(),{0}{1}'.format(os.linesep, istring)
+                else:
+                    if self.cStartWith.isChecked():
+                        fmt = '{0},{1}{2}'
+                    else:
+                        fmt = 'QUrl("{0}"),{1}{2}'
+                    code += fmt.format(self.eStartWith.text(), os.linesep,
+                                       istring)
             else:
-                if self.cStartWith.isChecked():
-                    fmt = '{0},{1}{2}'
+                if not self.eStartWith.text():
+                    code += '"",{0}{1}'.format(os.linesep, istring)
                 else:
-                    fmt = 'self.tr("{0}"),{1}{2}'
-                code += fmt.format(self.eStartWith.text(), os.linesep, istring)
+                    if self.cStartWith.isChecked():
+                        fmt = '{0},{1}{2}'
+                    else:
+                        fmt = '"{0}",{1}{2}'
+                    code += fmt.format(self.eStartWith.text(), os.linesep,
+                                       istring)
             if not self.eFilters.text():
                 code += '""'
             else:
@@ -467,7 +589,7 @@
                 else:
                     fmt = 'self.tr("{0}")'
                 code += fmt.format(self.eFilters.text())
-            if self.rfSaveFile.isChecked() or self.__pyqtVariant == 5:
+            if self.rfSaveFile.isChecked() or self.__dialogVariant == 5:
                 if self.eInitialFilter.text() == "":
                     initialFilter = "None"
                 else:
@@ -479,40 +601,75 @@
                 code += ',{0}{1}{2}'.format(os.linesep, istring, initialFilter)
             if (not self.cSymlinks.isChecked()) or \
                (not self.cConfirmOverwrite.isChecked()):
-                code += ',{0}{1}QFileDialog.Options('.format(
-                    os.linesep, istring)
+                code += ',{0}{1}{2}.Options('.format(
+                    os.linesep, istring, dialogType)
                 if not self.cSymlinks.isChecked():
-                    code += 'QFileDialog.DontResolveSymlinks'
+                    code += '{0}.DontResolveSymlinks'.format(dialogType)
                 if (not self.cSymlinks.isChecked()) and \
                    (not self.cConfirmOverwrite.isChecked()):
                     code += ' | '
                 if not self.cConfirmOverwrite.isChecked():
-                    code += 'QFileDialog.DontConfirmOverwrite'
+                    code += '{0}.DontConfirmOverwrite'.format(dialogType)
                 code += ')'
+            if self.rSaveFileUrl.isChecked() and \
+               bool(self.schemesEdit.text()):
+                code += \
+                    ',{0}{1}{2}'.format(os.linesep, istring,
+                                        self.__prepareSchemesList())
             code += '){0}'.format(estring)
-        elif self.rDirectory.isChecked():
-            code += 'getExistingDirectory({0}{1}'.format(os.linesep, istring)
+        elif self.rDirectory.isChecked() or self.rDirectoryUrl.isChecked():
+            if self.rDirectory.isChecked():
+                code += 'getExistingDirectory({0}{1}'.format(
+                    os.linesep, istring)
+            else:
+                code += 'getExistingDirectoryUrl({0}{1}'.format(
+                    os.linesep, istring)
             code += '{0},{1}{2}'.format(parent, os.linesep, istring)
             if not self.eCaption.text():
                 code += '"",{0}{1}'.format(os.linesep, istring)
             else:
                 code += 'self.tr("{0}"),{1}{2}'.format(
                     self.eCaption.text(), os.linesep, istring)
-            if not self.eWorkDir.text():
-                code += '""'
+            if self.rDirectoryUrl.isChecked():
+                if not self.eWorkDir.text():
+                    code += 'QUrl()'
+                else:
+                    if self.cWorkDir.isChecked():
+                        fmt = '{0}'
+                    else:
+                        fmt = 'QUrl("{0}")'
+                    code += fmt.format(self.eWorkDir.text())
             else:
-                if self.cWorkDir.isChecked():
-                    fmt = '{0}'
+                if not self.eWorkDir.text():
+                    code += '""'
                 else:
-                    fmt = 'self.tr("{0}")'
-                code += fmt.format(self.eWorkDir.text())
-            code += ',{0}{1}QFileDialog.Options('.format(os.linesep, istring)
+                    if self.cWorkDir.isChecked():
+                        fmt = '{0}'
+                    else:
+                        fmt = '"{0}"'
+                    code += fmt.format(self.eWorkDir.text())
+            code += ',{0}{1}{2}.Options('.format(os.linesep, istring,
+                                                 dialogType)
             if not self.cSymlinks.isChecked():
-                code += 'QFileDialog.DontResolveSymlinks | '
+                code += '{0}.DontResolveSymlinks | '.format(dialogType)
             if self.cDirOnly.isChecked():
-                code += 'QFileDialog.ShowDirsOnly'
+                code += '{0}.ShowDirsOnly'.format(dialogType)
             else:
-                code += 'QFileDialog.Option(0)'
-            code += ')){0}'.format(estring)
+                code += '{0}.Option(0)'.format(dialogType)
+            code += ')'
+            if self.rDirectoryUrl.isChecked():
+                code += \
+                    ',{0}{1}{2}'.format(os.linesep, istring,
+                                        self.__prepareSchemesList())
+            code += '){0}'.format(estring)
             
         return code
+    
+    def __prepareSchemesList(self):
+        """
+        Private method to prepare the list of supported schemes.
+        
+        @return string representation of the supported schemes
+        @rtype str
+        """
+        return repr(self.schemesEdit.text().strip().split())
--- a/eric6/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.ui	Tue Sep 03 19:27:46 2019 +0200
+++ b/eric6/Plugins/WizardPlugins/FileDialogWizard/FileDialogWizardDialog.ui	Tue Sep 03 19:31:20 2019 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>604</width>
-    <height>660</height>
+    <height>742</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -22,7 +22,7 @@
      <item>
       <widget class="QLabel" name="label">
        <property name="text">
-        <string>PyQt Variant:</string>
+        <string>Variant:</string>
        </property>
       </widget>
      </item>
@@ -126,6 +126,49 @@
         </property>
        </widget>
       </item>
+      <item row="2" column="0">
+       <widget class="QRadioButton" name="rOpenFileUrl">
+        <property name="toolTip">
+         <string>Select to create an 'Open File' dialog</string>
+        </property>
+        <property name="text">
+         <string>Open File URL</string>
+        </property>
+        <property name="checked">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QRadioButton" name="rOpenFileUrls">
+        <property name="toolTip">
+         <string>Select to create an 'Open Files' dialog</string>
+        </property>
+        <property name="text">
+         <string>Open Files URL</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="2">
+       <widget class="QRadioButton" name="rSaveFileUrl">
+        <property name="toolTip">
+         <string>Select to create a 'Save File' dialog</string>
+        </property>
+        <property name="text">
+         <string>Save File URL</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="3">
+       <widget class="QRadioButton" name="rDirectoryUrl">
+        <property name="toolTip">
+         <string>Select to create a 'Select Directory' dialog</string>
+        </property>
+        <property name="text">
+         <string>Select Directory URL</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -143,7 +186,11 @@
        </widget>
       </item>
       <item row="0" column="1">
-       <widget class="QLineEdit" name="eNameVariable"/>
+       <widget class="QLineEdit" name="eNameVariable">
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
+       </widget>
       </item>
       <item row="1" column="0">
        <widget class="QLabel" name="lFilterVariable">
@@ -153,7 +200,11 @@
        </widget>
       </item>
       <item row="1" column="1">
-       <widget class="QLineEdit" name="eFilterVariable"/>
+       <widget class="QLineEdit" name="eFilterVariable">
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
+       </widget>
       </item>
      </layout>
     </widget>
@@ -172,6 +223,9 @@
        <property name="toolTip">
         <string>Enter the title text</string>
        </property>
+       <property name="clearButtonEnabled">
+        <bool>true</bool>
+       </property>
       </widget>
      </item>
     </layout>
@@ -238,6 +292,9 @@
           <property name="toolTip">
            <string>Enter the parent expression</string>
           </property>
+          <property name="clearButtonEnabled">
+           <bool>true</bool>
+          </property>
          </widget>
         </item>
        </layout>
@@ -263,6 +320,9 @@
         <property name="toolTip">
          <string>Enter the working directory or a filename</string>
         </property>
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
        </widget>
       </item>
       <item row="1" column="1">
@@ -287,6 +347,9 @@
         <property name="toolTip">
          <string>Enter the filter specifications separated by ';;'</string>
         </property>
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
        </widget>
       </item>
       <item row="3" column="1">
@@ -311,6 +374,9 @@
         <property name="toolTip">
          <string>Enter the initial filter</string>
         </property>
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
        </widget>
       </item>
       <item row="5" column="1">
@@ -353,6 +419,9 @@
         <property name="toolTip">
          <string>Enter the working directory</string>
         </property>
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
        </widget>
       </item>
       <item row="0" column="0" colspan="2">
@@ -389,6 +458,32 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="urlPropertiesGroup">
+     <property name="title">
+      <string>URL Properties</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_4">
+      <item>
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>Supported Schemes:</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLineEdit" name="schemesEdit">
+        <property name="toolTip">
+         <string>Enter the list of supported schemes separated by spaces</string>
+        </property>
+        <property name="clearButtonEnabled">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
@@ -410,6 +505,10 @@
   <tabstop>rfOpenFile</tabstop>
   <tabstop>rfOpenFiles</tabstop>
   <tabstop>rfSaveFile</tabstop>
+  <tabstop>rOpenFileUrl</tabstop>
+  <tabstop>rOpenFileUrls</tabstop>
+  <tabstop>rSaveFileUrl</tabstop>
+  <tabstop>rDirectoryUrl</tabstop>
   <tabstop>eNameVariable</tabstop>
   <tabstop>eFilterVariable</tabstop>
   <tabstop>eCaption</tabstop>
@@ -428,7 +527,7 @@
   <tabstop>eWorkDir</tabstop>
   <tabstop>cWorkDir</tabstop>
   <tabstop>cDirOnly</tabstop>
-  <tabstop>buttonBox</tabstop>
+  <tabstop>schemesEdit</tabstop>
  </tabstops>
  <resources/>
  <connections>

eric ide

mercurial