src/eric7/DataViews/PyCoverageJsonReportDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 9078
44d1d68096b6
child 9221
bf71ee032bb4
diff -r 3fc8dfeb6ebe -r b99e7fd55fd3 src/eric7/DataViews/PyCoverageJsonReportDialog.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eric7/DataViews/PyCoverageJsonReportDialog.py	Thu Jul 07 11:23:56 2022 +0200
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to enter the parameters for a coverage JSON
+report.
+"""
+
+import os
+
+from PyQt6.QtCore import pyqtSlot
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox
+
+from EricWidgets.EricPathPicker import EricPathPickerModes
+
+from .Ui_PyCoverageJsonReportDialog import Ui_PyCoverageJsonReportDialog
+
+
+class PyCoverageJsonReportDialog(QDialog, Ui_PyCoverageJsonReportDialog):
+    """
+    Class implementing a dialog to enter the parameters for a coverage JSON
+    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.outputFilePicker.setMode(
+            EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE)
+        self.outputFilePicker.setDefaultDirectory(defaultDirectory)
+        self.outputFilePicker.setFilters(
+            self.tr("JSON Files (*.json);;All Files (*)"))
+        self.outputFilePicker.setText(
+            os.path.join(defaultDirectory, "coverage.json"))
+        
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+    
+    @pyqtSlot(str)
+    def on_outputFilePicker_textChanged(self, filename):
+        """
+        Private slot handling a change of the output file.
+        
+        @param filename current text of the file picker
+        @type str
+        """
+        self.buttonBox.button(
+            QDialogButtonBox.StandardButton.Ok).setEnabled(bool(filename))
+    
+    def getData(self):
+        """
+        Public method to get the entered data.
+        
+        @return tuple containing the output file and a flag indicating the
+            creation of a compact JSON file
+        
+        @rtype tuple of (str, bool)
+        """
+        return (
+            self.outputFilePicker.currentText(),
+            self.compactCheckBox.isChecked(),
+        )

eric ide

mercurial