|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2025 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the fastexport configuration dialog. |
|
8 """ |
|
9 |
|
10 from PyQt6.QtCore import pyqtSlot |
|
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
|
12 |
|
13 from eric7.EricWidgets.EricPathPicker import EricPathPickerModes |
|
14 |
|
15 from .Ui_HgFastexportConfigDialog import Ui_HgFastexportConfigDialog |
|
16 |
|
17 |
|
18 class HgFastexportConfigDialog(QDialog, Ui_HgFastexportConfigDialog): |
|
19 """ |
|
20 Class implementing the fastexport configuration dialog. |
|
21 """ |
|
22 |
|
23 def __init__(self, revisions=None, parent=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param revisions list of revisions, tags or branches to be exported |
|
28 (defaults to None) |
|
29 @type list of str (optional) |
|
30 @param parent reference to the parent widget (defaults to None) |
|
31 @type QWidget (optional) |
|
32 """ |
|
33 super().__init__(parent) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.outputPicker.setMode(EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE) |
|
37 self.authormapPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
|
38 self.importMarksPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
|
39 self.exportMarksPicker.setMode( |
|
40 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE |
|
41 ) |
|
42 fileFilters = self.tr("Text Files (*.txt);;All Files (*)") |
|
43 for picker in ( |
|
44 self.outputPicker, |
|
45 self.authormapPicker, |
|
46 self.importMarksPicker, |
|
47 self.exportMarksPicker, |
|
48 ): |
|
49 picker.setFilters(fileFilters) |
|
50 |
|
51 self.outputPicker.textChanged.connect(self.__updateOK) |
|
52 |
|
53 if revisions: |
|
54 self.revisionsEdit.setText(", ".join(revisions)) |
|
55 |
|
56 self.__updateOK() |
|
57 |
|
58 @pyqtSlot() |
|
59 def __updateOK(self): |
|
60 """ |
|
61 Private slot to updated the enabled state of the OK button. |
|
62 """ |
|
63 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
|
64 bool(self.outputPicker.text()) |
|
65 ) |
|
66 |
|
67 def getData(self): |
|
68 """ |
|
69 Public method to get the entered fastexport configuration data. |
|
70 |
|
71 @return tuple containing the fastexport configuration (output file, |
|
72 list of revisions, author map file, import marks file, export marks |
|
73 file) |
|
74 @rtype tuple of (str, list of str, str, str, str) |
|
75 """ |
|
76 return ( |
|
77 self.outputPicker.text(), |
|
78 [r.strip() for r in self.revisionsEdit.text().split(",") if r.strip()], |
|
79 self.authormapPicker.text(), |
|
80 self.importMarksPicker.text(), |
|
81 self.exportMarksPicker.text(), |
|
82 ) |