Skip to content

Commit

Permalink
feat: Support disabling and auto-hiding notifications. resolved #214
Browse files Browse the repository at this point in the history
  • Loading branch information
bookfere committed Apr 13, 2024
1 parent a69939c commit 33ed918
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 147 deletions.
4 changes: 2 additions & 2 deletions batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def layout_translate(self):
.set_encoding(encoding))
else:
input_encoding = QLabel(_('Default'))
table.setCellWidget(row, 2, input_encoding)
table.setCellWidget(row, 1, input_encoding)

input_fmt = InputFormat(ebook.files.keys())
table.setCellWidget(row, 1, input_fmt)
table.setCellWidget(row, 2, input_fmt)

output_format = OutputFormat()
table.setCellWidget(row, 3, output_format)
Expand Down
1 change: 1 addition & 0 deletions lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'cache_enabled': True,
'cache_path': None,
'log_translation': True,
'show_notification': True,
'translation_position': None,
'column_gap': {
'_type': 'percentage',
Expand Down
20 changes: 10 additions & 10 deletions lib/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ def callback(payload):
kwargs = {'args': ['ebook-viewer', output_path]}
payload('ebook-viewer', kwargs=kwargs)

self.gui.proceed_question(
callback,
self.gui.job_manager.launch_gui_app,
job.log_path,
_('Ebook Translation Log'),
_('Translation Completed'),
_('The translation of "{}" was completed. '
'Do you want to open the book?').format(ebook_title),
log_is_file=True,
icon=self.icon)
if self.config.get('show_notification', True):
self.gui.proceed_question(
callback,
self.gui.job_manager.launch_gui_app,
job.log_path,
_('Ebook Translation Log'),
_('Translation Completed'),
_('The translation of "{}" was completed. '
'Do you want to open the book?').format(ebook_title),
log_is_file=True, icon=self.icon, auto_hide_after=5)
13 changes: 12 additions & 1 deletion setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,23 @@ def change_input_format(format):
log_layout.addStretch(1)
misc_layout.addWidget(log_group, 1)

# Notification
notice_group = QGroupBox(_('Notification'))
notice_layout = QHBoxLayout(notice_group)
notice = QCheckBox(_('Enable'))
notice_layout.addWidget(notice)
misc_layout.addWidget(notice_group, 1)

layout.addWidget(misc_widget)

log_translation.setChecked(self.config.get('log_translation'))
log_translation.setChecked(self.config.get('log_translation', True))
log_translation.toggled.connect(
lambda checked: self.config.update(log_translation=checked))

notice.setChecked(self.config.get('show_notification', True))
notice.toggled.connect(
lambda checked: self.config.update(show_notification=checked))

# Search path
path_group = QGroupBox(_('Search Paths'))
path_layout = QVBoxLayout(path_group)
Expand Down
1 change: 1 addition & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_default(self):
'cache_enabled': True,
'cache_path': None,
'log_translation': True,
'show_notification': True,
'translation_position': None,
'column_gap': {
'_type': 'percentage',
Expand Down
5 changes: 4 additions & 1 deletion translations/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: bookfere@gmail.com\n"
"POT-Creation-Date: 2024-04-12 23:49+0800\n"
"POT-Creation-Date: 2024-04-13 10:33+0800\n"
"PO-Revision-Date: 2023-04-17 14:17+0800\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -566,6 +566,9 @@ msgstr ""
msgid "Show translation"
msgstr "Mostrar traducción"

msgid "Notification"
msgstr ""

msgid "Search Paths"
msgstr ""

Expand Down
5 changes: 4 additions & 1 deletion translations/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: bookfere@gmail.com\n"
"POT-Creation-Date: 2024-04-12 23:49+0800\n"
"POT-Creation-Date: 2024-04-13 10:33+0800\n"
"PO-Revision-Date: 2023-10-01 15:35-0400\n"
"Last-Translator: <a href=\"https://www.mobileread.com/forums/member.php?"
"u=90932\">PoP</a>\n"
Expand Down Expand Up @@ -575,6 +575,9 @@ msgstr "Registre de travail"
msgid "Show translation"
msgstr "Montrer la traduction"

msgid "Notification"
msgstr ""

msgid "Search Paths"
msgstr ""

Expand Down
Loading

0 comments on commit 33ed918

Please sign in to comment.