Skip to content

Commit

Permalink
Improvement: Warn users about epub conversion (#17)
Browse files Browse the repository at this point in the history
* Improvement: Warning user of epub conversion
Fixes #3

* chore: add separator before remove metaguiding action in menu

* chore: add type ignore comment for remove metaguiding action

* style: format code for consistency in action.py

* Merge branch 'main' into 0x6f677548/issue3
  • Loading branch information
0x6f677548 authored Feb 25, 2025
1 parent e423098 commit 835b90d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions epubmg_interfaceplugin/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ def genesis(self):
kepub_action = self.menu.addAction(_("Metaguide kepub")) # type: ignore # noqa
kepub_action.triggered.connect(self.metaguide_kepub_selection)

# Add separator
self.menu.addSeparator()

# Add remove metaguiding action to menu
remove_metaguiding_action = self.menu.addAction(_("Remove metaguiding"))
remove_metaguiding_action = self.menu.addAction(_("Remove metaguiding")) # type: ignore # noqa
remove_metaguiding_action.triggered.connect(
self.remove_metaguiding_epub_selection
)
Expand Down Expand Up @@ -113,6 +116,19 @@ def metaguide_selection_format(
default_yes=False,
):
return
else:
if not question_dialog(
self.gui,
"Metaguiding will modify your files",
"This feature will modify your files by adding metaguiding to them. "
"The original file will be saved as ORIGINAL_format (ex: ORIGINAL_EPUB), and the new file will overwrite the original file. "
"Any previous ORIGINAL_format file will be overwritten and lost. "
"Please make sure to backup your library before using this feature.\n\n"
"Do you want to continue?",
show_copy_button=True,
default_yes=False,
):
return

action_text = "remove metaguiding" if remove_metaguiding else "add metaguiding"

Expand All @@ -137,7 +153,9 @@ def metaguide_selection_format(
)

try:
metaguiding.metaguide_epub_file(temp_file, temp_file, remove_metaguiding = remove_metaguiding)
metaguiding.metaguide_epub_file(
temp_file, temp_file, remove_metaguiding=remove_metaguiding
)
except Exception as e: # pylint: disable=broad-except
common.log.error(
"Error processing book id: %d, format: %s"
Expand Down

0 comments on commit 835b90d

Please sign in to comment.