mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 22:13:58 -05:00
refresh sidebar on visibility change
This commit is contained in:
parent
a460ecbb9a
commit
1e143e99fe
1 changed files with 6 additions and 7 deletions
|
|
@ -170,7 +170,7 @@ class Browser(QMainWindow):
|
|||
if self.height() != 0:
|
||||
self.aspect_ratio = self.width() / self.height()
|
||||
self.set_layout(self.mw.pm.browser_layout(), True)
|
||||
self.handleSidebarMargin(not self.sidebarDockWidget.isHidden())
|
||||
self.onSidebarVisibilityChange(not self.sidebarDockWidget.isHidden())
|
||||
# disable undo/redo
|
||||
self.on_undo_state_change(mw.undo_actions_info())
|
||||
# legacy alias
|
||||
|
|
@ -727,7 +727,7 @@ class Browser(QMainWindow):
|
|||
self.form.actionSidebarFilter.triggered,
|
||||
self.focusSidebarSearchBar,
|
||||
)
|
||||
qconnect(dw.visibilityChanged, self.handleSidebarMargin)
|
||||
qconnect(dw.visibilityChanged, self.onSidebarVisibilityChange)
|
||||
grid = QGridLayout()
|
||||
grid.addWidget(self.sidebar.searchBar, 0, 0)
|
||||
grid.addWidget(self.sidebar.toolbar, 0, 1)
|
||||
|
|
@ -747,17 +747,16 @@ class Browser(QMainWindow):
|
|||
self.mw.progress.timer(10, self.sidebar.refresh, False, parent=self.sidebar)
|
||||
|
||||
def showSidebar(self, show: bool = True) -> None:
|
||||
was_hidden = self.sidebarDockWidget.isHidden()
|
||||
self.sidebarDockWidget.setVisible(show)
|
||||
|
||||
if was_hidden and show:
|
||||
self.sidebar.refresh()
|
||||
|
||||
def handleSidebarMargin(self, visible):
|
||||
def onSidebarVisibilityChange(self, visible):
|
||||
margins = self.form.verticalLayout_3.contentsMargins()
|
||||
margins.setLeft(0 if visible else margins.right())
|
||||
self.form.verticalLayout_3.setContentsMargins(margins)
|
||||
|
||||
if visible:
|
||||
self.sidebar.refresh()
|
||||
|
||||
def focusSidebar(self) -> None:
|
||||
self.showSidebar()
|
||||
self.sidebar.setFocus()
|
||||
|
|
|
|||
Loading…
Reference in a new issue