23 class GitArchiveDataDialog(QDialog, Ui_GitArchiveDataDialog): |
23 class GitArchiveDataDialog(QDialog, Ui_GitArchiveDataDialog): |
24 """ |
24 """ |
25 Class implementing a dialog to enter the data for the creation of an |
25 Class implementing a dialog to enter the data for the creation of an |
26 archive. |
26 archive. |
27 """ |
27 """ |
|
28 |
28 def __init__(self, tagsList, branchesList, formatsList, parent=None): |
29 def __init__(self, tagsList, branchesList, formatsList, parent=None): |
29 """ |
30 """ |
30 Constructor |
31 Constructor |
31 |
32 |
32 @param tagsList list of tags (list of strings) |
33 @param tagsList list of tags (list of strings) |
33 @param branchesList list of branches (list of strings) |
34 @param branchesList list of branches (list of strings) |
34 @param formatsList list of archive formats (list of strings) |
35 @param formatsList list of archive formats (list of strings) |
35 @param parent reference to the parent widget (QWidget) |
36 @param parent reference to the parent widget (QWidget) |
36 """ |
37 """ |
37 super().__init__(parent) |
38 super().__init__(parent) |
38 self.setupUi(self) |
39 self.setupUi(self) |
39 |
40 |
40 self.fileButton.setIcon(UI.PixmapCache.getIcon("open")) |
41 self.fileButton.setIcon(UI.PixmapCache.getIcon("open")) |
41 |
42 |
42 self.buttonBox.button( |
43 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
43 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
44 |
44 |
|
45 self.tagCombo.addItems(sorted(tagsList)) |
45 self.tagCombo.addItems(sorted(tagsList)) |
46 self.branchCombo.addItems(["master"] + sorted(branchesList)) |
46 self.branchCombo.addItems(["master"] + sorted(branchesList)) |
47 self.formatComboBox.addItems(sorted(formatsList)) |
47 self.formatComboBox.addItems(sorted(formatsList)) |
48 self.formatComboBox.setCurrentIndex( |
48 self.formatComboBox.setCurrentIndex(self.formatComboBox.findText("zip")) |
49 self.formatComboBox.findText("zip")) |
49 |
50 |
|
51 msh = self.minimumSizeHint() |
50 msh = self.minimumSizeHint() |
52 self.resize(max(self.width(), msh.width()), msh.height()) |
51 self.resize(max(self.width(), msh.width()), msh.height()) |
53 |
52 |
54 def __updateOK(self): |
53 def __updateOK(self): |
55 """ |
54 """ |
56 Private slot to update the OK button. |
55 Private slot to update the OK button. |
57 """ |
56 """ |
58 enabled = True |
57 enabled = True |
60 enabled = self.revEdit.text() != "" |
59 enabled = self.revEdit.text() != "" |
61 elif self.tagButton.isChecked(): |
60 elif self.tagButton.isChecked(): |
62 enabled = self.tagCombo.currentText() != "" |
61 enabled = self.tagCombo.currentText() != "" |
63 elif self.branchButton.isChecked(): |
62 elif self.branchButton.isChecked(): |
64 enabled = self.branchCombo.currentText() != "" |
63 enabled = self.branchCombo.currentText() != "" |
65 |
64 |
66 enabled &= bool(self.fileEdit.text()) |
65 enabled &= bool(self.fileEdit.text()) |
67 |
66 |
68 self.buttonBox.button( |
67 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
69 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) |
68 |
70 |
|
71 @pyqtSlot(str) |
69 @pyqtSlot(str) |
72 def on_fileEdit_textChanged(self, txt): |
70 def on_fileEdit_textChanged(self, txt): |
73 """ |
71 """ |
74 Private slot to handle changes of the file edit. |
72 Private slot to handle changes of the file edit. |
75 |
73 |
76 @param txt text of the edit (string) |
74 @param txt text of the edit (string) |
77 """ |
75 """ |
78 self.__updateOK() |
76 self.__updateOK() |
79 |
77 |
80 @pyqtSlot() |
78 @pyqtSlot() |
81 def on_fileButton_clicked(self): |
79 def on_fileButton_clicked(self): |
82 """ |
80 """ |
83 Private slot to select a file via a file selection dialog. |
81 Private slot to select a file via a file selection dialog. |
84 """ |
82 """ |
85 fileName = EricFileDialog.getSaveFileName( |
83 fileName = EricFileDialog.getSaveFileName( |
86 self, |
84 self, |
87 self.tr("Select Archive File"), |
85 self.tr("Select Archive File"), |
88 Utilities.fromNativeSeparators(self.fileEdit.text()), |
86 Utilities.fromNativeSeparators(self.fileEdit.text()), |
89 "") |
87 "", |
90 |
88 ) |
|
89 |
91 if fileName: |
90 if fileName: |
92 root, ext = os.path.splitext(fileName) |
91 root, ext = os.path.splitext(fileName) |
93 if not ext: |
92 if not ext: |
94 ext = "." + self.formatComboBox.currentText() |
93 ext = "." + self.formatComboBox.currentText() |
95 fileName = root + ext |
94 fileName = root + ext |
96 self.fileEdit.setText(Utilities.toNativeSeparators(fileName)) |
95 self.fileEdit.setText(Utilities.toNativeSeparators(fileName)) |
97 |
96 |
98 @pyqtSlot(bool) |
97 @pyqtSlot(bool) |
99 def on_revButton_toggled(self, checked): |
98 def on_revButton_toggled(self, checked): |
100 """ |
99 """ |
101 Private slot to handle changes of the rev select button. |
100 Private slot to handle changes of the rev select button. |
102 |
101 |
103 @param checked state of the button (boolean) |
102 @param checked state of the button (boolean) |
104 """ |
103 """ |
105 self.__updateOK() |
104 self.__updateOK() |
106 |
105 |
107 @pyqtSlot(str) |
106 @pyqtSlot(str) |
108 def on_revEdit_textChanged(self, txt): |
107 def on_revEdit_textChanged(self, txt): |
109 """ |
108 """ |
110 Private slot to handle changes of the rev edit. |
109 Private slot to handle changes of the rev edit. |
111 |
110 |
112 @param txt text of the edit (string) |
111 @param txt text of the edit (string) |
113 """ |
112 """ |
114 self.__updateOK() |
113 self.__updateOK() |
115 |
114 |
116 @pyqtSlot(bool) |
115 @pyqtSlot(bool) |
117 def on_tagButton_toggled(self, checked): |
116 def on_tagButton_toggled(self, checked): |
118 """ |
117 """ |
119 Private slot to handle changes of the Tag select button. |
118 Private slot to handle changes of the Tag select button. |
120 |
119 |
121 @param checked state of the button (boolean) |
120 @param checked state of the button (boolean) |
122 """ |
121 """ |
123 self.__updateOK() |
122 self.__updateOK() |
124 |
123 |
125 @pyqtSlot(str) |
124 @pyqtSlot(str) |
126 def on_tagCombo_editTextChanged(self, txt): |
125 def on_tagCombo_editTextChanged(self, txt): |
127 """ |
126 """ |
128 Private slot to handle changes of the Tag combo. |
127 Private slot to handle changes of the Tag combo. |
129 |
128 |
130 @param txt text of the combo (string) |
129 @param txt text of the combo (string) |
131 """ |
130 """ |
132 self.__updateOK() |
131 self.__updateOK() |
133 |
132 |
134 @pyqtSlot(bool) |
133 @pyqtSlot(bool) |
135 def on_branchButton_toggled(self, checked): |
134 def on_branchButton_toggled(self, checked): |
136 """ |
135 """ |
137 Private slot to handle changes of the Branch select button. |
136 Private slot to handle changes of the Branch select button. |
138 |
137 |
139 @param checked state of the button (boolean) |
138 @param checked state of the button (boolean) |
140 """ |
139 """ |
141 self.__updateOK() |
140 self.__updateOK() |
142 |
141 |
143 @pyqtSlot(str) |
142 @pyqtSlot(str) |
144 def on_branchCombo_editTextChanged(self, txt): |
143 def on_branchCombo_editTextChanged(self, txt): |
145 """ |
144 """ |
146 Private slot to handle changes of the Branch combo. |
145 Private slot to handle changes of the Branch combo. |
147 |
146 |
148 @param txt text of the combo (string) |
147 @param txt text of the combo (string) |
149 """ |
148 """ |
150 self.__updateOK() |
149 self.__updateOK() |
151 |
150 |
152 def getData(self): |
151 def getData(self): |
153 """ |
152 """ |
154 Public method to retrieve the entered data. |
153 Public method to retrieve the entered data. |
155 |
154 |
156 @return tuple of selected revision (string), archive format (string), |
155 @return tuple of selected revision (string), archive format (string), |
157 archive file (string) and prefix (string) |
156 archive file (string) and prefix (string) |
158 """ |
157 """ |
159 if self.revButton.isChecked(): |
158 if self.revButton.isChecked(): |
160 rev = self.revEdit.text() |
159 rev = self.revEdit.text() |