src/eric7/DataViews/PyCoverageHtmlReportDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 9078
44d1d68096b6
child 9221
bf71ee032bb4
diff -r 3fc8dfeb6ebe -r b99e7fd55fd3 src/eric7/DataViews/PyCoverageHtmlReportDialog.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eric7/DataViews/PyCoverageHtmlReportDialog.py	Thu Jul 07 11:23:56 2022 +0200
@@ -0,0 +1,77 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to enter the parameters for a coverage HTML
+report.
+"""
+
+from PyQt6.QtCore import pyqtSlot
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox
+
+from EricWidgets.EricPathPicker import EricPathPickerModes
+
+from .Ui_PyCoverageHtmlReportDialog import Ui_PyCoverageHtmlReportDialog
+
+
+class PyCoverageHtmlReportDialog(QDialog, Ui_PyCoverageHtmlReportDialog):
+    """
+    Class implementing a dialog to enter the parameters for a coverage HTML
+    report.
+    """
+    def __init__(self, defaultDirectory, parent=None):
+        """
+        Constructor
+        
+        @param defaultDirectory default directory for selecting the output
+            directory
+        @type str
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+        
+        self.outputDirectoryPicker.setMode(
+            EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE)
+        self.outputDirectoryPicker.setDefaultDirectory(defaultDirectory)
+        
+        self.extraCssPicker.setMode(
+            EricPathPickerModes.OPEN_FILE_MODE)
+        
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Ok).setEnabled(False)
+        
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+    
+    @pyqtSlot(str)
+    def on_outputDirectoryPicker_textChanged(self, directory):
+        """
+        Private slot handling a change of the output directory.
+        
+        @param directory current text of the directory picker
+        @type str
+        """
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Ok).setEnabled(bool(directory))
+    
+    def getData(self):
+        """
+        Public method to get the entered data.
+        
+        @return tuple containing the report title, the output directory, the
+            path of a file containing extra CSS and a flag indicating to open
+            the generated report in a browser
+        
+        @rtype tuple of (str, str, str, bool)
+        """
+        title = self.titleEdit.text()
+        return (
+            title if bool(title) else None,
+            self.outputDirectoryPicker.currentText(),
+            self.extraCssPicker.currentText(),
+            self.openReportCheckBox.isChecked(),
+        )

eric ide

mercurial