add toggle for browser sidebar (#3953)

* add toggle for browser sidebar

* Update CONTRIBUTORS
This commit is contained in:
JL710 2025-04-27 10:22:56 +02:00 committed by GitHub
parent 90f2e06b17
commit 62bad44eed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 7 deletions

View file

@ -223,6 +223,7 @@ derivativeoflog7 <https://github.com/derivativeoflog7>
rreemmii-dev <https://github.com/rreemmii-dev> rreemmii-dev <https://github.com/rreemmii-dev>
babofitos <https://github.com/babofitos> babofitos <https://github.com/babofitos>
Jonathan Schoreels <https://github.com/JSchoreels> Jonathan Schoreels <https://github.com/JSchoreels>
JL710
******************** ********************

View file

@ -40,6 +40,7 @@ qt-accel-layout-horizontal = &Horizontal
qt-accel-zoom-in = Zoom &In qt-accel-zoom-in = Zoom &In
qt-accel-zoom-out = Zoom &Out qt-accel-zoom-out = Zoom &Out
qt-accel-reset-zoom = &Reset Zoom qt-accel-reset-zoom = &Reset Zoom
qt-accel-toggle-sidebar = Toggle Sidebar
qt-accel-zoom-editor-in = Zoom Editor &In qt-accel-zoom-editor-in = Zoom Editor &In
qt-accel-zoom-editor-out = Zoom Editor &Out qt-accel-zoom-editor-out = Zoom Editor &Out
qt-accel-create-backup = Create &Backup qt-accel-create-backup = Create &Backup

View file

@ -366,6 +366,7 @@ class Browser(QMainWindow):
qconnect(f.actionFind.triggered, self.onFind) qconnect(f.actionFind.triggered, self.onFind)
qconnect(f.actionNote.triggered, self.onNote) qconnect(f.actionNote.triggered, self.onNote)
qconnect(f.actionSidebar.triggered, self.focusSidebar) qconnect(f.actionSidebar.triggered, self.focusSidebar)
qconnect(f.actionToggleSidebar.triggered, self.toggle_sidebar)
qconnect(f.actionCardList.triggered, self.onCardList) qconnect(f.actionCardList.triggered, self.onCardList)
# help # help
@ -695,7 +696,7 @@ class Browser(QMainWindow):
def setupSidebar(self) -> None: def setupSidebar(self) -> None:
dw = self.sidebarDockWidget = QDockWidget(tr.browsing_sidebar(), self) dw = self.sidebarDockWidget = QDockWidget(tr.browsing_sidebar(), self)
dw.setFeatures(QDockWidget.DockWidgetFeature.NoDockWidgetFeatures) dw.setFeatures(QDockWidget.DockWidgetFeature.DockWidgetClosable)
dw.setObjectName("Sidebar") dw.setObjectName("Sidebar")
dock_area = ( dock_area = (
Qt.DockWidgetArea.RightDockWidgetArea Qt.DockWidgetArea.RightDockWidgetArea
@ -729,8 +730,11 @@ class Browser(QMainWindow):
# UI is more responsive # UI is more responsive
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) -> None: def showSidebar(self, show: bool = True) -> None:
self.sidebarDockWidget.setVisible(True) want_visible = not self.sidebarDockWidget.isVisible()
self.sidebarDockWidget.setVisible(show)
if want_visible and show:
self.sidebar.refresh()
def focusSidebar(self) -> None: def focusSidebar(self) -> None:
self.showSidebar() self.showSidebar()
@ -741,10 +745,7 @@ class Browser(QMainWindow):
self.sidebar.searchBar.setFocus() self.sidebar.searchBar.setFocus()
def toggle_sidebar(self) -> None: def toggle_sidebar(self) -> None:
want_visible = not self.sidebarDockWidget.isVisible() self.showSidebar(not self.sidebarDockWidget.isVisible())
self.sidebarDockWidget.setVisible(want_visible)
if want_visible:
self.sidebar.refresh()
# legacy # legacy

View file

@ -317,6 +317,8 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionFullScreen"/> <addaction name="actionFullScreen"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionToggleSidebar"/>
<addaction name="separator"/>
<addaction name="actionZoomIn"/> <addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/> <addaction name="actionZoomOut"/>
<addaction name="actionResetZoom"/> <addaction name="actionResetZoom"/>
@ -702,6 +704,11 @@
<string>qt_accel_full_screen</string> <string>qt_accel_full_screen</string>
</property> </property>
</action> </action>
<action name="actionToggleSidebar">
<property name="text">
<string>qt_accel_toggle_sidebar</string>
</property>
</action>
<action name="actionZoomIn"> <action name="actionZoomIn">
<property name="text"> <property name="text">
<string>qt_accel_zoom_editor_in</string> <string>qt_accel_zoom_editor_in</string>