mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
347d1f8b54
@ -626,10 +626,10 @@ class DeviceMixin(object): # {{{
|
||||
self.default_thumbnail = (pixmap.width(), pixmap.height(),
|
||||
pixmap_to_data(pixmap))
|
||||
|
||||
def connect_to_folder_named(self, dir):
|
||||
if os.path.isdir(dir):
|
||||
kls = FOLDER_DEVICE
|
||||
self.device_manager.mount_device(kls=kls, kind='folder', path=dir)
|
||||
def connect_to_folder_named(self, folder):
|
||||
if os.path.exists(folder) and os.path.isdir(folder):
|
||||
self.device_manager.mount_device(kls=FOLDER_DEVICE, kind='folder',
|
||||
path=folder)
|
||||
|
||||
def connect_to_folder(self):
|
||||
dir = choose_dir(self, 'Select Device Folder',
|
||||
|
@ -448,7 +448,6 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
self.password.setText(opts.password if opts.password else '')
|
||||
self.opt_max_opds_items.setValue(opts.max_opds_items)
|
||||
self.opt_max_opds_ungrouped_items.setValue(opts.max_opds_ungrouped_items)
|
||||
self.opt_cs_restriction.setText(self.db.prefs.get('cs_restriction', ''))
|
||||
self.auto_launch.setChecked(config['autolaunch_server'])
|
||||
self.systray_icon.setChecked(config['systray_icon'])
|
||||
self.sync_news.setChecked(config['upload_news_to_device'])
|
||||
@ -498,9 +497,11 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
restrictions = sorted(saved_searches().names(),
|
||||
cmp=lambda x,y: cmp(x.lower(), y.lower()))
|
||||
restrictions.insert(0, '')
|
||||
self.opt_gui_restriction.addItems(restrictions)
|
||||
idx = self.opt_gui_restriction.findText(self.db.prefs.get('gui_restriction', ''))
|
||||
self.opt_gui_restriction.setCurrentIndex(0 if idx < 0 else idx)
|
||||
for x in ('gui', 'cs'):
|
||||
w = getattr(self, 'opt_%s_restriction'%x)
|
||||
w.addItems(restrictions)
|
||||
idx = w.findText(self.db.prefs.get(x+'_restriction', ''))
|
||||
w.setCurrentIndex(0 if idx < 0 else idx)
|
||||
self.opt_disable_animations.setChecked(config['disable_animations'])
|
||||
self.opt_show_donate_button.setChecked(config['show_donate_button'])
|
||||
idx = 0
|
||||
@ -914,7 +915,6 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
sc.set('max_opds_items', self.opt_max_opds_items.value())
|
||||
sc.set('max_opds_ungrouped_items',
|
||||
self.opt_max_opds_ungrouped_items.value())
|
||||
self.db.prefs.set('cs_restriction', unicode(self.opt_cs_restriction.text()))
|
||||
config['delete_news_from_library_on_upload'] = self.delete_news.isChecked()
|
||||
config['upload_news_to_device'] = self.sync_news.isChecked()
|
||||
config['search_as_you_type'] = self.search_as_you_type.isChecked()
|
||||
@ -936,7 +936,9 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
config['internally_viewed_formats'] = fmts
|
||||
val = self.opt_gui_layout.itemData(self.opt_gui_layout.currentIndex()).toString()
|
||||
config['gui_layout'] = unicode(val)
|
||||
self.db.prefs.set('gui_restriction', unicode(self.opt_gui_restriction.currentText()))
|
||||
for x in ('gui', 'cs'):
|
||||
w = getattr(self, 'opt_%s_restriction'%x)
|
||||
self.db.prefs.set(x+'_restriction', unicode(w.currentText()))
|
||||
|
||||
if must_restart:
|
||||
warning_dialog(self, _('Must restart'),
|
||||
|
@ -7,7 +7,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1000</width>
|
||||
<width>1001</width>
|
||||
<height>730</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -89,8 +89,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>720</width>
|
||||
<height>679</height>
|
||||
<width>725</width>
|
||||
<height>683</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
@ -573,7 +573,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_170">
|
||||
<property name="text">
|
||||
<string>Restriction to apply when the current library is opened (startup or change library):</string>
|
||||
<string>Restriction to apply when the current library is opened:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_gui_restriction</cstring>
|
||||
@ -588,6 +588,15 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Apply this restriction on calibre startup if the current library is being used. Also applied when switching to this library. Note that this setting is per library. </string>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
@ -1060,23 +1069,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="opt_cs_restriction">
|
||||
<property name="toolTip">
|
||||
<string>Provides a restriction to be used by the content server</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_164">
|
||||
<property name="text">
|
||||
<string>Restriction (saved search) to apply:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_cs_restriction</cstring>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="opt_cs_restriction">
|
||||
<property name="toolTip">
|
||||
<string>This restriction (based on a saved search) will restrict the books the content server makes available to those matching the search. This setting is per library (i.e. you can have a different restriction per library).</string>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -95,9 +95,9 @@ class LibraryServer(ContentServer, MobileServer, XMLServer, OPDSServer, Cache):
|
||||
'tools.digest_auth.users' : {opts.username.strip():opts.password.strip()},
|
||||
}
|
||||
|
||||
self.set_search_restriction(db.prefs.get('cs_restriction', ''))
|
||||
if opts.restriction is not None:
|
||||
self.set_search_restriction(opts.restriction)
|
||||
sr = db.prefs.get('cs_restriction', '') if opts.restriction is None \
|
||||
else opts.restriction
|
||||
self.set_search_restriction(sr)
|
||||
|
||||
self.is_running = False
|
||||
self.exception = None
|
||||
|
@ -34,7 +34,8 @@ def option_parser():
|
||||
help='Run process in background as a daemon. No effect on windows.')
|
||||
parser.add_option('--restriction', default=None,
|
||||
help=_('Specifies a restriction to be used for this invocation. '
|
||||
'This option overrides the default set in the GUI'))
|
||||
'This option overrides any per-library settings specified'
|
||||
' in the GUI'))
|
||||
return parser
|
||||
|
||||
def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
|
||||
|
@ -181,7 +181,9 @@ class MobileServer(object):
|
||||
num = int(num)
|
||||
except ValueError:
|
||||
raise cherrypy.HTTPError(400, 'num: %s is not an integer'%num)
|
||||
ids = self.db.search_getting_ids(search, self.search_restriction)
|
||||
if not search:
|
||||
search = ''
|
||||
ids = self.db.search_getting_ids(search.strip(), self.search_restriction)
|
||||
FM = self.db.FIELD_MAP
|
||||
items = [r for r in iter(self.db) if r[FM['id']] in ids]
|
||||
if sort is not None:
|
||||
|
@ -45,7 +45,10 @@ class XMLServer(object):
|
||||
|
||||
order = order.lower().strip() == 'ascending'
|
||||
|
||||
ids = self.db.search_getting_ids(search, self.search_restriction)
|
||||
if not search:
|
||||
search = ''
|
||||
|
||||
ids = self.db.search_getting_ids(search.strip(), self.search_restriction)
|
||||
|
||||
FM = self.db.FIELD_MAP
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user