mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

* Boolean naming convention * Rename no_strict_optional -> strict_optional * Update CONTRIBUTORS * Enable strict optional for aqt module * Fix errors * Enable strict optional for aqt browser * Fix layout.py errors * Fix find_duplicates.py errors * Fix browser.py errors * Revert a0 a1 names * Fix tree.py errors * Fix previewer.py errors * Fix model.py errors * Fix find_and_replace.py errors * Fix item.py errors * Fix toolbar.py errors * Fix table/__init__.py errors * Fix model.py errors * Fix state.py errors * Fix table.py errors * Fix errors in card_info.py * Fix searchbar.py errors * Fix name * Fix assert in browser.py * Formatting * Fix assert vh * assert is not None instead of truthy * Split _move_current() up to correct type signature (dae) We want either index or direction, but not both.
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import Enum
|
|
|
|
from aqt.qt import QEvent, QObject, QSplitter, Qt
|
|
|
|
|
|
class BrowserLayout(Enum):
|
|
AUTO = "auto"
|
|
VERTICAL = "vertical"
|
|
HORIZONTAL = "horizontal"
|
|
|
|
|
|
class QSplitterHandleEventFilter(QObject):
|
|
"""Event filter that equalizes QSplitter panes on double-clicking the handle"""
|
|
|
|
def __init__(self, splitter: QSplitter):
|
|
super().__init__(splitter)
|
|
self._splitter = splitter
|
|
|
|
def eventFilter(self, object: QObject | None, event: QEvent | None) -> bool:
|
|
assert event is not None
|
|
|
|
if event.type() == QEvent.Type.MouseButtonDblClick:
|
|
splitter_parent = self._splitter.parentWidget()
|
|
|
|
assert splitter_parent is not None
|
|
|
|
if self._splitter.orientation() == Qt.Orientation.Horizontal:
|
|
half_size = splitter_parent.width() // 2
|
|
else:
|
|
half_size = splitter_parent.height() // 2
|
|
self._splitter.setSizes([half_size, half_size])
|
|
return True
|
|
|
|
return super().eventFilter(object, event)
|