Commit Graph

97 Commits

Author SHA1 Message Date
Damien Elmes
c1587254f4 use isort to tidy up imports 2019-12-20 19:19:29 +10:00
Damien Elmes
ff6b58c265 opt in to qt's new non-integer scaling 2019-12-17 18:43:32 +10:00
Damien Elmes
c508498ba8 add aqt/ 2019-12-16 08:51:38 +10:00
Damien Elmes
7b93e9855e quieten local port message for now
the race condition that is causing this still needs to be investigated
2019-06-27 10:01:23 +10:00
Damien Elmes
1f36a7112f don't error out when non-latin characters written to js console
(some?) macOS users have an ascii encoding, so we need to escape
the non-ascii portions prior to writing
2019-05-17 08:43:25 +10:00
Damien Elmes
6594f62f5d fix stuck webview issue
A race condition could cause domDone to get stuck on false, causing
any further bridge messages and setHtml() calls to be ignored. Fix
the issue by clearing pending actions and resetting domDone when
setting HTML.
2019-04-29 16:41:47 +10:00
Damien Elmes
eef86bf37e don't try set filter if webview already deleted
https://anki.tenderapp.com/discussions/add-ons/32496-add-on-error
2019-04-21 19:12:04 +10:00
Damien Elmes
f80d250b47 Revert "Workaround for AltGr '@' issue."
This reverts commit 1e433a7cdd and
91178d3d58

Due to regressions this will be moved into an optional add-on, at
least for now.
2019-04-16 13:39:40 +10:00
Damien Elmes
91178d3d58 extend altgr fix to editor fields, and add warning about helper
extends https://github.com/dae/anki/pull/298
2019-04-10 16:16:29 +10:00
Damien Elmes
4a167304a6
Merge pull request #298 from dlon/altgr-fix
"@" suspends cards with text input for some keyboard layouts
2019-04-10 15:33:02 +10:00
Damien Elmes
111727240b standard blue focus highlight on windows 2019-04-10 15:16:06 +10:00
Damien Elmes
df4aad50e1 avoid popups for some non-serious warnings 2019-04-10 12:44:01 +10:00
David Lönnhager
1e433a7cdd Workaround for AltGr '@' issue. 2019-04-09 14:55:00 +02:00
Damien Elmes
0543df7dfa allow translators to override Windows font
to work around Qt's awful fallback handling on Windows 10

https://anki.tenderapp.com/discussions/ankidesktop/32922-chinese-characters-in-the-main-window-when-setting-language-to-japanese
2019-03-06 15:28:49 +10:00
Damien Elmes
ebdd8dae4b tidy up unused imports 2019-03-04 17:25:19 +10:00
Damien Elmes
f6b2135129 fix some warnings 2019-03-04 16:01:10 +10:00
Damien Elmes
da2ddcc6e2 explicitly import _ and ngettext 2019-03-04 11:58:34 +10:00
Glutanimate
ac53a0852e Set webview bg to system default window color instead of Qt.transparent
Qt.transparent prevents subpixel anti-aliasing from working, resulting
in slightly blurry fonts on non-retina displays.
(The window background color is not determined correctly on macOS, so
we hardcode it.)

Credits for discovering this issue go to the unknown author of
https://ankiweb.net/shared/info/94394764
2019-02-25 11:44:27 +01:00
Damien Elmes
1e9fb6ab29 turn local port message into a tooltip and automatically reload
Since we're automatically disabling proxies now, the main remaining
issue seems to be Windows users resuming their machine from sleep -
for some reason localhost is inaccessible during the resume process.
2019-02-06 07:55:34 +10:00
Damien Elmes
372d5ed6e8 update copyright and clarify licenses 2019-02-05 14:01:33 +10:00
Damien Elmes
a9f9df5109 Revert "workaround bottom toolbar issue on macOS/qt5.12"
This reverts commit 5e3f35a32c.

underlying issue should be fixed in qt5.12beta3
2018-10-29 21:08:16 +10:00
Damien Elmes
5e3f35a32c workaround bottom toolbar issue on macOS/qt5.12 2018-10-25 15:34:27 +10:00
Damien Elmes
14f4107dfd deal with onclick handlers that don't return false
Because <base> is set to the media server URL, <a href='#' ...> causes
a page transition from the current setHtml() page data. Previous Qt
versions allowed us to just ignore the request, but now returning False
in acceptNavigationRequest() causes the subsequent page navigation to
be rejected as well, resulting in no visible change when clicking on a
deck in the deck list.

To deal with this, Anki will now warn when such navigation requests
come in, as the anchors need to be updated to return false. pycmd()
has been updated to return false to make returning in onclick easier.

Also use QUrl.matches() instead of converting the potentially long
URL to a string.
2018-10-23 16:47:01 +10:00
Damien Elmes
fa9a54db98 allow the initial setHtml() request to proceed
Qt 5.11 appears to call acceptNavigationRequest() for the initial
page load now.
2018-10-23 16:11:08 +10:00
Damien Elmes
1af556cb8d delay event filter installation
Qt 5.11 doesn't initialize the focusProxy until
a page has been loaded.
2018-10-23 16:06:56 +10:00
Damien Elmes
b0091053bf don't require collection for top toolbar
This is a hack, and ideally the code would be refactored
so that the entire main window is not loaded until a collection
is available, but doing that will break a bunch of add-ons.

