mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Wire up the grid view button
This commit is contained in:
parent
0889f6f0c6
commit
fe363c95f5
@ -293,6 +293,7 @@ class LayoutMixin(object): # {{{
|
||||
self.status_bar = StatusBar(self)
|
||||
stylename = unicode(self.style().objectName())
|
||||
self.grid_view_button = GridViewButton(self)
|
||||
self.grid_view_button.toggled.connect(self.toggle_grid_view)
|
||||
|
||||
for x in button_order:
|
||||
button = self.grid_view_button if x == 'gv' else getattr(self, x+'_splitter').button
|
||||
@ -339,6 +340,9 @@ class LayoutMixin(object): # {{{
|
||||
self.library_view.currentIndex())
|
||||
self.library_view.setFocus(Qt.OtherFocusReason)
|
||||
|
||||
def toggle_grid_view(self, show):
|
||||
self.library_view.alternate_views.show_view('grid' if show else None)
|
||||
|
||||
def bd_cover_changed(self, id_, cdata):
|
||||
self.library_view.model().db.set_cover(id_, cdata)
|
||||
if self.cover_flow:
|
||||
|
@ -11,7 +11,8 @@ from PyQt4.Qt import QListView
|
||||
class AlternateViews(object):
|
||||
|
||||
def __init__(self, main_view):
|
||||
self.views = {}
|
||||
self.views = {None:main_view}
|
||||
self.stack_positions = {None:0}
|
||||
self.current_view = self.main_view = main_view
|
||||
self.stack = None
|
||||
|
||||
@ -21,9 +22,17 @@ class AlternateViews(object):
|
||||
|
||||
def add_view(self, key, view):
|
||||
self.views[key] = view
|
||||
self.stack_positions[key] = self.stack.count()
|
||||
self.stack.addWidget(view)
|
||||
self.stack.setCurrentIndex(0)
|
||||
|
||||
def show_view(self, key=None):
|
||||
view = self.views[key]
|
||||
if view is self.current_view:
|
||||
return
|
||||
self.stack.setCurrentIndex(self.stack_positions[key])
|
||||
self.current_view = view
|
||||
|
||||
class GridView(QListView):
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user