5 Commits

Author SHA1 Message Date
cefa65eadf Merge pull request #20 from spacelord47/fix/use_qt6_enums_properly
All checks were successful
continuous-integration/drone/tag Build is passing
Fixes: #19 
Fixes: #18
2023-11-05 16:02:06 +01:00
766d246f46 fix: use Qt6 enums properly
New Anki version(23.10) dropped compatibility for Qt5: https://forums.ankiweb.net/t/porting-tips-for-anki-23-10/35916#enumerations-6
2023-11-05 13:53:17 +00:00
23f9c0cb68 Patch version check for new versioning scheme
I haven't taken a look at anything in the new version yet.
But that closes #16.
2023-09-25 11:50:44 +02:00
ab68523be6 Merge PR #10 2023-03-24 18:16:25 +01:00
734f24646e Remove the usage of deprecated function.
mv.pm.night_mode() is deprecated (see
1ed2cce648/qt/aqt/profiles.py (L537)).
Furthermore, on anki Version ⁨2.1.54, Python 3.9.10 Qt 6.3.1 PyQt 6.3.1, this function returns false, even when the dark mode is set.
2022-12-14 08:36:12 +01:00
2 changed files with 10 additions and 11 deletions

1
.gitignore vendored
View File

@ -117,6 +117,7 @@ venv/
ENV/
env.bak/
venv.bak/
.idea
# Spyder project settings
.spyderproject

View File

@ -19,7 +19,10 @@ class EditorPreview(object):
def __init__(self):
gui_hooks.editor_did_init.append(self.editor_init_hook)
gui_hooks.editor_did_init_buttons.append(self.editor_init_button_hook)
if int(buildinfo.version.split(".")[2]) < 45: # < 2.1.45
buildversion = buildinfo.version.split(".")
# Anki changed their versioning scheme in 2023 to year.month(.patch), causing things to explode here.
if not int(buildversion[0]) >= 23 and int(buildversion[2]) < 45: # < 2.1.45
self.js = [
"js/vendor/jquery.min.js",
"js/vendor/css_browser_selector.min.js",
@ -53,22 +56,22 @@ class EditorPreview(object):
location = config["location"]
split = QSplitter()
if location == "above":
split.setOrientation(Qt.Vertical)
split.setOrientation(Qt.Orientation.Vertical)
split.addWidget(editor.editor_preview)
split.addWidget(editor.web)
sizes = [editorR, mainR]
elif location == "below":
split.setOrientation(Qt.Vertical)
split.setOrientation(Qt.Orientation.Vertical)
split.addWidget(editor.web)
split.addWidget(editor.editor_preview)
sizes = [mainR, editorR]
elif location == "left":
split.setOrientation(Qt.Horizontal)
split.setOrientation(Qt.Orientation.Horizontal)
split.addWidget(editor.editor_preview)
split.addWidget(editor.web)
sizes = [editorR, mainR]
elif location == "right":
split.setOrientation(Qt.Horizontal)
split.setOrientation(Qt.Orientation.Horizontal)
split.addWidget(editor.web)
split.addWidget(editor.editor_preview)
sizes = [mainR, editorR]
@ -111,12 +114,7 @@ class EditorPreview(object):
c = note.ephemeral_card()
a = mw.prepare_card_text_for_display(c.answer())
a = gui_hooks.card_will_show(a, c, "clayoutAnswer")
if theme_manager.night_mode:
bodyclass = theme_manager.body_classes_for_card_ord(
c.ord, mw.pm.night_mode()
)
else:
bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
bodyclass = theme_manager.body_classes_for_card_ord(c.ord, theme_manager.night_mode)
bodyclass += " editor-preview"
return f"_showAnswer({json.dumps(a)},'{bodyclass}');"