Skip to content

Commit

Permalink
make sure cursor format is same also when creating new
Browse files Browse the repository at this point in the history
  • Loading branch information
greenwyrt committed Aug 3, 2023
1 parent 98707f8 commit d05b6c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions plover_cat/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d05b6c6

Please sign in to comment.