mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Add left margin to browser when sidebar is closed (#4040)
* add left margin to browser when sidebar is closed * listen for event instead of explicit user action * refresh sidebar on visibility change * Add a margin on macOS even when not collapsed --------- Co-authored-by: Damien Elmes <gpg@ankiweb.net>
This commit is contained in:
parent
14b8a8ad0d
commit
f9f0894162
1 changed files with 13 additions and 2 deletions
|
@ -53,6 +53,7 @@ from aqt.operations.tag import (
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.sound import av_player
|
from aqt.sound import av_player
|
||||||
from aqt.switch import Switch
|
from aqt.switch import Switch
|
||||||
|
from aqt.theme import WidgetStyle
|
||||||
from aqt.undo import UndoActionsInfo
|
from aqt.undo import UndoActionsInfo
|
||||||
from aqt.utils import (
|
from aqt.utils import (
|
||||||
HelpPage,
|
HelpPage,
|
||||||
|
@ -170,6 +171,7 @@ class Browser(QMainWindow):
|
||||||
if self.height() != 0:
|
if self.height() != 0:
|
||||||
self.aspect_ratio = self.width() / self.height()
|
self.aspect_ratio = self.width() / self.height()
|
||||||
self.set_layout(self.mw.pm.browser_layout(), True)
|
self.set_layout(self.mw.pm.browser_layout(), True)
|
||||||
|
self.onSidebarVisibilityChange(not self.sidebarDockWidget.isHidden())
|
||||||
# disable undo/redo
|
# disable undo/redo
|
||||||
self.on_undo_state_change(mw.undo_actions_info())
|
self.on_undo_state_change(mw.undo_actions_info())
|
||||||
# legacy alias
|
# legacy alias
|
||||||
|
@ -726,6 +728,7 @@ class Browser(QMainWindow):
|
||||||
self.form.actionSidebarFilter.triggered,
|
self.form.actionSidebarFilter.triggered,
|
||||||
self.focusSidebarSearchBar,
|
self.focusSidebarSearchBar,
|
||||||
)
|
)
|
||||||
|
qconnect(dw.visibilityChanged, self.onSidebarVisibilityChange)
|
||||||
grid = QGridLayout()
|
grid = QGridLayout()
|
||||||
grid.addWidget(self.sidebar.searchBar, 0, 0)
|
grid.addWidget(self.sidebar.searchBar, 0, 0)
|
||||||
grid.addWidget(self.sidebar.toolbar, 0, 1)
|
grid.addWidget(self.sidebar.toolbar, 0, 1)
|
||||||
|
@ -745,9 +748,17 @@ class Browser(QMainWindow):
|
||||||
self.mw.progress.timer(10, self.sidebar.refresh, False, parent=self.sidebar)
|
self.mw.progress.timer(10, self.sidebar.refresh, False, parent=self.sidebar)
|
||||||
|
|
||||||
def showSidebar(self, show: bool = True) -> None:
|
def showSidebar(self, show: bool = True) -> None:
|
||||||
want_visible = not self.sidebarDockWidget.isVisible()
|
|
||||||
self.sidebarDockWidget.setVisible(show)
|
self.sidebarDockWidget.setVisible(show)
|
||||||
if want_visible and show:
|
|
||||||
|
def onSidebarVisibilityChange(self, visible):
|
||||||
|
margins = self.form.verticalLayout_3.contentsMargins()
|
||||||
|
skip_left_margin = not visible and not (
|
||||||
|
is_mac and aqt.mw.pm.get_widget_style() == WidgetStyle.NATIVE
|
||||||
|
)
|
||||||
|
margins.setLeft(0 if skip_left_margin else margins.right())
|
||||||
|
self.form.verticalLayout_3.setContentsMargins(margins)
|
||||||
|
|
||||||
|
if visible:
|
||||||
self.sidebar.refresh()
|
self.sidebar.refresh()
|
||||||
|
|
||||||
def focusSidebar(self) -> None:
|
def focusSidebar(self) -> None:
|
||||||
|
|
Loading…
Reference in a new issue