mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #5477
This commit is contained in:
commit
af4ad6faa5
@ -46,7 +46,7 @@ class Base(object):
|
|||||||
class Bool(Base):
|
class Bool(Base):
|
||||||
|
|
||||||
def setup_ui(self, parent):
|
def setup_ui(self, parent):
|
||||||
self.widgets = [QLabel('&'+self.col_metadata['name'], parent),
|
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
||||||
QComboBox(parent)]
|
QComboBox(parent)]
|
||||||
w = self.widgets[1]
|
w = self.widgets[1]
|
||||||
items = [_('Yes'), _('No'), _('Undefined')]
|
items = [_('Yes'), _('No'), _('Undefined')]
|
||||||
@ -57,7 +57,6 @@ class Bool(Base):
|
|||||||
for icon, text in zip(icons, items):
|
for icon, text in zip(icons, items):
|
||||||
w.addItem(QIcon(icon), text)
|
w.addItem(QIcon(icon), text)
|
||||||
|
|
||||||
|
|
||||||
def setter(self, val):
|
def setter(self, val):
|
||||||
val = {None: 2, False: 1, True: 0}[val]
|
val = {None: 2, False: 1, True: 0}[val]
|
||||||
if tweaks['bool_custom_columns_are_tristate'] == 'no' and val == 2:
|
if tweaks['bool_custom_columns_are_tristate'] == 'no' and val == 2:
|
||||||
@ -338,12 +337,14 @@ class BulkText(BulkBase):
|
|||||||
if self.col_metadata['is_multiple']:
|
if self.col_metadata['is_multiple']:
|
||||||
w = TagsLineEdit(parent, values)
|
w = TagsLineEdit(parent, values)
|
||||||
w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
||||||
self.widgets = [QLabel('&'+self.col_metadata['name']+': (tags to add)', parent), w]
|
self.widgets = [QLabel('&'+self.col_metadata['name']+': ' +
|
||||||
|
_('tags to add'), parent), w]
|
||||||
self.adding_widget = w
|
self.adding_widget = w
|
||||||
|
|
||||||
w = TagsLineEdit(parent, values)
|
w = TagsLineEdit(parent, values)
|
||||||
w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
w.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
||||||
self.widgets.append(QLabel('&'+self.col_metadata['name']+': (tags to remove)', parent))
|
self.widgets.append(QLabel('&'+self.col_metadata['name']+': ' +
|
||||||
|
_('tags to remove'), parent))
|
||||||
self.widgets.append(w)
|
self.widgets.append(w)
|
||||||
self.removing_widget = w
|
self.removing_widget = w
|
||||||
else:
|
else:
|
||||||
@ -413,12 +414,10 @@ def populate_bulk_metadata_page(layout, db, book_ids, parent=None):
|
|||||||
if len(w.widgets) == 1:
|
if len(w.widgets) == 1:
|
||||||
layout.addWidget(w.widgets[0], row, 0, 1, -1)
|
layout.addWidget(w.widgets[0], row, 0, 1, -1)
|
||||||
else:
|
else:
|
||||||
c = 0
|
for c in range(0, len(w.widgets), 2):
|
||||||
while c < len(w.widgets):
|
|
||||||
w.widgets[c].setBuddy(w.widgets[c+1])
|
w.widgets[c].setBuddy(w.widgets[c+1])
|
||||||
layout.addWidget(w.widgets[c], row, c%2)
|
layout.addWidget(w.widgets[c], row, 0)
|
||||||
layout.addWidget(w.widgets[c+1], row, (c+1)%2)
|
layout.addWidget(w.widgets[c+1], row, 1)
|
||||||
c += 2
|
|
||||||
row += 1
|
row += 1
|
||||||
items = []
|
items = []
|
||||||
if len(ans) > 0:
|
if len(ans) > 0:
|
||||||
|
@ -57,7 +57,9 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
self.__custom_col_layouts = [layout]
|
self.__custom_col_layouts = [layout]
|
||||||
ans = self.custom_column_widgets
|
ans = self.custom_column_widgets
|
||||||
for i in range(len(ans)-1):
|
for i in range(len(ans)-1):
|
||||||
w.setTabOrder(ans[i].widgets[1], ans[i+1].widgets[1])
|
w.setTabOrder(ans[i].widgets[-1], ans[i+1].widgets[1])
|
||||||
|
for c in range(2, len(ans[i].widgets), 2):
|
||||||
|
w.setTabOrder(ans[i].widgets[c-1], ans[i].widgets[c+1])
|
||||||
|
|
||||||
def initialize_combos(self):
|
def initialize_combos(self):
|
||||||
self.initalize_authors()
|
self.initalize_authors()
|
||||||
|
@ -74,6 +74,7 @@ class SearchBox2(QComboBox):
|
|||||||
self.setMaxCount(self.MAX_COUNT)
|
self.setMaxCount(self.MAX_COUNT)
|
||||||
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
|
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
|
||||||
self.setMinimumContentsLength(25)
|
self.setMinimumContentsLength(25)
|
||||||
|
self._in_a_search = False
|
||||||
|
|
||||||
def initialize(self, opt_name, colorize=False,
|
def initialize(self, opt_name, colorize=False,
|
||||||
help_text=_('Search')):
|
help_text=_('Search')):
|
||||||
@ -93,6 +94,7 @@ class SearchBox2(QComboBox):
|
|||||||
self.help_state = False
|
self.help_state = False
|
||||||
|
|
||||||
def clear_to_help(self):
|
def clear_to_help(self):
|
||||||
|
self._in_a_search = False
|
||||||
self.setEditText(self.help_text)
|
self.setEditText(self.help_text)
|
||||||
self.line_edit.home(False)
|
self.line_edit.home(False)
|
||||||
self.help_state = True
|
self.help_state = True
|
||||||
@ -111,6 +113,7 @@ class SearchBox2(QComboBox):
|
|||||||
def search_done(self, ok):
|
def search_done(self, ok):
|
||||||
if not unicode(self.currentText()).strip():
|
if not unicode(self.currentText()).strip():
|
||||||
return self.clear_to_help()
|
return self.clear_to_help()
|
||||||
|
self._in_a_search = ok
|
||||||
col = 'rgba(0,255,0,20%)' if ok else 'rgb(255,0,0,20%)'
|
col = 'rgba(0,255,0,20%)' if ok else 'rgb(255,0,0,20%)'
|
||||||
if not self.colorize:
|
if not self.colorize:
|
||||||
col = self.normal_background
|
col = self.normal_background
|
||||||
@ -184,6 +187,8 @@ class SearchBox2(QComboBox):
|
|||||||
def search_as_you_type(self, enabled):
|
def search_as_you_type(self, enabled):
|
||||||
self.as_you_type = enabled
|
self.as_you_type = enabled
|
||||||
|
|
||||||
|
def in_a_search(self):
|
||||||
|
return self._in_a_search
|
||||||
|
|
||||||
class SavedSearchBox(QComboBox):
|
class SavedSearchBox(QComboBox):
|
||||||
|
|
||||||
|
@ -835,20 +835,20 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.restriction_count_of_books_in_view += c - self.restriction_count_of_books_in_library
|
self.restriction_count_of_books_in_view += c - self.restriction_count_of_books_in_library
|
||||||
self.restriction_count_of_books_in_library = c
|
self.restriction_count_of_books_in_library = c
|
||||||
if self.restriction_in_effect:
|
if self.restriction_in_effect:
|
||||||
self.set_number_of_books_shown(all='not used', compute_count=False)
|
self.set_number_of_books_shown(compute_count=False)
|
||||||
|
|
||||||
def mark_restriction_set(self, r):
|
def mark_restriction_set(self, r):
|
||||||
self.restriction_in_effect = False if r is None or not r else True
|
self.restriction_in_effect = False if r is None or not r else True
|
||||||
|
|
||||||
def set_number_of_books_shown(self, all, compute_count):
|
def set_number_of_books_shown(self, compute_count):
|
||||||
if self.restriction_in_effect:
|
if self.current_view() == self.library_view and self.restriction_in_effect:
|
||||||
if compute_count:
|
if compute_count:
|
||||||
self.restriction_count_of_books_in_view = self.current_view().row_count()
|
self.restriction_count_of_books_in_view = self.current_view().row_count()
|
||||||
t = _("({0} of {1})").format(self.current_view().row_count(),
|
t = _("({0} of {1})").format(self.current_view().row_count(),
|
||||||
self.restriction_count_of_books_in_view)
|
self.restriction_count_of_books_in_view)
|
||||||
self.search_count.setStyleSheet('QLabel { border-radius: 8px; background-color: yellow; }')
|
self.search_count.setStyleSheet('QLabel { border-radius: 8px; background-color: yellow; }')
|
||||||
else: # No restriction
|
else: # No restriction or not library view
|
||||||
if all == 'yes':
|
if not self.search.in_a_search():
|
||||||
t = _("(all books)")
|
t = _("(all books)")
|
||||||
else:
|
else:
|
||||||
t = _("({0} of all)").format(self.current_view().row_count())
|
t = _("({0} of all)").format(self.current_view().row_count())
|
||||||
@ -857,18 +857,18 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.search_count.setText(t)
|
self.search_count.setText(t)
|
||||||
|
|
||||||
def search_box_cleared(self):
|
def search_box_cleared(self):
|
||||||
self.set_number_of_books_shown(all='yes', compute_count=True)
|
self.set_number_of_books_shown(compute_count=True)
|
||||||
self.tags_view.clear()
|
self.tags_view.clear()
|
||||||
self.saved_search.clear_to_help()
|
self.saved_search.clear_to_help()
|
||||||
|
|
||||||
def search_clear(self):
|
def search_clear(self):
|
||||||
self.set_number_of_books_shown(all='yes', compute_count=True)
|
self.set_number_of_books_shown(compute_count=True)
|
||||||
self.search.clear()
|
self.search.clear()
|
||||||
|
|
||||||
def search_done(self, view, ok):
|
def search_done(self, view, ok):
|
||||||
if view is self.current_view():
|
if view is self.current_view():
|
||||||
self.set_number_of_books_shown(all='no', compute_count=False)
|
|
||||||
self.search.search_done(ok)
|
self.search.search_done(ok)
|
||||||
|
self.set_number_of_books_shown(compute_count=False)
|
||||||
|
|
||||||
def sync_cf_to_listview(self, current, previous):
|
def sync_cf_to_listview(self, current, previous):
|
||||||
if self.cover_flow_sync_flag and self.cover_flow.isVisible() and \
|
if self.cover_flow_sync_flag and self.cover_flow.isVisible() and \
|
||||||
@ -2297,6 +2297,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.view_menu.actions()[1].setEnabled(True)
|
self.view_menu.actions()[1].setEnabled(True)
|
||||||
self.action_open_containing_folder.setEnabled(True)
|
self.action_open_containing_folder.setEnabled(True)
|
||||||
self.action_sync.setEnabled(True)
|
self.action_sync.setEnabled(True)
|
||||||
|
self.search_restriction.setEnabled(True)
|
||||||
for action in list(self.delete_menu.actions())[1:]:
|
for action in list(self.delete_menu.actions())[1:]:
|
||||||
action.setEnabled(True)
|
action.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
@ -2306,8 +2307,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
self.view_menu.actions()[1].setEnabled(False)
|
self.view_menu.actions()[1].setEnabled(False)
|
||||||
self.action_open_containing_folder.setEnabled(False)
|
self.action_open_containing_folder.setEnabled(False)
|
||||||
self.action_sync.setEnabled(False)
|
self.action_sync.setEnabled(False)
|
||||||
|
self.search_restriction.setEnabled(False)
|
||||||
for action in list(self.delete_menu.actions())[1:]:
|
for action in list(self.delete_menu.actions())[1:]:
|
||||||
action.setEnabled(False)
|
action.setEnabled(False)
|
||||||
|
self.set_number_of_books_shown(compute_count=False)
|
||||||
|
|
||||||
|
|
||||||
def device_job_exception(self, job):
|
def device_job_exception(self, job):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user