From c6cace1a9bccd393bf26edae42405f2aac8b6f70 Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Mon, 18 Apr 2016 11:46:07 +0200 Subject: [PATCH] Less ambiguous behavior when failing to load openIndexes (cf. #27) --- manuskript/ui/editors/mainEditor.py | 9 +++++++-- manuskript/ui/editors/tabSplitter.py | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/manuskript/ui/editors/mainEditor.py b/manuskript/ui/editors/mainEditor.py index 359ebe4f..fbeee882 100644 --- a/manuskript/ui/editors/mainEditor.py +++ b/manuskript/ui/editors/mainEditor.py @@ -72,6 +72,11 @@ class mainEditor(QWidget, Ui_mainEditor): else: ts = ts.secondTab + # No tabSplitter has focus, something is strange. + # But probably not important. + # Let's return self.tabSplitter.tab anyway. + return self.tabSplitter.tab + def currentEditor(self, tabWidget=None): if tabWidget is None: tabWidget = self.currentTabWidget() @@ -163,11 +168,11 @@ class mainEditor(QWidget, Ui_mainEditor): if qApp.keyboardModifiers() & Qt.ControlModifier: newTab = True - if newTab or not self.currentTabWidget().count(): + if newTab or not tabWidget.count(): editor = editorWidget(self) editor.setCurrentModelIndex(index) tabWidget.addTab(editor, title) - tabWidget.setCurrentIndex(self.currentTabWidget().count() - 1) + tabWidget.setCurrentIndex(tabWidget.count() - 1) else: self.currentEditor(tabWidget).setCurrentModelIndex(index) tabWidget.setTabText(tabWidget.currentIndex(), title) diff --git a/manuskript/ui/editors/tabSplitter.py b/manuskript/ui/editors/tabSplitter.py index 5410b8fa..50cb3fd1 100644 --- a/manuskript/ui/editors/tabSplitter.py +++ b/manuskript/ui/editors/tabSplitter.py @@ -102,9 +102,8 @@ class tabSplitter(QWidget, Ui_tabSplitter): self.secondTab.restoreOpenIndexes(openIndexes[2]) except: - - print("Failed to load indexes from settings...") - print("Indexes:", openIndexes) + # Cannot load open indexes. Let's simply open root. + self.mainEditor.setCurrentModelIndex(QModelIndex(), newTab=True) ############################################################################### # TARGET