mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
a4fe0095df
commit
5611a96148
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from PyQt4.Qt import QWidget, pyqtSignal, QCheckBox, QAbstractSpinBox, \
|
from PyQt4.Qt import QWidget, pyqtSignal, QCheckBox, QAbstractSpinBox, \
|
||||||
QLineEdit, QComboBox, QVariant
|
QLineEdit, QComboBox, QVariant, Qt
|
||||||
|
|
||||||
from calibre.customize.ui import preferences_plugins
|
from calibre.customize.ui import preferences_plugins
|
||||||
from calibre.utils.config import ConfigProxy
|
from calibre.utils.config import ConfigProxy
|
||||||
@ -82,6 +82,8 @@ class ConfigWidgetInterface(object):
|
|||||||
|
|
||||||
class Setting(object):
|
class Setting(object):
|
||||||
|
|
||||||
|
CHOICES_SEARCH_FLAGS = Qt.MatchExactly | Qt.MatchCaseSensitive
|
||||||
|
|
||||||
def __init__(self, name, config_obj, widget, gui_name=None,
|
def __init__(self, name, config_obj, widget, gui_name=None,
|
||||||
empty_string_is_None=True, choices=None, restart_required=False):
|
empty_string_is_None=True, choices=None, restart_required=False):
|
||||||
self.name, self.gui_name = name, gui_name
|
self.name, self.gui_name = name, gui_name
|
||||||
@ -168,7 +170,8 @@ class Setting(object):
|
|||||||
elif self.datatype == 'string':
|
elif self.datatype == 'string':
|
||||||
self.gui_obj.setText(val if val else '')
|
self.gui_obj.setText(val if val else '')
|
||||||
elif self.datatype == 'choice':
|
elif self.datatype == 'choice':
|
||||||
idx = self.gui_obj.findData(QVariant(val))
|
idx = self.gui_obj.findData(QVariant(val), role=Qt.UserRole,
|
||||||
|
flags=self.CHOICES_SEARCH_FLAGS)
|
||||||
if idx == -1:
|
if idx == -1:
|
||||||
idx = 0
|
idx = 0
|
||||||
self.gui_obj.setCurrentIndex(idx)
|
self.gui_obj.setCurrentIndex(idx)
|
||||||
|
@ -9,7 +9,7 @@ import re
|
|||||||
|
|
||||||
from PyQt4.Qt import Qt, QVariant, QListWidgetItem
|
from PyQt4.Qt import Qt, QVariant, QListWidgetItem
|
||||||
|
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
|
||||||
from calibre.gui2.preferences.behavior_ui import Ui_Form
|
from calibre.gui2.preferences.behavior_ui import Ui_Form
|
||||||
from calibre.gui2 import config, info_dialog, dynamic
|
from calibre.gui2 import config, info_dialog, dynamic
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
@ -20,6 +20,10 @@ from calibre.ebooks.oeb.iterator import is_supported
|
|||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
|
||||||
|
class OutputFormatSetting(Setting):
|
||||||
|
|
||||||
|
CHOICES_SEARCH_FLAGS = Qt.MatchFixedString
|
||||||
|
|
||||||
class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||||
|
|
||||||
def genesis(self, gui):
|
def genesis(self, gui):
|
||||||
@ -43,7 +47,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
output_formats = list(sorted(available_output_formats()))
|
output_formats = list(sorted(available_output_formats()))
|
||||||
output_formats.remove('oeb')
|
output_formats.remove('oeb')
|
||||||
choices = [(x.upper(), x) for x in output_formats]
|
choices = [(x.upper(), x) for x in output_formats]
|
||||||
r('output_format', prefs, choices=choices)
|
r('output_format', prefs, choices=choices, setting=OutputFormatSetting)
|
||||||
|
|
||||||
restrictions = sorted(saved_searches().names(), key=sort_key)
|
restrictions = sorted(saved_searches().names(), key=sort_key)
|
||||||
choices = [('', '')] + [(x, x) for x in restrictions]
|
choices = [('', '')] + [(x, x) for x in restrictions]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user