mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement v-sync for pin view
Also allow split/unsplit of book list via header context menu
This commit is contained in:
parent
7eef114a43
commit
10b7774c96
@ -159,6 +159,7 @@ def create_defs():
|
||||
defs['qv_retkey_changes_column'] = True
|
||||
defs['qv_follows_column'] = False
|
||||
defs['book_details_narrow_comments_layout'] = 'float'
|
||||
defs['book_list_split'] = False
|
||||
|
||||
|
||||
create_defs()
|
||||
|
@ -300,7 +300,15 @@ class BooksView(QTableView): # {{{
|
||||
type=Qt.QueuedConnection)
|
||||
self.set_row_header_visibility()
|
||||
if modelcls is not BooksModel:
|
||||
self.pin_view.close()
|
||||
self.pin_view.setVisible(False)
|
||||
else:
|
||||
self.set_pin_view_visibility(gprefs['book_list_split'])
|
||||
self.pin_view.verticalScrollBar().valueChanged.connect(self.verticalScrollBar().setValue)
|
||||
self.verticalScrollBar().valueChanged.connect(self.pin_view.verticalScrollBar().setValue)
|
||||
|
||||
def set_pin_view_visibility(self, visible=False):
|
||||
self.pin_view.setVisible(visible)
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff if visible else Qt.ScrollBarAsNeeded)
|
||||
|
||||
# Column Header Context Menu {{{
|
||||
def column_header_context_handler(self, action=None, column=None):
|
||||
@ -343,6 +351,9 @@ class BooksView(QTableView): # {{{
|
||||
current_col = self.column_map.index(column)
|
||||
index = self.model().index(current_row, current_col)
|
||||
qv.change_quickview_column(index)
|
||||
elif action == 'split':
|
||||
self.set_pin_view_visibility(not self.pin_view.isVisible())
|
||||
gprefs['book_list_split'] = self.pin_view.isVisible()
|
||||
|
||||
self.save_state()
|
||||
|
||||
@ -430,7 +441,11 @@ class BooksView(QTableView): # {{{
|
||||
partial(self.column_header_context_handler,
|
||||
action='addcustcol', column=col))
|
||||
|
||||
self.column_header_context_menu.popup(self.column_header.mapToGlobal(pos))
|
||||
self.column_header_context_menu.addSeparator()
|
||||
self.column_header_context_menu.addAction(
|
||||
_('Un-split the book list') if self.pin_view.isVisible() else _('Split the book list'),
|
||||
partial(self.column_header_context_handler, action='split', column=col or 'title'))
|
||||
self.column_header_context_menu.popup(self.column_header.mapToGlobal(pos))
|
||||
# }}}
|
||||
|
||||
# Sorting {{{
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
from PyQt5.Qt import QWidget, QHBoxLayout, QTableView
|
||||
from PyQt5.Qt import QSplitter, QTableView
|
||||
|
||||
|
||||
class PinTableView(QTableView):
|
||||
@ -15,12 +15,11 @@ class PinTableView(QTableView):
|
||||
self.verticalHeader().close()
|
||||
|
||||
|
||||
class PinContainer(QWidget):
|
||||
class PinContainer(QSplitter):
|
||||
|
||||
def __init__(self, books_view, parent=None):
|
||||
QWidget.__init__(self, parent)
|
||||
QSplitter.__init__(self, parent)
|
||||
self.setChildrenCollapsible(False)
|
||||
self.books_view = books_view
|
||||
self.l = l = QHBoxLayout(self)
|
||||
l.addWidget(books_view)
|
||||
l.addWidget(books_view.pin_view)
|
||||
l.setContentsMargins(0, 0, 0, 0)
|
||||
self.addWidget(books_view)
|
||||
self.addWidget(books_view.pin_view)
|
||||
|
Loading…
x
Reference in New Issue
Block a user