From 95db631c4a89c8cd1cddcc22b10203601655eef7 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 10:56:17 +0200 Subject: [PATCH 1/7] Give Quickview its own icon Icon comes from https://www.iconfinder.com/icons/2191555/eye_look_no_hide_see_show_watch_icon#size=128 --- resources/images/eye-quickview.png | Bin 0 -> 6529 bytes src/calibre/gui2/actions/show_quickview.py | 2 +- src/calibre/gui2/preferences/look_feel.ui | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 resources/images/eye-quickview.png diff --git a/resources/images/eye-quickview.png b/resources/images/eye-quickview.png new file mode 100644 index 0000000000000000000000000000000000000000..a928c201fae42fd9d6f7eedd3e331da228aac95a GIT binary patch literal 6529 zcma)B^;Zyqy&~&8iA!_X{3=*x;vxvY{IQKuGalU;xrHX#fCPkc#|UU9Zf;EN?H}nT4)E0mGM1LIEnu ze^|uH46(6w!5-Z>TveqrEfXKL%k?|ar8D`jnj4&SlgBV~I8|}vd-Itn7j$!<)Nva9 zp&}dydpyZ{m44$e6)98+wX-Vt~m!1oTYi4_ra=h6SP zOH=+GoCc1Kv4bCj)d%Pfx*yPCAh9E5zIyrt_lj45L!w39>y>rmj85oVeLWy76>2=A_!T%t6`(`qIxC2`qh)*3e$_InMj#P zE+Z*u7}gJ?^q8BT`bp6x;L$mlPc|83I6yHqAB%_{X$M`aWZ7%x!?Zmd=SvFODZ4la zoE`WYlG&Lsyz7qS+|Ok;F;O%0tqH&iYT)>j9o(Kd`l@|+3YL|Jl8|(jK+H6P@q4w? z3okYU%o-MuaTLrxGf^H>hpb(EeyX1QTM*wxH775v7v6lZd)-Q}F)e>YC-E|Do-F3J zxFQk4GA~H57vS5hJ4-e8uFw(_kxTbUYJ5y4>n?%$S|-6qPVyht7zUEYc1*OZt!0(G zbVYql0?Xt601`HG#*OKDYYZ-(4Z*sS{0z!aLkt6s)RgU! zVAu7)EkeBOIvy60SW?CJk(vI1l)p*%izLe*ik$S+w1mmpO1;*9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F<*8EJ$?(z=3-$LC-&OU#xuX=P8gRKW03SJX zdyMV40#ur<~Qbj3?rH!xj zS40rV@9-ypN$e+nVU-kpeu*EX%F1t&8B5gLPNw6^zy3{? - :/images/search.png:/images/search.png + :/images/eye-quickview.png:/images/eye-quickview.png &Quickview From 6fed620850dc163d8b89a4f779d6626bd1d37acc Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 15:30:56 +0200 Subject: [PATCH 2/7] Several QV improvements and bug fixes - Add quickview to the layout buttons, with all that entails - Allow changing quickview contents using the arrow keys on the booklist - Make Shift+Q (change focus to Quickview) actually work. I can't test this on non-Windows systems. - A fair amount of refactoring to make behavior more predictable. I put the quickview button at the end of the set of layout buttons because I couldn't make an argument for some other position. --- src/calibre/gui2/__init__.py | 2 +- src/calibre/gui2/actions/show_quickview.py | 91 +++++++++++++++++----- src/calibre/gui2/dialogs/quickview.py | 43 +++++++--- src/calibre/gui2/dialogs/quickview.ui | 26 +------ src/calibre/gui2/init.py | 19 ++++- src/calibre/gui2/preferences/look_feel.py | 2 +- src/calibre/gui2/preferences/look_feel.ui | 19 +++-- src/calibre/gui2/ui.py | 12 +-- 8 files changed, 145 insertions(+), 69 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 4950c76745..1313241101 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -155,7 +155,7 @@ def create_defs(): defs['qv_respects_vls'] = True defs['qv_dclick_changes_column'] = True defs['qv_retkey_changes_column'] = True - defs['qv_show_on_startup'] = False + defs['qv_follows_column'] = False create_defs() diff --git a/src/calibre/gui2/actions/show_quickview.py b/src/calibre/gui2/actions/show_quickview.py index 1c5d58df40..ba80a802ff 100644 --- a/src/calibre/gui2/actions/show_quickview.py +++ b/src/calibre/gui2/actions/show_quickview.py @@ -10,8 +10,37 @@ from PyQt5.Qt import QAction from calibre.gui2.actions import InterfaceAction from calibre.gui2.dialogs.quickview import Quickview -from calibre.gui2 import error_dialog +from calibre.gui2 import error_dialog, gprefs +from calibre.gui2.widgets import LayoutButton +class QuickviewButton(LayoutButton): # {{{ + + def __init__(self, gui, quickview_manager): + self.qv = quickview_manager + qaction = quickview_manager.qaction + LayoutButton.__init__(self, I('eye-quickview.png'), _('Quickview'), + parent=gui, shortcut=qaction.shortcut().toString()) + self.action_toggle = qaction + self.action_toggle.triggered.connect(self.toggle) + self.action_toggle.changed.connect(self.update_shortcut) + + def update_state(self, checked): + if checked: + self.set_state_to_hide() + self.qv._show_quickview() + else: + self.set_state_to_show() + self.qv._hide_quickview() + + def save_state(self): + gprefs['quickview visible'] = bool(self.isChecked()) + + def restore_state(self): + self.toggled.connect(self.update_state) + if gprefs.get('quickview visible', False): + self.toggle() + +# }}} class ShowQuickviewAction(InterfaceAction): @@ -23,8 +52,6 @@ class ShowQuickviewAction(InterfaceAction): current_instance = None def genesis(self): - self.qaction.triggered.connect(self.show_quickview) - self.focus_action = QAction(self.gui) self.gui.addAction(self.focus_action) self.gui.keyboard.register_shortcut('Focus To Quickview', _('Focus to Quickview'), @@ -42,55 +69,83 @@ class ShowQuickviewAction(InterfaceAction): self.search_action.triggered.connect(self.search_quickview) self.search_action.changed.connect(self.set_search_shortcut) self.menuless_qaction.changed.connect(self.set_search_shortcut) + self.qv_button = QuickviewButton(self.gui, self) - def show_quickview(self, *args): + def _hide_quickview(self): + ''' + This is called only from the QV button toggle + ''' if self.current_instance: if not self.current_instance.is_closed: - self.current_instance.reject() - self.current_instance = None - return + self.current_instance._reject() + self.current_instance = None + + def _show_quickview(self, *args): + ''' + This is called only from the QV button toggle + ''' + if self.current_instance: + if not self.current_instance.is_closed: + self.current_instance._reject() self.current_instance = None if self.gui.current_view() is not self.gui.library_view: error_dialog(self.gui, _('No quickview available'), _('Quickview is not available for books ' 'on the device.')).exec_() return + self.qv_button.set_state_to_hide() index = self.gui.library_view.currentIndex() self.current_instance = Quickview(self.gui, index) - self.current_instance.reopen_quickview.connect(self.reopen_quickview) + self.current_instance.reopen_after_dock_change.connect(self.open_quickview) self.set_search_shortcut() self.current_instance.show() + self.current_instance.quickview_closed.connect(self.qv_button.set_state_to_show) def set_search_shortcut(self): if self.current_instance and not self.current_instance.is_closed: self.current_instance.set_shortcuts(self.search_action.shortcut().toString(), self.menuless_qaction.shortcut().toString()) - def reopen_quickview(self): + def open_quickview(self): + ''' + QV moved from/to dock. Close and reopen the pane/window. + Also called when QV is closed and the user asks to move the focus + ''' if self.current_instance and not self.current_instance.is_closed: self.current_instance.reject() self.current_instance = None - self.show_quickview() + self.qaction.triggered.emit() def refill_quickview(self): + ''' + Called when the data or the columns shown in the QV pane might have changed. + ''' if self.current_instance and not self.current_instance.is_closed: self.current_instance.refill() def change_quickview_column(self, idx): - self.show_quickview() - if self.current_instance: - if self.current_instance.is_closed: - return - self.current_instance.change_quickview_column.emit(idx) + ''' + Called from the column header context menu to change the QV query column + ''' + self.focus_quickview() + self.current_instance.slave(idx) def library_changed(self, db): + ''' + If QV is open, close it then reopen it so the columns are correct + ''' if self.current_instance and not self.current_instance.is_closed: self.current_instance.reject() + self.qaction.triggered.emit() def focus_quickview(self): - if not (self.current_instance and not self.current_instance.is_closed): - self.show_quickview() - self.current_instance.set_focus() + ''' + Used to move the focus to the QV books table. Open QV if needed + ''' + if not self.current_instance or self.current_instance.is_closed: + self.open_quickview() + else: + self.current_instance.set_focus() def search_quickview(self): if not self.current_instance or self.current_instance.is_closed: diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py index 8b7f5141d7..ead75afd2e 100644 --- a/src/calibre/gui2/dialogs/quickview.py +++ b/src/calibre/gui2/dialogs/quickview.py @@ -95,21 +95,22 @@ class WidgetTabFilter(QObject): class Quickview(QDialog, Ui_Quickview): - change_quickview_column = pyqtSignal(object) - reopen_quickview = pyqtSignal() - tab_pressed_signal = pyqtSignal(object, object) + reopen_after_dock_change = pyqtSignal() + tab_pressed_signal = pyqtSignal(object, object) + quickview_closed = pyqtSignal() def __init__(self, gui, row): self.is_pane = gprefs.get('quickview_is_pane', False) if not self.is_pane: - QDialog.__init__(self, gui, flags=Qt.Window) + QDialog.__init__(self, gui, flags=Qt.Widget) else: QDialog.__init__(self, gui) Ui_Quickview.__init__(self) self.setupUi(self) self.isClosed = False self.current_book = None + self.closed_by_button = False if self.is_pane: self.main_grid_layout.setContentsMargins(0, 0, 0, 0) @@ -160,7 +161,7 @@ class Quickview(QDialog, Ui_Quickview): focus_filter.focus_entered_signal.connect(self.focus_entered) self.books_table.installEventFilter(focus_filter) - self.close_button = self.buttonBox.button(QDialogButtonBox.Close) + self.close_button.clicked.connect(self.close_button_clicked) self.tab_order_widgets = [self.items, self.books_table, self.lock_qv, self.dock_button, self.search_button, self.close_button] @@ -194,7 +195,7 @@ class Quickview(QDialog, Ui_Quickview): self.refresh(row) self.view.clicked.connect(self.slave) - self.change_quickview_column.connect(self.slave) + self.view.selectionModel().currentColumnChanged.connect(self.column_slave) QCoreApplication.instance().aboutToQuit.connect(self.save_state) self.search_button.clicked.connect(self.do_search) self.view.model().new_bookdisplay_data.connect(self.book_was_changed) @@ -210,9 +211,8 @@ class Quickview(QDialog, Ui_Quickview): self.lock_qv.setText(_('Lock Quickview contents')) self.search_button.setText(_('Search')) self.gui.quickview_splitter.add_quickview_dialog(self) + self.close_button.setVisible(False) else: - self.close_button.setText(_('&Close')) - self.dock_button.setText(_('&Dock')) self.dock_button.setToolTip(_('Embed the quickview panel into the main calibre window')) self.dock_button.setIcon(QIcon(I('arrow-down.png'))) self.set_focus() @@ -314,7 +314,7 @@ class Quickview(QDialog, Ui_Quickview): def show_as_pane_changed(self): gprefs['quickview_is_pane'] = not gprefs.get('quickview_is_pane', False) - self.reopen_quickview.emit() + self.reopen_after_dock_change.emit() # search button def do_search(self): @@ -544,10 +544,20 @@ class Quickview(QDialog, Ui_Quickview): self.view.column_map.index(key)) def set_focus(self): - self.items.setFocus(Qt.ActiveWindowFocusReason) + self.activateWindow() + self.books_table.setFocus() + + def column_slave(self, current): + ''' + called when the column is changed on the booklist + ''' + if gprefs['qv_follows_column']: + self.slave(current) - # called when a book is clicked on the library view def slave(self, current): + ''' + called when a book is clicked on the library view + ''' if self.is_closed: return self.refresh(current) @@ -572,8 +582,17 @@ class Quickview(QDialog, Ui_Quickview): self.db = self.view = self.gui = None self.is_closed = True - # called by the close button + def close_button_clicked(self): + self.closed_by_button = True + self.quickview_closed.emit() + def reject(self): + if not self.closed_by_button: + self.close_button_clicked() + else: + self._reject() + + def _reject(self): if self.is_pane: self.gui.quickview_splitter.hide_quickview_widget() self.gui.library_view.setFocus(Qt.ActiveWindowFocusReason) diff --git a/src/calibre/gui2/dialogs/quickview.ui b/src/calibre/gui2/dialogs/quickview.ui index f0517e00b4..3f1b6c497c 100644 --- a/src/calibre/gui2/dialogs/quickview.ui +++ b/src/calibre/gui2/dialogs/quickview.ui @@ -149,11 +149,11 @@ - - - QDialogButtonBox::Close + + + &Close - + false @@ -176,22 +176,4 @@ - - - buttonBox - rejected() - Quickview - reject() - - - 297 - 217 - - - 286 - 234 - - - - diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py index 16aec295e9..75c3b7e406 100644 --- a/src/calibre/gui2/init.py +++ b/src/calibre/gui2/init.py @@ -23,6 +23,7 @@ from calibre.gui2.tag_browser.ui import TagBrowserWidget from calibre.gui2.book_details import BookDetails from calibre.gui2.notify import get_notifier from calibre.gui2.layout_menu import LayoutMenu +from calibre.customize.ui import find_plugin _keep_refs = [] @@ -552,7 +553,7 @@ class LayoutMixin(object): # {{{ self.bd_splitter.addWidget(self.book_details) self.bd_splitter.setCollapsible(self.bd_splitter.other_index, False) self.centralwidget.layout().addWidget(self.bd_splitter) - button_order = ('sb', 'tb', 'bd', 'gv', 'cb') + button_order = ('sb', 'tb', 'bd', 'gv', 'cb', 'qv') # }}} else: # wide {{{ self.bd_splitter = Splitter('book_details_splitter', @@ -567,9 +568,13 @@ class LayoutMixin(object): # {{{ self.bd_splitter.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.centralwidget.layout().addWidget(self.bd_splitter) - button_order = ('sb', 'tb', 'cb', 'gv', 'bd') + button_order = ('sb', 'tb', 'cb', 'gv', 'bd', 'qv') # }}} + self.qv = find_plugin('Show Quickview') + if self.qv: + self.qv = self.qv.actual_plugin_ + self.status_bar = StatusBar(self) stylename = unicode(self.style().objectName()) self.grid_view_button = GridViewButton(self) @@ -582,7 +587,12 @@ class LayoutMixin(object): # {{{ if hasattr(self, x + '_splitter'): button = getattr(self, x + '_splitter').button else: - button = self.grid_view_button if x == 'gv' else self.search_bar_button + if x == 'gv': + button = self.grid_view_button + elif x == 'qv': + button = self.qv.qv_button + else: + button = self.search_bar_button self.layout_buttons.append(button) button.setVisible(False) if isosx and stylename != u'Calibre': @@ -722,6 +732,8 @@ class LayoutMixin(object): # {{{ s.save_state() self.grid_view_button.save_state() self.search_bar_button.save_state() + if self.qv: + self.qv.qv_button.save_state() def read_layout_settings(self): # View states are restored automatically when set_database is called @@ -729,6 +741,7 @@ class LayoutMixin(object): # {{{ getattr(self, x+'_splitter').restore_state() self.grid_view_button.restore_state() self.search_bar_button.restore_state() + # Can't do quickview here because the gui isn't totally set up. Do it in ui def update_status_bar(self, *args): v = self.current_view() diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index bc238796b2..0a50148705 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -387,7 +387,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('qv_respects_vls', gprefs) r('qv_dclick_changes_column', gprefs) r('qv_retkey_changes_column', gprefs) - r('qv_show_on_startup', gprefs) + r('qv_follows_column', gprefs) r('cover_flow_queue_length', config, restart_required=True) r('cover_browser_reflections', gprefs) diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui index 73559635ea..01071e4dc6 100644 --- a/src/calibre/gui2/preferences/look_feel.ui +++ b/src/calibre/gui2/preferences/look_feel.ui @@ -1142,25 +1142,30 @@ them to all have the same width and height - + &Apply virtual libraries in Quickview pane Check this box to make Quickview show books only in the -current virtual library. If unchecked, Quickview ignores virtual libraries. +current virtual library. If unchecked, Quickview ignores virtual libraries. If +unchecked then only row changes are taken into account. - - + + - &Show Quickview on startup + &Change QV item when book list column changes + + + Check this box to make Quickview change the column being examined +when the column in the book list is changed using the cursor arrow keys - + Pressing return in a cell changes both the book and the @@ -1171,7 +1176,7 @@ column being examined (the left-hand pane) - + Double-clicking in a cell changes both the book and the diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 9f58a2fa0d..d2a02da8b4 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -426,12 +426,14 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ if self.system_tray_icon is not None and self.system_tray_icon.isVisible() and opts.start_in_tray: self.hide_windows() self.auto_adder = AutoAdder(gprefs['auto_add_path'], self) - self.save_layout_state() - if gprefs['qv_show_on_startup']: - qv = find_plugin('Show Quickview') - if qv is not None: - qv.actual_plugin_.show_quickview() + # Now that the gui is initialized we can restore the quickview state + # The same thing will be true for any action-based operation with a + # layout button + qv = find_plugin('Show Quickview') + if qv is not None: + qv.actual_plugin_.qv_button.restore_state() + self.save_layout_state() # Collect cycles now gc.collect() From beadc00667fb2fc5216c5ecad2c9a938afb95f84 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 16:07:07 +0200 Subject: [PATCH 3/7] Add svg of icon file --- imgsrc/eye-quickview.svg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 imgsrc/eye-quickview.svg diff --git a/imgsrc/eye-quickview.svg b/imgsrc/eye-quickview.svg new file mode 100644 index 0000000000..c98a995ae5 --- /dev/null +++ b/imgsrc/eye-quickview.svg @@ -0,0 +1,4 @@ + \ No newline at end of file From b1dc2398c9b17d963cd722dc4fb2d2da63a0c4d1 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 16:09:12 +0200 Subject: [PATCH 4/7] Change the button order as requested. Question: why is the order 'cb, gv' in wide but 'gv, cb' in narrow? Using the logic that the buttons affect the center booklist pane, shouldn't the order be the same? --- src/calibre/gui2/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py index 75c3b7e406..3e86fce142 100644 --- a/src/calibre/gui2/init.py +++ b/src/calibre/gui2/init.py @@ -568,7 +568,7 @@ class LayoutMixin(object): # {{{ self.bd_splitter.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.centralwidget.layout().addWidget(self.bd_splitter) - button_order = ('sb', 'tb', 'cb', 'gv', 'bd', 'qv') + button_order = ('sb', 'tb', 'cb', 'gv', 'qv', 'bd') # }}} self.qv = find_plugin('Show Quickview') From 1836dc5d6feea67d203431219b1bb371f9fea0b8 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 16:36:15 +0200 Subject: [PATCH 5/7] Update the QV manual. I don't know if it will display properly. --- manual/gui.rst | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/manual/gui.rst b/manual/gui.rst index c063976e43..d486931b79 100644 --- a/manual/gui.rst +++ b/manual/gui.rst @@ -586,27 +586,37 @@ browser` you can change the number of covers displayed, and even have the Quickview ---------- -Sometimes you want to select a book and quickly get a list of books with the same value in some category (authors, tags, publisher, series, etc) as the currently selected book, but without changing the current view of the library. You can do this with Quickview. Quickview opens a second window showing the list of books matching the value of interest. - -For example, assume you want to see a list of all the books with the same author of the currently-selected book. Click in the author cell you are interested in and press the 'Q' key. A window will open with all the authors for that book on the left, and all the books by the selected author on the right. +Sometimes you want to select a book and quickly get a list of books with the same value in some category (authors, tags, publisher, series, etc) as the currently selected book, but without changing the current view of the library. You can do this with Quickview. Quickview opens either a second window or a pane on the booklist showing the list of books matching the value of interest. For example, assume you want to see a list of all the books with the one or more of the authors of the currently-selected book. Click in the author cell you are interested in and press the 'Q' key or click the Quickview icon in the Layout section of the calibre window. A window or pane will open with all the authors for that book on the left, and all the books by the selected author on the right. Some example Quickview usages: quickly seeing what other books: - - have some tag that is applied to the currently selected book, + - have some tag(s) applied to the currently selected book, - are in the same series as the current book - have the same values in a custom column as the current book - are written by one of the same authors of the current book + - share values in a custom column -without changing the contents of the library view. +There are two choices for where the Quickview informaton appears: -The Quickview window opens on top of the calibre window and will stay open until you explicitly close it. You can use Quickview and the calibre library view at the same time. For example, if in the calibre library view you click on a category column (tags, series, publisher, authors, etc) for a book, the Quickview window contents will change to show you in the left-hand side pane the items in that category for the selected book (e.g., the tags for that book). The first item in that list will be selected, and Quickview will show you on the right-hand side pane all the books in your library that reference that item. Click on an different item in the left-hand pane to see the books with that different item. + 1. It can open "undocked": on top of the calibre window and will stay open until you explicitly close it. + 2. It can open "docked": as a pane in the booklist section of the calibre main window. + +You can move the window from docked to undocked as desired using the "Dock/Undock" button. + +The Quickview pane can be left open permanently, in which case it follows movements on the booklist. For example, if you click in the calibre library view on a category column (tags, series, publisher, authors, etc) for a book, the Quickview window contents will change to show you in the left-hand side pane the values in that category for the selected book (e.g., the tags for that book). The first item in that list will be selected, and Quickview will show you on the right-hand side pane all the books in your library that use that value. Click on an different valye in the left-hand pane to see the books with that different value. Double-click on a book in the Quickview window to select that book in the library view. This will also change the items display in the QuickView window (the left-hand pane) to show the items in the newly-selected book. -Shift- (or Ctrl-) double-click on a book in the Quickview window to open the edit metadata dialog on that book in the calibre window. +Shift- or Ctrl- double-click on a book in the Quickview window to open the edit metadata dialog on that book in the calibre window. The edited book will be Quickview'ed when you close the edit metadata dialog. You can see if a column can be Quickview'ed by hovering your mouse over the column heading and looking at the tooltip for that heading. You can also know by right-clicking on the column heading to see of the "Quickview" option is shown in the menu, in which case choosing that Quickview option is equivalent to pressing 'Q' in the current cell. -Quickview respects the virtual library setting, showing only books in the current virtual library. +Options (in Preferences / Look and Feel / Quickview): + + - Respect (or not) the current virtual library. If checked then Quickview shows only books in the current virtual library. Default: Respect virtual libraries (checked) + - Change the Quickview window contents when the column is changed on the booklist using the cursor keys. Default: don't follow changes made with cursor keys (unchecked) + - Change the column being "quickview'ed" when a cell in the Quickview window is double-clicked. Otherwise the book is changed but the column being examined is not. Default: Change the column (checked) + - Change the column being "quickview'ed" to the current column when the return key is pressed in the Quickview pane. Otherwise the book is changed but the column being examined is not. Default: Change the column (checked) + - Choose which columns are shown in the Quickview window/pane. .. raw:: html epub From 312304d51c645db06344e017d1eae1f99df4878c Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 17:04:37 +0200 Subject: [PATCH 6/7] Small oops -- it is possible for qv to be None. --- src/calibre/gui2/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py index 3e86fce142..44e8187388 100644 --- a/src/calibre/gui2/init.py +++ b/src/calibre/gui2/init.py @@ -589,7 +589,7 @@ class LayoutMixin(object): # {{{ else: if x == 'gv': button = self.grid_view_button - elif x == 'qv': + elif x == 'qv' and self.qv: button = self.qv.qv_button else: button = self.search_bar_button From 8162aa04a45e9492761ded4540cb8ffcd72908f4 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 4 Jul 2017 18:43:31 +0200 Subject: [PATCH 7/7] Ooops again: fix it right. Although I am no longer convinced that the qv plugin can be not installed/enabled. --- src/calibre/gui2/init.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py index 44e8187388..3bd8e9c834 100644 --- a/src/calibre/gui2/init.py +++ b/src/calibre/gui2/init.py @@ -589,7 +589,9 @@ class LayoutMixin(object): # {{{ else: if x == 'gv': button = self.grid_view_button - elif x == 'qv' and self.qv: + elif x == 'qv': + if self.qv is None: + continue button = self.qv.qv_button else: button = self.search_bar_button