Skip to content
Permalink
Browse files

Restore tabs on Python console load

  • Loading branch information
NathanW2 committed Aug 13, 2014
1 parent b88723d commit d42c24f28cce3f7d73e8ce03d1afbad67aa7aa34
Showing with 17 additions and 10 deletions.
  1. +2 −0 python/console/console.py
  2. +15 −10 python/console/console_editor.py
@@ -539,6 +539,8 @@ def __init__(self, parent=None):
self.findPrevButton.clicked.connect(self._findPrev)
self.lineEditFind.textChanged.connect(self._textFindChanged)

self.tabEditorWidget.restoreTabsOrAddNew()

def _findText(self):
self.tabEditorWidget.currentWidget().newEditor.findText(True)

@@ -901,16 +901,6 @@ def __init__(self, parent):
self.connect(self.restoreTabsButton, SIGNAL('clicked()'), self.restoreTabs)
self.connect(self.clButton, SIGNAL('clicked()'), self.closeRestore)

# Restore script of the previuos session
self.settings = QSettings()
tabScripts = self.settings.value("pythonConsole/tabScripts", [])
self.restoreTabList = tabScripts

if self.restoreTabList:
self.topFrame.show()
else:
self.newTabEditor(filename=None)

## Fixes #7653
if sys.platform != 'darwin':
self.setDocumentMode(True)
@@ -949,6 +939,7 @@ def __init__(self, parent):
self.setCornerWidget(self.newTabButton, Qt.TopLeftCorner)
self.connect(self.newTabButton, SIGNAL('clicked()'), self.newTabEditor)


def _currentWidgetChanged(self, tab):
if self.settings.value("pythonConsole/enableObjectInsp",
False, type=bool):
@@ -1113,6 +1104,20 @@ def closeCurrentWidget(self):
if currWidget.path in self.restoreTabList:
self.parent.updateTabListScript(currWidget.path, action='remove')

def restoreTabsOrAddNew(self):
"""
Restore tabs if they are found in the settings. If none are found it will add a new empty tab.
"""
# Restore script of the previuos session
self.settings = QSettings()
tabScripts = self.settings.value("pythonConsole/tabScripts", [])
self.restoreTabList = tabScripts

if self.restoreTabList:
self.restoreTabs()
else:
self.newTabEditor(filename=None)

def restoreTabs(self):
for script in self.restoreTabList:
pathFile = unicode(script)

0 comments on commit d42c24f

Please sign in to comment.
You can’t perform that action at this time.