Skip to content

Commit

Permalink
Restore tabs on Python console load
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Aug 13, 2014
1 parent b88723d commit d42c24f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions python/console/console.py
Expand Up @@ -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)

Expand Down
25 changes: 15 additions & 10 deletions python/console/console_editor.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d42c24f

Please sign in to comment.