src/eric7/Plugins/VcsPlugins/vcsMercurial/HgArchiveDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
19 19
20 class HgArchiveDialog(QDialog, Ui_HgArchiveDialog): 20 class HgArchiveDialog(QDialog, Ui_HgArchiveDialog):
21 """ 21 """
22 Class implementing a dialog to enter the archive data. 22 Class implementing a dialog to enter the archive data.
23 """ 23 """
24
24 def __init__(self, vcs, parent=None): 25 def __init__(self, vcs, parent=None):
25 """ 26 """
26 Constructor 27 Constructor
27 28
28 @param vcs reference to the Mercurial object (Hg) 29 @param vcs reference to the Mercurial object (Hg)
29 @param parent reference to the parent widget (QWidget) 30 @param parent reference to the parent widget (QWidget)
30 """ 31 """
31 super().__init__(parent) 32 super().__init__(parent)
32 self.setupUi(self) 33 self.setupUi(self)
33 34
34 self.archivePicker.setMode( 35 self.archivePicker.setMode(EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE)
35 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE) 36
36 37 self.typeComboBox.addItem(self.tr("Detect Automatically"), "")
37 self.typeComboBox.addItem( 38 self.typeComboBox.addItem(self.tr("Directory of Files"), "files")
38 self.tr("Detect Automatically"), "") 39 self.typeComboBox.addItem(self.tr("Uncompressed TAR-Archive"), "tar")
39 self.typeComboBox.addItem( 40 self.typeComboBox.addItem(self.tr("Bzip2 compressed TAR-Archive"), "tbz2")
40 self.tr("Directory of Files"), "files") 41 self.typeComboBox.addItem(self.tr("Gzip compressed TAR-Archive"), "tgz")
41 self.typeComboBox.addItem( 42 self.typeComboBox.addItem(self.tr("Uncompressed ZIP-Archive"), "uzip")
42 self.tr("Uncompressed TAR-Archive"), "tar") 43 self.typeComboBox.addItem(self.tr("Compressed ZIP-Archive"), "zip")
43 self.typeComboBox.addItem( 44
44 self.tr("Bzip2 compressed TAR-Archive"), "tbz2")
45 self.typeComboBox.addItem(
46 self.tr("Gzip compressed TAR-Archive"), "tgz")
47 self.typeComboBox.addItem(
48 self.tr("Uncompressed ZIP-Archive"), "uzip")
49 self.typeComboBox.addItem(
50 self.tr("Compressed ZIP-Archive"), "zip")
51
52 self.__unixFileFilters = [ 45 self.__unixFileFilters = [
53 self.tr("Bzip2 compressed TAR-Archive (*.tar.bz2)"), 46 self.tr("Bzip2 compressed TAR-Archive (*.tar.bz2)"),
54 self.tr("Gzip compressed TAR-Archive (*.tar.gz)"), 47 self.tr("Gzip compressed TAR-Archive (*.tar.gz)"),
55 self.tr("Uncompressed TAR-Archive (*.tar)"), 48 self.tr("Uncompressed TAR-Archive (*.tar)"),
56 ] 49 ]
57 self.__windowsFileFilters = [ 50 self.__windowsFileFilters = [
58 self.tr("Compressed ZIP-Archive (*.zip)"), 51 self.tr("Compressed ZIP-Archive (*.zip)"),
59 self.tr("Uncompressed ZIP-Archive (*.uzip)") 52 self.tr("Uncompressed ZIP-Archive (*.uzip)"),
60 ] 53 ]
61 fileFilters = ( 54 fileFilters = (
62 ";;".join(self.__windowsFileFilters + self.__unixFileFilters) 55 ";;".join(self.__windowsFileFilters + self.__unixFileFilters)
63 if Utilities.isWindowsPlatform() else 56 if Utilities.isWindowsPlatform()
64 ";;".join(self.__unixFileFilters + self.__windowsFileFilters) 57 else ";;".join(self.__unixFileFilters + self.__windowsFileFilters)
65 ) 58 )
66 fileFilters += ";;" + self.tr("All Files (*)") 59 fileFilters += ";;" + self.tr("All Files (*)")
67 60
68 self.archivePicker.setFilters(fileFilters) 61 self.archivePicker.setFilters(fileFilters)
69 62
70 self.__typeFilters = { 63 self.__typeFilters = {
71 "tar": ["*.tar"], 64 "tar": ["*.tar"],
72 "tbz2": ["*.tar.bz2", "*.tbz2"], 65 "tbz2": ["*.tar.bz2", "*.tbz2"],
73 "tgz": ["*.tar.gz", "*.tgz"], 66 "tgz": ["*.tar.gz", "*.tgz"],
74 "uzip": ["*.uzip", "*.zip"], 67 "uzip": ["*.uzip", "*.zip"],
75 "zip": ["*.zip"], 68 "zip": ["*.zip"],
76 } 69 }
77 70
78 self.subReposCheckBox.setEnabled(vcs.hasSubrepositories()) 71 self.subReposCheckBox.setEnabled(vcs.hasSubrepositories())
79 72
80 self.buttonBox.button( 73 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
81 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 74
82
83 self.__projectPath = ( 75 self.__projectPath = (
84 vcs.getPlugin().getProjectHelper().getProject().getProjectPath() 76 vcs.getPlugin().getProjectHelper().getProject().getProjectPath()
85 ) 77 )
86 78
87 msh = self.minimumSizeHint() 79 msh = self.minimumSizeHint()
88 self.resize(max(self.width(), msh.width()), msh.height()) 80 self.resize(max(self.width(), msh.width()), msh.height())
89 81
90 @pyqtSlot(str) 82 @pyqtSlot(str)
91 def on_archivePicker_textChanged(self, archive): 83 def on_archivePicker_textChanged(self, archive):
92 """ 84 """
93 Private slot to handle changes of the archive name. 85 Private slot to handle changes of the archive name.
94 86
95 @param archive name of the archive (string) 87 @param archive name of the archive (string)
96 """ 88 """
97 self.buttonBox.button( 89 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
98 QDialogButtonBox.StandardButton.Ok).setEnabled(archive != "") 90 archive != ""
99 91 )
92
100 @pyqtSlot(int) 93 @pyqtSlot(int)
101 def on_typeComboBox_activated(self, index): 94 def on_typeComboBox_activated(self, index):
102 """ 95 """
103 Private slot to react on changes of the selected archive type. 96 Private slot to react on changes of the selected archive type.
104 97
105 @param index index of the selected type (integer) 98 @param index index of the selected type (integer)
106 """ 99 """
107 type_ = self.typeComboBox.itemData(index) 100 type_ = self.typeComboBox.itemData(index)
108 if type_ == "files": 101 if type_ == "files":
109 self.archivePicker.setMode(EricPathPickerModes.DIRECTORY_MODE) 102 self.archivePicker.setMode(EricPathPickerModes.DIRECTORY_MODE)
110 else: 103 else:
111 self.archivePicker.setMode( 104 self.archivePicker.setMode(
112 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE) 105 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE
106 )
113 if type_ in self.__typeFilters: 107 if type_ in self.__typeFilters:
114 self.archivePicker.setNameFilters( 108 self.archivePicker.setNameFilters(self.__typeFilters[type_])
115 self.__typeFilters[type_])
116 else: 109 else:
117 self.archivePicker.setNameFilters([]) 110 self.archivePicker.setNameFilters([])
118 111
119 def getData(self): 112 def getData(self):
120 """ 113 """
121 Public method to retrieve the data. 114 Public method to retrieve the data.
122 115
123 @return tuple giving the archive name (string), the archive type 116 @return tuple giving the archive name (string), the archive type
124 (string), the directory prefix 8string) and a flag indicating 117 (string), the directory prefix 8string) and a flag indicating
125 to recurse into subrepositories (boolean) 118 to recurse into subrepositories (boolean)
126 """ 119 """
127 return ( 120 return (

eric ide

mercurial