mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Allow users to make hiding exclusive to full screen
This commit is contained in:
parent
09dc6a2ac6
commit
fa057df818
6 changed files with 118 additions and 37 deletions
|
@ -50,6 +50,8 @@ preferences-reduce-motion = Reduce motion
|
|||
preferences-reduce-motion-tooltip = Disable various animations and transitions of the user interface
|
||||
preferences-hide-top-bar-during-review = Hide top bar during review
|
||||
preferences-hide-bottom-bar-during-review = Hide bottom bar during review
|
||||
preferences-always = Always
|
||||
preferences-in-full-screen = In full screen
|
||||
preferences-appearance = Appearance
|
||||
preferences-general = General
|
||||
preferences-style = Style
|
||||
|
|
|
@ -134,34 +134,8 @@
|
|||
<property name="title">
|
||||
<string>preferences_distractions</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hide_top_bar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>preferences_hide_top_bar_during_review</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hide_bottom_bar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>preferences_hide_bottom_bar_during_review</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="reduce_motion">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
@ -177,7 +151,43 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="hide_bottom_bar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>preferences_hide_bottom_bar_during_review</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="bottomBarComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="hide_top_bar">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>preferences_hide_top_bar_during_review</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="minimalist_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
@ -190,6 +200,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="topBarComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -158,15 +158,11 @@ class MainWebView(AnkiWebView):
|
|||
return True
|
||||
|
||||
if evt.type() == QEvent.Type.Enter:
|
||||
if self.mw.pm.hide_top_bar():
|
||||
self.mw.toolbarWeb.hide_timer.start()
|
||||
self.mw.bottomWeb.hide_timer.start()
|
||||
handled = True
|
||||
if self.mw.pm.hide_bottom_bar():
|
||||
self.mw.bottomWeb.hide_timer.start()
|
||||
handled = True
|
||||
self.mw.toolbarWeb.hide_timer.start()
|
||||
self.mw.bottomWeb.hide_timer.start()
|
||||
return True
|
||||
|
||||
return handled
|
||||
return False
|
||||
|
||||
|
||||
class AnkiQt(QMainWindow):
|
||||
|
@ -1375,6 +1371,10 @@ title="{}" {}>{}</button>""".format(
|
|||
self.form.menubar.setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)
|
||||
self.form.menubar.setMinimumSize(0, 0)
|
||||
|
||||
# Update Toolbar states
|
||||
self.toolbarWeb.hide_if_allowed()
|
||||
self.bottomWeb.hide_if_allowed()
|
||||
|
||||
# Auto update
|
||||
##########################################################################
|
||||
|
||||
|
|
|
@ -213,11 +213,35 @@ class Preferences(QDialog):
|
|||
self.form.minimalist_mode.setChecked(self.mw.pm.minimalist_mode())
|
||||
qconnect(self.form.minimalist_mode.stateChanged, self.mw.pm.set_minimalist_mode)
|
||||
|
||||
hide_choices = [tr.preferences_in_full_screen(), tr.preferences_always()]
|
||||
|
||||
self.form.hide_top_bar.setChecked(self.mw.pm.hide_top_bar())
|
||||
qconnect(self.form.hide_top_bar.stateChanged, self.mw.pm.set_hide_top_bar)
|
||||
qconnect(
|
||||
self.form.hide_top_bar.stateChanged,
|
||||
self.form.topBarComboBox.setVisible,
|
||||
)
|
||||
self.form.topBarComboBox.addItems(hide_choices)
|
||||
self.form.topBarComboBox.setCurrentIndex(self.mw.pm.top_bar_hide_mode())
|
||||
|
||||
qconnect(
|
||||
self.form.topBarComboBox.currentIndexChanged,
|
||||
self.mw.pm.set_top_bar_hide_mode,
|
||||
)
|
||||
|
||||
self.form.hide_bottom_bar.setChecked(self.mw.pm.hide_bottom_bar())
|
||||
qconnect(self.form.hide_bottom_bar.stateChanged, self.mw.pm.set_hide_bottom_bar)
|
||||
qconnect(
|
||||
self.form.hide_bottom_bar.stateChanged,
|
||||
self.form.bottomBarComboBox.setVisible,
|
||||
)
|
||||
self.form.bottomBarComboBox.addItems(hide_choices)
|
||||
self.form.bottomBarComboBox.setCurrentIndex(self.mw.pm.bottom_bar_hide_mode())
|
||||
|
||||
qconnect(
|
||||
self.form.bottomBarComboBox.currentIndexChanged,
|
||||
self.mw.pm.set_bottom_bar_hide_mode,
|
||||
)
|
||||
|
||||
self.form.uiScale.setValue(int(self.mw.pm.uiScale() * 100))
|
||||
themes = [
|
||||
|
|
|
@ -24,6 +24,7 @@ from anki.utils import int_time, is_mac, is_win, point_version
|
|||
from aqt import appHelpSite, gui_hooks
|
||||
from aqt.qt import *
|
||||
from aqt.theme import AnkiStyles, Theme, theme_manager
|
||||
from aqt.toolbar import HideMode
|
||||
from aqt.utils import disable_help_button, send_to_trash, showWarning, tr
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -539,12 +540,26 @@ create table if not exists profiles
|
|||
self.meta["hide_top_bar"] = on
|
||||
gui_hooks.body_classes_need_update()
|
||||
|
||||
def top_bar_hide_mode(self) -> bool:
|
||||
return self.meta.get("top_bar_hide_mode", HideMode.FULLSCREEN)
|
||||
|
||||
def set_top_bar_hide_mode(self, mode: HideMode) -> None:
|
||||
self.meta["top_bar_hide_mode"] = mode
|
||||
gui_hooks.body_classes_need_update()
|
||||
|
||||
def hide_bottom_bar(self) -> bool:
|
||||
return self.meta.get("hide_bottom_bar", False)
|
||||
|
||||
def set_hide_bottom_bar(self, on: bool) -> None:
|
||||
self.meta["hide_bottom_bar"] = on
|
||||
|
||||
def bottom_bar_hide_mode(self) -> bool:
|
||||
return self.meta.get("bottom_bar_hide_mode", HideMode.FULLSCREEN)
|
||||
|
||||
def set_bottom_bar_hide_mode(self, mode: HideMode) -> None:
|
||||
self.meta["bottom_bar_hide_mode"] = mode
|
||||
gui_hooks.body_classes_need_update()
|
||||
|
||||
def last_addon_update_check(self) -> int:
|
||||
return self.meta.get("last_addon_update_check", 0)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
from __future__ import annotations
|
||||
|
||||
import enum
|
||||
import re
|
||||
from typing import Any, Callable, Optional, cast
|
||||
|
||||
|
@ -15,6 +16,11 @@ from aqt.utils import tr
|
|||
from aqt.webview import AnkiWebView
|
||||
|
||||
|
||||
class HideMode(enum.IntEnum):
|
||||
FULLSCREEN = 0
|
||||
ALWAYS = 1
|
||||
|
||||
|
||||
# wrapper class for set_bridge_command()
|
||||
class TopToolbar:
|
||||
def __init__(self, toolbar: Toolbar) -> None:
|
||||
|
@ -90,6 +96,13 @@ class TopWebView(ToolbarWebView):
|
|||
return
|
||||
|
||||
if self.mw.pm.hide_top_bar():
|
||||
if (
|
||||
self.mw.pm.top_bar_hide_mode() == HideMode.FULLSCREEN
|
||||
and not Qt.WindowState.WindowFullScreen in self.mw.windowState()
|
||||
):
|
||||
self.show()
|
||||
return
|
||||
|
||||
self.hide()
|
||||
|
||||
def hide(self) -> None:
|
||||
|
@ -188,6 +201,13 @@ class BottomWebView(ToolbarWebView):
|
|||
return
|
||||
|
||||
if self.mw.pm.hide_bottom_bar():
|
||||
if (
|
||||
self.mw.pm.bottom_bar_hide_mode() == HideMode.FULLSCREEN
|
||||
and not Qt.WindowState.WindowFullScreen in self.mw.windowState()
|
||||
):
|
||||
self.show()
|
||||
return
|
||||
|
||||
self.hide()
|
||||
|
||||
def hide(self) -> None:
|
||||
|
|
Loading…
Reference in a new issue