8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import QSignalMapper, QTimer, QFileInfo, pyqtSignal, QRegExp, \ |
12 from PyQt4.QtCore import QSignalMapper, QTimer, QFileInfo, pyqtSignal, QRegExp, \ |
13 QObject, Qt |
13 QObject, Qt, QUrl |
14 from PyQt4.QtGui import QColor, QKeySequence, QLineEdit, QToolBar, QWidgetAction, \ |
14 from PyQt4.QtGui import QColor, QKeySequence, QLineEdit, QToolBar, QWidgetAction, \ |
15 QDialog, QApplication, QMenu, QPalette, QComboBox |
15 QDialog, QApplication, QMenu, QPalette, QComboBox |
16 from PyQt4.Qsci import QsciScintilla |
16 from PyQt4.Qsci import QsciScintilla |
17 |
17 |
18 from E5Gui.E5Application import e5App |
18 from E5Gui.E5Application import e5App |
2463 """<p>Move to the previous split.</p>""" |
2460 """<p>Move to the previous split.</p>""" |
2464 )) |
2461 )) |
2465 self.prevSplitAct.triggered[()].connect(self.prevSplit) |
2462 self.prevSplitAct.triggered[()].connect(self.prevSplit) |
2466 self.viewActions.append(self.prevSplitAct) |
2463 self.viewActions.append(self.prevSplitAct) |
2467 |
2464 |
|
2465 self.previewAct = E5Action(QApplication.translate('ViewManager', |
|
2466 'Preview'), |
|
2467 UI.PixmapCache.getIcon("previewer.png"), |
|
2468 QApplication.translate('ViewManager', 'Preview'), |
|
2469 0, 0, self, 'vm_preview') |
|
2470 self.previewAct.setStatusTip(QApplication.translate('ViewManager', |
|
2471 'Preview the current file in the web browser')) |
|
2472 self.previewAct.setWhatsThis(QApplication.translate('ViewManager', |
|
2473 """<b>Preview</b>""" |
|
2474 """<p>This opens the web browser with a preview of""" |
|
2475 """ the current file.</p>""" |
|
2476 )) |
|
2477 self.previewAct.triggered[()].connect(self.__previewEditor) |
|
2478 self.viewActions.append(self.previewAct) |
|
2479 |
2468 self.viewActGrp.setEnabled(False) |
2480 self.viewActGrp.setEnabled(False) |
2469 self.viewFoldActGrp.setEnabled(False) |
2481 self.viewFoldActGrp.setEnabled(False) |
2470 self.unhighlightAct.setEnabled(False) |
2482 self.unhighlightAct.setEnabled(False) |
2471 self.splitViewAct.setEnabled(False) |
2483 self.splitViewAct.setEnabled(False) |
2472 self.splitOrientationAct.setEnabled(False) |
2484 self.splitOrientationAct.setEnabled(False) |
2473 self.splitRemoveAct.setEnabled(False) |
2485 self.splitRemoveAct.setEnabled(False) |
2474 self.nextSplitAct.setEnabled(False) |
2486 self.nextSplitAct.setEnabled(False) |
2475 self.prevSplitAct.setEnabled(False) |
2487 self.prevSplitAct.setEnabled(False) |
|
2488 self.previewAct.setEnabled(False) |
2476 |
2489 |
2477 def initViewMenu(self): |
2490 def initViewMenu(self): |
2478 """ |
2491 """ |
2479 Public method to create the View menu |
2492 Public method to create the View menu |
2480 |
2493 |
2483 menu = QMenu(QApplication.translate('ViewManager', '&View'), self.ui) |
2496 menu = QMenu(QApplication.translate('ViewManager', '&View'), self.ui) |
2484 menu.setTearOffEnabled(True) |
2497 menu.setTearOffEnabled(True) |
2485 menu.addActions(self.viewActGrp.actions()) |
2498 menu.addActions(self.viewActGrp.actions()) |
2486 menu.addSeparator() |
2499 menu.addSeparator() |
2487 menu.addActions(self.viewFoldActGrp.actions()) |
2500 menu.addActions(self.viewFoldActGrp.actions()) |
|
2501 menu.addSeparator() |
|
2502 menu.addAction(self.previewAct) |
2488 menu.addSeparator() |
2503 menu.addSeparator() |
2489 menu.addAction(self.unhighlightAct) |
2504 menu.addAction(self.unhighlightAct) |
2490 if self.canSplit(): |
2505 if self.canSplit(): |
2491 menu.addSeparator() |
2506 menu.addSeparator() |
2492 menu.addAction(self.splitViewAct) |
2507 menu.addAction(self.splitViewAct) |
2508 tb.setIconSize(UI.Config.ToolBarIconSize) |
2523 tb.setIconSize(UI.Config.ToolBarIconSize) |
2509 tb.setObjectName("ViewToolbar") |
2524 tb.setObjectName("ViewToolbar") |
2510 tb.setToolTip(QApplication.translate('ViewManager', 'View')) |
2525 tb.setToolTip(QApplication.translate('ViewManager', 'View')) |
2511 |
2526 |
2512 tb.addActions(self.viewActGrp.actions()) |
2527 tb.addActions(self.viewActGrp.actions()) |
|
2528 tb.addSeparator() |
|
2529 tb.addAction(self.previewAct) |
2513 |
2530 |
2514 toolbarManager.addToolBar(tb, tb.windowTitle()) |
2531 toolbarManager.addToolBar(tb, tb.windowTitle()) |
2515 toolbarManager.addAction(self.unhighlightAct, tb.windowTitle()) |
2532 toolbarManager.addAction(self.unhighlightAct, tb.windowTitle()) |
2516 toolbarManager.addAction(self.splitViewAct, tb.windowTitle()) |
2533 toolbarManager.addAction(self.splitViewAct, tb.windowTitle()) |
2517 toolbarManager.addAction(self.splitRemoveAct, tb.windowTitle()) |
2534 toolbarManager.addAction(self.splitRemoveAct, tb.windowTitle()) |
4340 self.splitViewAct.setIcon( |
4357 self.splitViewAct.setIcon( |
4341 UI.PixmapCache.getIcon("splitVertical.png")) |
4358 UI.PixmapCache.getIcon("splitVertical.png")) |
4342 self.splitRemoveAct.setIcon( |
4359 self.splitRemoveAct.setIcon( |
4343 UI.PixmapCache.getIcon("remsplitVertical.png")) |
4360 UI.PixmapCache.getIcon("remsplitVertical.png")) |
4344 |
4361 |
|
4362 def __previewEditor(self): |
|
4363 """ |
|
4364 Private method to preview the contents of the current editor in a web browser. |
|
4365 """ |
|
4366 aw = self.activeWindow() |
|
4367 if aw is not None and aw.isPreviewable(): |
|
4368 fn = aw.getFileName() |
|
4369 if fn: |
|
4370 project = e5App().getObject("Project") |
|
4371 if project.isProjectFile(fn): |
|
4372 baseUrl = QUrl.fromLocalFile(project.getProjectPath()) |
|
4373 else: |
|
4374 baseUrl = QUrl.fromLocalFile(fn) |
|
4375 else: |
|
4376 baseUrl = QUrl() |
|
4377 previewer = self.ui.getHelpViewer(preview=True).previewer() |
|
4378 previewer.setHtml(aw.text(), baseUrl) |
|
4379 |
4345 ################################################################## |
4380 ################################################################## |
4346 ## Below are the action methods for the macro menu |
4381 ## Below are the action methods for the macro menu |
4347 ################################################################## |
4382 ################################################################## |
4348 |
4383 |
4349 def __macroStartRecording(self): |
4384 def __macroStartRecording(self): |
4659 self.viewActGrp.setEnabled(False) |
4694 self.viewActGrp.setEnabled(False) |
4660 self.viewFoldActGrp.setEnabled(False) |
4695 self.viewFoldActGrp.setEnabled(False) |
4661 self.unhighlightAct.setEnabled(False) |
4696 self.unhighlightAct.setEnabled(False) |
4662 self.splitViewAct.setEnabled(False) |
4697 self.splitViewAct.setEnabled(False) |
4663 self.splitOrientationAct.setEnabled(False) |
4698 self.splitOrientationAct.setEnabled(False) |
|
4699 self.previewAct.setEnabled(False) |
4664 self.macroActGrp.setEnabled(False) |
4700 self.macroActGrp.setEnabled(False) |
4665 self.bookmarkActGrp.setEnabled(False) |
4701 self.bookmarkActGrp.setEnabled(False) |
4666 self.__enableSpellingActions() |
4702 self.__enableSpellingActions() |
4667 self.__setSbFile() |
4703 self.__setSbFile() |
4668 |
4704 |
4732 self.revertAct.setEnabled(editor.isModified()) |
4768 self.revertAct.setEnabled(editor.isModified()) |
4733 |
4769 |
4734 self.undoAct.setEnabled(editor.isUndoAvailable()) |
4770 self.undoAct.setEnabled(editor.isUndoAvailable()) |
4735 self.redoAct.setEnabled(editor.isRedoAvailable()) |
4771 self.redoAct.setEnabled(editor.isRedoAvailable()) |
4736 self.gotoLastEditAct.setEnabled(editor.isLastEditPositionAvailable()) |
4772 self.gotoLastEditAct.setEnabled(editor.isLastEditPositionAvailable()) |
|
4773 |
|
4774 self.previewAct.setEnabled(editor.isPreviewable()) |
4737 |
4775 |
4738 lex = editor.getLexer() |
4776 lex = editor.getLexer() |
4739 if lex is not None: |
4777 if lex is not None: |
4740 self.commentAct.setEnabled(lex.canBlockComment()) |
4778 self.commentAct.setEnabled(lex.canBlockComment()) |
4741 self.uncommentAct.setEnabled(lex.canBlockComment()) |
4779 self.uncommentAct.setEnabled(lex.canBlockComment()) |