diff --git a/resources/images/reports.png b/resources/images/reports.png new file mode 100644 index 0000000000..7dfa558a14 Binary files /dev/null and b/resources/images/reports.png differ diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 1b41d960c7..a606e63de7 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -129,6 +129,7 @@ class Boss(QObject): self.gui.manage_fonts.container_changed.connect(self.apply_container_update_to_gui) self.gui.manage_fonts.embed_all_fonts.connect(self.manage_fonts_embed) self.gui.manage_fonts.subset_all_fonts.connect(self.manage_fonts_subset) + self.gui.reports.edit_requested.connect(self.report_edit_requested) @property def currently_editing(self): @@ -1151,6 +1152,17 @@ class Boss(QObject): self.gui.image_browser.show() self.gui.image_browser.raise_() + def show_reports(self): + self.gui.reports.refresh() + self.gui.reports.show() + self.gui.reports.raise_() + + def report_edit_requested(self, name, location=None): + mt = current_container().mime_map.get(name, guess_type(name)) + editor = self.edit_file_requested(name, None, mt) + if editor is None and location is not None: + pass + def image_activated(self, name): mt = current_container().mime_map.get(name, guess_type(name)) self.edit_file_requested(name, None, mt) diff --git a/src/calibre/gui2/tweak_book/reports.py b/src/calibre/gui2/tweak_book/reports.py index e3f637826c..b398d51610 100644 --- a/src/calibre/gui2/tweak_book/reports.py +++ b/src/calibre/gui2/tweak_book/reports.py @@ -175,7 +175,7 @@ class FilesWidget(QWidget): human_readable, (m.total_size, m.images_size, m.fonts_size)))) def double_clicked(self, index): - name = self.model.name(index) + name = self.model.name(self.proxy.mapToSource(index)) if name is not None: self.edit_requested.emit(name, None) @@ -231,6 +231,7 @@ class Reports(Dialog): def __init__(self, parent=None): Dialog.__init__(self, _('Reports'), 'reports-dialog', parent=parent) self.data_gathered.connect(self.display_data, type=Qt.QueuedConnection) + self.setAttribute(Qt.WA_DeleteOnClose, False) def setup_ui(self): self.l = l = QVBoxLayout(self) diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 4cb13b4100..81043a778b 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -38,6 +38,7 @@ from calibre.gui2.tweak_book.search import SavedSearches from calibre.gui2.tweak_book.toc import TOCViewer from calibre.gui2.tweak_book.char_select import CharSelect from calibre.gui2.tweak_book.live_css import LiveCSS +from calibre.gui2.tweak_book.reports import Reports from calibre.gui2.tweak_book.manage_fonts import ManageFonts from calibre.gui2.tweak_book.function_replace import DebugOutput from calibre.gui2.tweak_book.editor.widget import register_text_editor_actions @@ -238,6 +239,7 @@ class Main(MainWindow): self.toc_view = TOCViewer(self) self.saved_searches = SavedSearches(self) self.image_browser = InsertImage(self, for_browsing=True) + self.reports = Reports(self) self.insert_char = CharSelect(self) self.manage_fonts = ManageFonts(self) self.sr_debug_output = DebugOutput(self) @@ -368,6 +370,8 @@ class Main(MainWindow): _('Filter style information')) self.action_manage_fonts = treg('font.png', _('Manage &fonts'), self.boss.manage_fonts, 'manage-fonts', (), _('Manage fonts in the book')) self.action_add_cover = treg('default_cover.png', _('Add &cover'), self.boss.add_cover, 'add-cover', (), _('Add a cover to the book')) + self.action_reports = treg( + 'reports.png', _('&Reports'), self.boss.show_reports, 'show-reports', ('Ctrl+Shift+R',), _('Show a report on various aspects of the book')) def ereg(icon, text, target, sid, keys, description): return reg(icon, text, partial(self.boss.editor_action, target), sid, keys, description) @@ -525,6 +529,7 @@ class Main(MainWindow): e.addAction(self.action_filter_css) e.addAction(self.action_spell_check_book) e.addAction(self.action_check_book) + e.addAction(self.action_reports) e = b.addMenu(_('&View')) t = e.addMenu(_('Tool&bars'))