eric6/Plugins/PluginWizardQFileDialog.py

Sun, 04 Oct 2020 15:25:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 04 Oct 2020 15:25:17 +0200
changeset 7749
285855999b4e
parent 7635
0cdead130a81
child 7759
51aa6c6b66f7
permissions
-rw-r--r--

Configuration Dialog: optimized the display of the various configuration pages.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7256
diff changeset
3 # Copyright (c) 2007 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the QFileDialog wizard plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2407
diff changeset
10
3122
4bcf6c0f4432 Added support for PyQt5 to the QFileDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
11 import re
4bcf6c0f4432 Added support for PyQt5 to the QFileDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
13 from PyQt5.QtCore import QObject
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3523
diff changeset
14 from PyQt5.QtWidgets import QDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
16 from E5Gui.E5Application import e5App
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
17 from E5Gui.E5Action import E5Action
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 467
diff changeset
18 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
5316
31cbc97d4974 Got rid of the manually set version numbers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
20 import UI.Info
31cbc97d4974 Got rid of the manually set version numbers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
21
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 # Start-Of-Header
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 name = "QFileDialog Wizard Plugin"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 autoactivate = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 deactivateable = True
5316
31cbc97d4974 Got rid of the manually set version numbers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
27 version = UI.Info.VersionOnly
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 className = "FileDialogWizard"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 packageName = "__core__"
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 shortDescription = "Show the QFileDialog wizard."
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 longDescription = """This plugin shows the QFileDialog wizard."""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 pyqtApi = 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 # End-Of-Header
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 error = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
37
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 class FileDialogWizard(QObject):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Class implementing the QFileDialog wizard plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 def __init__(self, ui):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param ui reference to the user interface object (UI.UserInterface)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2407
diff changeset
48 super(FileDialogWizard, self).__init__(ui)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__ui = ui
3122
4bcf6c0f4432 Added support for PyQt5 to the QFileDialog wizard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
50
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
51 # PyQt5
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
52 self.__pyqtRe = re.compile(r"(?:import|from)\s+PyQt([5])")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 def activate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 Public method to activate this plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @return tuple of None and activation status (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
60 self.__initActions()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__initMenu()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 return None, True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def deactivate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Public method to deactivate this plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 menu = self.__ui.getMenu("wizards")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 if menu:
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
71 menu.removeAction(self.qFileDialogAction)
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
72 menu.removeAction(self.e5FileDialogAction)
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
73 self.__ui.removeE5Actions(
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
74 [self.qFileDialogAction, self.e5FileDialogAction],
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
75 'wizards')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
77 def __initActions(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
79 Private method to initialize the actions.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
81 self.qFileDialogAction = E5Action(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
82 self.tr('QFileDialog Wizard'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
83 self.tr('Q&FileDialog Wizard...'), 0, 0, self,
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
84 'wizards_qfiledialog')
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
85 self.qFileDialogAction.setStatusTip(self.tr('QFileDialog Wizard'))
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
86 self.qFileDialogAction.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """<b>QFileDialog Wizard</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """<p>This wizard opens a dialog for entering all the parameters"""
3004
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
89 """ needed to create a QFileDialog. The generated code is"""
c4bf32c791d0 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2962
diff changeset
90 """ inserted at the current cursor position.</p>"""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 ))
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
92 self.qFileDialogAction.triggered.connect(self.__handleQFileDialog)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
94 self.e5FileDialogAction = E5Action(
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
95 self.tr('E5FileDialog Wizard'),
7238
c1eda208462b PluginWizardQFileDialog: fixed a typo in a display string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
96 self.tr('E&5FileDialog Wizard...'), 0, 0, self,
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
97 'wizards_e5filedialog')
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
98 self.e5FileDialogAction.setStatusTip(self.tr('E5FileDialog Wizard'))
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
99 self.e5FileDialogAction.setWhatsThis(self.tr(
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
100 """<b>E5FileDialog Wizard</b>"""
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
101 """<p>This wizard opens a dialog for entering all the parameters"""
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
102 """ needed to create an E5FileDialog. The generated code is"""
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
103 """ inserted at the current cursor position.</p>"""
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
104 ))
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
105 self.e5FileDialogAction.triggered.connect(self.__handleE5FileDialog)
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
106
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
107 self.__ui.addE5Actions(
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
108 [self.qFileDialogAction, self.e5FileDialogAction],
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
109 'wizards')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 def __initMenu(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 Private method to add the actions to the right menu.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 menu = self.__ui.getMenu("wizards")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 if menu:
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
117 menu.addAction(self.e5FileDialogAction)
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
118 menu.addAction(self.qFileDialogAction)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
120 def __callForm(self, editor, variant):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 Private method to display a dialog and get the code.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 @param editor reference to the current editor
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
125 @type Editor
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
126 @param variant variant of code to be generated
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
127 (-1 = E5FileDialog, 0 = unknown, 5 = PyQt5)
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
128 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 @return the generated code (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7238
diff changeset
131 from WizardPlugins.FileDialogWizard.FileDialogWizardDialog import (
2407
b98cc8ee1142 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
132 FileDialogWizardDialog
7256
4ef3b78ebb4e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7238
diff changeset
133 )
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
134 dlg = FileDialogWizardDialog(variant, None)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 if dlg.exec_() == QDialog.Accepted:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 line, index = editor.getCursorPosition()
117
d63640116aec Fixed a division bug caused by porting to Python3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
137 indLevel = editor.indentation(line) // editor.indentationWidth()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if editor.indentationsUseTabs():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 indString = '\t'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 indString = editor.indentationWidth() * ' '
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 return (dlg.getCode(indLevel, indString), 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 return (None, 0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
146 def __handle(self, variant):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
2962
d6c9d1ca2da4 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2712
diff changeset
148 Private method to handle the wizards action.
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
149
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
150 @param variant dialog variant to be generated
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
151 (E5FileDialog or QFileDialog)
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
152 @type str
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
153 @exception ValueError raised to indicate an illegal file dialog variant
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 """
53
c3eb7cc1ff8b Renamed e5App to e5App.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
155 editor = e5App().getObject("ViewManager").activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
157 if editor is None:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
158 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3004
diff changeset
159 self.__ui,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
160 self.tr('No current editor'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3180
diff changeset
161 self.tr('Please open or create a file first.'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 else:
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
163 if variant == "QFileDialog":
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
164 match = self.__pyqtRe.search(editor.text())
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
165 if match is None:
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
166 # unknown
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
167 dialogVariant = 0
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
168 else:
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
169 # PyQt5
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
170 dialogVariant = int(match.group(1))
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
171 elif variant == "E5FileDialog":
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
172 # E5FileDialog
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
173 dialogVariant = -1
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
174 else:
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
175 raise ValueError("Illegal dialog variant given")
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
176
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
177 code, ok = self.__callForm(editor, dialogVariant)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 line, index = editor.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 # It should be done on this way to allow undo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 editor.beginUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 editor.insertAt(code, line, index)
467
0911d8be9b07 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
183 editor.endUndoAction()
7207
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
184
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
185 def __handleQFileDialog(self):
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
186 """
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
187 Private slot to handle the wizard QFileDialog action.
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
188 """
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
189 self.__handle("QFileDialog")
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
190
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
191 def __handleE5FileDialog(self):
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
192 """
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
193 Private slot to handle the wizard E5FileDialog action.
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
194 """
4ba7a9b26020 QFileDialog Wizard:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7199
diff changeset
195 self.__handle("E5FileDialog")

eric ide

mercurial