9 """ |
9 """ |
10 |
10 |
11 from PyQt5.QtCore import pyqtSlot, Qt |
11 from PyQt5.QtCore import pyqtSlot, Qt |
12 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QHeaderView |
12 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QHeaderView |
13 |
13 |
|
14 from E5Gui.E5PathPicker import E5PathPickerModes |
|
15 |
14 from .Ui_VirtualenvManagerDialog import Ui_VirtualenvManagerDialog |
16 from .Ui_VirtualenvManagerDialog import Ui_VirtualenvManagerDialog |
|
17 |
|
18 import Utilities |
15 |
19 |
16 |
20 |
17 class VirtualenvManagerDialog(QDialog, Ui_VirtualenvManagerDialog): |
21 class VirtualenvManagerDialog(QDialog, Ui_VirtualenvManagerDialog): |
18 """ |
22 """ |
19 Class implementing a dialog to manage the list of defined virtual |
23 Class implementing a dialog to manage the list of defined virtual |
36 super(VirtualenvManagerDialog, self).__init__(parent) |
40 super(VirtualenvManagerDialog, self).__init__(parent) |
37 self.setupUi(self) |
41 self.setupUi(self) |
38 |
42 |
39 self.__manager = manager |
43 self.__manager = manager |
40 |
44 |
|
45 baseDir = self.__manager.getVirtualEnvironmentsBaseDir() |
|
46 if not baseDir: |
|
47 baseDir = Utilities.getHomeDir() |
|
48 |
|
49 self.envBaseDirectoryPicker.setMode(E5PathPickerModes.DirectoryMode) |
|
50 self.envBaseDirectoryPicker.setWindowTitle( |
|
51 self.tr("Virtualenv Base Directory")) |
|
52 self.envBaseDirectoryPicker.setText(baseDir) |
|
53 |
41 self.__populateVenvList() |
54 self.__populateVenvList() |
42 self.__updateButtons() |
55 self.__updateButtons() |
43 |
56 |
44 self.venvList.header().setSortIndicator(0, Qt.AscendingOrder) |
57 self.venvList.header().setSortIndicator(0, Qt.AscendingOrder) |
45 |
58 |
92 def on_addButton_clicked(self): |
105 def on_addButton_clicked(self): |
93 """ |
106 """ |
94 Private slot to add a new entry. |
107 Private slot to add a new entry. |
95 """ |
108 """ |
96 from .VirtualenvAddEditDialog import VirtualenvAddEditDialog |
109 from .VirtualenvAddEditDialog import VirtualenvAddEditDialog |
97 dlg = VirtualenvAddEditDialog(self.__manager) |
110 dlg = VirtualenvAddEditDialog( |
|
111 self.__manager, |
|
112 baseDir=self.envBaseDirectoryPicker.text() |
|
113 ) |
98 if dlg.exec() == QDialog.Accepted: |
114 if dlg.exec() == QDialog.Accepted: |
99 (venvName, venvDirectory, venvInterpreter, isGlobal, isConda, |
115 (venvName, venvDirectory, venvInterpreter, isGlobal, isConda, |
100 isRemote, execPath) = dlg.getData() |
116 isRemote, execPath) = dlg.getData() |
101 |
117 |
102 self.__manager.addVirtualEnv( |
118 self.__manager.addVirtualEnv( |
106 @pyqtSlot() |
122 @pyqtSlot() |
107 def on_newButton_clicked(self): |
123 def on_newButton_clicked(self): |
108 """ |
124 """ |
109 Private slot to create a new virtual environment. |
125 Private slot to create a new virtual environment. |
110 """ |
126 """ |
111 self.__manager.createVirtualEnv() |
127 self.__manager.createVirtualEnv( |
|
128 baseDir=self.envBaseDirectoryPicker.text()) |
112 |
129 |
113 @pyqtSlot() |
130 @pyqtSlot() |
114 def on_editButton_clicked(self): |
131 def on_editButton_clicked(self): |
115 """ |
132 """ |
116 Private slot to edit the selected entry. |
133 Private slot to edit the selected entry. |
124 selectedItem.text(1), selectedItem.text(2), |
141 selectedItem.text(1), selectedItem.text(2), |
125 selectedItem.data(0, VirtualenvManagerDialog.IsGlobalRole), |
142 selectedItem.data(0, VirtualenvManagerDialog.IsGlobalRole), |
126 selectedItem.data(0, VirtualenvManagerDialog.IsCondaRole), |
143 selectedItem.data(0, VirtualenvManagerDialog.IsCondaRole), |
127 selectedItem.data(0, VirtualenvManagerDialog.IsRemoteRole), |
144 selectedItem.data(0, VirtualenvManagerDialog.IsRemoteRole), |
128 selectedItem.data(0, VirtualenvManagerDialog.ExecPathRole), |
145 selectedItem.data(0, VirtualenvManagerDialog.ExecPathRole), |
|
146 baseDir=self.envBaseDirectoryPicker.text() |
129 ) |
147 ) |
130 if dlg.exec() == QDialog.Accepted: |
148 if dlg.exec() == QDialog.Accepted: |
131 (venvName, venvDirectory, venvInterpreter, isGlobal, isConda, |
149 (venvName, venvDirectory, venvInterpreter, isGlobal, isConda, |
132 isRemote, execPath) = dlg.getData() |
150 isRemote, execPath) = dlg.getData() |
133 if venvName != oldVenvName: |
151 if venvName != oldVenvName: |
271 contents. |
289 contents. |
272 """ |
290 """ |
273 self.venvList.header().resizeSections( |
291 self.venvList.header().resizeSections( |
274 QHeaderView.ResizeToContents) |
292 QHeaderView.ResizeToContents) |
275 self.venvList.header().setStretchLastSection(True) |
293 self.venvList.header().setStretchLastSection(True) |
|
294 |
|
295 def closeEvent(self, evt): |
|
296 """ |
|
297 Protected method to handle the close event. |
|
298 |
|
299 @param evt reference to the close event |
|
300 @type QCloseEvent |
|
301 """ |
|
302 baseDir = self.envBaseDirectoryPicker.text() |
|
303 self.__manager.setVirtualEnvironmentsBaseDir(baseDir) |
|
304 |
|
305 evt.accept() |