Fixes
https://anki.tenderapp.com/discussions/beta-testing/1276-anki-215-beta#comment_46241878
2018-10-12 12:08:19 +10:00
Damien Elmes
63661713df use 127.0.0.1 instead of localhost in local urls 2018-10-11 15:45:55 +10:00
Damien Elmes
2868ec0e8b catch js results that are received after collection closed 2018-09-28 16:27:41 +10:00
Glutanimate
2f58152f13 Try to more closely imitate native widget theming on Linux
Renames stdHtml buttonspec to widgetspec, and applies a number of Linux-
specific adjustments, including:

+ updated button designs that more native/modern
+ updated widget focus colors that follow the theme
  default color palette
2018-08-30 22:07:06 +02:00
Damien Elmes
9987c18a1c warn and close when media server requests fail 2018-06-29 17:17:13 +10:00
Mark Harmstone
40612c5329 stdHtml: fix certain fonts not working on Linux 2018-05-27 21:16:55 +01:00
Damien Elmes
56e1643bfa allow pycmd() to return a value
based on pull request #228
2018-03-08 17:48:14 +10:00
Damien Elmes
dc6ebca944 filter middle click pastes 2018-03-02 11:16:02 +10:00
Damien Elmes
118326df1e remove format literals so we can support python 3.5 2018-01-16 16:07:30 +10:00
Damien Elmes
41205bd5ca allow user to override scaling
which may help wth issues like
https://anki.tenderapp.com/discussions/beta-testing/918-text-size-in-ubuntu-1710
and
https://anki.tenderapp.com/discussions/ankidesktop/25708-anki-with-high-dpi-screen
2017-11-27 11:01:15 +10:00
Damien Elmes
1d3e5787a2 separate basic and extended paste modes
- basic mode is the default, and includes only HTML elements that can be
added/edited easily with the default editor
- extended mode is enabled by holding down shift and includes a bunch of
other HTML elements
2017-10-25 20:20:28 +10:00
Damien Elmes
33c5b5f9e7 remove lodpi hack, don't assume physical DPI is always 72 2017-10-05 16:42:46 +10:00
Damien Elmes
e1a4c52175 pass opts to main window; force zoom factor to 1 on lodpi 2017-10-03 12:12:57 +10:00
Damien Elmes
d530134218 option to disable qt's hidpi scaling
https://anki.tenderapp.com/discussions/beta-testing/765-problem-with-the-ui-of-anki
2017-10-02 16:26:23 +10:00
Damien Elmes
a4b45af5a9 fix scrollbar appearing in toolbar
https://anki.tenderapp.com/discussions/beta-testing/675-anki-210-beta-10/page/2#comment_43239350
2017-08-28 21:15:38 +10:00
Damien Elmes
a8ce74a784 compensate for qt's integer scaling on windows
fixes

https://anki.tenderapp.com/discussions/beta-testing/687-high-resolution-display-scaling-issue
2017-08-15 14:47:03 +10:00
Damien Elmes
ba16b8714b remove images and move away from qt resources
- the bulk of image use is in webviews, so we move almost all used
images to web/imgs, as it's easier to manage
- change AnkiWebView to always use the local media server as a base, as
much of the UI has come to depend on it
- remove images from a few areas, as they felt dated
- delete a bunch of unused images
- href=# links were being opened in a browser window, so the code now
ignores them - the HTML should really be updated to return false in the
onclick handler
- update a few icons
2017-08-11 20:59:43 +10:00
Damien Elmes
f3f90842dc move the inline css and some more js into separate files
- stdHtml() css= arg now takes a list of files like js=
- the files are loaded in the head of the document so that styling
that comes later in the document can easily override it

fixes:
https://anki.tenderapp.com/discussions/beta-testing/661-anki-210-beta-7/page/1#comment_43164447
https://anki.tenderapp.com/discussions/beta-testing/661-anki-210-beta-7#comment_43177130
2017-08-10 19:02:32 +10:00
Damien Elmes
c8e8225395 remove unused bodyClass arg 2017-08-10 18:10:50 +10:00
Damien Elmes
a57b913450 opt in to qt's full hidpi support
doesn't seem to affect the webviews on Linux, so we need to keep the old
zoom code around for now
2017-08-10 15:02:46 +10:00
Damien Elmes
c74cbf6108 fix media server port allocation
the old code was allowing the main thread to read .port before it had
been updated, and was binding to sockets that were already in use on
Windows. instead, we use a system-assigned free port and block the main
thread until it's been allocated
2017-08-08 14:56:34 +10:00
Damien Elmes
538119201c ensure deferred js is executed on the correct page
setHtml() and deferred js now share a single queue, to ensure that js
calls are delivered to the correct page

also remove the onLoadFinished hook, which is no longer used
2017-08-07 16:01:35 +10:00
Damien Elmes
9c63714e80 delay setHtml() until previous page has fully loaded
based on 0241eb70dc
2017-08-07 15:15:31 +10:00
Damien Elmes
b0213b9fd7 ignore webchannel events received after webview deleted
thanks to David for the report
2017-08-07 14:51:42 +10:00
Damien Elmes
a11035b2fa Revert "fix TypeError: channel.execCallbacks[message.id] is not a function"
This reverts commit 331239de05.

This commit caused the blur event from the editor to fire after the saveNow()
callback had run, which broke the reviewer when returning from editcurrent.
Reverting for now, as the actual error is harmless AFAICT.
2017-08-06 15:12:28 +10:00