Skip to content

Commit

Permalink
ui additions and bug fixes, fixes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
greenwyrt committed Aug 6, 2023
1 parent d05b6c6 commit 13b7511
Show file tree
Hide file tree
Showing 24 changed files with 2,063 additions and 2,053 deletions.
26 changes: 26 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
CHANGES

ver 2.1.1

This is a minor revision as most are under the hood changes

- Change: hookup menu Undo/Redo items to stack, now items will display things like "Redo/Undo insert ..."

- Change: remove unused actions from UI

- Change: New qcommand `style_update` to update style changes, brings style changes into undo framework

- Change: QUndoCommand text messages standardized

- Change: Main editor and dialogs have new/condensed tooltips, docs updated.

- Change: Toolbox Dock now uses tabs (holding scroll areas) rather than pages, less scrolling needed and more space for ui since page titles do not take up vertical space

- Bug: word wrapped text did not return proper times for timestamps, added `split` method to elements

- Bug: fixed RTF parser that did not respect spaces as delimiters vs text, now using new json format

- Bug: fix #10 where editor falls back to default system font, should now fall back to first style font

- Change: SRT export now word-wraps to 47 characters max automatically.

- Change: gather UI updates into `update_gui` to update every cursor move

ver 2.1.0

This version focuses mainly on "things" to be inserted.
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Attributes:
- `space_placement`: value from Plover config
- `add_space`: whether to add space upon merge, default is `True`

## style_update

- `styles`: reference to style dict in editor
- `style_name`: name of style to be updated
- `new_style_dict`: dict containing new style attributes
- `old_style_dict`: dict with old style attributes

## set_par_style:

Expand Down
1 change: 1 addition & 0 deletions docs/reference/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ It has the methods:
- `__getitem__`: returns new instance after deepcopy
- `__repr__`: representation as `dict`
- `length`: returns length of string, here as placeholder in order to keep consistency with other subclassed elements, the functional length
- `split`: splits text string on whitespace (re from textwrapper), returns list of elements containing each text piece separately, but same otherwise as original
- `from_dict`: can populate class using a dict
- `to_display`: formatted string for display in GUI, should be a string for three lines, 1) icon letter, 2) element data, if any, 3) text
- `to_json`: returns dict of attributes
Expand Down
26 changes: 25 additions & 1 deletion docs/reference/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,28 @@ The Open Document Format (`ODF`) is an open source standard for documents based

### RTF/CRE

