Tue, 02 Mar 2021 17:17:09 +0100
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7900
diff
changeset
|
3 | # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing QMessageBox replacements and more convenience function. |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
10 | from PyQt5.QtCore import Qt |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3178
diff
changeset
|
11 | from PyQt5.QtWidgets import QMessageBox, QApplication |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
13 | ############################################################################### |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
14 | ## Mappings to standard QMessageBox ## |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
15 | ############################################################################### |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
16 | |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
17 | # QMessageBox.Icon |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
18 | NoIcon = QMessageBox.Icon.NoIcon |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
19 | Critical = QMessageBox.Icon.Critical |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
20 | Information = QMessageBox.Icon.Information |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
21 | Question = QMessageBox.Icon.Question |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
22 | Warning = QMessageBox.Icon.Warning # __IGNORE_WARNING_M131__ |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
23 | |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
24 | StandardButtons = QMessageBox.StandardButtons |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
25 | |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
26 | # QMessageBox.StandardButton |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
27 | Abort = QMessageBox.StandardButton.Abort |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
28 | Apply = QMessageBox.StandardButton.Apply |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
29 | Cancel = QMessageBox.StandardButton.Cancel |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
30 | Close = QMessageBox.StandardButton.Close |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
31 | Discard = QMessageBox.StandardButton.Discard |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
32 | Help = QMessageBox.StandardButton.Help |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
33 | Ignore = QMessageBox.StandardButton.Ignore |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
34 | No = QMessageBox.StandardButton.No |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
35 | NoToAll = QMessageBox.StandardButton.NoToAll |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
36 | Ok = QMessageBox.StandardButton.Ok |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
37 | Open = QMessageBox.StandardButton.Open |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
38 | Reset = QMessageBox.StandardButton.Reset |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
39 | RestoreDefaults = QMessageBox.StandardButton.RestoreDefaults |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
40 | Retry = QMessageBox.StandardButton.Retry |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
41 | Save = QMessageBox.StandardButton.Save |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
42 | SaveAll = QMessageBox.StandardButton.SaveAll |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
43 | Yes = QMessageBox.StandardButton.Yes |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
44 | YesToAll = QMessageBox.StandardButton.YesToAll |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
45 | NoButton = QMessageBox.StandardButton.NoButton |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
46 | |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
47 | # QMessageBox.ButtonRole |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
48 | AcceptRole = QMessageBox.ButtonRole.AcceptRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
49 | ActionRole = QMessageBox.ButtonRole.ActionRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
50 | ApplyRole = QMessageBox.ButtonRole.ApplyRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
51 | DestructiveRole = QMessageBox.ButtonRole.DestructiveRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
52 | InvalidRole = QMessageBox.ButtonRole.InvalidRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
53 | HelpRole = QMessageBox.ButtonRole.HelpRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
54 | NoRole = QMessageBox.ButtonRole.NoRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
55 | RejectRole = QMessageBox.ButtonRole.RejectRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
56 | ResetRole = QMessageBox.ButtonRole.ResetRole |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
57 | YesRole = QMessageBox.ButtonRole.YesRole |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
58 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
59 | ############################################################################### |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
60 | ## Replacement for the QMessageBox class ## |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
61 | ############################################################################### |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
62 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
63 | |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
64 | class E5MessageBox(QMessageBox): |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
65 | """ |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
66 | Class implementing a replacement for QMessageBox. |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
67 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
68 | def __init__(self, icon, title, text, modal=False, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
69 | buttons=QMessageBox.StandardButton.NoButton, |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
70 | parent=None): |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
71 | """ |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
72 | Constructor |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
73 | |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
74 | @param icon type of icon to be shown (QMessageBox.Icon) |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
75 | @param title caption of the message box (string) |
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
76 | @param text text to be shown by the message box (string) |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
77 | @param modal flag indicating a modal dialog (boolean) |
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
78 | @param buttons set of standard buttons to generate (StandardButtons) |
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
79 | @param parent parent widget of the message box (QWidget) |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
80 | """ |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2302
diff
changeset
|
81 | super(E5MessageBox, self).__init__(parent) |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
82 | self.setIcon(icon) |
588
573767cf6bde
Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
83 | if modal: |
573767cf6bde
Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
84 | if parent is not None: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
85 | self.setWindowModality(Qt.WindowModality.WindowModal) |
588
573767cf6bde
Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
86 | else: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
87 | self.setWindowModality(Qt.WindowModality.ApplicationModal) |
588
573767cf6bde
Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
88 | else: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
89 | self.setWindowModality(Qt.WindowModality.NonModal) |
564
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
90 | if title == "": |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
91 | self.setWindowTitle("{0}".format( |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
92 | QApplication.applicationName())) |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
93 | else: |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
94 | self.setWindowTitle("{0} - {1}".format( |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
95 | QApplication.applicationName(), title)) |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
96 | self.setText(text) |
564
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
97 | self.setStandardButtons(buttons) |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
98 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
99 | ############################################################################### |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
100 | ## Replacements for QMessageBox static methods ## |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
101 | ############################################################################### |
553
5af61623ae3c
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
550
diff
changeset
|
102 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
103 | |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
104 | def __messageBox(parent, title, text, icon, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
105 | buttons=QMessageBox.StandardButton.Ok, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
106 | defaultButton=QMessageBox.StandardButton.NoButton, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
107 | textFormat=Qt.TextFormat.AutoText): |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | """ |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
109 | Private module function to show a modal message box. |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
111 | @param parent parent widget of the message box (QWidget) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
112 | @param title caption of the message box (string) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
113 | @param text text to be shown by the message box (string) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
114 | @param icon type of icon to be shown (QMessageBox.Icon) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
115 | @param buttons flags indicating which buttons to show |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | (QMessageBox.StandardButtons) |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | @param defaultButton flag indicating the default button |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | (QMessageBox.StandardButton) |
1366
f2e7957924cb
Fixed a security issue using QLabel for showing SSL certificate infos without setting the label's text format to Qt.PlainText.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
119 | @param textFormat format of the text (Qt.TextFormat) |
562
8bf0dbc1ca6a
Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
553
diff
changeset
|
120 | @return button pressed by the user (QMessageBox.StandardButton) |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | """ |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | messageBox = QMessageBox(parent) |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
123 | messageBox.setIcon(icon) |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | if parent is not None: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
125 | messageBox.setWindowModality(Qt.WindowModality.WindowModal) |
564
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
126 | if title == "": |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
127 | messageBox.setWindowTitle("{0}".format( |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
128 | QApplication.applicationName())) |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
129 | else: |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
130 | messageBox.setWindowTitle("{0} - {1}".format( |
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
562
diff
changeset
|
131 | QApplication.applicationName(), title)) |
1366
f2e7957924cb
Fixed a security issue using QLabel for showing SSL certificate infos without setting the label's text format to Qt.PlainText.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
132 | messageBox.setTextFormat(textFormat) |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | messageBox.setText(text) |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | messageBox.setStandardButtons(buttons) |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | messageBox.setDefaultButton(defaultButton) |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
136 | messageBox.exec() |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
137 | clickedButton = messageBox.clickedButton() |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | if clickedButton is None: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
139 | return QMessageBox.StandardButton.NoButton |
536
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | else: |
6d8d39753c82
Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | return messageBox.standardButton(clickedButton) |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
142 | |
545
1538031b5175
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
541
diff
changeset
|
143 | # the about functions are here for consistancy |
1538031b5175
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
541
diff
changeset
|
144 | about = QMessageBox.about |
1538031b5175
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
541
diff
changeset
|
145 | aboutQt = QMessageBox.aboutQt |
1538031b5175
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
541
diff
changeset
|
146 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
147 | |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
148 | def critical(parent, title, text, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
149 | buttons=QMessageBox.StandardButton.Ok, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
150 | defaultButton=QMessageBox.StandardButton.NoButton): |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
151 | """ |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
152 | Function to show a modal critical message box. |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
153 | |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
154 | @param parent parent widget of the message box (QWidget) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
155 | @param title caption of the message box (string) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
156 | @param text text to be shown by the message box (string) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
157 | @param buttons flags indicating which buttons to show |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
158 | (QMessageBox.StandardButtons) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
159 | @param defaultButton flag indicating the default button |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
160 | (QMessageBox.StandardButton) |
562
8bf0dbc1ca6a
Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
553
diff
changeset
|
161 | @return button pressed by the user (QMessageBox.StandardButton) |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
162 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
163 | return __messageBox(parent, title, text, QMessageBox.Icon.Critical, |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
164 | buttons, defaultButton) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
165 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
166 | |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
167 | def information(parent, title, text, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
168 | buttons=QMessageBox.StandardButton.Ok, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
169 | defaultButton=QMessageBox.StandardButton.NoButton): |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
170 | """ |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
171 | Function to show a modal information message box. |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
172 | |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
173 | @param parent parent widget of the message box (QWidget) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
174 | @param title caption of the message box (string) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
175 | @param text text to be shown by the message box (string) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
176 | @param buttons flags indicating which buttons to show |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
177 | (QMessageBox.StandardButtons) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
178 | @param defaultButton flag indicating the default button |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
179 | (QMessageBox.StandardButton) |
562
8bf0dbc1ca6a
Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
553
diff
changeset
|
180 | @return button pressed by the user (QMessageBox.StandardButton) |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
181 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
182 | return __messageBox(parent, title, text, QMessageBox.Icon.Information, |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
183 | buttons, defaultButton) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
184 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
185 | |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
186 | def question(parent, title, text, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
187 | buttons=QMessageBox.StandardButton.Ok, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
188 | defaultButton=QMessageBox.StandardButton.NoButton): |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
189 | """ |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
190 | Function to show a modal question message box. |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
191 | |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
192 | @param parent parent widget of the message box (QWidget) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
193 | @param title caption of the message box (string) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
194 | @param text text to be shown by the message box (string) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
195 | @param buttons flags indicating which buttons to show |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
196 | (QMessageBox.StandardButtons) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
197 | @param defaultButton flag indicating the default button |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
198 | (QMessageBox.StandardButton) |
562
8bf0dbc1ca6a
Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
553
diff
changeset
|
199 | @return button pressed by the user (QMessageBox.StandardButton) |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
200 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
201 | return __messageBox(parent, title, text, QMessageBox.Icon.Question, |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
202 | buttons, defaultButton) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
203 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
204 | |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
205 | def warning(parent, title, text, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
206 | buttons=QMessageBox.StandardButton.Ok, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
207 | defaultButton=QMessageBox.StandardButton.NoButton): |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
208 | """ |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
209 | Function to show a modal warning message box. |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
210 | |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
211 | @param parent parent widget of the message box (QWidget) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
212 | @param title caption of the message box (string) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
213 | @param text text to be shown by the message box (string) |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
214 | @param buttons flags indicating which buttons to show |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
215 | (QMessageBox.StandardButtons) |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
216 | @param defaultButton flag indicating the default button |
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
217 | (QMessageBox.StandardButton) |
562
8bf0dbc1ca6a
Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
553
diff
changeset
|
218 | @return button pressed by the user (QMessageBox.StandardButton) |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
219 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
220 | return __messageBox(parent, title, text, QMessageBox.Icon.Warning, |
537
72b32daeb8d6
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
536
diff
changeset
|
221 | buttons, defaultButton) |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
222 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
223 | ############################################################################### |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
224 | ## Additional convenience functions ## |
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
225 | ############################################################################### |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
226 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
227 | |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
228 | def yesNo(parent, title, text, icon=Question, yesDefault=False, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
229 | textFormat=Qt.TextFormat.AutoText): |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
230 | """ |
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
231 | Function to show a model yes/no message box. |
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
232 | |
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
233 | @param parent parent widget of the message box (QWidget) |
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
234 | @param title caption of the message box (string) |
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
235 | @param text text to be shown by the message box (string) |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
236 | @param icon icon for the dialog (Critical, Information, Question or |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
237 | Warning) |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
238 | @param yesDefault flag indicating that the Yes button should be the |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
239 | default button (boolean) |
1366
f2e7957924cb
Fixed a security issue using QLabel for showing SSL certificate infos without setting the label's text format to Qt.PlainText.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
240 | @param textFormat format of the text (Qt.TextFormat) |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
241 | @return flag indicating the selection of the Yes button (boolean) |
7628
f904d0eef264
Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
242 | @exception ValueError raised to indicate a bad parameter value |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
243 | """ |
7628
f904d0eef264
Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
244 | if icon not in [Critical, Information, Question, Warning]: |
f904d0eef264
Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
245 | raise ValueError("Bad value for 'icon' parameter.") |
541
00e1a5d060c5
Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
537
diff
changeset
|
246 | |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
247 | res = __messageBox( |
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
248 | parent, title, text, icon, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
249 | QMessageBox.StandardButtons(QMessageBox.StandardButton.Yes | |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
250 | QMessageBox.StandardButton.No), |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
251 | yesDefault and QMessageBox.StandardButton.Yes or |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
252 | QMessageBox.StandardButton.No, |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
253 | textFormat) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
254 | return res == QMessageBox.StandardButton.Yes |
549
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
255 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
256 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
257 | def retryAbort(parent, title, text, icon=Question, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
258 | textFormat=Qt.TextFormat.AutoText): |
550
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
259 | """ |
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
260 | Function to show a model abort/retry message box. |
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
261 | |
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
262 | @param parent parent widget of the message box (QWidget) |
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
263 | @param title caption of the message box (string) |
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
264 | @param text text to be shown by the message box (string) |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
265 | @param icon icon for the dialog (Critical, Information, Question or |
2990
583beaf0b4b8
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
266 | Warning) |
1366
f2e7957924cb
Fixed a security issue using QLabel for showing SSL certificate infos without setting the label's text format to Qt.PlainText.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
267 | @param textFormat format of the text (Qt.TextFormat) |
550
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
268 | @return flag indicating the selection of the Retry button (boolean) |
7628
f904d0eef264
Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
269 | @exception ValueError raised to indicate a bad parameter value |
550
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
270 | """ |
7628
f904d0eef264
Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
271 | if icon not in [Critical, Information, Question, Warning]: |
f904d0eef264
Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
272 | raise ValueError("Bad value for 'icon' parameter.") |
550
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
273 | |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
274 | res = __messageBox( |
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
275 | parent, title, text, icon, |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
276 | QMessageBox.StandardButtons(QMessageBox.StandardButton.Retry | |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
277 | QMessageBox.StandardButton.Abort), |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
278 | QMessageBox.StandardButton.Retry, |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
279 | textFormat) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
280 | return res == QMessageBox.StandardButton.Retry |
550
22b951013193
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
549
diff
changeset
|
281 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
282 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
283 | def okToClearData(parent, title, text, saveFunc, |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
284 | textFormat=Qt.TextFormat.AutoText): |
549
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
285 | """ |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
286 | Function to show a model message box to ask for clearing the data. |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
287 | |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
288 | @param parent parent widget of the message box (QWidget) |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
289 | @param title caption of the message box (string) |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
290 | @param text text to be shown by the message box (string) |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
291 | @param saveFunc reference to a function performing the save action. It |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
292 | must be a parameterless function returning a flag indicating success. |
1366
f2e7957924cb
Fixed a security issue using QLabel for showing SSL certificate infos without setting the label's text format to Qt.PlainText.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
293 | @param textFormat format of the text (Qt.TextFormat) |
549
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
294 | @return flag indicating that it is ok to clear the data (boolean) |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
295 | """ |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
296 | res = __messageBox( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
297 | parent, title, text, QMessageBox.Icon.Warning, |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
298 | QMessageBox.StandardButtons( |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
299 | QMessageBox.StandardButton.Abort | |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
300 | QMessageBox.StandardButton.Discard | |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
301 | QMessageBox.StandardButton.Save), |
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
302 | QMessageBox.StandardButton.Save, |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2990
diff
changeset
|
303 | textFormat) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
304 | if res == QMessageBox.StandardButton.Abort: |
549
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
305 | return False |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
306 | if res == QMessageBox.StandardButton.Save: |
549
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
307 | return saveFunc() |
fe99d46d56c8
Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
545
diff
changeset
|
308 | return True |