Commit Graph

85 Commits

Author SHA1 Message Date
Damien Elmes
df4aad50e1 avoid popups for some non-serious warnings 2019-04-10 12:44:01 +10: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
Damien Elmes
331239de05 fix TypeError: channel.execCallbacks[message.id] is not a function
we need to avoid calling setHtml() until the bridge command has
had a chance to pass its return code back down the channel
2017-08-06 13:46:18 +10:00
Damien Elmes
718b4b35d1 don't translate js console msgs 2017-08-06 13:10:51 +10:00
Damien Elmes
37d3996be0 move height resizing to webview; remove onLoaded from toolbar/reviewer 2017-08-02 16:22:54 +10:00
Damien Elmes
7d14a96889 automatically defer eval() calls until DOM loaded 2017-08-02 16:17:08 +10:00
Damien Elmes
66500f5262 move webview js into separate file 2017-08-01 17:04:55 +10:00
Damien Elmes
cd76281695 avoid errors caused by calling setHtml() before previous page loaded 2017-08-01 14:30:04 +10:00
Damien Elmes
7ad6966943 split js code out into separate files, mathjax improvements
- js code that was previously bundled in .py files is now in the
web folder
- add helpers to create links to bundled files, and update
stdHtml() to accept a list of javascript files to include
instead of text
- render MathJax in card layout and preview screens - these should be
updated in the future to update the document dynamically like the
reviewer does
- start media server earlier so it can be used to serve content for
the toolbar, etc
- work around a bug in WebEngine on Windows that could cause the
media server to hang
2017-07-28 16:35:45 +10:00
Damien Elmes
d99dcaafdc don't open separate browser window on iframe load
https://anki.tenderapp.com/discussions/beta-testing/627-anki-210-beta-1#comment_43008395
2017-07-17 12:40:38 +10:00
Damien Elmes
ea5f2bb0ef don't need to set bgcol when the window is transparent 2017-06-24 19:15:14 +10:00
Damien Elmes
7bd33242cf disable pinch to zoom gesture 2017-06-23 14:34:56 +10:00
Damien Elmes
a3bdd04d42 set bgcol in ankiwebview 2017-06-23 13:07:59 +10:00
Damien Elmes
59f877737e start webview as transparent to reduce flicker 2017-06-22 18:01:01 +10:00