21 from Globals import isWindowsPlatform |
21 from Globals import isWindowsPlatform |
22 |
22 |
23 import UI.PixmapCache |
23 import UI.PixmapCache |
24 import Utilities |
24 import Utilities |
25 |
25 |
26 from .FlaskCommandDialog import FlaskCommandDialog |
|
27 |
|
28 from .FlaskBabelExtension.PyBabelProjectExtension import PyBabelProject |
26 from .FlaskBabelExtension.PyBabelProjectExtension import PyBabelProject |
29 |
27 from .FlaskMigrateExtension.MigrateProjectExtension import MigrateProject |
30 |
28 |
31 # TODO: move database related code to a separate package (FlaskMigrateExtension) |
29 |
32 class Project(QObject): |
30 class Project(QObject): |
33 """ |
31 """ |
34 Class implementing the Flask project support. |
32 Class implementing the Flask project support. |
35 """ |
33 """ |
36 def __init__(self, plugin, iconSuffix, parent=None): |
34 def __init__(self, plugin, iconSuffix, parent=None): |
74 } |
72 } |
75 |
73 |
76 self.__capabilities = {} |
74 self.__capabilities = {} |
77 |
75 |
78 self.__pybabelProject = PyBabelProject(self.__plugin, self, self) |
76 self.__pybabelProject = PyBabelProject(self.__plugin, self, self) |
|
77 self.__migrateProject = MigrateProject(self.__plugin, self, self) |
79 |
78 |
80 def initActions(self): |
79 def initActions(self): |
81 """ |
80 """ |
82 Public method to define the Flask actions. |
81 Public method to define the Flask actions. |
83 """ |
82 """ |
166 )) |
165 )) |
167 self.showRoutesAct.triggered.connect(self.__showRoutes) |
166 self.showRoutesAct.triggered.connect(self.__showRoutes) |
168 self.actions.append(self.showRoutesAct) |
167 self.actions.append(self.showRoutesAct) |
169 |
168 |
170 ################################## |
169 ################################## |
171 ## database action below ## |
|
172 ################################## |
|
173 |
|
174 # TODO: replace this with 'flask-migrate' |
|
175 self.initDatabaseAct = E5Action( |
|
176 self.tr('Initialize Database'), |
|
177 self.tr('&Initialize Database'), |
|
178 0, 0, |
|
179 self, 'flask_init_database') |
|
180 self.initDatabaseAct.setStatusTip(self.tr( |
|
181 'Shows a dialog with the result of the database creation')) |
|
182 self.initDatabaseAct.setWhatsThis(self.tr( |
|
183 """<b>Initialize Database</b>""" |
|
184 """<p>Shows a dialog with the result of the database""" |
|
185 """ creation.</p>""" |
|
186 )) |
|
187 self.initDatabaseAct.triggered.connect(self.__initDatabase) |
|
188 self.actions.append(self.initDatabaseAct) |
|
189 |
|
190 ################################## |
|
191 ## documentation action below ## |
170 ## documentation action below ## |
192 ################################## |
171 ################################## |
193 |
172 |
194 self.documentationAct = E5Action( |
173 self.documentationAct = E5Action( |
195 self.tr('Documentation'), |
174 self.tr('Documentation'), |
233 @rtype QMenu |
213 @rtype QMenu |
234 """ |
214 """ |
235 self.__menus = {} # clear menus references |
215 self.__menus = {} # clear menus references |
236 |
216 |
237 self.__menus["pybabel"] = self.__pybabelProject.initMenu() |
217 self.__menus["pybabel"] = self.__pybabelProject.initMenu() |
|
218 self.__menus["migrate"] = self.__migrateProject.initMenu() |
238 |
219 |
239 menu = QMenu(self.tr('&Flask'), self.__ui) |
220 menu = QMenu(self.tr('&Flask'), self.__ui) |
240 menu.setTearOffEnabled(True) |
221 menu.setTearOffEnabled(True) |
241 |
222 |
242 menu.addAction(self.runServerAct) |
223 menu.addAction(self.runServerAct) |
245 menu.addSeparator() |
226 menu.addSeparator() |
246 menu.addAction(self.runPythonShellAct) |
227 menu.addAction(self.runPythonShellAct) |
247 menu.addSeparator() |
228 menu.addSeparator() |
248 menu.addAction(self.showRoutesAct) |
229 menu.addAction(self.showRoutesAct) |
249 menu.addSeparator() |
230 menu.addSeparator() |
250 menu.addAction(self.initDatabaseAct) |
231 menu.addMenu(self.__menus["migrate"]) |
251 menu.addSeparator() |
232 menu.addSeparator() |
252 menu.addMenu(self.__menus["pybabel"]) |
233 menu.addMenu(self.__menus["pybabel"]) |
253 menu.addSeparator() |
234 menu.addSeparator() |
254 menu.addAction(self.documentationAct) |
235 menu.addAction(self.documentationAct) |
255 menu.addSeparator() |
236 menu.addSeparator() |
657 """ |
638 """ |
658 # 1. support for flask-babel (i.e. pybabel) |
639 # 1. support for flask-babel (i.e. pybabel) |
659 self.__pybabelProject.determineCapability() |
640 self.__pybabelProject.determineCapability() |
660 |
641 |
661 # 2. support for flask-migrate |
642 # 2. support for flask-migrate |
662 # TODO: add support for flask-migrate |
643 self.__migrateProject.determineCapability() |
663 |
644 |
664 def hasCapability(self, key): |
645 def hasCapability(self, key): |
665 """ |
646 """ |
666 Public method to check, if a capability is available. |
647 Public method to check, if a capability is available. |
667 |
648 |