11 from PyQt5.QtWidgets import QDialog |
11 from PyQt5.QtWidgets import QDialog |
12 |
12 |
13 from E5Gui.E5Application import e5App |
13 from E5Gui.E5Application import e5App |
14 |
14 |
15 from .Ui_FlaskConfigDialog import Ui_FlaskConfigDialog |
15 from .Ui_FlaskConfigDialog import Ui_FlaskConfigDialog |
|
16 |
|
17 import UI.PixmapCache |
16 |
18 |
17 |
19 |
18 class FlaskConfigDialog(QDialog, Ui_FlaskConfigDialog): |
20 class FlaskConfigDialog(QDialog, Ui_FlaskConfigDialog): |
19 """ |
21 """ |
20 Class implementing a dialog to configure project specific flask settings. |
22 Class implementing a dialog to configure project specific flask settings. |
29 @type QWidget |
31 @type QWidget |
30 """ |
32 """ |
31 super(FlaskConfigDialog, self).__init__(parent) |
33 super(FlaskConfigDialog, self).__init__(parent) |
32 self.setupUi(self) |
34 self.setupUi(self) |
33 |
35 |
|
36 self.newEnvironmentButton.setIcon( |
|
37 UI.PixmapCache.getIcon("virtualenvConfig")) |
|
38 |
|
39 self.__virtualEnvManager = e5App().getObject("VirtualEnvManager") |
|
40 |
34 self.virtualEnvironmentComboBox.addItem("") |
41 self.virtualEnvironmentComboBox.addItem("") |
35 self.virtualEnvironmentComboBox.addItems( |
42 self.virtualEnvironmentComboBox.addItems( |
36 sorted(e5App().getObject("VirtualEnvManager").getVirtualenvNames( |
43 sorted(self.__virtualEnvManager.getVirtualenvNames( |
37 noRemote=True, noConda=True |
44 noRemote=True, noConda=True |
38 )) |
45 )) |
39 ) |
46 ) |
40 |
47 |
41 # TODO: set initial values based on configuration |
48 if "virtual_environment_name" in configuration: |
|
49 self.virtualEnvironmentComboBox.setCurrentText( |
|
50 configuration["virtual_environment_name"]) |
|
51 self.flaskBabelBox.setChecked( |
|
52 configuration.get("flask_babel_override", False)) |
|
53 self.flaskBabelCheckBox.setChecked( |
|
54 configuration.get("flask_babel_available", False)) |
|
55 self.flaskMigrateBox.setChecked( |
|
56 configuration.get("flask_migrate_override", False)) |
|
57 self.flaskMigrateCheckBox.setChecked( |
|
58 configuration.get("flask_migrate_available", False)) |
42 |
59 |
43 msh = self.minimumSizeHint() |
60 msh = self.minimumSizeHint() |
44 self.resize(max(self.width(), msh.width()), msh.height()) |
61 self.resize(max(self.width(), msh.width()), msh.height()) |
45 |
62 |
46 def getConfiguration(self): |
63 def getConfiguration(self): |
51 @rtype dict |
68 @rtype dict |
52 """ |
69 """ |
53 configuration = { |
70 configuration = { |
54 "virtual_environment_name": |
71 "virtual_environment_name": |
55 self.virtualEnvironmentComboBox.currentText(), |
72 self.virtualEnvironmentComboBox.currentText(), |
|
73 "flask_babel_override": |
|
74 self.flaskBabelBox.isChecked(), |
|
75 "flask_babel_available": |
|
76 self.flaskBabelCheckBox.isChecked(), |
|
77 "flask_migrate_override": |
|
78 self.flaskMigrateBox.isChecked(), |
|
79 "flask_migrate_available": |
|
80 self.flaskMigrateCheckBox.isChecked(), |
56 } |
81 } |
57 |
82 |
58 return configuration |
83 return configuration |
|
84 |
|
85 @pyqtSlot() |
|
86 def on_newEnvironmentButton_clicked(self): |
|
87 """ |
|
88 Private slot to open a dialog for adding a new virtual environment. |
|
89 """ |
|
90 ## self.__virtualEnvManager.createVirtualEnv() |
|
91 from VirtualEnv.VirtualenvConfigurationDialog import ( |
|
92 VirtualenvConfigurationDialog |
|
93 ) |
|
94 |
|
95 dlg = VirtualenvConfigurationDialog(self) |
|
96 if dlg.exec() == QDialog.Accepted: |
|
97 resultDict = dlg.getData() |
|
98 |
|
99 if resultDict["envType"] == "conda": |
|
100 # conda environments are not suitable |
|
101 return |
|
102 else: |
|
103 # now do the call |
|
104 from VirtualEnv.VirtualenvExecDialog import ( |
|
105 VirtualenvExecDialog |
|
106 ) |
|
107 dia = VirtualenvExecDialog( |
|
108 resultDict, self.__virtualEnvManager, self) |
|
109 dia.show() |
|
110 dia.start(resultDict["arguments"]) |
|
111 dia.exec() |
|
112 |
|
113 # reload the list of environments |
|
114 currentEnvName = self.virtualEnvironmentComboBox.currentText() |
|
115 |
|
116 self.virtualEnvironmentComboBox.clear() |
|
117 self.virtualEnvironmentComboBox.addItem("") |
|
118 self.virtualEnvironmentComboBox.addItems( |
|
119 sorted(self.__virtualEnvManager.getVirtualenvNames( |
|
120 noRemote=True, noConda=True |
|
121 )) |
|
122 ) |
|
123 |
|
124 self.virtualEnvironmentComboBox.setCurrentText(currentEnvName) |