Commit graph

46 commits

Author SHA1 Message Date
qxo
c53e49a8c8 fix: try catch excepton in get_windows_dark_mode and global cache the check (#1587)
* fix: try catch excepton on get_windows_dark_mode and global cache that check

* add commitor email to CONTRIBUTORS

* remove is_windows_dark_mode cache

* avoid logging the missing key (dae)

The check happens frequently, so this will fill up the user's console if we print it each time.
2022-01-16 14:07:28 +10:00
RumovZ
794999ac28 Use white menubar on Windows in lightmode (#1590) 2022-01-16 13:45:16 +10:00
Damien Elmes
2ad5b2ed3c implement a basic native macOS audio recorder
This was motivated by the fact that recording was crashing on the native
M1 build. That ended up being mostly a PEBKAC problem - turns out the
Mac Mini has no built-in microphone 🤦.

I still thinks this has some value though - it doesn't crash in such
cases, and probably doesn't suffer from the problem shown in this thread
either:

https://forums.ankiweb.net/t/anki-crashes-when-trying-to-record-on-mac/14764

For now, this is only enabled when running on arm64. If it turns out to
be reliable, it could be offered as an option on amd64 as well.
2021-12-07 18:48:24 +10:00
Damien Elmes
cbf14b16c4 move aqt/platform.py code into theme.py
We have other platform-specific code scattered through the codebase,
and better it lives in a location where it is used.
2021-11-25 19:10:57 +10:00
Damien Elmes
0e4c02eac1 update platform checks (eg isWin -> is_win) + devMode 2021-11-25 09:06:16 +10:00
Damien Elmes
0d46cb7fd9 add minimal theme detection on Linux
Closes #1116
2021-11-25 08:45:14 +10:00
RumovZ
54d39d1b3b Live theme changes (#1497)
* Allow theme change at runtime and add hook

* Save or restore default palette on theme change

* Update aqt widget styles on theme change

* styling fixes

- drop _light_palette, as default_palette serves the same purpose
- save default platform theme, and restore it when switching away
from nightmode
- update macOS light/dark mode on theme switch
- fix unreadable menus on Windows

* update night-mode classes on theme change

This is the easy part - CSS styling that uses standard_css or our
css variables should update automatically. The main remaining issue
is JS code that sets colors based on the theme at the time it's run -
eg the graph code, and the editor.

* switch night mode value on toggle

* expose current theme via a store; switch graphs to use it

https://github.com/ankitects/anki/issues/1471#issuecomment-972402492

* start using currentTheme in editor/components

This fixes basic editing - there are still components that need updating.

* add simple xcodeproj for code completion

* add helper to get currently-active system theme on macOS

* fix setCurrentTheme not being immediately available

* live update tag color

* style().name() doesn't work on Qt5

* automatic theme switching on Windows/Mac

* currentTheme -> pageTheme

* Replace `nightModeKey` with `pageTheme`

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2021-11-25 07:17:41 +10:00
Damien Elmes
8dbf6f74f8 fix placeholder text color on win/lin 2021-10-15 12:57:19 +10:00
Damien Elmes
6b4b13f58e fix incorrect web background color being picked up in qt6+win/lin 2021-10-15 12:57:19 +10:00
Damien Elmes
631c345ef0 switch to new-style PyQt scoped enums and Qt6
The enum changes should work on PyQt 5.x, and are required in PyQt 6.x.
They are not supported by the PyQt5 typings however, so we need to run
our tests with PyQt6.
2021-10-15 12:57:19 +10:00
RumovZ
ea9fc3730e Switch CardInfoDialog to ts page (#1414)
* Only collect card stats on the backend ...

... instead of rendering an HTML string using askama.

* Add ts page Card Info

* Update test for new `col.card_stats()`

* Remove obsolete CardStats code

* Use new ts page in `CardInfoDialog`

* Align start and end instead of left and right

Curiously, `text-align: start` does not work for `th` tags if assigned
via classes.

* Adopt ts refactorings after rebase

#1405 and #1409

* Clean up `ts/card-info/BUILD.bazel`

* Port card info logic from Rust to TS

* Move repeated field to the top

https://github.com/ankitects/anki/pull/1414#discussion_r725402730

* Convert pseudo classes to interfaces

* CardInfoPage -> CardInfo

* Make revlog in card info optional

* Add legacy support for old card stats

* Check for undefined instead of falsy

* Make Revlog separate component

* drop askama dependency (dae)

* Fix nightmode for legacy card stats
2021-10-14 19:22:47 +10:00
Damien Elmes
3c1729e91b run pyupgrade over codebase [python upgrade required]
This adds Python 3.9 and 3.10 typing syntax to files that import
attributions from __future___. Python 3.9 should be able to cope with
the 3.10 syntax, but Python 3.8 will no longer work.

On Windows/Mac, install the latest Python 3.9 version from python.org.
There are currently no orjson wheels for Python 3.10 on Windows/Mac,
which will break the build unless you have Rust installed separately.

On Linux, modern distros should have Python 3.9 available already. If
you're on an older distro, you'll need to build Python from source first.
2021-10-04 15:05:48 +10:00
hikaru-y
3eb4321087 Store default palette before "fusion" QStyle is applied
Once a QStyle different from the system default is applied, the system default palette can no longer be retrieved with standardPalette().
2021-06-24 23:46:11 +09:00
Damien Elmes
f35b471dca make switch more legible in dark mode 2021-05-24 11:31:56 +10:00
Damien Elmes
9ad1e50544 fix a bunch of qt typing issues uncovered by the following commit 2021-03-19 19:45:21 +10:00
Damien Elmes
bf7528d90a minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
b44cc23b66 use constants for other color references
str_color/qcolor() doesn't appear to have been used by any add-ons
except one of mine, so changing the signature should be safe
2021-02-05 18:58:22 +10:00
Damien Elmes
b6e873b17b move remaining Filter button items into sidebar
- Closes #976
- Added helper to apply arbitrary colour to an icon.
- Fix #979 - low res icons in night mode.
- The icons and colours are not perfect - please feel free to send
through a PR if you can improve them.
- Convert colors dictionary into module consts, so we can
use code completion.
- Added "Edited Today" and "Due Tomorrow"
- Rename camelCase attribute to snake_case and tweak the wording
of some enum constants. We've already broken compatibility with the
major sidebar add-ons, so we may as well make these changes while we
can.
- Removed Filter button. Currently there is no exposed way to toggle
the Sidebar off - wonder if we still need it?
2021-02-05 18:58:22 +10:00
Damien Elmes
51ac1ea935 turn top bar dark when night mode enabled on macOS 2021-02-04 19:19:56 +10:00
Damien Elmes
8b0be88df5 fix invisible scrollbar in nightmode
vars.scss no longer contains the Qt theme definitions, so the
easiest solution was to duplicate the colour in this case
2020-10-06 14:35:21 +10:00
Damien Elmes
2411e944e4 drop the old sass vars and define the properties directly 2020-09-01 10:24:38 +10:00
Damien Elmes
514409d86f migrate the majority of the sass vars to css variables
Allows add-ons to easily override the theme, and allows us to apply
styling to elements outside of the normal document flow (like applying
the normal background colour to a position: fixed element).
2020-09-01 10:24:38 +10:00
Damien Elmes
684cf9732c pass night mode into body_class() instead of changing globally 2020-07-31 14:47:17 +10:00
Damien Elmes
41f469459e pare back dark mode support
Anki now solely relies on the night mode setting in the preferences
to decide whether to show in light or dark mode. Some users wanted
to run Anki in light mode while keeping the rest of their system dark,
and there were various display problems when dark mode was changed
after Anki started that couldn't be easily worked around.

NSRequiresAquaAppearance is set again, which means we can rely on
the interface appearing properly and not changing as the macOS theme
is changed.

Users who only use dark mode, and preferred the native look of widgets
in dark mode, can achieve the previous appearance by running the
following command in the terminal:

defaults write net.ankiweb.dtop NSRequiresAquaSystemAppearance -bool no

And the following in the debug console:

mw.pm.meta["dark_mode_widgets"] = True

This is hidden behind a debug console command because it requires the
user ensure their system is always set to the same light/dark mode
as Anki.
2020-04-15 21:44:56 +10:00
Damien Elmes
0c4feaa800 cache dark mode value so UI doesn't break when it changes
https://anki.tenderapp.com/discussions/ankidesktop/39550-cant-deactivate-night-mode-on-2121-for-mac
2020-03-23 18:39:37 +10:00
Alan Du
c283013ccd Monkeytype qt/aqt/theme.py 2020-03-01 10:16:08 -05:00
Damien Elmes
8b728b4a1e fix dark mode target Qt version 2020-02-26 16:53:35 +10:00
Damien Elmes
c172557e47 formatting fix 2020-02-25 17:29:10 +10:00
Damien Elmes
9aa23c4846 don't pick up system dark theme in -alternate Mac build
The older Qt doesn't support it properly
2020-02-25 15:46:39 +10:00
Damien Elmes
cc27baef35 formatting 2020-02-07 17:55:26 +10:00
Damien Elmes
d20ac6f341 more legible graph colours in night mode 2020-02-07 13:21:46 +10:00
Damien Elmes
85b3a1dc94 formatting 2020-02-02 13:09:02 +10:00
Damien Elmes
62b5c4bf73 only apply padding fix to stats screen
It was breaking the display of dialogs like the filtered deck screen
2020-02-02 13:07:24 +10:00
Damien Elmes
6dbbc52d1a more contrast on buttons and scrollbars 2020-02-02 12:53:35 +10:00
Damien Elmes
c1c1a54ea8 match fusion bars to webview bars, bump size again 2020-02-02 12:25:07 +10:00
Damien Elmes
cca836de34 make pylint happy 2020-01-31 14:30:41 +10:00
Damien Elmes
3377fea96c only import darkdetect on a Mac 2020-01-31 14:14:54 +10:00
Damien Elmes
74f5acce6e when dark mode not active, match fusion buttons 2020-01-31 13:39:52 +10:00
Damien Elmes
a25c092a8b ignore dark mode when running from source, as it doesn't work 2020-01-31 13:30:35 +10:00
Damien Elmes
b7c492c40c maintain separate icon cache for light and dark themes 2020-01-31 13:30:12 +10:00
Damien Elmes
7a63c42b39 use night mode when dark mode active, using standard macOS theme 2020-01-31 13:15:08 +10:00
Damien Elmes
a8e0b53165 add .night_mode as well
Please report if this causes any regressions.
2020-01-31 07:00:01 +10:00
Damien Elmes
6973df52a0 fix tags area and stats buttons in night mode 2020-01-26 09:13:38 +10:00
Damien Elmes
e61759bf35 fix night mode tooltips 2020-01-24 07:55:14 +10:00
Damien Elmes
a9749bbcb1 fix inconsistently sized buttons and add platform classes 2020-01-23 18:05:55 +10:00
Damien Elmes
35435a130e basic night mode support
Forces the Fusion theme when running night mode, so we don't need
to work around platform themes that don't respond to the defined
palette.

Feedback/suggestions on the chosen colours welcome - _vars.scss is the
file to change if you want to experiment with adjustments.
2020-01-23 17:27:07 +10:00