|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
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 |
|
14 from EricWidgets.EricPathPicker import EricPathPickerModes |
|
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 """ |
|
24 def __init__(self, defaultDirectory, parent=None): |
|
25 """ |
|
26 Constructor |
|
27 |
|
28 @param defaultDirectory default directory for selecting the output |
|
29 directory |
|
30 @type str |
|
31 @param parent reference to the parent widget (defaults to None) |
|
32 @type QWidget (optional) |
|
33 """ |
|
34 super().__init__(parent) |
|
35 self.setupUi(self) |
|
36 |
|
37 self.outputDirectoryPicker.setMode( |
|
38 EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE) |
|
39 self.outputDirectoryPicker.setDefaultDirectory(defaultDirectory) |
|
40 |
|
41 self.extraCssPicker.setMode( |
|
42 EricPathPickerModes.OPEN_FILE_MODE) |
|
43 |
|
44 self.buttonBox.button( |
|
45 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
|
46 |
|
47 msh = self.minimumSizeHint() |
|
48 self.resize(max(self.width(), msh.width()), msh.height()) |
|
49 |
|
50 @pyqtSlot(str) |
|
51 def on_outputDirectoryPicker_textChanged(self, directory): |
|
52 """ |
|
53 Private slot handling a change of the output directory. |
|
54 |
|
55 @param directory current text of the directory picker |
|
56 @type str |
|
57 """ |
|
58 self.buttonBox.button( |
|
59 QDialogButtonBox.StandardButton.Ok).setEnabled(bool(directory)) |
|
60 |
|
61 def getData(self): |
|
62 """ |
|
63 Public method to get the entered data. |
|
64 |
|
65 @return tuple containing the report title, the output directory, the |
|
66 path of a file containing extra CSS and a flag indicating to open |
|
67 the generated report in a browser |
|
68 |
|
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 ) |