ViewManager/ViewManager.py

changeset 3101
5213d9f28318
parent 3100
1c86bf655433
child 3102
0bc989a51428
--- a/ViewManager/ViewManager.py	Wed Nov 20 19:50:35 2013 +0100
+++ b/ViewManager/ViewManager.py	Thu Nov 21 18:37:41 2013 +0100
@@ -3327,6 +3327,44 @@
         self.unhighlightAct.triggered[()].connect(self.unhighlight)
         self.viewActions.append(self.unhighlightAct)
         
+        self.newDocumentViewAct = E5Action(
+            QApplication.translate('ViewManager', 'New Document View'),
+            UI.PixmapCache.getIcon("documentNewView.png"),
+            QApplication.translate('ViewManager', 'New &Document View'),
+            0, 0, self, 'vm_view_new_document_view')
+        self.newDocumentViewAct.setStatusTip(QApplication.translate(
+            'ViewManager', 'Open a new view of the current document'))
+        self.newDocumentViewAct.setWhatsThis(QApplication.translate(
+            'ViewManager',
+            """<b>New Document View</b>"""
+            """<p>Opens a new view of the current document. Both views show"""
+            """ the same document. However, the cursors may be positioned"""
+            """ independently.</p>"""
+        ))
+        self.newDocumentViewAct.triggered[()].connect(self.__newDocumentView)
+        self.viewActions.append(self.newDocumentViewAct)
+        
+        self.newDocumentSplitViewAct = E5Action(
+            QApplication.translate(
+                'ViewManager', 'New Document View (with new split)'),
+            UI.PixmapCache.getIcon("splitVertical.png"),
+            QApplication.translate(
+                'ViewManager', 'New Document View (with new split)'),
+            0, 0, self, 'vm_view_new_document_split_view')
+        self.newDocumentSplitViewAct.setStatusTip(QApplication.translate(
+            'ViewManager',
+            'Open a new view of the current document in a new split'))
+        self.newDocumentSplitViewAct.setWhatsThis(QApplication.translate(
+            'ViewManager',
+            """<b>New Document View</b>"""
+            """<p>Opens a new view of the current document in a new split."""
+            """ Both views show the same document. However, the cursors may"""
+            """ be positioned independently.</p>"""
+        ))
+        self.newDocumentSplitViewAct.triggered[()].connect(
+            self.__newDocumentSplitView)
+        self.viewActions.append(self.newDocumentSplitViewAct)
+        
         self.splitViewAct = E5Action(
             QApplication.translate('ViewManager', 'Split view'),
             UI.PixmapCache.getIcon("splitVertical.png"),
@@ -3447,7 +3485,10 @@
         menu.addAction(self.previewAct)
         menu.addSeparator()
         menu.addAction(self.unhighlightAct)
+        menu.addSeparator()
+        menu.addAction(self.newDocumentViewAct)
         if self.canSplit():
+            menu.addAction(self.newDocumentSplitViewAct)
             menu.addSeparator()
             menu.addAction(self.splitViewAct)
             menu.addAction(self.splitOrientationAct)
@@ -3473,6 +3514,10 @@
         tb.addActions(self.viewActGrp.actions())
         tb.addSeparator()
         tb.addAction(self.previewAct)
+        tb.addSeparator()
+        tb.addAction(self.newDocumentViewAct)
+        if self.canSplit():
+            tb.addAction(self.newDocumentSplitViewAct)
         
         toolbarManager.addToolBar(tb, tb.windowTitle())
         toolbarManager.addAction(self.unhighlightAct, tb.windowTitle())
@@ -5551,6 +5596,23 @@
             line, index = aw.getCursorPosition()
             aw.foldLine(line)
         
+    def __newDocumentView(self):
+        """
+        Private method to open a new view of the current editor.
+        """
+        aw = self.activeWindow()
+        if aw:
+            self.newEditorView(aw.getFileName(), aw, aw.getFileType())
+        
+    def __newDocumentSplitView(self):
+        """
+        Private method to open a new view of the current editor in a new split.
+        """
+        aw = self.activeWindow()
+        if aw:
+            self.addSplit()
+            self.newEditorView(aw.getFileName(), aw, aw.getFileType())
+        
     def __splitView(self):
         """
         Private method to handle the split view action.
@@ -6045,6 +6107,8 @@
         self.viewActGrp.setEnabled(False)
         self.viewFoldActGrp.setEnabled(False)
         self.unhighlightAct.setEnabled(False)
+        self.newDocumentViewAct.setEnabled(False)
+        self.newDocumentSplitViewAct.setEnabled(False)
         self.splitViewAct.setEnabled(False)
         self.splitOrientationAct.setEnabled(False)
         self.previewAct.setEnabled(True)
@@ -6082,7 +6146,9 @@
         self.viewActGrp.setEnabled(True)
         self.viewFoldActGrp.setEnabled(True)
         self.unhighlightAct.setEnabled(True)
+        self.newDocumentViewAct.setEnabled(True)
         if self.canSplit():
+            self.newDocumentSplitViewAct.setEnabled(True)
             self.splitViewAct.setEnabled(True)
             self.splitOrientationAct.setEnabled(True)
         self.macroActGrp.setEnabled(True)

eric ide

mercurial