Project/ProjectFormsBrowser.py

changeset 2995
63d874899b8b
parent 2965
d133c7edd88a
child 3020
542e97d4ecb3
child 3057
10516539f238
equal deleted inserted replaced
2994:5ae1349b8fb4 2995:63d874899b8b
10 import os 10 import os
11 import sys 11 import sys
12 import shutil 12 import shutil
13 13
14 from PyQt4.QtCore import QThread, QFileInfo, pyqtSignal, QProcess 14 from PyQt4.QtCore import QThread, QFileInfo, pyqtSignal, QProcess
15 from PyQt4.QtGui import QDialog, QInputDialog, QApplication, QMenu, QProgressDialog 15 from PyQt4.QtGui import QDialog, QInputDialog, QApplication, QMenu, \
16 QProgressDialog
16 17
17 from E5Gui.E5Application import e5App 18 from E5Gui.E5Application import e5App
18 from E5Gui import E5MessageBox, E5FileDialog 19 from E5Gui import E5MessageBox, E5FileDialog
19 20
20 from .ProjectBrowserModel import ProjectBrowserFileItem, \ 21 from .ProjectBrowserModel import ProjectBrowserFileItem, \
33 class ProjectFormsBrowser(ProjectBaseBrowser): 34 class ProjectFormsBrowser(ProjectBaseBrowser):
34 """ 35 """
35 A class used to display the forms part of the project. 36 A class used to display the forms part of the project.
36 37
37 @signal appendStderr(str) emitted after something was received from 38 @signal appendStderr(str) emitted after something was received from
38 a QProcess on stderr 39 a QProcess on stderr
39 @signal sourceFile(str) emitted to open a forms file in an editor 40 @signal sourceFile(str) emitted to open a forms file in an editor
40 @signal uipreview(str) emitted to preview a forms file 41 @signal uipreview(str) emitted to preview a forms file
41 @signal trpreview(list of str) emitted to preview form files in the 42 @signal trpreview(list of str) emitted to preview form files in the
42 translations previewer 43 translations previewer
43 @signal closeSourceWindow(str) emitted after a file has been removed/deleted 44 @signal closeSourceWindow(str) emitted after a file has been
44 from the project 45 removed/deleted from the project
45 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The name 46 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The
46 of the menu and a reference to the menu are given. 47 name of the menu and a reference to the menu are given.
47 @signal menusAboutToBeCreated() emitted when the context menus are about to 48 @signal menusAboutToBeCreated() emitted when the context menus are about to
48 be created. This is the right moment to add or remove hook methods. 49 be created. This is the right moment to add or remove hook methods.
49 """ 50 """
50 appendStderr = pyqtSignal(str) 51 appendStderr = pyqtSignal(str)
51 uipreview = pyqtSignal(str) 52 uipreview = pyqtSignal(str)
52 showMenu = pyqtSignal(str, QMenu) 53 showMenu = pyqtSignal(str, QMenu)
53 menusAboutToBeCreated = pyqtSignal() 54 menusAboutToBeCreated = pyqtSignal()
57 Constructor 58 Constructor
58 59
59 @param project reference to the project object 60 @param project reference to the project object
60 @param parent parent widget of this browser (QWidget) 61 @param parent parent widget of this browser (QWidget)
61 """ 62 """
62 ProjectBaseBrowser.__init__(self, project, ProjectBrowserFormType, parent) 63 ProjectBaseBrowser.__init__(self, project, ProjectBrowserFormType,
64 parent)
63 65
64 self.selectedItemsFilter = \ 66 self.selectedItemsFilter = \
65 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem] 67 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
66 68
67 self.setWindowTitle(self.trUtf8('Forms')) 69 self.setWindowTitle(self.trUtf8('Forms'))
68 70
69 self.setWhatsThis(self.trUtf8( 71 self.setWhatsThis(self.trUtf8(
70 """<b>Project Forms Browser</b>""" 72 """<b>Project Forms Browser</b>"""
71 """<p>This allows to easily see all forms contained in the current""" 73 """<p>This allows to easily see all forms contained in the"""
72 """ project. Several actions can be executed via the context menu.</p>""" 74 """ current project. Several actions can be executed via the"""
75 """ context menu.</p>"""
73 )) 76 ))
74 77
75 # templates for Qt4 78 # templates for Qt4
76 # these two lists have to stay in sync 79 # these two lists have to stay in sync
77 self.templates4 = ['dialog4.tmpl', 'widget4.tmpl', 'mainwindow4.tmpl', 80 self.templates4 = ['dialog4.tmpl', 'widget4.tmpl', 'mainwindow4.tmpl',
115 self.dirMultiMenuActions = [] 118 self.dirMultiMenuActions = []
116 119
117 self.menusAboutToBeCreated.emit() 120 self.menusAboutToBeCreated.emit()
118 121
119 self.menu = QMenu(self) 122 self.menu = QMenu(self)
120 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 123 if self.project.getProjectType() in \
121 self.menu.addAction(self.trUtf8('Compile form'), self.__compileForm) 124 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
125 self.menu.addAction(
126 self.trUtf8('Compile form'), self.__compileForm)
122 self.menu.addAction(self.trUtf8('Compile all forms'), 127 self.menu.addAction(self.trUtf8('Compile all forms'),
123 self.__compileAllForms) 128 self.__compileAllForms)
124 self.menu.addAction(self.trUtf8('Generate Dialog Code...'), 129 self.menu.addAction(self.trUtf8('Generate Dialog Code...'),
125 self.__generateDialogCode) 130 self.__generateDialogCode)
126 self.menu.addSeparator() 131 self.menu.addSeparator()
127 self.menu.addAction(self.trUtf8('Open in Qt-Designer'), self.__openFile) 132 self.menu.addAction(
128 self.menu.addAction(self.trUtf8('Open in Editor'), self.__openFileInEditor) 133 self.trUtf8('Open in Qt-Designer'), self.__openFile)
134 self.menu.addAction(
135 self.trUtf8('Open in Editor'), self.__openFileInEditor)
129 self.menu.addSeparator() 136 self.menu.addSeparator()
130 self.menu.addAction(self.trUtf8('Preview form'), self.__UIPreview) 137 self.menu.addAction(self.trUtf8('Preview form'), self.__UIPreview)
131 self.menu.addAction(self.trUtf8('Preview translations'), self.__TRPreview) 138 self.menu.addAction(
139 self.trUtf8('Preview translations'), self.__TRPreview)
132 else: 140 else:
133 if self.hooks["compileForm"] is not None: 141 if self.hooks["compileForm"] is not None:
134 self.menu.addAction( 142 self.menu.addAction(
135 self.hooksMenuEntries.get("compileForm", 143 self.hooksMenuEntries.get("compileForm",
136 self.trUtf8('Compile form')), self.__compileForm) 144 self.trUtf8('Compile form')), self.__compileForm)
154 self.__openFile) 162 self.__openFile)
155 self.menu.addAction(self.trUtf8('Open'), self.__openFileInEditor) 163 self.menu.addAction(self.trUtf8('Open'), self.__openFileInEditor)
156 self.menu.addSeparator() 164 self.menu.addSeparator()
157 act = self.menu.addAction(self.trUtf8('Rename file'), self._renameFile) 165 act = self.menu.addAction(self.trUtf8('Rename file'), self._renameFile)
158 self.menuActions.append(act) 166 self.menuActions.append(act)
159 act = self.menu.addAction(self.trUtf8('Remove from project'), self._removeFile) 167 act = self.menu.addAction(
168 self.trUtf8('Remove from project'), self._removeFile)
160 self.menuActions.append(act) 169 self.menuActions.append(act)
161 act = self.menu.addAction(self.trUtf8('Delete'), self.__deleteFile) 170 act = self.menu.addAction(self.trUtf8('Delete'), self.__deleteFile)
162 self.menuActions.append(act) 171 self.menuActions.append(act)
163 self.menu.addSeparator() 172 self.menu.addSeparator()
164 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 173 if self.project.getProjectType() in \
174 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
165 self.menu.addAction(self.trUtf8('New form...'), self.__newForm) 175 self.menu.addAction(self.trUtf8('New form...'), self.__newForm)
166 else: 176 else:
167 if self.hooks["newForm"] is not None: 177 if self.hooks["newForm"] is not None:
168 self.menu.addAction( 178 self.menu.addAction(
169 self.hooksMenuEntries.get("newForm", 179 self.hooksMenuEntries.get("newForm",
181 self._collapseAllDirs) 191 self._collapseAllDirs)
182 self.menu.addSeparator() 192 self.menu.addSeparator()
183 self.menu.addAction(self.trUtf8('Configure...'), self._configure) 193 self.menu.addAction(self.trUtf8('Configure...'), self._configure)
184 194
185 self.backMenu = QMenu(self) 195 self.backMenu = QMenu(self)
186 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"] or \ 196 if self.project.getProjectType() in \
187 self.hooks["compileAllForms"] is not None: 197 ["Qt4", "PyQt5", "E4Plugin", "PySide"] or \
198 self.hooks["compileAllForms"] is not None:
188 self.backMenu.addAction(self.trUtf8('Compile all forms'), 199 self.backMenu.addAction(self.trUtf8('Compile all forms'),
189 self.__compileAllForms) 200 self.__compileAllForms)
190 self.backMenu.addSeparator() 201 self.backMenu.addSeparator()
191 self.backMenu.addAction(self.trUtf8('New form...'), self.__newForm) 202 self.backMenu.addAction(self.trUtf8('New form...'), self.__newForm)
192 else: 203 else:
193 if self.hooks["newForm"] is not None: 204 if self.hooks["newForm"] is not None:
194 self.backMenu.addAction( 205 self.backMenu.addAction(
195 self.hooksMenuEntries.get("newForm", 206 self.hooksMenuEntries.get("newForm",
196 self.trUtf8('New form...')), self.__newForm) 207 self.trUtf8('New form...')), self.__newForm)
197 self.backMenu.addAction(self.trUtf8('Add forms...'), self.project.addUiFiles) 208 self.backMenu.addAction(
209 self.trUtf8('Add forms...'), self.project.addUiFiles)
198 self.backMenu.addAction(self.trUtf8('Add forms directory...'), 210 self.backMenu.addAction(self.trUtf8('Add forms directory...'),
199 self.project.addUiDir) 211 self.project.addUiDir)
200 self.backMenu.addSeparator() 212 self.backMenu.addSeparator()
201 self.backMenu.addAction(self.trUtf8('Expand all directories'), 213 self.backMenu.addAction(self.trUtf8('Expand all directories'),
202 self._expandAllDirs) 214 self._expandAllDirs)
206 self.backMenu.addAction(self.trUtf8('Configure...'), self._configure) 218 self.backMenu.addAction(self.trUtf8('Configure...'), self._configure)
207 self.backMenu.setEnabled(False) 219 self.backMenu.setEnabled(False)
208 220
209 # create the menu for multiple selected files 221 # create the menu for multiple selected files
210 self.multiMenu = QMenu(self) 222 self.multiMenu = QMenu(self)
211 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 223 if self.project.getProjectType() in \
224 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
212 act = self.multiMenu.addAction(self.trUtf8('Compile forms'), 225 act = self.multiMenu.addAction(self.trUtf8('Compile forms'),
213 self.__compileSelectedForms) 226 self.__compileSelectedForms)
214 self.multiMenu.addSeparator() 227 self.multiMenu.addSeparator()
215 self.multiMenu.addAction(self.trUtf8('Open in Qt-Designer'), 228 self.multiMenu.addAction(self.trUtf8('Open in Qt-Designer'),
216 self.__openFile) 229 self.__openFile)
228 self.multiMenu.addSeparator() 241 self.multiMenu.addSeparator()
229 if self.hooks["open"] is not None: 242 if self.hooks["open"] is not None:
230 self.multiMenu.addAction( 243 self.multiMenu.addAction(
231 self.hooksMenuEntries.get("open", self.trUtf8('Open')), 244 self.hooksMenuEntries.get("open", self.trUtf8('Open')),
232 self.__openFile) 245 self.__openFile)
233 self.multiMenu.addAction(self.trUtf8('Open'), self.__openFileInEditor) 246 self.multiMenu.addAction(
247 self.trUtf8('Open'), self.__openFileInEditor)
234 self.multiMenu.addSeparator() 248 self.multiMenu.addSeparator()
235 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), 249 act = self.multiMenu.addAction(self.trUtf8('Remove from project'),
236 self._removeFile) 250 self._removeFile)
237 self.multiMenuActions.append(act) 251 self.multiMenuActions.append(act)
238 act = self.multiMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) 252 act = self.multiMenu.addAction(
253 self.trUtf8('Delete'), self.__deleteFile)
239 self.multiMenuActions.append(act) 254 self.multiMenuActions.append(act)
240 self.multiMenu.addSeparator() 255 self.multiMenu.addSeparator()
241 self.multiMenu.addAction(self.trUtf8('Expand all directories'), 256 self.multiMenu.addAction(self.trUtf8('Expand all directories'),
242 self._expandAllDirs) 257 self._expandAllDirs)
243 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), 258 self.multiMenu.addAction(self.trUtf8('Collapse all directories'),
244 self._collapseAllDirs) 259 self._collapseAllDirs)
245 self.multiMenu.addSeparator() 260 self.multiMenu.addSeparator()
246 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) 261 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure)
247 262
248 self.dirMenu = QMenu(self) 263 self.dirMenu = QMenu(self)
249 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 264 if self.project.getProjectType() in \
265 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
250 self.dirMenu.addAction(self.trUtf8('Compile all forms'), 266 self.dirMenu.addAction(self.trUtf8('Compile all forms'),
251 self.__compileAllForms) 267 self.__compileAllForms)
252 self.dirMenu.addSeparator() 268 self.dirMenu.addSeparator()
253 else: 269 else:
254 if self.hooks["compileAllForms"] is not None: 270 if self.hooks["compileAllForms"] is not None:
255 self.dirMenu.addAction( 271 self.dirMenu.addAction(
256 self.hooksMenuEntries.get("compileAllForms", 272 self.hooksMenuEntries.get("compileAllForms",
257 self.trUtf8('Compile all forms')), 273 self.trUtf8('Compile all forms')),
258 self.__compileAllForms) 274 self.__compileAllForms)
259 self.dirMenu.addSeparator() 275 self.dirMenu.addSeparator()
260 act = self.dirMenu.addAction(self.trUtf8('Remove from project'), self._removeDir) 276 act = self.dirMenu.addAction(
277 self.trUtf8('Remove from project'), self._removeDir)
261 self.dirMenuActions.append(act) 278 self.dirMenuActions.append(act)
262 act = self.dirMenu.addAction(self.trUtf8('Delete'), self._deleteDirectory) 279 act = self.dirMenu.addAction(
280 self.trUtf8('Delete'), self._deleteDirectory)
263 self.dirMenuActions.append(act) 281 self.dirMenuActions.append(act)
264 self.dirMenu.addSeparator() 282 self.dirMenu.addSeparator()
265 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 283 if self.project.getProjectType() in \
284 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
266 self.dirMenu.addAction(self.trUtf8('New form...'), self.__newForm) 285 self.dirMenu.addAction(self.trUtf8('New form...'), self.__newForm)
267 else: 286 else:
268 if self.hooks["newForm"] is not None: 287 if self.hooks["newForm"] is not None:
269 self.dirMenu.addAction( 288 self.dirMenu.addAction(
270 self.hooksMenuEntries.get("newForm", 289 self.hooksMenuEntries.get("newForm",
271 self.trUtf8('New form...')), self.__newForm) 290 self.trUtf8('New form...')), self.__newForm)
272 self.dirMenu.addAction(self.trUtf8('Add forms...'), self.__addFormFiles) 291 self.dirMenu.addAction(
292 self.trUtf8('Add forms...'), self.__addFormFiles)
273 self.dirMenu.addAction(self.trUtf8('Add forms directory...'), 293 self.dirMenu.addAction(self.trUtf8('Add forms directory...'),
274 self.__addFormsDirectory) 294 self.__addFormsDirectory)
275 self.dirMenu.addSeparator() 295 self.dirMenu.addSeparator()
276 self.dirMenu.addAction(self.trUtf8('Copy Path to Clipboard'), 296 self.dirMenu.addAction(self.trUtf8('Copy Path to Clipboard'),
277 self._copyToClipboard) 297 self._copyToClipboard)
282 self._collapseAllDirs) 302 self._collapseAllDirs)
283 self.dirMenu.addSeparator() 303 self.dirMenu.addSeparator()
284 self.dirMenu.addAction(self.trUtf8('Configure...'), self._configure) 304 self.dirMenu.addAction(self.trUtf8('Configure...'), self._configure)
285 305
286 self.dirMultiMenu = QMenu(self) 306 self.dirMultiMenu = QMenu(self)
287 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 307 if self.project.getProjectType() in \
308 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
288 self.dirMultiMenu.addAction(self.trUtf8('Compile all forms'), 309 self.dirMultiMenu.addAction(self.trUtf8('Compile all forms'),
289 self.__compileAllForms) 310 self.__compileAllForms)
290 self.dirMultiMenu.addSeparator() 311 self.dirMultiMenu.addSeparator()
291 else: 312 else:
292 if self.hooks["compileAllForms"] is not None: 313 if self.hooks["compileAllForms"] is not None:
303 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), 324 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'),
304 self._expandAllDirs) 325 self._expandAllDirs)
305 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), 326 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'),
306 self._collapseAllDirs) 327 self._collapseAllDirs)
307 self.dirMultiMenu.addSeparator() 328 self.dirMultiMenu.addSeparator()
308 self.dirMultiMenu.addAction(self.trUtf8('Configure...'), self._configure) 329 self.dirMultiMenu.addAction(
330 self.trUtf8('Configure...'), self._configure)
309 331
310 self.menu.aboutToShow.connect(self.__showContextMenu) 332 self.menu.aboutToShow.connect(self.__showContextMenu)
311 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) 333 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti)
312 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir) 334 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir)
313 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti) 335 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti)
330 if cnt <= 1: 352 if cnt <= 1:
331 index = self.indexAt(coord) 353 index = self.indexAt(coord)
332 if index.isValid(): 354 if index.isValid():
333 self._selectSingleItem(index) 355 self._selectSingleItem(index)
334 categories = self.getSelectedItemsCountCategorized( 356 categories = self.getSelectedItemsCountCategorized(
335 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) 357 [ProjectBrowserFileItem,
358 ProjectBrowserSimpleDirectoryItem])
336 cnt = categories["sum"] 359 cnt = categories["sum"]
337 360
338 bfcnt = categories[str(ProjectBrowserFileItem)] 361 bfcnt = categories[str(ProjectBrowserFileItem)]
339 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)] 362 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)]
340 if cnt > 1 and cnt == bfcnt: 363 if cnt > 1 and cnt == bfcnt:
496 path = os.path.join(self.project.ppath, itm.data(0)) 519 path = os.path.join(self.project.ppath, itm.data(0))
497 520
498 if self.hooks["newForm"] is not None: 521 if self.hooks["newForm"] is not None:
499 self.hooks["newForm"](path) 522 self.hooks["newForm"](path)
500 else: 523 else:
501 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 524 if self.project.getProjectType() in \
525 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
502 self.__newUiForm(path) 526 self.__newUiForm(path)
503 527
504 def __newUiForm(self, path): 528 def __newUiForm(self, path):
505 """ 529 """
506 Private slot to handle the New Form menu action for Qt-related projects. 530 Private slot to handle the New Form menu action for Qt-related
531 projects.
507 532
508 @param path full directory path for the new form file (string) 533 @param path full directory path for the new form file (string)
509 """ 534 """
510 selectedForm, ok = QInputDialog.getItem( 535 selectedForm, ok = QInputDialog.getItem(
511 None, 536 None,
551 try: 576 try:
552 shutil.copy(templateFile, fname) 577 shutil.copy(templateFile, fname)
553 except IOError as e: 578 except IOError as e:
554 E5MessageBox.critical(self, 579 E5MessageBox.critical(self,
555 self.trUtf8("New Form"), 580 self.trUtf8("New Form"),
556 self.trUtf8("<p>The new form file <b>{0}</b> could not be created.<br>" 581 self.trUtf8(
582 "<p>The new form file <b>{0}</b> could not be created.<br>"
557 "Problem: {1}</p>").format(fname, str(e))) 583 "Problem: {1}</p>").format(fname, str(e)))
558 return 584 return
559 585
560 self.project.appendFile(fname) 586 self.project.appendFile(fname)
561 self.designerFile.emit(fname) 587 self.designerFile.emit(fname)
572 fn2 = itm.fileName() 598 fn2 = itm.fileName()
573 fullNames.append(fn2) 599 fullNames.append(fn2)
574 fn = self.project.getRelativePath(fn2) 600 fn = self.project.getRelativePath(fn2)
575 files.append(fn) 601 files.append(fn)
576 602
577 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog 603 from UI.DeleteFilesConfirmationDialog import \
604 DeleteFilesConfirmationDialog
578 dlg = DeleteFilesConfirmationDialog(self.parent(), 605 dlg = DeleteFilesConfirmationDialog(self.parent(),
579 self.trUtf8("Delete forms"), 606 self.trUtf8("Delete forms"),
580 self.trUtf8("Do you really want to delete these forms from the project?"), 607 self.trUtf8(
608 "Do you really want to delete these forms from the project?"),
581 files) 609 files)
582 610
583 if dlg.exec_() == QDialog.Accepted: 611 if dlg.exec_() == QDialog.Accepted:
584 for fn2, fn in zip(fullNames, files): 612 for fn2, fn in zip(fullNames, files):
585 self.closeSourceWindow.emit(fn2) 613 self.closeSourceWindow.emit(fn2)
586 self.project.deleteFile(fn) 614 self.project.deleteFile(fn)
587 615
588 ############################################################################ 616 ###########################################################################
589 ## Methods to handle the various compile commands 617 ## Methods to handle the various compile commands
590 ############################################################################ 618 ###########################################################################
591 619
592 def __readStdout(self): 620 def __readStdout(self):
593 """ 621 """
594 Private slot to handle the readyReadStandardOutput signal of the 622 Private slot to handle the readyReadStandardOutput signal of the
595 pyuic/rbuic process. 623 pyuic/rbuic process.
647 E5MessageBox.information(self, 675 E5MessageBox.information(self,
648 self.trUtf8("Form Compilation"), 676 self.trUtf8("Form Compilation"),
649 self.trUtf8("The compilation of the form file" 677 self.trUtf8("The compilation of the form file"
650 " was successful.")) 678 " was successful."))
651 else: 679 else:
652 ui.showNotification(UI.PixmapCache.getPixmap("designer48.png"), 680 ui.showNotification(
681 UI.PixmapCache.getPixmap("designer48.png"),
653 self.trUtf8("Form Compilation"), 682 self.trUtf8("Form Compilation"),
654 self.trUtf8("The compilation of the form file" 683 self.trUtf8("The compilation of the form file"
655 " was successful.")) 684 " was successful."))
656 self.project.projectFormCompiled.emit(self.compiledFile) 685 self.project.projectFormCompiled.emit(self.compiledFile)
657 except IOError as msg: 686 except IOError as msg:
658 if not self.noDialog: 687 if not self.noDialog:
659 E5MessageBox.information(self, 688 E5MessageBox.information(self,
660 self.trUtf8("Form Compilation"), 689 self.trUtf8("Form Compilation"),
661 self.trUtf8("<p>The compilation of the form file failed.</p>" 690 self.trUtf8(
691 "<p>The compilation of the form file failed.</p>"
662 "<p>Reason: {0}</p>").format(str(msg))) 692 "<p>Reason: {0}</p>").format(str(msg)))
663 else: 693 else:
664 ui.showNotification(UI.PixmapCache.getPixmap("designer48.png"), 694 ui.showNotification(
695 UI.PixmapCache.getPixmap("designer48.png"),
665 self.trUtf8("Form Compilation"), 696 self.trUtf8("Form Compilation"),
666 self.trUtf8("<p>The compilation of the form file failed.</p>" 697 self.trUtf8(
698 "<p>The compilation of the form file failed.</p>"
667 "<p>Reason: {0}</p>").format(str(msg))) 699 "<p>Reason: {0}</p>").format(str(msg)))
668 else: 700 else:
669 if not self.noDialog: 701 if not self.noDialog:
670 E5MessageBox.information(self, 702 E5MessageBox.information(self,
671 self.trUtf8("Form Compilation"), 703 self.trUtf8("Form Compilation"),
687 """ 719 """
688 self.compileProc = QProcess() 720 self.compileProc = QProcess()
689 args = [] 721 args = []
690 self.buf = "" 722 self.buf = ""
691 723
692 if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]: 724 if self.project.pdata["PROGLANGUAGE"][0] in \
725 ["Python", "Python2", "Python3"]:
693 if self.project.getProjectType() in ["Qt4", "E4Plugin"]: 726 if self.project.getProjectType() in ["Qt4", "E4Plugin"]:
694 self.uicompiler = 'pyuic4' 727 self.uicompiler = 'pyuic4'
695 if Utilities.isWindowsPlatform(): 728 if Utilities.isWindowsPlatform():
696 uic = self.uicompiler + '.bat' 729 uic = self.uicompiler + '.bat'
697 else: 730 else:
720 return None 753 return None
721 754
722 ofn, ext = os.path.splitext(fn) 755 ofn, ext = os.path.splitext(fn)
723 fn = os.path.join(self.project.ppath, fn) 756 fn = os.path.join(self.project.ppath, fn)
724 757
725 if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]: 758 if self.project.pdata["PROGLANGUAGE"][0] in \
759 ["Python", "Python2", "Python3"]:
726 dirname, filename = os.path.split(ofn) 760 dirname, filename = os.path.split(ofn)
727 self.compiledFile = os.path.join(dirname, "Ui_" + filename + ".py") 761 self.compiledFile = os.path.join(dirname, "Ui_" + filename + ".py")
728 args.append("-x") 762 args.append("-x")
729 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": 763 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
730 self.compiledFile = ofn + '.rb' 764 self.compiledFile = ofn + '.rb'
867 if self.project.getProjectType() not in \ 901 if self.project.getProjectType() not in \
868 ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 902 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
869 # ignore the request for non Qt GUI projects 903 # ignore the request for non Qt GUI projects
870 return 904 return
871 905
872 progress = QProgressDialog(self.trUtf8("Determining changed forms..."), 906 progress = QProgressDialog(
907 self.trUtf8("Determining changed forms..."),
873 None, 0, 100) 908 None, 0, 100)
874 progress.setMinimumDuration(0) 909 progress.setMinimumDuration(0)
875 i = 0 910 i = 0
876 911
877 # get list of changed forms 912 # get list of changed forms
894 i += 1 929 i += 1
895 progress.setValue(i) 930 progress.setValue(i)
896 QApplication.processEvents() 931 QApplication.processEvents()
897 932
898 if changedForms: 933 if changedForms:
899 progress.setLabelText(self.trUtf8("Compiling changed forms...")) 934 progress.setLabelText(
935 self.trUtf8("Compiling changed forms..."))
900 progress.setMaximum(len(changedForms)) 936 progress.setMaximum(len(changedForms))
901 i = 0 937 i = 0
902 progress.setValue(i) 938 progress.setValue(i)
903 QApplication.processEvents() 939 QApplication.processEvents()
904 for fn in changedForms: 940 for fn in changedForms:
919 """ 955 """
920 Public slot used to handle the preferencesChanged signal. 956 Public slot used to handle the preferencesChanged signal.
921 """ 957 """
922 ProjectBaseBrowser.handlePreferencesChanged(self) 958 ProjectBaseBrowser.handlePreferencesChanged(self)
923 959
924 ############################################################################ 960 ###########################################################################
925 ## Support for hooks below 961 ## Support for hooks below
926 ############################################################################ 962 ###########################################################################
927 963
928 def _initHookMethods(self): 964 def _initHookMethods(self):
929 """ 965 """
930 Protected method to initialize the hooks dictionary. 966 Protected method to initialize the hooks dictionary.
931 967

eric ide

mercurial