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):
|
||||
|
||||
def setup_ui(self, parent):
|
||||
self.widgets = [QLabel('&'+self.col_metadata['name'], parent),
|
||||
self.widgets = [QLabel('&'+self.col_metadata['name']+':', parent),
|
||||
QComboBox(parent)]
|
||||
w = self.widgets[1]
|
||||
items = [_('Yes'), _('No'), _('Undefined')]
|
||||
@ -57,7 +57,6 @@ class Bool(Base):
|
||||
for icon, text in zip(icons, items):
|
||||
w.addItem(QIcon(icon), text)
|
||||
|
||||
|
||||
def setter(self, val):
|
||||
val = {None: 2, False: 1, True: 0}[val]
|
||||
if tweaks['bool_custom_columns_are_tristate'] == 'no' and val == 2:
|
||||
@ -338,12 +337,14 @@ class BulkText(BulkBase):
|
||||
if self.col_metadata['is_multiple']:
|
||||
w = TagsLineEdit(parent, values)
|
||||
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
|
||||
|
||||
w = TagsLineEdit(parent, values)
|
||||
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.removing_widget = w
|
||||
else:
|
||||
@ -413,12 +414,10 @@ def populate_bulk_metadata_page(layout, db, book_ids, parent=None):
|
||||
if len(w.widgets) == 1:
|
||||
layout.addWidget(w.widgets[0], row, 0, 1, -1)
|
||||
else:
|
||||
c = 0
|
||||
while c < len(w.widgets):
|
||||
for c in range(0, len(w.widgets), 2):
|
||||
w.widgets[c].setBuddy(w.widgets[c+1])
|
||||
layout.addWidget(w.widgets[c], row, c%2)
|
||||
layout.addWidget(w.widgets[c+1], row, (c+1)%2)
|
||||
c += 2
|
||||
layout.addWidget(w.widgets[c], row, 0)
|
||||
layout.addWidget(w.widgets[c+1], row, 1)
|
||||
row += 1
|
||||
items = []
|
||||
if len(ans) > 0:
|
||||
|
@ -57,7 +57,9 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
||||
self.__custom_col_layouts = [layout]
|
||||
ans = self.custom_column_widgets
|
||||
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):
|
||||
self.initalize_authors()
|
||||
|
@ -74,6 +74,7 @@ class SearchBox2(QComboBox):
|
||||
self.setMaxCount(self.MAX_COUNT)
|
||||
self.setSizeAdjustPolicy(self.AdjustToMinimumContentsLengthWithIcon)
|
||||
self.setMinimumContentsLength(25)
|
||||
self._in_a_search = False
|
||||
|
||||
def initialize(self, opt_name, colorize=False,
|
||||
help_text=_('Search')):
|
||||
@ -93,6 +94,7 @@ class SearchBox2(QComboBox):
|
||||
self.help_state = False
|
||||
|
||||
def clear_to_help(self):
|
||||
self._in_a_search = False
|
||||
self.setEditText(self.help_text)
|
||||
self.line_edit.home(False)
|
||||
self.help_state = True
|
||||
@ -111,6 +113,7 @@ class SearchBox2(QComboBox):
|
||||
def search_done(self, ok):
|
||||
if not unicode(self.currentText()).strip():
|
||||
return self.clear_to_help()
|
||||
self._in_a_search = ok
|
||||
col = 'rgba(0,255,0,20%)' if ok else 'rgb(255,0,0,20%)'
|
||||
if not self.colorize:
|
||||
col = self.normal_background
|
||||
@ -184,6 +187,8 @@ class SearchBox2(QComboBox):
|
||||
def search_as_you_type(self, enabled):
|
||||
self.as_you_type = enabled
|
||||
|
||||
def in_a_search(self):
|
||||
return self._in_a_search
|
||||
|
||||
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_library = c
|
||||
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):
|
||||
self.restriction_in_effect = False if r is None or not r else True
|
||||
|
||||
def set_number_of_books_shown(self, all, compute_count):
|
||||
if self.restriction_in_effect:
|
||||
def set_number_of_books_shown(self, compute_count):
|
||||
if self.current_view() == self.library_view and self.restriction_in_effect:
|
||||
if compute_count:
|
||||
self.restriction_count_of_books_in_view = self.current_view().row_count()
|
||||
t = _("({0} of {1})").format(self.current_view().row_count(),
|
||||
self.restriction_count_of_books_in_view)
|
||||
self.search_count.setStyleSheet('QLabel { border-radius: 8px; background-color: yellow; }')
|
||||
else: # No restriction
|
||||
if all == 'yes':
|
||||
else: # No restriction or not library view
|
||||
if not self.search.in_a_search():
|
||||
t = _("(all books)")
|
||||
else:
|
||||
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)
|
||||
|
||||
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.saved_search.clear_to_help()
|
||||
|
||||
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()
|
||||
|
||||
def search_done(self, view, ok):
|
||||
if view is self.current_view():
|
||||
self.set_number_of_books_shown(all='no', compute_count=False)
|
||||
self.search.search_done(ok)
|
||||
self.set_number_of_books_shown(compute_count=False)
|
||||
|
||||
def sync_cf_to_listview(self, current, previous):
|
||||
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.action_open_containing_folder.setEnabled(True)
|
||||
self.action_sync.setEnabled(True)
|
||||
self.search_restriction.setEnabled(True)
|
||||
for action in list(self.delete_menu.actions())[1:]:
|
||||
action.setEnabled(True)
|
||||
else:
|
||||
@ -2306,8 +2307,10 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.view_menu.actions()[1].setEnabled(False)
|
||||
self.action_open_containing_folder.setEnabled(False)
|
||||
self.action_sync.setEnabled(False)
|
||||
self.search_restriction.setEnabled(False)
|
||||
for action in list(self.delete_menu.actions())[1:]:
|
||||
action.setEnabled(False)
|
||||
self.set_number_of_books_shown(compute_count=False)
|
||||
|
||||
|
||||
def device_job_exception(self, job):
|
||||
|
Loading…
x
Reference in New Issue
Block a user