Add an option to disable middle click to paste on Linux (#3904)

* Add checkbox

* Working in editor

* Toolbar webview

* Other webviews

* Even more webviews

* Move to profile settings

* Add to contributors [skip ci]

* Fix checks

* Fix checks

* Better?

* Remove unneded

* Remove checkbox and a few other things

* How the hell did that happen

* Undo FTL changes (dae)

* Remove superfluous config entry (dae)

* Add comment about profile keys (dae)
This commit is contained in:
(x⋅ln(7))⁻¹ 2025-04-15 11:51:00 +02:00 committed by GitHub
parent 066f5fd281
commit 369dec9319
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View file

@ -219,6 +219,7 @@ Jakub Fidler <jakub.fidler@protonmail.com>
Valerie Enfys <val@unidentified.systems>
Julien Chol <https://github.com/chel-ou>
ikkz <ylei.mk@gmail.com>
derivativeoflog7 <https://github.com/derivativeoflog7>
rreemmii-dev <https://github.com/rreemmii-dev>
babofitos <https://github.com/babofitos>

View file

@ -94,6 +94,8 @@ metaConf = dict(
defaultLang=None,
)
# Old Anki versions expected these keys to exist. Don't add new ones here - it's better practice
# to always use profile.get(..., defaultValue) instead, as keys may be missing.
profileConf: dict[str, Any] = dict(
# profile
mainWindowGeom=None,
@ -698,6 +700,12 @@ create table if not exists profiles
def set_current_sync_url(self, url: str | None) -> None:
self.profile["currentSyncUrl"] = url
def middle_click_paste_enabled(self) -> bool:
return self.profile.get("middleClickPasteEnabled", True)
def set_middle_click_paste_enabled(self, val: bool) -> None:
self.profile["middleClickPasteEnabled"] = val
def custom_sync_url(self) -> str | None:
"""A custom server provided by the user."""
return self.profile.get("customSyncUrl")

View file

@ -350,8 +350,11 @@ class AnkiWebView(QWebEngineView):
isinstance(evt, QMouseEvent)
and evt.type() == QEvent.Type.MouseButtonRelease
):
from aqt import mw
if evt.button() == Qt.MouseButton.MiddleButton and is_lin:
self.onMiddleClickPaste()
if mw.pm.middle_click_paste_enabled():
self.onMiddleClickPaste()
return True
return False