mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Merge branch 'lazy-operations-look_feel' of https://github.com/un-pogaz/calibre
This commit is contained in:
commit
d8168dd59c
@ -36,6 +36,7 @@ from qt.core import (
|
|||||||
Qt,
|
Qt,
|
||||||
QTableWidget,
|
QTableWidget,
|
||||||
QTableWidgetItem,
|
QTableWidgetItem,
|
||||||
|
QTabWidget,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QWidget,
|
QWidget,
|
||||||
pyqtSignal,
|
pyqtSignal,
|
||||||
@ -692,8 +693,16 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.css_highlighter = get_highlighter('css')()
|
self.css_highlighter = get_highlighter('css')()
|
||||||
self.css_highlighter.apply_theme(get_theme(None))
|
self.css_highlighter.apply_theme(get_theme(None))
|
||||||
self.css_highlighter.set_document(self.opt_book_details_css.document())
|
self.css_highlighter.set_document(self.opt_book_details_css.document())
|
||||||
|
self.lazy_tabs = {}
|
||||||
for i in range(self.tabWidget.count()):
|
for i in range(self.tabWidget.count()):
|
||||||
self.sections_view.addItem(QListWidgetItem(self.tabWidget.tabIcon(i), self.tabWidget.tabText(i).replace('&', '')))
|
self.sections_view.addItem(QListWidgetItem(self.tabWidget.tabIcon(i), self.tabWidget.tabText(i).replace('&', '')))
|
||||||
|
# retrieve tabs and subtabs of look & feel to load their content later when clicking of them
|
||||||
|
w = self.tabWidget.widget(i).widget()
|
||||||
|
self.lazy_tabs[(i, None)] = w
|
||||||
|
if isinstance(w, QTabWidget):
|
||||||
|
w.currentChanged.connect(partial(self.lazy_tab_operations, i))
|
||||||
|
for ii in range(w.count()):
|
||||||
|
self.lazy_tabs[(i, ii)] = w.widget(ii)
|
||||||
self.sections_view.setCurrentRow(self.tabWidget.currentIndex())
|
self.sections_view.setCurrentRow(self.tabWidget.currentIndex())
|
||||||
self.sections_view.currentRowChanged.connect(self.tabWidget.setCurrentIndex)
|
self.sections_view.currentRowChanged.connect(self.tabWidget.setCurrentIndex)
|
||||||
self.sections_view.setMaximumWidth(self.sections_view.sizeHintForColumn(0) + 16)
|
self.sections_view.setMaximumWidth(self.sections_view.sizeHintForColumn(0) + 16)
|
||||||
@ -854,6 +863,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.tb_focus_label.setVisible(self.opt_tag_browser_allow_keyboard_focus.isChecked())
|
self.tb_focus_label.setVisible(self.opt_tag_browser_allow_keyboard_focus.isChecked())
|
||||||
self.update_color_palette_state()
|
self.update_color_palette_state()
|
||||||
self.opt_gui_layout.setCurrentIndex(0 if self.gui.layout_container.is_wide else 1)
|
self.opt_gui_layout.setCurrentIndex(0 if self.gui.layout_container.is_wide else 1)
|
||||||
|
self.lazy_tab_operations(self.tabWidget.currentIndex(), None)
|
||||||
|
|
||||||
def open_cg_cache(self):
|
def open_cg_cache(self):
|
||||||
open_local_file(self.gui.grid_view.thumbnail_cache.location)
|
open_local_file(self.gui.grid_view.thumbnail_cache.location)
|
||||||
@ -863,9 +873,20 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
_('Current space used: %s') % human_readable(size))
|
_('Current space used: %s') % human_readable(size))
|
||||||
|
|
||||||
def tab_changed(self, index):
|
def tab_changed(self, index):
|
||||||
|
self.lazy_tab_operations(index, None)
|
||||||
if self.tabWidget.currentWidget() is self.cover_grid_tab:
|
if self.tabWidget.currentWidget() is self.cover_grid_tab:
|
||||||
self.show_current_cache_usage()
|
self.show_current_cache_usage()
|
||||||
|
|
||||||
|
def lazy_tab_operations(self, idx_section, idx_subtab):
|
||||||
|
'''
|
||||||
|
Check if the tab has lazy operations.
|
||||||
|
Perfom the lazy operations only once, the first time the tab is selected.
|
||||||
|
'''
|
||||||
|
tab = self.lazy_tabs.get((idx_section, idx_subtab), None)
|
||||||
|
if hasattr(tab, 'lazy_populate_content'):
|
||||||
|
tab.lazy_populate_content()
|
||||||
|
self.lazy_tabs.pop((idx_section, idx_subtab), None)
|
||||||
|
|
||||||
def show_current_cache_usage(self):
|
def show_current_cache_usage(self):
|
||||||
t = Thread(target=self.calc_cache_size)
|
t = Thread(target=self.calc_cache_size)
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
|
@ -141,8 +141,14 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form):
|
|||||||
self.tb_icon_rules_groupbox.setContentsMargins(0, 0, 0, 0)
|
self.tb_icon_rules_groupbox.setContentsMargins(0, 0, 0, 0)
|
||||||
self.tb_icon_rules_gridlayout.setContentsMargins(2, 2, 2, 2)
|
self.tb_icon_rules_gridlayout.setContentsMargins(2, 2, 2, 2)
|
||||||
|
|
||||||
field_metadata = gui.current_db.field_metadata
|
try:
|
||||||
category_icons = gui.tags_view.model().category_custom_icons
|
self.table_column_widths = gprefs.get('tag_browser_rules_dialog_table_widths', None)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def lazy_populate_content(self):
|
||||||
|
field_metadata = self.gui.current_db.field_metadata
|
||||||
|
category_icons = self.gui.tags_view.model().category_custom_icons
|
||||||
v = gprefs['tags_browser_value_icons']
|
v = gprefs['tags_browser_value_icons']
|
||||||
row = 0
|
row = 0
|
||||||
for category,vdict in v.items():
|
for category,vdict in v.items():
|
||||||
@ -170,11 +176,6 @@ class TbIconRulesTab(ConfigTabWidget, Ui_Form):
|
|||||||
self.do_sort(VALUE_COLUMN)
|
self.do_sort(VALUE_COLUMN)
|
||||||
self.do_sort(CATEGORY_COLUMN)
|
self.do_sort(CATEGORY_COLUMN)
|
||||||
|
|
||||||
try:
|
|
||||||
self.table_column_widths = gprefs.get('tag_browser_rules_dialog_table_widths', None)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def show_context_menu(self, point):
|
def show_context_menu(self, point):
|
||||||
clicked_item = self.rules_table.itemAt(point)
|
clicked_item = self.rules_table.itemAt(point)
|
||||||
if clicked_item is None:
|
if clicked_item is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user