From 79987ee09d442f461811955316cc07007a4914c6 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Thu, 7 Nov 2013 13:11:31 +0100 Subject: [PATCH] Quickview changes: 1) Close the quickview window on library change. Keeping track of what should be shown in the new library wasn't working. 2) Add keyboard shortcuts to move between quickview's controls. 3) Add a checkbox to "lock" quickview's contents, preventing their change when moving around on the main spreadsheet. --- src/calibre/gui2/actions/show_quickview.py | 2 +- src/calibre/gui2/dialogs/quickview.py | 27 ++++++++-------- src/calibre/gui2/dialogs/quickview.ui | 36 ++++++++++++++++++++-- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/calibre/gui2/actions/show_quickview.py b/src/calibre/gui2/actions/show_quickview.py index b80ba2e6e0..a34d758f71 100644 --- a/src/calibre/gui2/actions/show_quickview.py +++ b/src/calibre/gui2/actions/show_quickview.py @@ -47,4 +47,4 @@ def change_quickview_column(self, idx): def library_changed(self, db): if self.current_instance and not self.current_instance.is_closed: - self.current_instance.set_database(db) + self.current_instance.reject() diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py index 8763501391..ebd75cc1e3 100644 --- a/src/calibre/gui2/dialogs/quickview.py +++ b/src/calibre/gui2/dialogs/quickview.py @@ -6,7 +6,7 @@ from PyQt4.Qt import (Qt, QDialog, QAbstractItemView, QTableWidgetItem, QListWidgetItem, QByteArray, QCoreApplication, - QApplication, pyqtSignal) + QApplication, pyqtSignal, QDialogButtonBox) from calibre.customize.ui import find_plugin from calibre.gui2 import gprefs @@ -112,14 +112,8 @@ def __init__(self, gui, view, row): self.search_button.clicked.connect(self.do_search) view.model().new_bookdisplay_data.connect(self.book_was_changed) - def set_database(self, db): - self.db = db - self.items.blockSignals(True) - self.books_table.blockSignals(True) - self.items.clear() - self.books_table.setRowCount(0) - self.books_table.blockSignals(False) - self.items.blockSignals(False) + close_button = self.buttonBox.button(QDialogButtonBox.Close) + close_button.setAutoDefault(False) # search button def do_search(self): @@ -138,7 +132,7 @@ def book_was_changed(self, mi): # view is changed, triggering a book_was_changed signal. Unfortunately # this happens before the library_changed actions are run, meaning we # still have the old database. To avoid the problem we just ignore the - # operation if we get an exception. The set_database will come + # operation if we get an exception. The "close" will come # eventually. try: self.refresh(self.view.model().index(self.db.row(mi.id), self.current_column)) @@ -153,6 +147,9 @@ def item_selected(self, txt): # Given a cell in the library view, display the information def refresh(self, idx): + if self.lock_qv.isChecked(): + return + bv_row = idx.row() self.current_column = idx.column() key = self.view.model().column_map[self.current_column] @@ -167,7 +164,7 @@ def refresh(self, idx): self.indicate_no_items() return key = self.current_key - self.items_label.setText('{0} ({1})'.format( + self.items_label.setText(_('&Item: {0} ({1})').format( self.db.field_metadata[key]['name'], key)) self.items.blockSignals(True) @@ -219,7 +216,7 @@ def fill_in_books_box(self, selected_item): sort_results=False) self.books_table.setRowCount(len(books)) - self.books_label.setText(_('Books with selected item "{0}": {1}'). + self.books_label.setText(_('&Books with selected item "{0}": {1}'). format(selected_item, len(books))) select_item = None @@ -296,7 +293,7 @@ def save_state(self): gprefs['quickview_dialog_books_table_widths'] = self.books_table_column_widths gprefs['quickview_dialog_geometry'] = bytearray(self.saveGeometry()) - def close(self): + def _close(self): self.save_state() # clean up to prevent memory leaks self.db = self.view = self.gui = None @@ -304,10 +301,10 @@ def close(self): # called by the window system def closeEvent(self, *args): - self.close() + self._close() QDialog.closeEvent(self, *args) # called by the close button def reject(self): - self.close() + self._close() QDialog.reject(self) \ No newline at end of file diff --git a/src/calibre/gui2/dialogs/quickview.ui b/src/calibre/gui2/dialogs/quickview.ui index 4b040e34d3..3bd909288f 100644 --- a/src/calibre/gui2/dialogs/quickview.ui +++ b/src/calibre/gui2/dialogs/quickview.ui @@ -22,8 +22,8 @@ - - Items + + items @@ -39,6 +39,9 @@ + + books_table + @@ -59,14 +62,41 @@ + + + + &Lock Quickview contents + + + Select to prevent Quickview from changing content when the + selection on the library view is changed + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + - Search + &Search Search in the library view for the selected item + + false +