mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add a checkbox to allow users to disable the popup that asks if books should be auto-converted before sending to device
This commit is contained in:
parent
68d66e9a30
commit
04cec656d2
@ -273,11 +273,34 @@ def error_dialog(parent, title, msg, det_msg='', show=False,
|
|||||||
return d
|
return d
|
||||||
|
|
||||||
def question_dialog(parent, title, msg, det_msg='', show_copy_button=False,
|
def question_dialog(parent, title, msg, det_msg='', show_copy_button=False,
|
||||||
default_yes=True):
|
default_yes=True,
|
||||||
|
# Skippable dialogs
|
||||||
|
# Set skip_dialog_name to a unique name for this dialog
|
||||||
|
# Set skip_dialog_msg to a message displayed to the user
|
||||||
|
skip_dialog_name=None, skip_dialog_msg=_('Show this confirmation again'),
|
||||||
|
skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True):
|
||||||
from calibre.gui2.dialogs.message_box import MessageBox
|
from calibre.gui2.dialogs.message_box import MessageBox
|
||||||
|
|
||||||
|
auto_skip = set(gprefs.get('questions_to_auto_skip', []))
|
||||||
|
if (skip_dialog_name is not None and skip_dialog_name in auto_skip):
|
||||||
|
return bool(skip_dialog_skipped_value)
|
||||||
|
|
||||||
d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
|
d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
|
||||||
show_copy_button=show_copy_button, default_yes=default_yes)
|
show_copy_button=show_copy_button, default_yes=default_yes)
|
||||||
return d.exec_() == d.Accepted
|
|
||||||
|
if skip_dialog_name is not None and skip_dialog_msg:
|
||||||
|
tc = d.toggle_checkbox
|
||||||
|
tc.setVisible(True)
|
||||||
|
tc.setText(skip_dialog_msg)
|
||||||
|
tc.setChecked(bool(skip_dialog_skip_precheck))
|
||||||
|
|
||||||
|
ret = d.exec_() == d.Accepted
|
||||||
|
|
||||||
|
if skip_dialog_name is not None and not d.toggle_checkbox.isChecked():
|
||||||
|
auto_skip.add(skip_dialog_name)
|
||||||
|
gprefs.set('questions_to_auto_skip', list(auto_skip))
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
def info_dialog(parent, title, msg, det_msg='', show=False,
|
def info_dialog(parent, title, msg, det_msg='', show=False,
|
||||||
show_copy_button=True):
|
show_copy_button=True):
|
||||||
|
@ -683,7 +683,7 @@ class DeviceMixin(object): # {{{
|
|||||||
return self.ask_a_yes_no_question(
|
return self.ask_a_yes_no_question(
|
||||||
_('No suitable formats'), msg,
|
_('No suitable formats'), msg,
|
||||||
ans_when_user_unavailable=True,
|
ans_when_user_unavailable=True,
|
||||||
det_msg=autos
|
det_msg=autos, skip_dialog_name='auto_convert_before_send'
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_default_thumbnail(self, height):
|
def set_default_thumbnail(self, height):
|
||||||
|
@ -44,6 +44,7 @@ class MessageBox(QDialog, Ui_Dialog): # {{{
|
|||||||
self.msg.setText(msg)
|
self.msg.setText(msg)
|
||||||
self.det_msg.setPlainText(det_msg)
|
self.det_msg.setPlainText(det_msg)
|
||||||
self.det_msg.setVisible(False)
|
self.det_msg.setVisible(False)
|
||||||
|
self.toggle_checkbox.setVisible(False)
|
||||||
|
|
||||||
if show_copy_button:
|
if show_copy_button:
|
||||||
self.ctc_button = self.bb.addButton(_('&Copy to clipboard'),
|
self.ctc_button = self.bb.addButton(_('&Copy to clipboard'),
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QDialogButtonBox" name="bb">
|
<widget class="QDialogButtonBox" name="bb">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -63,6 +63,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="toggle_checkbox">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -162,6 +162,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
for key in dynamic.keys():
|
for key in dynamic.keys():
|
||||||
if key.endswith('_again') and dynamic[key] is False:
|
if key.endswith('_again') and dynamic[key] is False:
|
||||||
dynamic[key] = True
|
dynamic[key] = True
|
||||||
|
gprefs['questions_to_auto_skip'] = []
|
||||||
info_dialog(self, _('Done'),
|
info_dialog(self, _('Done'),
|
||||||
_('Confirmation dialogs have all been reset'), show=True)
|
_('Confirmation dialogs have all been reset'), show=True)
|
||||||
|
|
||||||
|
@ -407,11 +407,14 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
return getattr(self, '__systray_minimized', False)
|
return getattr(self, '__systray_minimized', False)
|
||||||
|
|
||||||
def ask_a_yes_no_question(self, title, msg, det_msg='',
|
def ask_a_yes_no_question(self, title, msg, det_msg='',
|
||||||
show_copy_button=False, ans_when_user_unavailable=True):
|
show_copy_button=False, ans_when_user_unavailable=True,
|
||||||
|
skip_dialog_name=None, skipped_value=True):
|
||||||
if self.is_minimized_to_tray:
|
if self.is_minimized_to_tray:
|
||||||
return ans_when_user_unavailable
|
return ans_when_user_unavailable
|
||||||
return question_dialog(self, title, msg, det_msg=det_msg,
|
return question_dialog(self, title, msg, det_msg=det_msg,
|
||||||
show_copy_button=show_copy_button)
|
show_copy_button=show_copy_button,
|
||||||
|
skip_dialog_name=skip_dialog_name,
|
||||||
|
skip_dialog_skipped_value=skipped_value)
|
||||||
|
|
||||||
def hide_windows(self):
|
def hide_windows(self):
|
||||||
for window in QApplication.topLevelWidgets():
|
for window in QApplication.topLevelWidgets():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user