Project/ProjectFormsBrowser.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2791
a9577f248f04
parent 2995
63d874899b8b
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
16 import os 16 import os
17 import sys 17 import sys
18 import shutil 18 import shutil
19 19
20 from PyQt4.QtCore import QThread, QFileInfo, pyqtSignal, QProcess 20 from PyQt4.QtCore import QThread, QFileInfo, pyqtSignal, QProcess
21 from PyQt4.QtGui import QDialog, QInputDialog, QApplication, QMenu, QProgressDialog 21 from PyQt4.QtGui import QDialog, QInputDialog, QApplication, QMenu, \
22 QProgressDialog
22 23
23 from E5Gui.E5Application import e5App 24 from E5Gui.E5Application import e5App
24 from E5Gui import E5MessageBox, E5FileDialog 25 from E5Gui import E5MessageBox, E5FileDialog
25 26
26 from .ProjectBrowserModel import ProjectBrowserFileItem, \ 27 from .ProjectBrowserModel import ProjectBrowserFileItem, \
39 class ProjectFormsBrowser(ProjectBaseBrowser): 40 class ProjectFormsBrowser(ProjectBaseBrowser):
40 """ 41 """
41 A class used to display the forms part of the project. 42 A class used to display the forms part of the project.
42 43
43 @signal appendStderr(str) emitted after something was received from 44 @signal appendStderr(str) emitted after something was received from
44 a QProcess on stderr 45 a QProcess on stderr
45 @signal sourceFile(str) emitted to open a forms file in an editor 46 @signal sourceFile(str) emitted to open a forms file in an editor
46 @signal uipreview(str) emitted to preview a forms file 47 @signal uipreview(str) emitted to preview a forms file
47 @signal trpreview(list of str) emitted to preview form files in the 48 @signal trpreview(list of str) emitted to preview form files in the
48 translations previewer 49 translations previewer
49 @signal closeSourceWindow(str) emitted after a file has been removed/deleted 50 @signal closeSourceWindow(str) emitted after a file has been
50 from the project 51 removed/deleted from the project
51 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The name 52 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The
52 of the menu and a reference to the menu are given. 53 name of the menu and a reference to the menu are given.
53 @signal menusAboutToBeCreated() emitted when the context menus are about to 54 @signal menusAboutToBeCreated() emitted when the context menus are about to
54 be created. This is the right moment to add or remove hook methods. 55 be created. This is the right moment to add or remove hook methods.
55 """ 56 """
56 appendStderr = pyqtSignal(str) 57 appendStderr = pyqtSignal(str)
57 uipreview = pyqtSignal(str) 58 uipreview = pyqtSignal(str)
58 showMenu = pyqtSignal(str, QMenu) 59 showMenu = pyqtSignal(str, QMenu)
59 menusAboutToBeCreated = pyqtSignal() 60 menusAboutToBeCreated = pyqtSignal()
63 Constructor 64 Constructor
64 65
65 @param project reference to the project object 66 @param project reference to the project object
66 @param parent parent widget of this browser (QWidget) 67 @param parent parent widget of this browser (QWidget)
67 """ 68 """
68 ProjectBaseBrowser.__init__(self, project, ProjectBrowserFormType, parent) 69 ProjectBaseBrowser.__init__(self, project, ProjectBrowserFormType,
70 parent)
69 71
70 self.selectedItemsFilter = \ 72 self.selectedItemsFilter = \
71 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem] 73 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]
72 74
73 self.setWindowTitle(self.trUtf8('Forms')) 75 self.setWindowTitle(self.trUtf8('Forms'))
74 76
75 self.setWhatsThis(self.trUtf8( 77 self.setWhatsThis(self.trUtf8(
76 """<b>Project Forms Browser</b>""" 78 """<b>Project Forms Browser</b>"""
77 """<p>This allows to easily see all forms contained in the current""" 79 """<p>This allows to easily see all forms contained in the"""
78 """ project. Several actions can be executed via the context menu.</p>""" 80 """ current project. Several actions can be executed via the"""
81 """ context menu.</p>"""
79 )) 82 ))
80 83
81 # templates for Qt4 84 # templates for Qt4
82 # these two lists have to stay in sync 85 # these two lists have to stay in sync
83 self.templates4 = ['dialog4.tmpl', 'widget4.tmpl', 'mainwindow4.tmpl', 86 self.templates4 = ['dialog4.tmpl', 'widget4.tmpl', 'mainwindow4.tmpl',
121 self.dirMultiMenuActions = [] 124 self.dirMultiMenuActions = []
122 125
123 self.menusAboutToBeCreated.emit() 126 self.menusAboutToBeCreated.emit()
124 127
125 self.menu = QMenu(self) 128 self.menu = QMenu(self)
126 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 129 if self.project.getProjectType() in \
127 self.menu.addAction(self.trUtf8('Compile form'), self.__compileForm) 130 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
131 self.menu.addAction(
132 self.trUtf8('Compile form'), self.__compileForm)
128 self.menu.addAction(self.trUtf8('Compile all forms'), 133 self.menu.addAction(self.trUtf8('Compile all forms'),
129 self.__compileAllForms) 134 self.__compileAllForms)
130 self.menu.addAction(self.trUtf8('Generate Dialog Code...'), 135 self.menu.addAction(self.trUtf8('Generate Dialog Code...'),
131 self.__generateDialogCode) 136 self.__generateDialogCode)
132 self.menu.addSeparator() 137 self.menu.addSeparator()
133 self.menu.addAction(self.trUtf8('Open in Qt-Designer'), self.__openFile) 138 self.menu.addAction(
134 self.menu.addAction(self.trUtf8('Open in Editor'), self.__openFileInEditor) 139 self.trUtf8('Open in Qt-Designer'), self.__openFile)
140 self.menu.addAction(
141 self.trUtf8('Open in Editor'), self.__openFileInEditor)
135 self.menu.addSeparator() 142 self.menu.addSeparator()
136 self.menu.addAction(self.trUtf8('Preview form'), self.__UIPreview) 143 self.menu.addAction(self.trUtf8('Preview form'), self.__UIPreview)
137 self.menu.addAction(self.trUtf8('Preview translations'), self.__TRPreview) 144 self.menu.addAction(
145 self.trUtf8('Preview translations'), self.__TRPreview)
138 else: 146 else:
139 if self.hooks["compileForm"] is not None: 147 if self.hooks["compileForm"] is not None:
140 self.menu.addAction( 148 self.menu.addAction(
141 self.hooksMenuEntries.get("compileForm", 149 self.hooksMenuEntries.get("compileForm",
142 self.trUtf8('Compile form')), self.__compileForm) 150 self.trUtf8('Compile form')), self.__compileForm)
160 self.__openFile) 168 self.__openFile)
161 self.menu.addAction(self.trUtf8('Open'), self.__openFileInEditor) 169 self.menu.addAction(self.trUtf8('Open'), self.__openFileInEditor)
162 self.menu.addSeparator() 170 self.menu.addSeparator()
163 act = self.menu.addAction(self.trUtf8('Rename file'), self._renameFile) 171 act = self.menu.addAction(self.trUtf8('Rename file'), self._renameFile)
164 self.menuActions.append(act) 172 self.menuActions.append(act)
165 act = self.menu.addAction(self.trUtf8('Remove from project'), self._removeFile) 173 act = self.menu.addAction(
174 self.trUtf8('Remove from project'), self._removeFile)
166 self.menuActions.append(act) 175 self.menuActions.append(act)
167 act = self.menu.addAction(self.trUtf8('Delete'), self.__deleteFile) 176 act = self.menu.addAction(self.trUtf8('Delete'), self.__deleteFile)
168 self.menuActions.append(act) 177 self.menuActions.append(act)
169 self.menu.addSeparator() 178 self.menu.addSeparator()
170 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 179 if self.project.getProjectType() in \
180 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
171 self.menu.addAction(self.trUtf8('New form...'), self.__newForm) 181 self.menu.addAction(self.trUtf8('New form...'), self.__newForm)
172 else: 182 else:
173 if self.hooks["newForm"] is not None: 183 if self.hooks["newForm"] is not None:
174 self.menu.addAction( 184 self.menu.addAction(
175 self.hooksMenuEntries.get("newForm", 185 self.hooksMenuEntries.get("newForm",
187 self._collapseAllDirs) 197 self._collapseAllDirs)
188 self.menu.addSeparator() 198 self.menu.addSeparator()
189 self.menu.addAction(self.trUtf8('Configure...'), self._configure) 199 self.menu.addAction(self.trUtf8('Configure...'), self._configure)
190 200
191 self.backMenu = QMenu(self) 201 self.backMenu = QMenu(self)
192 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"] or \ 202 if self.project.getProjectType() in \
193 self.hooks["compileAllForms"] is not None: 203 ["Qt4", "PyQt5", "E4Plugin", "PySide"] or \
204 self.hooks["compileAllForms"] is not None:
194 self.backMenu.addAction(self.trUtf8('Compile all forms'), 205 self.backMenu.addAction(self.trUtf8('Compile all forms'),
195 self.__compileAllForms) 206 self.__compileAllForms)
196 self.backMenu.addSeparator() 207 self.backMenu.addSeparator()
197 self.backMenu.addAction(self.trUtf8('New form...'), self.__newForm) 208 self.backMenu.addAction(self.trUtf8('New form...'), self.__newForm)
198 else: 209 else:
199 if self.hooks["newForm"] is not None: 210 if self.hooks["newForm"] is not None:
200 self.backMenu.addAction( 211 self.backMenu.addAction(
201 self.hooksMenuEntries.get("newForm", 212 self.hooksMenuEntries.get("newForm",
202 self.trUtf8('New form...')), self.__newForm) 213 self.trUtf8('New form...')), self.__newForm)
203 self.backMenu.addAction(self.trUtf8('Add forms...'), self.project.addUiFiles) 214 self.backMenu.addAction(
215 self.trUtf8('Add forms...'), self.project.addUiFiles)
204 self.backMenu.addAction(self.trUtf8('Add forms directory...'), 216 self.backMenu.addAction(self.trUtf8('Add forms directory...'),
205 self.project.addUiDir) 217 self.project.addUiDir)
206 self.backMenu.addSeparator() 218 self.backMenu.addSeparator()
207 self.backMenu.addAction(self.trUtf8('Expand all directories'), 219 self.backMenu.addAction(self.trUtf8('Expand all directories'),
208 self._expandAllDirs) 220 self._expandAllDirs)
212 self.backMenu.addAction(self.trUtf8('Configure...'), self._configure) 224 self.backMenu.addAction(self.trUtf8('Configure...'), self._configure)
213 self.backMenu.setEnabled(False) 225 self.backMenu.setEnabled(False)
214 226
215 # create the menu for multiple selected files 227 # create the menu for multiple selected files
216 self.multiMenu = QMenu(self) 228 self.multiMenu = QMenu(self)
217 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 229 if self.project.getProjectType() in \
230 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
218 act = self.multiMenu.addAction(self.trUtf8('Compile forms'), 231 act = self.multiMenu.addAction(self.trUtf8('Compile forms'),
219 self.__compileSelectedForms) 232 self.__compileSelectedForms)
220 self.multiMenu.addSeparator() 233 self.multiMenu.addSeparator()
221 self.multiMenu.addAction(self.trUtf8('Open in Qt-Designer'), 234 self.multiMenu.addAction(self.trUtf8('Open in Qt-Designer'),
222 self.__openFile) 235 self.__openFile)
234 self.multiMenu.addSeparator() 247 self.multiMenu.addSeparator()
235 if self.hooks["open"] is not None: 248 if self.hooks["open"] is not None:
236 self.multiMenu.addAction( 249 self.multiMenu.addAction(
237 self.hooksMenuEntries.get("open", self.trUtf8('Open')), 250 self.hooksMenuEntries.get("open", self.trUtf8('Open')),
238 self.__openFile) 251 self.__openFile)
239 self.multiMenu.addAction(self.trUtf8('Open'), self.__openFileInEditor) 252 self.multiMenu.addAction(
253 self.trUtf8('Open'), self.__openFileInEditor)
240 self.multiMenu.addSeparator() 254 self.multiMenu.addSeparator()
241 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), 255 act = self.multiMenu.addAction(self.trUtf8('Remove from project'),
242 self._removeFile) 256 self._removeFile)
243 self.multiMenuActions.append(act) 257 self.multiMenuActions.append(act)
244 act = self.multiMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) 258 act = self.multiMenu.addAction(
259 self.trUtf8('Delete'), self.__deleteFile)
245 self.multiMenuActions.append(act) 260 self.multiMenuActions.append(act)
246 self.multiMenu.addSeparator() 261 self.multiMenu.addSeparator()
247 self.multiMenu.addAction(self.trUtf8('Expand all directories'), 262 self.multiMenu.addAction(self.trUtf8('Expand all directories'),
248 self._expandAllDirs) 263 self._expandAllDirs)
249 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), 264 self.multiMenu.addAction(self.trUtf8('Collapse all directories'),
250 self._collapseAllDirs) 265 self._collapseAllDirs)
251 self.multiMenu.addSeparator() 266 self.multiMenu.addSeparator()
252 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) 267 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure)
253 268
254 self.dirMenu = QMenu(self) 269 self.dirMenu = QMenu(self)
255 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 270 if self.project.getProjectType() in \
271 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
256 self.dirMenu.addAction(self.trUtf8('Compile all forms'), 272 self.dirMenu.addAction(self.trUtf8('Compile all forms'),
257 self.__compileAllForms) 273 self.__compileAllForms)
258 self.dirMenu.addSeparator() 274 self.dirMenu.addSeparator()
259 else: 275 else:
260 if self.hooks["compileAllForms"] is not None: 276 if self.hooks["compileAllForms"] is not None:
261 self.dirMenu.addAction( 277 self.dirMenu.addAction(
262 self.hooksMenuEntries.get("compileAllForms", 278 self.hooksMenuEntries.get("compileAllForms",
263 self.trUtf8('Compile all forms')), 279 self.trUtf8('Compile all forms')),
264 self.__compileAllForms) 280 self.__compileAllForms)
265 self.dirMenu.addSeparator() 281 self.dirMenu.addSeparator()
266 act = self.dirMenu.addAction(self.trUtf8('Remove from project'), self._removeDir) 282 act = self.dirMenu.addAction(
283 self.trUtf8('Remove from project'), self._removeDir)
267 self.dirMenuActions.append(act) 284 self.dirMenuActions.append(act)
268 act = self.dirMenu.addAction(self.trUtf8('Delete'), self._deleteDirectory) 285 act = self.dirMenu.addAction(
286 self.trUtf8('Delete'), self._deleteDirectory)
269 self.dirMenuActions.append(act) 287 self.dirMenuActions.append(act)
270 self.dirMenu.addSeparator() 288 self.dirMenu.addSeparator()
271 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 289 if self.project.getProjectType() in \
290 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
272 self.dirMenu.addAction(self.trUtf8('New form...'), self.__newForm) 291 self.dirMenu.addAction(self.trUtf8('New form...'), self.__newForm)
273 else: 292 else:
274 if self.hooks["newForm"] is not None: 293 if self.hooks["newForm"] is not None:
275 self.dirMenu.addAction( 294 self.dirMenu.addAction(
276 self.hooksMenuEntries.get("newForm", 295 self.hooksMenuEntries.get("newForm",
277 self.trUtf8('New form...')), self.__newForm) 296 self.trUtf8('New form...')), self.__newForm)
278 self.dirMenu.addAction(self.trUtf8('Add forms...'), self.__addFormFiles) 297 self.dirMenu.addAction(
298 self.trUtf8('Add forms...'), self.__addFormFiles)
279 self.dirMenu.addAction(self.trUtf8('Add forms directory...'), 299 self.dirMenu.addAction(self.trUtf8('Add forms directory...'),
280 self.__addFormsDirectory) 300 self.__addFormsDirectory)
281 self.dirMenu.addSeparator() 301 self.dirMenu.addSeparator()
282 self.dirMenu.addAction(self.trUtf8('Copy Path to Clipboard'), 302 self.dirMenu.addAction(self.trUtf8('Copy Path to Clipboard'),
283 self._copyToClipboard) 303 self._copyToClipboard)
288 self._collapseAllDirs) 308 self._collapseAllDirs)
289 self.dirMenu.addSeparator() 309 self.dirMenu.addSeparator()
290 self.dirMenu.addAction(self.trUtf8('Configure...'), self._configure) 310 self.dirMenu.addAction(self.trUtf8('Configure...'), self._configure)
291 311
292 self.dirMultiMenu = QMenu(self) 312 self.dirMultiMenu = QMenu(self)
293 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 313 if self.project.getProjectType() in \
314 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
294 self.dirMultiMenu.addAction(self.trUtf8('Compile all forms'), 315 self.dirMultiMenu.addAction(self.trUtf8('Compile all forms'),
295 self.__compileAllForms) 316 self.__compileAllForms)
296 self.dirMultiMenu.addSeparator() 317 self.dirMultiMenu.addSeparator()
297 else: 318 else:
298 if self.hooks["compileAllForms"] is not None: 319 if self.hooks["compileAllForms"] is not None:
309 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), 330 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'),
310 self._expandAllDirs) 331 self._expandAllDirs)
311 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), 332 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'),
312 self._collapseAllDirs) 333 self._collapseAllDirs)
313 self.dirMultiMenu.addSeparator() 334 self.dirMultiMenu.addSeparator()
314 self.dirMultiMenu.addAction(self.trUtf8('Configure...'), self._configure) 335 self.dirMultiMenu.addAction(
336 self.trUtf8('Configure...'), self._configure)
315 337
316 self.menu.aboutToShow.connect(self.__showContextMenu) 338 self.menu.aboutToShow.connect(self.__showContextMenu)
317 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) 339 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti)
318 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir) 340 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir)
319 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti) 341 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti)
336 if cnt <= 1: 358 if cnt <= 1:
337 index = self.indexAt(coord) 359 index = self.indexAt(coord)
338 if index.isValid(): 360 if index.isValid():
339 self._selectSingleItem(index) 361 self._selectSingleItem(index)
340 categories = self.getSelectedItemsCountCategorized( 362 categories = self.getSelectedItemsCountCategorized(
341 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem]) 363 [ProjectBrowserFileItem,
364 ProjectBrowserSimpleDirectoryItem])
342 cnt = categories["sum"] 365 cnt = categories["sum"]
343 366
344 bfcnt = categories[str(ProjectBrowserFileItem)] 367 bfcnt = categories[str(ProjectBrowserFileItem)]
345 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)] 368 sdcnt = categories[str(ProjectBrowserSimpleDirectoryItem)]
346 if cnt > 1 and cnt == bfcnt: 369 if cnt > 1 and cnt == bfcnt:
502 path = os.path.join(self.project.ppath, itm.data(0)) 525 path = os.path.join(self.project.ppath, itm.data(0))
503 526
504 if self.hooks["newForm"] is not None: 527 if self.hooks["newForm"] is not None:
505 self.hooks["newForm"](path) 528 self.hooks["newForm"](path)
506 else: 529 else:
507 if self.project.getProjectType() in ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 530 if self.project.getProjectType() in \
531 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
508 self.__newUiForm(path) 532 self.__newUiForm(path)
509 533
510 def __newUiForm(self, path): 534 def __newUiForm(self, path):
511 """ 535 """
512 Private slot to handle the New Form menu action for Qt-related projects. 536 Private slot to handle the New Form menu action for Qt-related
537 projects.
513 538
514 @param path full directory path for the new form file (string) 539 @param path full directory path for the new form file (string)
515 """ 540 """
516 selectedForm, ok = QInputDialog.getItem( 541 selectedForm, ok = QInputDialog.getItem(
517 None, 542 None,
557 try: 582 try:
558 shutil.copy(templateFile, fname) 583 shutil.copy(templateFile, fname)
559 except IOError as e: 584 except IOError as e:
560 E5MessageBox.critical(self, 585 E5MessageBox.critical(self,
561 self.trUtf8("New Form"), 586 self.trUtf8("New Form"),
562 self.trUtf8("<p>The new form file <b>{0}</b> could not be created.<br>" 587 self.trUtf8(
588 "<p>The new form file <b>{0}</b> could not be created.<br>"
563 "Problem: {1}</p>").format(fname, str(e))) 589 "Problem: {1}</p>").format(fname, str(e)))
564 return 590 return
565 591
566 self.project.appendFile(fname) 592 self.project.appendFile(fname)
567 self.designerFile.emit(fname) 593 self.designerFile.emit(fname)
578 fn2 = itm.fileName() 604 fn2 = itm.fileName()
579 fullNames.append(fn2) 605 fullNames.append(fn2)
580 fn = self.project.getRelativePath(fn2) 606 fn = self.project.getRelativePath(fn2)
581 files.append(fn) 607 files.append(fn)
582 608
583 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog 609 from UI.DeleteFilesConfirmationDialog import \
610 DeleteFilesConfirmationDialog
584 dlg = DeleteFilesConfirmationDialog(self.parent(), 611 dlg = DeleteFilesConfirmationDialog(self.parent(),
585 self.trUtf8("Delete forms"), 612 self.trUtf8("Delete forms"),
586 self.trUtf8("Do you really want to delete these forms from the project?"), 613 self.trUtf8(
614 "Do you really want to delete these forms from the project?"),
587 files) 615 files)
588 616
589 if dlg.exec_() == QDialog.Accepted: 617 if dlg.exec_() == QDialog.Accepted:
590 for fn2, fn in zip(fullNames, files): 618 for fn2, fn in zip(fullNames, files):
591 self.closeSourceWindow.emit(fn2) 619 self.closeSourceWindow.emit(fn2)
592 self.project.deleteFile(fn) 620 self.project.deleteFile(fn)
593 621
594 ############################################################################ 622 ###########################################################################
595 ## Methods to handle the various compile commands 623 ## Methods to handle the various compile commands
596 ############################################################################ 624 ###########################################################################
597 625
598 def __readStdout(self): 626 def __readStdout(self):
599 """ 627 """
600 Private slot to handle the readyReadStandardOutput signal of the 628 Private slot to handle the readyReadStandardOutput signal of the
601 pyuic/rbuic process. 629 pyuic/rbuic process.
653 E5MessageBox.information(self, 681 E5MessageBox.information(self,
654 self.trUtf8("Form Compilation"), 682 self.trUtf8("Form Compilation"),
655 self.trUtf8("The compilation of the form file" 683 self.trUtf8("The compilation of the form file"
656 " was successful.")) 684 " was successful."))
657 else: 685 else:
658 ui.showNotification(UI.PixmapCache.getPixmap("designer48.png"), 686 ui.showNotification(
687 UI.PixmapCache.getPixmap("designer48.png"),
659 self.trUtf8("Form Compilation"), 688 self.trUtf8("Form Compilation"),
660 self.trUtf8("The compilation of the form file" 689 self.trUtf8("The compilation of the form file"
661 " was successful.")) 690 " was successful."))
662 self.project.projectFormCompiled.emit(self.compiledFile) 691 self.project.projectFormCompiled.emit(self.compiledFile)
663 except IOError as msg: 692 except IOError as msg:
664 if not self.noDialog: 693 if not self.noDialog:
665 E5MessageBox.information(self, 694 E5MessageBox.information(self,
666 self.trUtf8("Form Compilation"), 695 self.trUtf8("Form Compilation"),
667 self.trUtf8("<p>The compilation of the form file failed.</p>" 696 self.trUtf8(
697 "<p>The compilation of the form file failed.</p>"
668 "<p>Reason: {0}</p>").format(str(msg))) 698 "<p>Reason: {0}</p>").format(str(msg)))
669 else: 699 else:
670 ui.showNotification(UI.PixmapCache.getPixmap("designer48.png"), 700 ui.showNotification(
701 UI.PixmapCache.getPixmap("designer48.png"),
671 self.trUtf8("Form Compilation"), 702 self.trUtf8("Form Compilation"),
672 self.trUtf8("<p>The compilation of the form file failed.</p>" 703 self.trUtf8(
704 "<p>The compilation of the form file failed.</p>"
673 "<p>Reason: {0}</p>").format(str(msg))) 705 "<p>Reason: {0}</p>").format(str(msg)))
674 else: 706 else:
675 if not self.noDialog: 707 if not self.noDialog:
676 E5MessageBox.information(self, 708 E5MessageBox.information(self,
677 self.trUtf8("Form Compilation"), 709 self.trUtf8("Form Compilation"),
693 """ 725 """
694 self.compileProc = QProcess() 726 self.compileProc = QProcess()
695 args = [] 727 args = []
696 self.buf = "" 728 self.buf = ""
697 729
698 if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]: 730 if self.project.pdata["PROGLANGUAGE"][0] in \
731 ["Python", "Python2", "Python3"]:
699 if self.project.getProjectType() in ["Qt4", "E4Plugin"]: 732 if self.project.getProjectType() in ["Qt4", "E4Plugin"]:
700 self.uicompiler = 'pyuic4' 733 self.uicompiler = 'pyuic4'
701 if Utilities.isWindowsPlatform(): 734 if Utilities.isWindowsPlatform():
702 uic = self.uicompiler + '.bat' 735 uic = self.uicompiler + '.bat'
703 else: 736 else:
726 return None 759 return None
727 760
728 ofn, ext = os.path.splitext(fn) 761 ofn, ext = os.path.splitext(fn)
729 fn = os.path.join(self.project.ppath, fn) 762 fn = os.path.join(self.project.ppath, fn)
730 763
731 if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]: 764 if self.project.pdata["PROGLANGUAGE"][0] in \
765 ["Python", "Python2", "Python3"]:
732 dirname, filename = os.path.split(ofn) 766 dirname, filename = os.path.split(ofn)
733 self.compiledFile = os.path.join(dirname, "Ui_" + filename + ".py") 767 self.compiledFile = os.path.join(dirname, "Ui_" + filename + ".py")
734 args.append("-x") 768 args.append("-x")
735 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": 769 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby":
736 self.compiledFile = ofn + '.rb' 770 self.compiledFile = ofn + '.rb'
760 ).format(self.uicompiler)) 794 ).format(self.uicompiler))
761 return None 795 return None
762 796
763 def __generateDialogCode(self): 797 def __generateDialogCode(self):
764 """ 798 """
765 Private method to generate dialog code for the form (Qt4 only) 799 Private method to generate dialog code for the form (Qt4 only).
766 """ 800 """
767 itm = self.model().item(self.currentIndex()) 801 itm = self.model().item(self.currentIndex())
768 fn = itm.fileName() 802 fn = itm.fileName()
769 803
770 if self.hooks["generateDialogCode"] is not None: 804 if self.hooks["generateDialogCode"] is not None:
873 if self.project.getProjectType() not in \ 907 if self.project.getProjectType() not in \
874 ["Qt4", "PyQt5", "E4Plugin", "PySide"]: 908 ["Qt4", "PyQt5", "E4Plugin", "PySide"]:
875 # ignore the request for non Qt GUI projects 909 # ignore the request for non Qt GUI projects
876 return 910 return
877 911
878 progress = QProgressDialog(self.trUtf8("Determining changed forms..."), 912 progress = QProgressDialog(
913 self.trUtf8("Determining changed forms..."),
879 None, 0, 100) 914 None, 0, 100)
880 progress.setMinimumDuration(0) 915 progress.setMinimumDuration(0)
881 i = 0 916 i = 0
882 917
883 # get list of changed forms 918 # get list of changed forms
900 i += 1 935 i += 1
901 progress.setValue(i) 936 progress.setValue(i)
902 QApplication.processEvents() 937 QApplication.processEvents()
903 938
904 if changedForms: 939 if changedForms:
905 progress.setLabelText(self.trUtf8("Compiling changed forms...")) 940 progress.setLabelText(
941 self.trUtf8("Compiling changed forms..."))
906 progress.setMaximum(len(changedForms)) 942 progress.setMaximum(len(changedForms))
907 i = 0 943 i = 0
908 progress.setValue(i) 944 progress.setValue(i)
909 QApplication.processEvents() 945 QApplication.processEvents()
910 for fn in changedForms: 946 for fn in changedForms:
925 """ 961 """
926 Public slot used to handle the preferencesChanged signal. 962 Public slot used to handle the preferencesChanged signal.
927 """ 963 """
928 ProjectBaseBrowser.handlePreferencesChanged(self) 964 ProjectBaseBrowser.handlePreferencesChanged(self)
929 965
930 ############################################################################ 966 ###########################################################################
931 ## Support for hooks below 967 ## Support for hooks below
932 ############################################################################ 968 ###########################################################################
933 969
934 def _initHookMethods(self): 970 def _initHookMethods(self):
935 """ 971 """
936 Protected method to initialize the hooks dictionary. 972 Protected method to initialize the hooks dictionary.
937 973

eric ide

mercurial