From d05b6c620103aaee56c6fca37a085eb0b495e0ed Mon Sep 17 00:00:00 2001 From: greenwyrt <117969582+greenwyrt@users.noreply.github.com> Date: Wed, 2 Aug 2023 21:50:16 -0700 Subject: [PATCH] make sure cursor format is same also when creating new --- CHANGES.md | 2 ++ plover_cat/main_window.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 25d38c1..daf3b76 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -36,6 +36,8 @@ UI Changes: - Change: Main editor widget is now tabbed between the editor and a recent files pane. When loading a transcript, the editor text only appears after loading is completed (increases speed). +- Change: aligned paper tape, [thanks AshenColors](https://github.com/greenwyrt/plover2CAT/pull/11#issue-1832014437) + Internal Changes: - Multiple dialog windows with own code and UI to implement new features. diff --git a/plover_cat/main_window.py b/plover_cat/main_window.py index 16c1c40..65ace6a 100644 --- a/plover_cat/main_window.py +++ b/plover_cat/main_window.py @@ -560,6 +560,8 @@ def update_navigation(self): block = block.next() def update_index_menu(self, index_dict): + if not index_dict: + return log.debug("Updating index entry insertion sub-menu.") self.menuIndexEntry.clear() for ind, (k, v) in enumerate(index_dict.items()): @@ -651,6 +653,10 @@ def create_new(self): self.statusBar.showMessage("Created project.") log.debug("New project successfully created and set up.") self.update_paragraph_style() + document_cursor = self.textEdit.textCursor() + document_cursor.setBlockFormat(self.par_formats[self.style_selector.currentText()]) + document_cursor.setCharFormat(self.txt_formats[self.style_selector.currentText()]) + self.textEdit.setTextCursor(document_cursor) def open_file(self, file_path = ""): self.mainTabs.setCurrentIndex(1) @@ -734,6 +740,10 @@ def open_file(self, file_path = ""): self.autosave_setup(self.actionEnableAutosave.isChecked()) if self.textEdit.document().characterCount() == 1: self.update_paragraph_style() + document_cursor = self.textEdit.textCursor() + document_cursor.setBlockFormat(self.par_formats[self.style_selector.currentText()]) + document_cursor.setCharFormat(self.txt_formats[self.style_selector.currentText()]) + self.textEdit.setTextCursor(document_cursor) def save_file(self): if not self.file_name: @@ -2364,6 +2374,8 @@ def extract_indexes(self): index_dict = {} current_cursor = self.textEdit.textCursor() block = self.textEdit.document().begin() + if len(self.textEdit.toPlainText()) == 0: + return while True: block_strokes = block.userData()["strokes"] for ind, el in enumerate(block_strokes.data):