2020-01-23 06:08:10 +01:00
|
|
|
# Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2021-02-05 06:26:12 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-11-24 22:17:41 +01:00
|
|
|
import enum
|
2022-09-21 04:02:30 +02:00
|
|
|
import os
|
2020-01-23 06:08:10 +01:00
|
|
|
import platform
|
2022-09-21 04:02:30 +02:00
|
|
|
import re
|
2021-11-25 10:10:57 +01:00
|
|
|
import subprocess
|
2021-02-05 06:26:12 +01:00
|
|
|
from dataclasses import dataclass
|
2022-06-07 01:30:42 +02:00
|
|
|
from typing import Callable, List, Tuple
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2022-10-10 05:29:09 +02:00
|
|
|
import anki.lang
|
2021-11-24 22:17:41 +01:00
|
|
|
import aqt
|
2022-10-10 05:29:09 +02:00
|
|
|
from anki.lang import is_rtl
|
2021-11-25 10:10:57 +01:00
|
|
|
from anki.utils import is_lin, is_mac, is_win
|
|
|
|
from aqt import QApplication, colors, gui_hooks
|
2021-10-07 08:26:29 +02:00
|
|
|
from aqt.qt import (
|
|
|
|
QColor,
|
|
|
|
QGuiApplication,
|
|
|
|
QIcon,
|
|
|
|
QPainter,
|
|
|
|
QPalette,
|
|
|
|
QPixmap,
|
|
|
|
QStyleFactory,
|
|
|
|
Qt,
|
|
|
|
)
|
2021-02-05 06:26:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class ColoredIcon:
|
|
|
|
path: str
|
|
|
|
# (day, night)
|
2021-10-03 10:59:42 +02:00
|
|
|
color: tuple[str, str]
|
2021-02-05 06:26:12 +01:00
|
|
|
|
|
|
|
def current_color(self, night_mode: bool) -> str:
|
|
|
|
if night_mode:
|
|
|
|
return self.color[1]
|
|
|
|
else:
|
|
|
|
return self.color[0]
|
|
|
|
|
2021-10-03 10:59:42 +02:00
|
|
|
def with_color(self, color: tuple[str, str]) -> ColoredIcon:
|
2021-02-05 06:26:12 +01:00
|
|
|
return ColoredIcon(path=self.path, color=color)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
|
|
|
|
2021-11-24 22:17:41 +01:00
|
|
|
class Theme(enum.IntEnum):
|
|
|
|
FOLLOW_SYSTEM = 0
|
|
|
|
LIGHT = 1
|
|
|
|
DARK = 2
|
|
|
|
|
|
|
|
|
2020-01-23 06:08:10 +01:00
|
|
|
class ThemeManager:
|
2020-01-31 04:14:16 +01:00
|
|
|
_night_mode_preference = False
|
2021-10-03 10:59:42 +02:00
|
|
|
_icon_cache_light: dict[str, QIcon] = {}
|
|
|
|
_icon_cache_dark: dict[str, QIcon] = {}
|
2020-01-23 06:08:10 +01:00
|
|
|
_icon_size = 128
|
2021-10-03 10:59:42 +02:00
|
|
|
_dark_mode_available: bool | None = None
|
|
|
|
default_palette: QPalette | None = None
|
2021-11-24 22:17:41 +01:00
|
|
|
_default_style: str | None = None
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2022-10-10 05:29:09 +02:00
|
|
|
def rtl(self) -> bool:
|
|
|
|
return is_rtl(anki.lang.current_lang)
|
|
|
|
|
|
|
|
def left(self) -> str:
|
|
|
|
return "right" if self.rtl() else "left"
|
|
|
|
|
|
|
|
def right(self) -> str:
|
|
|
|
return "left" if self.rtl() else "right"
|
|
|
|
|
2021-05-24 03:31:56 +02:00
|
|
|
# Qt applies a gradient to the buttons in dark mode
|
|
|
|
# from about #505050 to #606060.
|
|
|
|
DARK_MODE_BUTTON_BG_MIDPOINT = "#555555"
|
|
|
|
|
2020-01-31 04:14:16 +01:00
|
|
|
def macos_dark_mode(self) -> bool:
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
"True if the user has night mode on."
|
2021-11-25 00:06:16 +01:00
|
|
|
if not is_mac:
|
2020-01-31 05:12:37 +01:00
|
|
|
return False
|
|
|
|
|
2021-02-04 10:07:34 +01:00
|
|
|
if not self._night_mode_preference:
|
|
|
|
return False
|
|
|
|
|
|
|
|
if self._dark_mode_available is None:
|
2021-11-24 22:17:41 +01:00
|
|
|
self._dark_mode_available = set_macos_dark_mode(True)
|
2021-02-04 10:07:34 +01:00
|
|
|
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
return self._dark_mode_available
|
2020-01-31 04:14:16 +01:00
|
|
|
|
|
|
|
def get_night_mode(self) -> bool:
|
2020-04-15 13:37:16 +02:00
|
|
|
return self._night_mode_preference
|
2020-01-31 04:14:16 +01:00
|
|
|
|
|
|
|
def set_night_mode(self, val: bool) -> None:
|
|
|
|
self._night_mode_preference = val
|
2020-02-07 04:19:41 +01:00
|
|
|
self._update_stat_colors()
|
2020-01-31 04:14:16 +01:00
|
|
|
|
|
|
|
night_mode = property(get_night_mode, set_night_mode)
|
|
|
|
|
2022-09-21 04:02:30 +02:00
|
|
|
def themed_icon(self, path: str) -> str:
|
|
|
|
"Fetch themed version of svg."
|
|
|
|
from aqt.utils import aqt_data_folder
|
|
|
|
|
|
|
|
if m := re.match(r"(?:mdi:)(.+)$", path):
|
|
|
|
name = m.group(1)
|
|
|
|
else:
|
|
|
|
return path
|
|
|
|
|
|
|
|
filename = f"{name}-{'dark' if self.night_mode else 'light'}.svg"
|
|
|
|
|
2022-09-28 07:12:14 +02:00
|
|
|
return (
|
|
|
|
os.path.join(aqt_data_folder(), "qt", "icons", filename)
|
|
|
|
.replace("\\\\?\\", "")
|
|
|
|
.replace("\\", "/")
|
|
|
|
)
|
2022-09-21 04:02:30 +02:00
|
|
|
|
2021-10-03 10:59:42 +02:00
|
|
|
def icon_from_resources(self, path: str | ColoredIcon) -> QIcon:
|
2022-09-21 04:02:30 +02:00
|
|
|
"Fetch icon from Qt resources."
|
2020-01-31 04:30:12 +01:00
|
|
|
if self.night_mode:
|
|
|
|
cache = self._icon_cache_light
|
|
|
|
else:
|
|
|
|
cache = self._icon_cache_dark
|
2021-02-05 06:26:12 +01:00
|
|
|
|
|
|
|
if isinstance(path, str):
|
|
|
|
key = path
|
|
|
|
else:
|
|
|
|
key = f"{path.path}-{path.color}"
|
|
|
|
|
|
|
|
icon = cache.get(key)
|
2020-01-23 06:08:10 +01:00
|
|
|
if icon:
|
|
|
|
return icon
|
|
|
|
|
2021-02-05 06:26:12 +01:00
|
|
|
if isinstance(path, str):
|
|
|
|
# default black/white
|
2022-09-21 04:02:30 +02:00
|
|
|
if "mdi:" in path:
|
|
|
|
icon = QIcon(self.themed_icon(path))
|
|
|
|
else:
|
|
|
|
icon = QIcon(path)
|
|
|
|
if self.night_mode:
|
|
|
|
img = icon.pixmap(self._icon_size, self._icon_size).toImage()
|
|
|
|
img.invertPixels()
|
|
|
|
icon = QIcon(QPixmap(img))
|
2021-02-05 06:26:12 +01:00
|
|
|
else:
|
|
|
|
# specified colours
|
|
|
|
icon = QIcon(path.path)
|
2021-03-17 05:51:59 +01:00
|
|
|
pixmap = icon.pixmap(16)
|
|
|
|
painter = QPainter(pixmap)
|
2021-10-05 05:53:01 +02:00
|
|
|
painter.setCompositionMode(
|
|
|
|
QPainter.CompositionMode.CompositionMode_SourceIn
|
|
|
|
)
|
2021-03-17 05:51:59 +01:00
|
|
|
painter.fillRect(pixmap.rect(), QColor(path.current_color(self.night_mode)))
|
2021-02-05 06:26:12 +01:00
|
|
|
painter.end()
|
2021-03-17 05:51:59 +01:00
|
|
|
icon = QIcon(pixmap)
|
2021-02-05 06:26:12 +01:00
|
|
|
return icon
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2020-01-31 04:30:12 +01:00
|
|
|
return cache.setdefault(path, icon)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2021-10-03 10:59:42 +02:00
|
|
|
def body_class(self, night_mode: bool | None = None) -> str:
|
2022-09-03 04:14:47 +02:00
|
|
|
"Returns space-separated class list for platform/theme/global settings."
|
2020-01-23 09:05:55 +01:00
|
|
|
classes = []
|
2021-11-25 00:06:16 +01:00
|
|
|
if is_win:
|
2020-01-23 09:05:55 +01:00
|
|
|
classes.append("isWin")
|
2021-11-25 00:06:16 +01:00
|
|
|
elif is_mac:
|
2020-01-23 09:05:55 +01:00
|
|
|
classes.append("isMac")
|
|
|
|
else:
|
|
|
|
classes.append("isLin")
|
2020-07-31 06:47:17 +02:00
|
|
|
|
|
|
|
if night_mode is None:
|
|
|
|
night_mode = self.night_mode
|
|
|
|
if night_mode:
|
2020-01-30 22:00:01 +01:00
|
|
|
classes.extend(["nightMode", "night_mode"])
|
2020-01-31 04:39:52 +01:00
|
|
|
if self.macos_dark_mode():
|
|
|
|
classes.append("macos-dark-mode")
|
2022-09-03 04:14:47 +02:00
|
|
|
if aqt.mw.pm.reduced_motion():
|
|
|
|
classes.append("reduced-motion")
|
2020-01-23 09:05:55 +01:00
|
|
|
return " ".join(classes)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2020-07-31 06:47:17 +02:00
|
|
|
def body_classes_for_card_ord(
|
2021-10-03 10:59:42 +02:00
|
|
|
self, card_ord: int, night_mode: bool | None = None
|
2020-07-31 06:47:17 +02:00
|
|
|
) -> str:
|
2020-01-23 06:08:10 +01:00
|
|
|
"Returns body classes used when showing a card."
|
2020-07-31 06:47:17 +02:00
|
|
|
return f"card card{card_ord+1} {self.body_class(night_mode)}"
|
2020-01-23 06:08:10 +01:00
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
def var(self, vars: tuple[str, str]) -> str:
|
|
|
|
"""Given day/night colors/props, return the correct one for the current theme."""
|
2020-08-27 08:12:30 +02:00
|
|
|
idx = 1 if self.night_mode else 0
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
return vars[idx]
|
2021-02-05 06:26:12 +01:00
|
|
|
|
2021-10-03 10:59:42 +02:00
|
|
|
def qcolor(self, colors: tuple[str, str]) -> QColor:
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
return QColor(self.var(colors))
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2021-11-24 22:17:41 +01:00
|
|
|
def _determine_night_mode(self) -> bool:
|
|
|
|
theme = aqt.mw.pm.theme()
|
|
|
|
if theme == Theme.LIGHT:
|
|
|
|
return False
|
|
|
|
elif theme == Theme.DARK:
|
|
|
|
return True
|
|
|
|
else:
|
2021-11-25 00:06:16 +01:00
|
|
|
if is_win:
|
2021-11-24 22:17:41 +01:00
|
|
|
return get_windows_dark_mode()
|
2021-11-25 00:06:16 +01:00
|
|
|
elif is_mac:
|
2021-11-24 22:17:41 +01:00
|
|
|
return get_macos_dark_mode()
|
|
|
|
else:
|
2021-11-24 23:41:15 +01:00
|
|
|
return get_linux_dark_mode()
|
2021-11-24 22:17:41 +01:00
|
|
|
|
|
|
|
def apply_style_if_system_style_changed(self) -> None:
|
|
|
|
theme = aqt.mw.pm.theme()
|
|
|
|
if theme != Theme.FOLLOW_SYSTEM:
|
|
|
|
return
|
|
|
|
if self._determine_night_mode() != self.night_mode:
|
|
|
|
self.apply_style()
|
|
|
|
|
|
|
|
def apply_style(self) -> None:
|
|
|
|
"Apply currently configured style."
|
|
|
|
app = aqt.mw.app
|
|
|
|
self.night_mode = self._determine_night_mode()
|
|
|
|
if not self.default_palette:
|
|
|
|
self.default_palette = QGuiApplication.palette()
|
|
|
|
self._default_style = app.style().objectName()
|
2020-01-23 06:08:10 +01:00
|
|
|
self._apply_palette(app)
|
|
|
|
self._apply_style(app)
|
2021-11-24 22:17:41 +01:00
|
|
|
gui_hooks.theme_did_change()
|
2020-01-23 06:08:10 +01:00
|
|
|
|
|
|
|
def _apply_style(self, app: QApplication) -> None:
|
2022-09-19 02:58:05 +02:00
|
|
|
from aqt.stylesheets import splitter_styles
|
|
|
|
|
2022-09-24 07:57:10 +02:00
|
|
|
buf = splitter_styles(self)
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
if not is_mac:
|
|
|
|
from aqt.stylesheets import (
|
|
|
|
button_styles,
|
2022-09-21 04:02:30 +02:00
|
|
|
checkbox_styles,
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
combobox_styles,
|
|
|
|
general_styles,
|
|
|
|
scrollbar_styles,
|
|
|
|
spinbox_styles,
|
|
|
|
table_styles,
|
|
|
|
tabwidget_styles,
|
|
|
|
win10_styles,
|
|
|
|
)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
buf += "".join(
|
|
|
|
[
|
2022-09-24 07:57:10 +02:00
|
|
|
general_styles(self),
|
|
|
|
button_styles(self),
|
|
|
|
combobox_styles(self),
|
|
|
|
tabwidget_styles(self),
|
|
|
|
table_styles(self),
|
|
|
|
spinbox_styles(self),
|
|
|
|
checkbox_styles(self),
|
|
|
|
scrollbar_styles(self),
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
]
|
|
|
|
)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
Redesign Qt widgets with stylesheets (#2050)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Add custom styling for Qt controls
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Create stylesheet overrides for various Qt widgets
Including QPushButton, QComboBox, QSpinBox, QLineEdit, QListWidget, QTabWidget, QTreeWidget, QToolTip, QTableView, QScrollBar and sub-widgets.
* Make webview scrollbar look identical to Qt one
* Add blue colors for primary buttons
* Tweak disabled state of SpinBox button
* Apply styles to all platforms
mainly so people like @hgiesel can easily test the widget style overrides, but maybe you actually prefer them over the native ones, who knows :)
* Tweak webview button borders
* Add type annotations to eventFilter
* Adjust padding of QComboBox and its drop-down arrow
* Use isinstance for comparison
* Remove reimport of Any
* Revert "Merge branch 'redesign-test' into custom-qt-controls"
This reverts commit ff36297456b693a0d4b4b69f5f487ac1a01c1861, reversing
changes made to 6bb45355d143aa081d2d643933bd02ddc43206de.
* Add missing copyright header
* Left-align QTabWidget headers
* Exclude macOS from stylesheet overrides
* Fix failure to start on macOS (dae)
* Use standard macOS theme in dark mode (dae)
I believe this was originally behind a feature flag because the user
had to use a hack to get it to work
(https://forums.ankiweb.net/t/title-bar-dark-mode-fix-broken/1189),
and it did not work correctly when the system theme was changed.
Since the introduction of libankihelper and the app automatically
updating as the system theme changes, these issues no longer seem to
exist, and switching between light and dark appears to work consistently.
Pushed into this PR because it addresses the background color issue
mentioned in code review.
Closes #2054
2022-09-08 12:44:38 +02:00
|
|
|
if is_win and platform.release() == "10":
|
2022-09-24 07:57:10 +02:00
|
|
|
buf += win10_styles(self)
|
2020-02-02 03:22:10 +01:00
|
|
|
|
2020-01-23 06:08:10 +01:00
|
|
|
# allow addons to modify the styling
|
|
|
|
buf = gui_hooks.style_did_init(buf)
|
|
|
|
|
|
|
|
app.setStyleSheet(buf)
|
|
|
|
|
|
|
|
def _apply_palette(self, app: QApplication) -> None:
|
2021-11-24 22:17:41 +01:00
|
|
|
set_macos_dark_mode(self.night_mode)
|
|
|
|
|
2020-01-23 06:08:10 +01:00
|
|
|
if not self.night_mode:
|
2021-11-24 22:17:41 +01:00
|
|
|
app.setStyle(QStyleFactory.create(self._default_style)) # type: ignore
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
self.default_palette.setColor(
|
|
|
|
QPalette.ColorRole.Window, self.qcolor(colors.CANVAS)
|
|
|
|
)
|
2021-11-24 22:17:41 +01:00
|
|
|
app.setPalette(self.default_palette)
|
2020-01-23 06:08:10 +01:00
|
|
|
return
|
|
|
|
|
2020-01-31 04:14:16 +01:00
|
|
|
if not self.macos_dark_mode():
|
|
|
|
app.setStyle(QStyleFactory.create("fusion")) # type: ignore
|
2020-01-23 06:08:10 +01:00
|
|
|
|
|
|
|
palette = QPalette()
|
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
text = self.qcolor(colors.FG)
|
|
|
|
palette.setColor(QPalette.ColorRole.WindowText, text)
|
|
|
|
palette.setColor(QPalette.ColorRole.ToolTipText, text)
|
|
|
|
palette.setColor(QPalette.ColorRole.Text, text)
|
|
|
|
palette.setColor(QPalette.ColorRole.ButtonText, text)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2021-02-05 09:50:01 +01:00
|
|
|
hlbg = self.qcolor(colors.HIGHLIGHT_BG)
|
2020-01-23 06:08:10 +01:00
|
|
|
hlbg.setAlpha(64)
|
2021-10-05 05:53:01 +02:00
|
|
|
palette.setColor(
|
|
|
|
QPalette.ColorRole.HighlightedText, self.qcolor(colors.HIGHLIGHT_FG)
|
|
|
|
)
|
|
|
|
palette.setColor(QPalette.ColorRole.Highlight, hlbg)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
canvas = self.qcolor(colors.CANVAS)
|
|
|
|
palette.setColor(QPalette.ColorRole.Window, canvas)
|
|
|
|
palette.setColor(QPalette.ColorRole.AlternateBase, canvas)
|
2020-02-02 03:53:35 +01:00
|
|
|
|
2021-10-05 05:53:01 +02:00
|
|
|
palette.setColor(QPalette.ColorRole.Button, QColor("#454545"))
|
2020-01-23 06:08:10 +01:00
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
canvas_inset = self.qcolor(colors.CANVAS_INSET)
|
|
|
|
palette.setColor(QPalette.ColorRole.Base, canvas_inset)
|
|
|
|
palette.setColor(QPalette.ColorRole.ToolTipBase, canvas_inset)
|
|
|
|
|
|
|
|
palette.setColor(
|
|
|
|
QPalette.ColorRole.PlaceholderText, self.qcolor(colors.FG_SUBTLE)
|
|
|
|
)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
disabled_color = self.qcolor(colors.FG_DISABLED)
|
2021-10-05 05:53:01 +02:00
|
|
|
palette.setColor(
|
|
|
|
QPalette.ColorGroup.Disabled, QPalette.ColorRole.Text, disabled_color
|
|
|
|
)
|
|
|
|
palette.setColor(
|
|
|
|
QPalette.ColorGroup.Disabled, QPalette.ColorRole.ButtonText, disabled_color
|
|
|
|
)
|
|
|
|
palette.setColor(
|
|
|
|
QPalette.ColorGroup.Disabled,
|
|
|
|
QPalette.ColorRole.HighlightedText,
|
|
|
|
disabled_color,
|
|
|
|
)
|
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
palette.setColor(QPalette.ColorRole.Link, self.qcolor(colors.ACCENT_LINK))
|
2021-10-05 05:53:01 +02:00
|
|
|
|
|
|
|
palette.setColor(QPalette.ColorRole.BrightText, Qt.GlobalColor.red)
|
2020-01-23 06:08:10 +01:00
|
|
|
|
|
|
|
app.setPalette(palette)
|
|
|
|
|
2020-02-27 03:11:00 +01:00
|
|
|
def _update_stat_colors(self) -> None:
|
2020-02-07 04:19:41 +01:00
|
|
|
import anki.stats as s
|
2020-02-07 08:55:26 +01:00
|
|
|
|
Introduce new color palette using Sass maps (#2016)
* Remove --medium-border variable
* Implement color palette using Sass maps
I hand-picked the gray tones, the other colors are from the Tailwind CSS v3 palette.
Significant changes:
- light theme is brighter
- dark theme is darker
- borders are softer
I also deleted some platform- and night-mode-specific code.
* Use custom colors for note view switch
* Use same placeholder color for all inputs
* Skew color palette for more dark values
by removing gray[3], which wasn't used anywhere. Slight adjustments were made to the darker tones.
* Adjust frame- window- and border colors
* Give deck browser entries --frame-bg as background color
* Define styling for QComboBox and QLineEdit globally
* Experiment with CSS filter for inline-colors
Inside darker inputs, some colors like dark blue will be hard to read, so we could try to improve text-color contrast with global adjustments depending on the theme.
* Use different map structure for _vars.scss
after @hgiesel's idea: https://github.com/ankitects/anki/pull/2016#discussion_r947087871
* Move custom QLineEdit styles out of searchbar.py
* Merge branch 'main' into color-palette
* Revert QComboBox stylesheet override
* Align gray color palette more with macOS
* Adjust light theme
* Use --slightly-grey-text for options tab color
* Replace gray tones with more neutral values
* Improve categorization of global colors
by renaming almost all of them and sorting them into separate maps.
* Saturate highlight-bg in light theme
* Tweak gray tones
* Adjust box-shadow of EditingArea to make fields look inset
* Add Sass functions to access color palette and semantic variables
in response to https://github.com/ankitects/anki/pull/2016#issuecomment-1220571076
* Showcase use of access functions in several locations
@hgiesel in buttons.scss I access the color palette directly. Is this what you meant by "... keep it local to the component, and possibly make it global at a later time ..."?
* Fix focus box shadow transition and remove default shadow for a cleaner look
I couldn't quite get the inset look the way I wanted, because inset box-shadows do not respect the border radius, therefore causing aliasing.
* Tweak light theme border and shadow colors
* Add functions and colors to base_lib
* Add vars_lib as dependency to base_lib and button_mixins_lib
* Improve uses of default-themed variables
* Use old --frame-bg color and use darker tone for canvas-default
* Return CSS var by default and add palette-of function for raw value
* Showcase use of palette-of function
The #{...} syntax is required only because the use cases are CSS var definitions. In other cases a simple palette-of(keyword, theme) would suffice.
* Light theme: decrease brightness of canvas-default and adjust fg-default
* Use canvas-inset variable for switch knob
* Adjust light theme
* Add back box-shadow to EditingArea
* Light theme: darken background and flatten transition
also set hue and saturation of gray-8 to 0 (like all the other grays).
* Reduce flag colors to single default value
* Tweak card/note accent colors
* Experiment with inset look for fields again
Is this too dark in night mode? It's the same color used for all other text inputs.
* Dark theme: make border-default one shade darker
* Tweak inset shadow color
* Dark theme: make border-faint darker than canvas-default
meaning two shades darker than it currently was.
* Fix PlainTextInput not expanding
* Dark theme: use less saturated flag colors
* Adjust gray tones
* Fix nested variables not getting extracted correctly
* Rename canvas-outset to canvas-elevated
* Light theme: darken canvas-default
* Make canvas-elevated a bit darker
* Rename variables and use them in various components
* Refactor button mixins
* Remove fusion vars from Anki
* Adjust button gradients
* Refactor button mixins
* Fix deck browser table td background color
* Use color function in buttons.scss
* Rework QTabWidget stylesheet
* Fix crash on browser open
* Perfect QTableView header
* Fix bottom toolbar button gradient
* Fix focus outline of bottom toolbar buttons
* Fix custom webview scrollbar
* Fix uses of vars in various webviews
The command @use vars as * lead to repeated inclusion of the CSS vars.
* Enable primary button color with mixin
* Run prettier
* Fix Python code style issues
* Tweak colors
* Lighten scrollbar shades in light theme
* Fix code style issues caused by merge
* Fix harsh border color in editor
caused by leftover --medium-border variables, probably introduced with a merge commit.
* Compile Sass before extracting Python colors/props
This means the Python side doesn't need to worry about the map structure and Sass functions, just copy the output CSS values.
* Desaturate primary button colors by 10%
* Convert accidentally capitalized variable names to lowercase
* Simplify color definitions with qcolor function
* Remove default border-focus variable
* Remove redundant colon
* Apply custom scrollbar CSS only on Windows and Linux
* Make border-subtle color brighter than background in dark theme
* Make border-subtle color a shade brighter in light theme
* Use border-subtle for NoteEditor and EditorToolbar border
* Small patches
2022-09-16 06:11:18 +02:00
|
|
|
s.colLearn = self.var(colors.STATE_NEW)
|
|
|
|
s.colRelearn = self.var(colors.STATE_LEARN)
|
|
|
|
s.colCram = self.var(colors.STATE_SUSPENDED)
|
|
|
|
s.colSusp = self.var(colors.STATE_SUSPENDED)
|
|
|
|
s.colMature = self.var(colors.STATE_REVIEW)
|
2021-10-14 11:22:47 +02:00
|
|
|
s._legacy_nightmode = self._night_mode_preference
|
2020-02-07 04:19:41 +01:00
|
|
|
|
2020-01-23 06:08:10 +01:00
|
|
|
|
2021-11-25 10:10:57 +01:00
|
|
|
def get_windows_dark_mode() -> bool:
|
|
|
|
"True if Windows system is currently in dark mode."
|
|
|
|
if not is_win:
|
|
|
|
return False
|
|
|
|
|
2022-03-23 13:20:37 +01:00
|
|
|
from winreg import ( # type: ignore[attr-defined] # pylint: disable=import-error
|
2021-11-25 10:10:57 +01:00
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
OpenKey,
|
|
|
|
QueryValueEx,
|
|
|
|
)
|
|
|
|
|
2022-01-16 05:07:28 +01:00
|
|
|
try:
|
2022-09-15 04:04:19 +02:00
|
|
|
key = OpenKey(
|
|
|
|
HKEY_CURRENT_USER,
|
|
|
|
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
|
|
|
|
)
|
2022-01-16 05:07:28 +01:00
|
|
|
return not QueryValueEx(key, "AppsUseLightTheme")[0]
|
|
|
|
except Exception as err:
|
|
|
|
# key reportedly missing or set to wrong type on some systems
|
|
|
|
return False
|
2021-11-25 10:10:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def set_macos_dark_mode(enabled: bool) -> bool:
|
|
|
|
"True if setting successful."
|
2021-12-06 13:18:53 +01:00
|
|
|
from aqt._macos_helper import macos_helper
|
|
|
|
|
|
|
|
if not macos_helper:
|
2021-11-25 10:10:57 +01:00
|
|
|
return False
|
2021-12-06 13:18:53 +01:00
|
|
|
return macos_helper.set_darkmode_enabled(enabled)
|
2021-11-25 10:10:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def get_macos_dark_mode() -> bool:
|
|
|
|
"True if macOS system is currently in dark mode."
|
2021-12-06 13:18:53 +01:00
|
|
|
from aqt._macos_helper import macos_helper
|
|
|
|
|
|
|
|
if not macos_helper:
|
2021-11-25 10:10:57 +01:00
|
|
|
return False
|
2021-12-06 13:18:53 +01:00
|
|
|
return macos_helper.system_is_dark()
|
2021-11-25 10:10:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
def get_linux_dark_mode() -> bool:
|
|
|
|
"""True if Linux system is in dark mode.
|
2022-06-07 01:30:42 +02:00
|
|
|
Only works if D-Bus is installed and system uses org.freedesktop.appearance
|
|
|
|
color-scheme to indicate dark mode preference OR if GNOME theme has
|
|
|
|
'-dark' in the name."""
|
2021-11-25 10:10:57 +01:00
|
|
|
if not is_lin:
|
|
|
|
return False
|
|
|
|
|
2022-06-07 01:30:42 +02:00
|
|
|
def parse_stdout_dbus_send(stdout: str) -> bool:
|
|
|
|
dbus_response = stdout.split()
|
|
|
|
if len(dbus_response) != 4:
|
|
|
|
return False
|
|
|
|
|
|
|
|
# https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.impl.portal.Settings.xml#L40
|
|
|
|
PREFER_DARK = "1"
|
|
|
|
|
|
|
|
return dbus_response[-1] == PREFER_DARK
|
|
|
|
|
|
|
|
dark_mode_detection_strategies: List[Tuple[str, Callable[[str], bool]]] = [
|
|
|
|
(
|
|
|
|
"dbus-send --session --print-reply=literal --reply-timeout=1000 "
|
|
|
|
"--dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop "
|
|
|
|
"org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' "
|
|
|
|
"string:'color-scheme'",
|
|
|
|
parse_stdout_dbus_send,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"gsettings get org.gnome.desktop.interface gtk-theme",
|
|
|
|
lambda stdout: "-dark" in stdout.lower(),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
for cmd, parse_stdout in dark_mode_detection_strategies:
|
|
|
|
try:
|
|
|
|
process = subprocess.run(
|
|
|
|
cmd,
|
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
capture_output=True,
|
|
|
|
encoding="utf8",
|
|
|
|
)
|
|
|
|
except FileNotFoundError as e:
|
|
|
|
# detection strategy failed, missing program
|
|
|
|
print(e)
|
|
|
|
continue
|
|
|
|
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
# detection strategy failed, command returned error
|
|
|
|
print(e)
|
|
|
|
continue
|
|
|
|
|
|
|
|
return parse_stdout(process.stdout)
|
2022-01-24 10:48:32 +01:00
|
|
|
|
2022-06-07 01:30:42 +02:00
|
|
|
return False # all dark mode detection strategies failed
|
2021-11-25 10:10:57 +01:00
|
|
|
|
|
|
|
|
2020-01-23 06:08:10 +01:00
|
|
|
theme_manager = ThemeManager()
|