Skip to content

Commit d42c24f

Browse files
committedAug 13, 2014
Restore tabs on Python console load
1 parent b88723d commit d42c24f

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed
 

‎python/console/console.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ def __init__(self, parent=None):
539539
self.findPrevButton.clicked.connect(self._findPrev)
540540
self.lineEditFind.textChanged.connect(self._textFindChanged)
541541

542+
self.tabEditorWidget.restoreTabsOrAddNew()
543+
542544
def _findText(self):
543545
self.tabEditorWidget.currentWidget().newEditor.findText(True)
544546

‎python/console/console_editor.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -901,16 +901,6 @@ def __init__(self, parent):
901901
self.connect(self.restoreTabsButton, SIGNAL('clicked()'), self.restoreTabs)
902902
self.connect(self.clButton, SIGNAL('clicked()'), self.closeRestore)
903903

904-
# Restore script of the previuos session
905-
self.settings = QSettings()
906-
tabScripts = self.settings.value("pythonConsole/tabScripts", [])
907-
self.restoreTabList = tabScripts
908-
909-
if self.restoreTabList:
910-
self.topFrame.show()
911-
else:
912-
self.newTabEditor(filename=None)
913-
914904
## Fixes #7653
915905
if sys.platform != 'darwin':
916906
self.setDocumentMode(True)
@@ -949,6 +939,7 @@ def __init__(self, parent):
949939
self.setCornerWidget(self.newTabButton, Qt.TopLeftCorner)
950940
self.connect(self.newTabButton, SIGNAL('clicked()'), self.newTabEditor)
951941

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

1107+
def restoreTabsOrAddNew(self):
1108+
"""
1109+
Restore tabs if they are found in the settings. If none are found it will add a new empty tab.
1110+
"""
1111+
# Restore script of the previuos session
1112+
self.settings = QSettings()
1113+
tabScripts = self.settings.value("pythonConsole/tabScripts", [])
1114+
self.restoreTabList = tabScripts
1115+
1116+
if self.restoreTabList:
1117+
self.restoreTabs()
1118+
else:
1119+
self.newTabEditor(filename=None)
1120+
11161121
def restoreTabs(self):
11171122
for script in self.restoreTabList:
11181123
pathFile = unicode(script)

0 commit comments

Comments
 (0)
Please sign in to comment.