Plover2CAT offers exports to RTF/CRE, the commonly used data exchange format for transcripts. As a result, it is possible to import transcripts from Plover2CAT to commercial software such as CaseCatalyst. Plover2CAT exports a [subset](rtf_support.md) of the [RTF spec](https://web.archive.org/web/20201017075356/http://www.legalxml.org/workgroups/substantive/transcripts/cre-spec.htm).
Plover2CAT offers exports to RTF/CRE, the commonly used data exchange format for transcripts. As a result, it is possible to import transcripts from Plover2CAT to commercial software such as CaseCatalyst. Plover2CAT exports a [subset](rtf_support.md) of the [RTF spec](https://web.archive.org/web/20201017075356/http://www.legalxml.org/workgroups/substantive/transcripts/cre-spec.htm).

## Export from editor

The editor offloads exporting to another thread through `documentWorker`.

`documentWorker` takes:

- `document`: copy of transcript in dict form (save transcript automatically to update)
- `path`: export file path
- `config`: transcript config
- `styles`: dict of styles for transcript
- `user_field_dict`: dict of fields
- `home_dir`: transcript dir path

`documentWorker` has two signals:

- `progress`: sent after generating a paragraph with paragraph number, updates progress bar in editor
- `finished`: sent after export file is created

Each export format has its own method called from editor.

### Wrappers and helpers

Wrapping of paragraphs is done with `steno_wrap_*` after appropriate formatting with `format_*_text`, resulting in a `dict` containing `{line_num: line_data_dict}`.
20 changes: 16 additions & 4 deletions docs/reference/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ The main class in Plover2CAT is PloverCATWindow that subclasses `QMainWindow` an
- `recorder`: instance of `QAudioRecorder`
- `config`: dict holding transcript configuration
- `file_name`: path for transcript folder
- `backup_document`: dict of transcript data, updated on save
- `styles`: dict holding styles
- `txt_formats`: dict holding "full" font formatting info (after recursion)
- `par_formats`: dict holding "full" paragraph formatting info (after recursion)
- `user_field_dict`: dict, holds user defined fields
- `auto_paragraph_affixes`: dict, holds affixes for styles
- `index_dialog`: index dialog editor
- `suggest_dialog`: suggestion dialog editor
- `styles_path`: path referencing style file
- `stroke_time`: text string timestamp of last stroke
- `audio_file`: path referencing file being played/recorded
Expand All @@ -22,6 +25,7 @@ The main class in Plover2CAT is PloverCATWindow that subclasses `QMainWindow` an
- `last_raw_steno`: string, raw steno of last stroke
- `last_string_sent`: string, text sent with last stroke
- `last_backspaces_sent`: integer, number of backspaces sent with last stroke
- `track_lengths`: deque holding len of string_sent and backspaces_sent, used for tracking/comparing corrections if strokes need to be combined
- `autosave_time`: `QTimer` object for activating autosave
- `undo_stack`: holds `QUndoStack`
- `cutcopy_storage`: `element_collection` holding steno to paste
Expand Down Expand Up @@ -56,6 +60,7 @@ Methods that use manipulate the stroke data or use `QUndoCommands` are in *itali
### GUI

- `set_shortcuts`: reads `shortcuts.json` and makes menu shortcuts as needed
- `edit_shortcuts`: opens shortcut dialog editor
- `about`: displays version
- `acknowledge`: displays acknowledgments
- `open_help`: sends user to help docs
Expand All @@ -77,17 +82,20 @@ Methods that use manipulate the stroke data or use `QUndoCommands` are in *itali
- `navigate_to`: function accepts block number, moves and sets editor cursor to beginning of block
- `update_gui`: collects other functions to be updated each time cursor changes
- `update_navigation`: updates Navigation pane, displays list of heading paragraphs
- `update_index_menu`: generates sub-menu items for quick index entry insertion
- `set_autosave_time`: set autosave time interval

### Transcript management

- `create_new`: creates new transcript project
- *`open_file`*: opens existing transcript project
- `save_file`: saves transcript project
- `save_transcript`: extracts transcript data from editor
- `save_transcript`: extracts transcript data from editor, only updates values if necessary, ie every par starting with first with `userState` == 1
- `dulwich_save`: commits transcript files to repo with commit message
- *`load_transcript`*: loads transcript data into editor and `userData` in blocks
- `revert_file`: reverts transcript back to selected commit from repo
- *`save_as_file`*: saves transcript data and tape into new location
- `autosave`: saves present transcript to hidden file
- `close_file`: closes transcript project and cleans up editor
- `action_close`: quits editor window
- `recentfile_open`: opens a recent file through `action`
Expand All @@ -101,7 +109,7 @@ Methods that use manipulate the stroke data or use `QUndoCommands` are in *itali
- `remove_dict`: file selection dialog to remove custom dict from `dict/` and plover dictionary stack
- `set_dictionary_config`: takes list of dictionary paths, generate default dict if missing, backups present dictionary stack and loads transcript dictionaries
- `restore_dictionary_from_backup`: restore plover dictionary stack from backup file

- `transcript_suggest`: trigger suggestion dialog
### Config management

- `load_config_file`: reads config file and sets editor UI variables
Expand All @@ -116,12 +124,13 @@ Methods that use manipulate the stroke data or use `QUndoCommands` are in *itali
- `gen_style_formats`: generates complete font and paragraph format dicts recursively for each style
- `select_style_file`: load style fil from user file selction
- `style_from_template`: reads ODF or RTF file, extracting only style information to write to new style file
- `display_block_data`: triggered manually after text changes or split/merge, updates style and block properties display, triggers autocomplete dropdown if toggled
- `display_block_data`: updates style and block properties display, triggers autocomplete dropdown if toggled
- `display_block_steno`: takes strokes, update Reveal Steno dock with strokes, called from `display_block_data`
- `refresh_steno_display`: updates Reveal Steno pane manually
- *`update_paragraph_style`*: updates style of present paragraph block
- `update_style_display`: updates UI elements to display present style
- `style_edit`: changes properties of current style to user selections
- `check_undo_stack`: will trigger editor style refresh if undo/redo action is related to style changes
- `new_style`: create a new style based on current style
- *`refresh_editor_styles`*: complete refresh of all paragraph blocks based on present styles
- *`to_next_styles`*: sets current block style based on `nextstylename` attribute of previous block if exists
Expand Down Expand Up @@ -161,7 +170,10 @@ Methods that use manipulate the stroke data or use `QUndoCommands` are in *itali
- *`edit_fields`*: calls `fieldDialogWindow` to create and edit user fields, and refreshes existing field elements in text
- `add_begin_auto_affix`: checks and adds prefix set for `style`, copying `element` and returning `automatic_text` element
- `add_end_auto_affix`: checks and adds suffix set for `style`, copying `element` and returning `automatic_text` element

- `insert_index_entry`: create index element and insert into transcript
- `extract_indexes`: find all index entries in transcript
- `update_indices`: check and updates transcript index entries according to present indices from indices dialog
- `edit_indices`: opens indices editor dialog
### Search

- `search`: wrapper function for three types of searches
Expand Down
1 change: 0 additions & 1 deletion docs/reference/rtf_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Recognized RTF/CRE flags
Timecode (\cxt)
Steno (\cxs)
Automatic Text (\cxa)
Delete space (\cxds)



2 changes: 1 addition & 1 deletion plover_cat/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2.1.0"
__version__ = "2.1.1"

21 changes: 19 additions & 2 deletions plover_cat/affix_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="styleName"/>
<widget class="QComboBox" name="styleName">
<property name="toolTip">
<string>Style to set affixes for</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Line" name="line">
Expand All @@ -42,6 +46,9 @@
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="prefixString">
<property name="toolTip">
<string>String to add at start of paragraph</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
Expand All @@ -55,7 +62,11 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="suffixString"/>
<widget class="QLineEdit" name="suffixString">
<property name="toolTip">
<string>String to add to end of paragraph</string>
</property>
</widget>
</item>
</layout>
</item>
Expand All @@ -66,13 +77,19 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Insert tab character into prefix/suffix string</string>
</property>
<property name="text">
<string>Insert tab at cursor</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveAffixes">
<property name="toolTip">
<string>Save changes for selected style</string>
</property>
<property name="text">
<string>Save</string>
</property>
Expand Down
75 changes: 0 additions & 75 deletions plover_cat/affix_dialog_ui.py

This file was deleted.

41 changes: 17 additions & 24 deletions plover_cat/documentWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from PyQt5.QtGui import QFontMetrics
from time import sleep
from plover import log
from plover_cat.helpers import save_json, ms_to_hours, return_commits, inch_to_spaces
from plover_cat.helpers import save_json, ms_to_hours, return_commits, inch_to_spaces, write_command
from plover_cat.steno_objects import *
from plover_cat.rtf_parsing import *
from plover_cat.export_helpers import *
Expand Down Expand Up @@ -485,8 +485,8 @@ def save_rtf(self):
info_string.append(write_command("cxnoflines", value = page_vspan))
# cxlinex and cxtimex is hardcoded as it is also harcoded in odf
# based on rtf spec, confusing whether left text margin, or left page margin
info_string.append(write_command("creatim", value = create_string))
info_string.append(write_command("buptim", value = backup_string))
info_string.append(write_command("creatim", value = create_string, group = True))
info_string.append(write_command("buptim", value = backup_string, group = True))
info_string.append(write_command("cxlinex", value = int(in_to_twip(-0.15))))
info_string.append(write_command("cxtimex", value = int(in_to_twip(-1.5))))
info_string.append(write_command("cxnofstrokes", value = stroke_count))
Expand All @@ -510,27 +510,20 @@ def save_srt(self):
line_num = 1
doc_lines = []
log.debug(f"Exporting in SRT to {self.path}")
for block_num, block_data in self.document.items():
doc_lines += [block_num]
audiostarttime = block_data["audiostarttime"]
# webvtt uses periods for ms separator
audiostarttime = audiostarttime.replace(".", ",")
if "audioendtime" in block_data:
audioendtime = block_data["audioendtime"]
elif int(block_num) == (len(self.document) - 1):
log.debug(f"Block {block_num} does not have audioendtime. Last block in document. Setting 0 as timestamp.")
audioendtime = ms_to_hours(0)
else:
log.debug(f"Block {block_num} does not have audioendtime. Attempting to use starttime from next block.")
try:
audioendtime = self.document[str(int(block_num) + 1)]["audiostarttime"]
except (TypeError, KeyError) as err:
audioendtime = ms_to_hours(0)
audioendtime = audioendtime.replace(".", ",")
doc_lines += [audiostarttime + " --> " + audioendtime]
el_list = [ef.gen_element(element_dict = i, user_field_dict = self.user_field_dict) for i in block_data["strokes"]]
doc_lines += ["".join([el.to_text() for el in el_list])]
doc_lines += [""]
for block_num, block_data in self.document.items():
if "audioendtime" not in block_data:
if str(int(block_num) + 1) in self.document and "audiostarttime" in self.document[str(int(block_num) + 1)]:
block_data["audioendtime"] = self.document[str(int(block_num) + 1)]["audiostarttime"]
else:
block_data["audioendtime"] = None
el_list = element_collection([ef.gen_element(element_dict = i, user_field_dict = self.user_field_dict) for i in block_data["strokes"]])
par_dict = format_srt_text(el_list, line_num = line_num, audiostarttime = block_data["audiostarttime"], audioendtime = block_data["audioendtime"])
line_num += len(par_dict)
for k, v in par_dict.items():
doc_lines += [k]
doc_lines += [ms_to_hours(v["starttime"]).replace(".", ",") + " --> " + ms_to_hours(v["endtime"]).replace(".", ",")]
doc_lines += ["".join([el.to_text() for el in v["text"]])]
doc_lines += [""]
self.progress.emit(int(block_num))
file_path = pathlib.Path(self.path)
with open(file_path, "w", encoding="utf-8") as f:
Expand Down
Loading

0 comments on commit 13b7511

Please sign in to comment.