mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use a radio button for the case-sensitive/primary find options as they are mutually exclusive
This commit is contained in:
parent
470f621748
commit
bf63198d19
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import textwrap
|
||||
|
||||
from PyQt5.Qt import (QWidget, pyqtSignal, QCheckBox, QAbstractSpinBox,
|
||||
QLineEdit, QComboBox, Qt, QIcon, QDialog, QVBoxLayout,
|
||||
QLineEdit, QComboBox, Qt, QIcon, QDialog, QVBoxLayout, QRadioButton,
|
||||
QDialogButtonBox)
|
||||
|
||||
from calibre.customize.ui import preferences_plugins
|
||||
@ -101,6 +101,9 @@ class Setting(object):
|
||||
if isinstance(self.gui_obj, QCheckBox):
|
||||
self.datatype = 'bool'
|
||||
self.gui_obj.stateChanged.connect(self.changed)
|
||||
elif isinstance(self.gui_obj, QRadioButton):
|
||||
self.datatype = 'bool'
|
||||
self.gui_obj.toggled.connect(self.changed)
|
||||
elif isinstance(self.gui_obj, QAbstractSpinBox):
|
||||
self.datatype = 'number'
|
||||
self.gui_obj.valueChanged.connect(self.changed)
|
||||
|
@ -7,13 +7,11 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt5.Qt import QApplication
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, \
|
||||
CommaSeparatedList, AbortCommit
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, CommaSeparatedList
|
||||
from calibre.gui2.preferences.search_ui import Ui_Form
|
||||
from calibre.gui2 import config, error_dialog, gprefs
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.library.caches import set_use_primary_find_in_search
|
||||
|
||||
class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
@ -102,12 +100,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.muc_changed = False
|
||||
self.opt_grouped_search_make_user_categories.lineEdit().editingFinished.connect(
|
||||
self.muc_box_changed)
|
||||
self.opt_case_sensitive.toggled.connect(self.case_sensitive_toggled)
|
||||
self.case_sensitive_toggled()
|
||||
|
||||
def case_sensitive_toggled(self):
|
||||
if self.opt_case_sensitive.isChecked():
|
||||
self.opt_use_primary_find_in_search.setChecked(False)
|
||||
|
||||
def set_similar_fields(self, initial=False):
|
||||
self.set_similar('similar_authors_search_key', initial=initial)
|
||||
@ -218,11 +210,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.gst_value.blockSignals(False)
|
||||
|
||||
def commit(self):
|
||||
if self.opt_case_sensitive.isChecked() and self.opt_use_primary_find_in_search.isChecked():
|
||||
error_dialog(self, _('Incompatible options'), _(
|
||||
'The option to have un-accented characters match accented characters has no effect'
|
||||
' if you also turn on case-sensitive searching. So only turn on one of those options'), show=True)
|
||||
raise AbortCommit()
|
||||
if self.gst_changed:
|
||||
self.db.new_api.set_pref('grouped_search_terms', self.gst)
|
||||
self.db.field_metadata.add_grouped_search_terms(self.gst)
|
||||
@ -237,7 +224,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
return ConfigWidgetBase.commit(self)
|
||||
|
||||
def refresh_gui(self, gui):
|
||||
set_use_primary_find_in_search(prefs['use_primary_find_in_search'])
|
||||
gui.current_db.new_api.clear_caches() # Clear the search cache
|
||||
gui.set_highlight_only_button_icon()
|
||||
if self.muc_changed:
|
||||
gui.tags_view.recount()
|
||||
|
@ -307,14 +307,14 @@ to be shown as user categories</string>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="opt_case_sensitive">
|
||||
<widget class="QRadioButton" name="opt_case_sensitive">
|
||||
<property name="text">
|
||||
<string>Case sensitive searching</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="opt_use_primary_find_in_search">
|
||||
<widget class="QRadioButton" name="opt_use_primary_find_in_search">
|
||||
<property name="text">
|
||||
<string>Unaccented characters match accented characters</string>
|
||||
</property>
|
||||
|
@ -440,7 +440,8 @@ def create_global_prefs(conf_obj=None):
|
||||
'libraries. Note that this option will have no effect if you turn '
|
||||
'on case-sensitive searching')%u'\xf1')
|
||||
c.add_opt('case_sensitive', default=False, help=_(
|
||||
'Make searches case-sensitive'))
|
||||
'Make searches case-sensitive. Note that turning on case-sensitive searches disables matching of '
|
||||
'accented characters by their unaccented versions.'))
|
||||
|
||||
c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.')
|
||||
return c
|
||||
|
Loading…
x
Reference in New Issue
Block a user