Skip to content

Commit

Permalink
Merge pull request #53 from Shirajuki/contanki-compatibility
Browse files Browse the repository at this point in the history
Fixes #38: Visual glitch / Contanki addon compatibility
  • Loading branch information
Shirajuki authored Oct 27, 2022
2 parents 8c8bb59 + 8d62d99 commit 58386b0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 43 deletions.
10 changes: 0 additions & 10 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
themes_parsed = get_theme(theme)
color_mode = 2 if theme_manager.get_night_mode() else 1 # 1 = light and 2 = dark

from .utils.dark_title_bar import set_dark_titlebar, set_dark_titlebar_qt, dwmapi
set_dark_titlebar(mw, dwmapi)
logger.debug(dwmapi)

### CSS injections
def load_custom_style():
# Theme config
Expand Down Expand Up @@ -183,8 +179,6 @@ def on_webview_will_set_content(web_content: WebContent, context: Optional[Any])
def on_dialog_manager_did_open_dialog(dialog_manager: DialogManager, dialog_name: str, dialog_instance: QWidget) -> None:
logger.debug(dialog_name)
dialog: AnkiQt = dialog_manager._dialogs[dialog_name][1]
# If dwmapi found and nightmode is enabled, set dark titlebar to dialog window
set_dark_titlebar_qt(dialog, dwmapi)
# AddCards
if dialog_name == "AddCards":
context: AddCards = dialog_manager._dialogs[dialog_name][1]
Expand All @@ -197,7 +191,6 @@ def on_dialog_manager_did_open_dialog(dialog_manager: DialogManager, dialog_name
elif dialog_name == "Browser":
context: Browser = dialog_manager._dialogs[dialog_name][1]
context.setStyleSheet(open(css_files_dir['QBrowser'], encoding='utf-8').read())
pass
# EditCurrent
elif dialog_name == "EditCurrent":
context: EditCurrent = dialog_manager._dialogs[dialog_name][1]
Expand Down Expand Up @@ -233,7 +226,6 @@ def on_dialog_manager_did_open_dialog(dialog_manager: DialogManager, dialog_name
def monkey_setup_dialog_gc(obj: Any) -> None:
obj.finished.connect(lambda: mw.gcWindow(obj))
logger.debug(obj)
set_dark_titlebar_qt(obj, dwmapi)
# AddCards
if isinstance(obj, AddCards):
obj.setStyleSheet(open(css_files_dir['QAddCards'], encoding='utf-8').read())
Expand All @@ -254,14 +246,12 @@ def monkey_setup_dialog_gc(obj: Any) -> None:
if attribute_exists(gui_hooks, "addons_dialog_will_show"):
def on_addons_dialog_will_show(dialog: AddonsDialog) -> None:
logger.debug(dialog)
set_dark_titlebar_qt(dialog, dwmapi)
dialog.setStyleSheet(open(css_files_dir['QAddonsDialog'], encoding='utf-8').read())
gui_hooks.addons_dialog_will_show.append(on_addons_dialog_will_show)
# Browser
if attribute_exists(gui_hooks, "browser_will_show"):
def on_browser_will_show(browser: Browser) -> None:
logger.debug(browser)
set_dark_titlebar_qt(browser, dwmapi)
browser.setStyleSheet(open(css_files_dir['QBrowser'], encoding='utf-8').read())
gui_hooks.browser_will_show.append(on_browser_will_show)

Expand Down
6 changes: 6 additions & 0 deletions user_files/themes/Anki.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"#454545",
"--button-bg"
],
"BUTTON_FOCUS_BG": [
"Button Focus Background",
"#0093d0",
"#0093d0",
"--button-focus-bg"
],
"CURRENT_DECK": [
"Selected Deck",
"#e7e7e7",
Expand Down
8 changes: 7 additions & 1 deletion user_files/themes/Nord.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
"Button Background",
"#D8DEE9",
"#3B4252",
""
"--button-bg"
],
"BUTTON_FOCUS_BG": [
"Button Focus Background",
"#0093d0",
"#0093d0",
"--button-focus-bg"
],
"CURRENT_DECK": [
"Selected Deck",
Expand Down
29 changes: 0 additions & 29 deletions utils/dark_title_bar.py

This file was deleted.

3 changes: 0 additions & 3 deletions utils/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ..config import config, write_config, get_config
from aqt.utils import showInfo
from aqt.webview import AnkiWebView
from .dark_title_bar import set_dark_titlebar_qt, dwmapi
from .logger import logger
from aqt.theme import theme_manager, colors
from ..injections.toolbar import redraw_toolbar, redraw_toolbar_legacy
Expand Down Expand Up @@ -38,7 +37,6 @@ def __init__(self, parent, *args, **kwargs):
self.setSizePolicy(self.make_size_policy())
self.setMinimumSize(420, 420)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
set_dark_titlebar_qt(self, dwmapi, fix=False)
# Root layout
self.root_layout = QVBoxLayout(self)
# Main layout
Expand Down Expand Up @@ -92,7 +90,6 @@ def __init__(self, parent: QWidget, *args, **kwargs):
self.setSizePolicy(self.make_size_policy())
self.setMinimumSize(420, 580)
self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
set_dark_titlebar_qt(self, dwmapi, fix=False)

# Color/theme
## Loads theme color
Expand Down

0 comments on commit 58386b0

Please sign in to comment.