Revert "Use a radio button for the case-sensitive/primary find options as they are mutually exclusive"

Radio buttons prevent both options from being turned off, which is a
valid use case.

This reverts commit bf63198d19bb9544d68856020081c3c837165ec6.
This commit is contained in:
Kovid Goyal 2016-08-26 05:12:18 +05:30
parent c0acacf674
commit bd2c7c3934
4 changed files with 14 additions and 11 deletions

View File

@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
import textwrap import textwrap
from PyQt5.Qt import (QWidget, pyqtSignal, QCheckBox, QAbstractSpinBox, from PyQt5.Qt import (QWidget, pyqtSignal, QCheckBox, QAbstractSpinBox,
QLineEdit, QComboBox, Qt, QIcon, QDialog, QVBoxLayout, QRadioButton, QLineEdit, QComboBox, Qt, QIcon, QDialog, QVBoxLayout,
QDialogButtonBox) QDialogButtonBox)
from calibre.customize.ui import preferences_plugins from calibre.customize.ui import preferences_plugins
@ -101,9 +101,6 @@ class Setting(object):
if isinstance(self.gui_obj, QCheckBox): if isinstance(self.gui_obj, QCheckBox):
self.datatype = 'bool' self.datatype = 'bool'
self.gui_obj.stateChanged.connect(self.changed) 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): elif isinstance(self.gui_obj, QAbstractSpinBox):
self.datatype = 'number' self.datatype = 'number'
self.gui_obj.valueChanged.connect(self.changed) self.gui_obj.valueChanged.connect(self.changed)
@ -115,7 +112,7 @@ class Setting(object):
self.gui_obj.editTextChanged.connect(self.changed) self.gui_obj.editTextChanged.connect(self.changed)
self.gui_obj.currentIndexChanged.connect(self.changed) self.gui_obj.currentIndexChanged.connect(self.changed)
else: else:
raise ValueError('Unknown data type') raise ValueError('Unknown data type %s' % self.gui_obj.__class__)
if isinstance(self.config_obj, ConfigProxy) and \ if isinstance(self.config_obj, ConfigProxy) and \
not unicode(self.gui_obj.toolTip()): not unicode(self.gui_obj.toolTip()):

View File

@ -7,11 +7,13 @@ __docformat__ = 'restructuredtext en'
from PyQt5.Qt import QApplication from PyQt5.Qt import QApplication
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, CommaSeparatedList from calibre.gui2.preferences import ConfigWidgetBase, test_widget, \
CommaSeparatedList, AbortCommit
from calibre.gui2.preferences.search_ui import Ui_Form from calibre.gui2.preferences.search_ui import Ui_Form
from calibre.gui2 import config, error_dialog, gprefs from calibre.gui2 import config, error_dialog, gprefs
from calibre.utils.config import prefs from calibre.utils.config import prefs
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
from calibre.library.caches import set_use_primary_find_in_search
class ConfigWidget(ConfigWidgetBase, Ui_Form): class ConfigWidget(ConfigWidgetBase, Ui_Form):
@ -210,6 +212,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.gst_value.blockSignals(False) self.gst_value.blockSignals(False)
def commit(self): 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: if self.gst_changed:
self.db.new_api.set_pref('grouped_search_terms', self.gst) self.db.new_api.set_pref('grouped_search_terms', self.gst)
self.db.field_metadata.add_grouped_search_terms(self.gst) self.db.field_metadata.add_grouped_search_terms(self.gst)
@ -224,7 +231,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
return ConfigWidgetBase.commit(self) return ConfigWidgetBase.commit(self)
def refresh_gui(self, gui): def refresh_gui(self, gui):
gui.current_db.new_api.clear_caches() # Clear the search cache set_use_primary_find_in_search(prefs['use_primary_find_in_search'])
gui.set_highlight_only_button_icon() gui.set_highlight_only_button_icon()
if self.muc_changed: if self.muc_changed:
gui.tags_view.recount() gui.tags_view.recount()

View File

@ -307,14 +307,14 @@ to be shown as user categories</string>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QRadioButton" name="opt_case_sensitive"> <widget class="QCheckBox" name="opt_case_sensitive">
<property name="text"> <property name="text">
<string>Case sensitive searching</string> <string>Case sensitive searching</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QRadioButton" name="opt_use_primary_find_in_search"> <widget class="QCheckBox" name="opt_use_primary_find_in_search">
<property name="text"> <property name="text">
<string>Unaccented characters match accented characters</string> <string>Unaccented characters match accented characters</string>
</property> </property>

View File

@ -440,8 +440,7 @@ def create_global_prefs(conf_obj=None):
'libraries. Note that this option will have no effect if you turn ' 'libraries. Note that this option will have no effect if you turn '
'on case-sensitive searching')%u'\xf1') 'on case-sensitive searching')%u'\xf1')
c.add_opt('case_sensitive', default=False, help=_( c.add_opt('case_sensitive', default=False, help=_(
'Make searches case-sensitive. Note that turning on case-sensitive searches disables matching of ' 'Make searches case-sensitive'))
'accented characters by their unaccented versions.'))
c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.') c.add_opt('migrated', default=False, help='For Internal use. Don\'t modify.')
return c return c