View menu (#1668)
* Add main view menu * Add browser view menu * Use standard keys for zooming and full screen * Capitalise menu item names * Toggle Showing Cards/Notes -> Toggle Cards/Notes * Explicitly set linux full screen key on_toggle_fullscreen -> on_toggle_full_screen
This commit is contained in:
parent
fd6a78e7cf
commit
700fc50f7a
@ -91,7 +91,7 @@ browsing-suspended = Suspended
|
||||
browsing-tag-duplicates = Tag Duplicates
|
||||
browsing-tag-rename-warning-empty = You can't rename a tag that has no notes.
|
||||
browsing-target-field = Target field:
|
||||
browsing-toggle-showing-cards-notes = Toggle Showing Cards/Notes
|
||||
browsing-toggle-showing-cards-notes = Toggle Cards/Notes
|
||||
browsing-toggle-mark = Toggle Mark
|
||||
browsing-toggle-suspend = Toggle Suspend
|
||||
browsing-treat-input-as-regular-expression = Treat input as regular expression
|
||||
|
@ -33,3 +33,10 @@ qt-accel-undo = &Undo
|
||||
qt-accel-redo = &Redo
|
||||
qt-accel-set-due-date = Set &Due Date...
|
||||
qt-accel-forget = &Forget
|
||||
qt-accel-view = &View
|
||||
qt-accel-full-screen = Toggle &Full Screen
|
||||
qt-accel-zoom-in = Zoom &In
|
||||
qt-accel-zoom-out = Zoom &Out
|
||||
qt-accel-reset-zoom = &Reset Zoom
|
||||
qt-accel-zoom-editor-in = Zoom Editor &In
|
||||
qt-accel-zoom-editor-out = Zoom Editor &Out
|
||||
|
@ -178,6 +178,7 @@ class Browser(QMainWindow):
|
||||
def setupMenus(self) -> None:
|
||||
# actions
|
||||
f = self.form
|
||||
|
||||
# edit
|
||||
qconnect(f.actionUndo.triggered, self.undo)
|
||||
qconnect(f.actionRedo.triggered, self.redo)
|
||||
@ -187,6 +188,24 @@ class Browser(QMainWindow):
|
||||
f.actionClose.setVisible(False)
|
||||
qconnect(f.actionCreateFilteredDeck.triggered, self.createFilteredDeck)
|
||||
f.actionCreateFilteredDeck.setShortcuts(["Ctrl+G", "Ctrl+Alt+G"])
|
||||
|
||||
# view
|
||||
qconnect(f.actionFullScreen.triggered, self.mw.on_toggle_full_screen)
|
||||
qconnect(
|
||||
f.actionZoomIn.triggered,
|
||||
lambda: self.editor.web.setZoomFactor(self.editor.web.zoomFactor() + 0.1),
|
||||
)
|
||||
f.actionZoomIn.setShortcut(QKeySequence.StandardKey.ZoomIn)
|
||||
qconnect(
|
||||
f.actionZoomOut.triggered,
|
||||
lambda: self.editor.web.setZoomFactor(self.editor.web.zoomFactor() - 0.1),
|
||||
)
|
||||
f.actionZoomOut.setShortcut(QKeySequence.StandardKey.ZoomOut)
|
||||
qconnect(
|
||||
f.actionResetZoom.triggered,
|
||||
lambda: self.editor.web.setZoomFactor(1),
|
||||
)
|
||||
|
||||
# notes
|
||||
qconnect(f.actionAdd.triggered, self.mw.onAddCard)
|
||||
qconnect(f.actionCopy.triggered, self.on_create_copy)
|
||||
@ -199,6 +218,7 @@ class Browser(QMainWindow):
|
||||
qconnect(f.actionFindReplace.triggered, self.onFindReplace)
|
||||
qconnect(f.actionManage_Note_Types.triggered, self.mw.onNoteTypes)
|
||||
qconnect(f.actionDelete.triggered, self.delete_selected_notes)
|
||||
|
||||
# cards
|
||||
qconnect(f.actionChange_Deck.triggered, self.set_deck_of_selected_cards)
|
||||
qconnect(f.action_Info.triggered, self.showCardInfo)
|
||||
@ -216,6 +236,7 @@ class Browser(QMainWindow):
|
||||
)
|
||||
self._update_flag_labels()
|
||||
qconnect(f.actionExport.triggered, self._on_export_notes)
|
||||
|
||||
# jumps
|
||||
qconnect(f.actionPreviousCard.triggered, self.onPreviousCard)
|
||||
qconnect(f.actionNextCard.triggered, self.onNextCard)
|
||||
@ -225,13 +246,16 @@ class Browser(QMainWindow):
|
||||
qconnect(f.actionNote.triggered, self.onNote)
|
||||
qconnect(f.actionSidebar.triggered, self.focusSidebar)
|
||||
qconnect(f.actionCardList.triggered, self.onCardList)
|
||||
|
||||
# help
|
||||
qconnect(f.actionGuide.triggered, self.onHelp)
|
||||
|
||||
# keyboard shortcut for shift+home/end
|
||||
self.pgUpCut = QShortcut(QKeySequence("Shift+Home"), self)
|
||||
qconnect(self.pgUpCut.activated, self.onFirstCard)
|
||||
self.pgDownCut = QShortcut(QKeySequence("Shift+End"), self)
|
||||
qconnect(self.pgDownCut.activated, self.onLastCard)
|
||||
|
||||
# add-on hook
|
||||
gui_hooks.browser_menus_did_init(self)
|
||||
self.mw.maybeHideAccelerators(self)
|
||||
|
@ -219,8 +219,6 @@
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_toggle_mode"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSelectAll"/>
|
||||
<addaction name="actionSelectNotes"/>
|
||||
<addaction name="actionInvertSelection"/>
|
||||
@ -300,7 +298,20 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDelete"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuqt_accel_view">
|
||||
<property name="title">
|
||||
<string>qt_accel_view</string>
|
||||
</property>
|
||||
<addaction name="action_toggle_mode"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFullScreen"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionZoomIn"/>
|
||||
<addaction name="actionZoomOut"/>
|
||||
<addaction name="actionResetZoom"/>
|
||||
</widget>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuqt_accel_view"/>
|
||||
<addaction name="menu_Notes"/>
|
||||
<addaction name="menu_Cards"/>
|
||||
<addaction name="menuJump"/>
|
||||
@ -665,6 +676,34 @@
|
||||
<string notr="true">Ctrl+Alt+E</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFullScreen">
|
||||
<property name="text">
|
||||
<string>qt_accel_full_screen</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoomIn">
|
||||
<property name="text">
|
||||
<string>qt_accel_zoom_editor_in</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoomOut">
|
||||
<property name="text">
|
||||
<string>qt_accel_zoom_editor_out</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionResetZoom">
|
||||
<property name="text">
|
||||
<string>qt_accel_reset_zoom</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+0</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionbrowsing_toggle_showing_cards_notes">
|
||||
<property name="text">
|
||||
<string>browsing_toggle_showing_cards_notes</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
@ -92,8 +92,19 @@
|
||||
<addaction name="actionNoteTypes"/>
|
||||
<addaction name="actionPreferences"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuqt_accel_view">
|
||||
<property name="title">
|
||||
<string>qt_accel_view</string>
|
||||
</property>
|
||||
<addaction name="actionFullScreen"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionZoomIn"/>
|
||||
<addaction name="actionZoomOut"/>
|
||||
<addaction name="actionResetZoom"/>
|
||||
</widget>
|
||||
<addaction name="menuCol"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuqt_accel_view"/>
|
||||
<addaction name="menuTools"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
@ -236,6 +247,29 @@
|
||||
<string notr="true">Ctrl+Shift+Z</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFullScreen">
|
||||
<property name="text">
|
||||
<string>qt_accel_full_screen</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoomIn">
|
||||
<property name="text">
|
||||
<string>qt_accel_zoom_in</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoomOut">
|
||||
<property name="text">
|
||||
<string>qt_accel_zoom_out</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionResetZoom">
|
||||
<property name="text">
|
||||
<string>qt_accel_reset_zoom</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string notr="true">Ctrl+0</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
@ -209,7 +209,6 @@ class AnkiQt(QMainWindow):
|
||||
self.setup_timers()
|
||||
self.updateTitleBar()
|
||||
self.setup_focus()
|
||||
self.setup_shortcuts()
|
||||
# screens
|
||||
self.setupDeckBrowser()
|
||||
self.setupOverview()
|
||||
@ -244,17 +243,6 @@ class AnkiQt(QMainWindow):
|
||||
def on_focus_changed(self, old: QWidget, new: QWidget) -> None:
|
||||
gui_hooks.focus_did_change(new, old)
|
||||
|
||||
def setup_shortcuts(self) -> None:
|
||||
QShortcut(
|
||||
QKeySequence("Ctrl+Meta+F" if is_mac else "F11"),
|
||||
self,
|
||||
self.on_toggle_fullscreen,
|
||||
).setContext(Qt.ShortcutContext.ApplicationShortcut)
|
||||
|
||||
def on_toggle_fullscreen(self) -> None:
|
||||
window = self.app.activeWindow()
|
||||
window.setWindowState(window.windowState() ^ Qt.WindowState.WindowFullScreen)
|
||||
|
||||
# Profiles
|
||||
##########################################################################
|
||||
|
||||
@ -1277,28 +1265,62 @@ title="{}" {}>{}</button>""".format(
|
||||
|
||||
def setupMenus(self) -> None:
|
||||
m = self.form
|
||||
|
||||
# File
|
||||
qconnect(
|
||||
m.actionSwitchProfile.triggered, self.unloadProfileAndShowProfileManager
|
||||
)
|
||||
qconnect(m.actionImport.triggered, self.onImport)
|
||||
qconnect(m.actionExport.triggered, self.onExport)
|
||||
qconnect(m.actionExit.triggered, self.close)
|
||||
qconnect(m.actionPreferences.triggered, self.onPrefs)
|
||||
qconnect(m.actionAbout.triggered, self.onAbout)
|
||||
qconnect(m.actionUndo.triggered, self.undo)
|
||||
qconnect(m.actionRedo.triggered, self.redo)
|
||||
qconnect(m.actionFullDatabaseCheck.triggered, self.onCheckDB)
|
||||
qconnect(m.actionCheckMediaDatabase.triggered, self.on_check_media_db)
|
||||
|
||||
# Help
|
||||
qconnect(m.actionDocumentation.triggered, self.onDocumentation)
|
||||
qconnect(m.actionDonate.triggered, self.onDonate)
|
||||
qconnect(m.actionAbout.triggered, self.onAbout)
|
||||
|
||||
# Edit
|
||||
qconnect(m.actionUndo.triggered, self.undo)
|
||||
qconnect(m.actionRedo.triggered, self.redo)
|
||||
|
||||
# Tools
|
||||
qconnect(m.actionFullDatabaseCheck.triggered, self.onCheckDB)
|
||||
qconnect(m.actionCheckMediaDatabase.triggered, self.on_check_media_db)
|
||||
qconnect(m.actionStudyDeck.triggered, self.onStudyDeck)
|
||||
qconnect(m.actionCreateFiltered.triggered, self.onCram)
|
||||
qconnect(m.actionEmptyCards.triggered, self.onEmptyCards)
|
||||
qconnect(m.actionNoteTypes.triggered, self.onNoteTypes)
|
||||
qconnect(m.actionPreferences.triggered, self.onPrefs)
|
||||
|
||||
# View
|
||||
qconnect(
|
||||
m.actionZoomIn.triggered,
|
||||
lambda: self.web.setZoomFactor(self.web.zoomFactor() + 0.1),
|
||||
)
|
||||
m.actionZoomIn.setShortcut(QKeySequence.StandardKey.ZoomIn)
|
||||
qconnect(
|
||||
m.actionZoomOut.triggered,
|
||||
lambda: self.web.setZoomFactor(self.web.zoomFactor() - 0.1),
|
||||
)
|
||||
m.actionZoomOut.setShortcut(QKeySequence.StandardKey.ZoomOut)
|
||||
qconnect(m.actionResetZoom.triggered, lambda: self.web.setZoomFactor(1))
|
||||
# app-wide shortcut
|
||||
qconnect(m.actionFullScreen.triggered, self.on_toggle_full_screen)
|
||||
m.actionFullScreen.setShortcut(
|
||||
QKeySequence("F11") if is_lin else QKeySequence.StandardKey.FullScreen
|
||||
)
|
||||
m.actionFullScreen.setShortcutContext(Qt.ShortcutContext.ApplicationShortcut)
|
||||
|
||||
def updateTitleBar(self) -> None:
|
||||
self.setWindowTitle("Anki")
|
||||
|
||||
# View
|
||||
##########################################################################
|
||||
|
||||
def on_toggle_full_screen(self) -> None:
|
||||
window = self.app.activeWindow()
|
||||
window.setWindowState(window.windowState() ^ Qt.WindowState.WindowFullScreen)
|
||||
|
||||
# Auto update
|
||||
##########################################################################
|
||||
|
||||
|
@ -358,7 +358,7 @@ class AnkiWebView(QWebEngineView):
|
||||
self._domDone = False
|
||||
super().load(url)
|
||||
|
||||
def zoomFactor(self) -> float:
|
||||
def app_zoom_factor(self) -> float:
|
||||
# overridden scale factor?
|
||||
webscale = os.environ.get("ANKI_WEBSCALE")
|
||||
if webscale:
|
||||
@ -448,7 +448,7 @@ div[contenteditable="true"]:focus {{
|
||||
color_hl_txt=color_hl_txt,
|
||||
)
|
||||
|
||||
zoom = self.zoomFactor()
|
||||
zoom = self.app_zoom_factor()
|
||||
|
||||
window_bg_day = self.get_window_bg_color(False).name()
|
||||
window_bg_night = self.get_window_bg_color(True).name()
|
||||
|
Loading…
Reference in New Issue
Block a user