eric6/Plugins/PluginWizardQFileDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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

eric ide

mercurial