Sun, 24 Dec 2023 19:49:52 +0100
Corrected some source code documentation issues.
9078 | 1 | # -*- coding: utf-8 -*- |
2 | ||
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
3 | # Copyright (c) 2022 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
9078 | 4 | # |
5 | ||
6 | """ | |
7 | Module implementing a dialog to enter the parameters for a coverage HTML | |
8 | report. | |
9 | """ | |
10 | ||
11 | from PyQt6.QtCore import pyqtSlot | |
12 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox | |
13 | ||
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
14 | from eric7.EricWidgets.EricPathPicker import EricPathPickerModes |
9078 | 15 | |
16 | from .Ui_PyCoverageHtmlReportDialog import Ui_PyCoverageHtmlReportDialog | |
17 | ||
18 | ||
19 | class PyCoverageHtmlReportDialog(QDialog, Ui_PyCoverageHtmlReportDialog): | |
20 | """ | |
21 | Class implementing a dialog to enter the parameters for a coverage HTML | |
22 | report. | |
23 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
9078 | 25 | def __init__(self, defaultDirectory, parent=None): |
26 | """ | |
27 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
28 | |
9078 | 29 | @param defaultDirectory default directory for selecting the output |
30 | directory | |
31 | @type str | |
32 | @param parent reference to the parent widget (defaults to None) | |
33 | @type QWidget (optional) | |
34 | """ | |
35 | super().__init__(parent) | |
36 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | |
9078 | 38 | self.outputDirectoryPicker.setMode( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | ) |
9078 | 41 | self.outputDirectoryPicker.setDefaultDirectory(defaultDirectory) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | self.extraCssPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
45 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
46 | |
9078 | 47 | msh = self.minimumSizeHint() |
48 | self.resize(max(self.width(), msh.width()), msh.height()) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
9078 | 50 | @pyqtSlot(str) |
51 | def on_outputDirectoryPicker_textChanged(self, directory): | |
52 | """ | |
53 | Private slot handling a change of the output directory. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
54 | |
9078 | 55 | @param directory current text of the directory picker |
56 | @type str | |
57 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
58 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | bool(directory) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
60 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | |
9078 | 62 | def getData(self): |
63 | """ | |
64 | Public method to get the entered data. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | |
9078 | 66 | @return tuple containing the report title, the output directory, the |
67 | path of a file containing extra CSS and a flag indicating to open | |
68 | the generated report in a browser | |
69 | @rtype tuple of (str, str, str, bool) | |
70 | """ | |
71 | title = self.titleEdit.text() | |
72 | return ( | |
73 | title if bool(title) else None, | |
74 | self.outputDirectoryPicker.currentText(), | |
75 | self.extraCssPicker.currentText(), | |
76 | self.openReportCheckBox.isChecked(), | |
77 | ) |