Commit graph

320 commits

Author SHA1 Message Date
xiaoyifang 7bcdfac334
Merge branch 'goldendict:master' into staged 2022-06-21 07:52:25 +08:00
Igor Kushnir 39abe4f1a6 Restart search when case sensitivity changes
One issue with the current implementation is that a wrong-cased match
remains selected when the user checks the Case Sensitive checkbox.
Another issue is that the noResults property of searchText is not
updated right away, which means that searchText's background color
remains wrong until next search.

Handle toggling case sensitivity in the same way as editing the searched
text: restart search from the beginning of the page. This improves the
Search-in-page UI consistency.
2022-06-20 19:18:57 +03:00
Xiao YiFang 1830415da5 fix: highlight a rare case when toPlainText omit space between two words 2022-06-16 21:03:58 +08:00
Xiao YiFang 4b9d71376d remove javascript highlight logic
webengine's findtext(highlight) has little features compared to webkits
2022-06-16 08:08:49 +08:00
Xiao YiFang 5571f877bc fix: F12 inspect windows open on the first time 2022-06-15 08:12:27 +08:00
Xiao YiFang 4cf184d646 fix upstream merge conflict 2022-06-15 07:51:45 +08:00
Xiao YiFang 949ad6de57 fix mergeconflict when merge upstream 2022-06-14 22:07:01 +08:00
Igor Kushnir 9b5756d5e1 Don't update pages history in ArticleView::setCurrentArticle()
The current article is saved to pages history user data before any
navigation to another page and before reloading the current page.
Therefore saving it each time the user activates an article is
redundant. This redundancy is not consistent, because when a user
activates an article by clicking on it, the current article changes in
the UI, but is not immediately saved in history as setCurrentArticle()
is not called. The inconsistent redundancy is a waste of CPU time and
can hide bugs.
2022-06-12 21:26:09 +03:00
Igor Kushnir 7df106c68c Refactor: get rid of ArticleView::articleToJump
This variable overrides history user data, which makes the current
article and position restoring code in ArticleView::loadFinished()
difficult to understand.

Encode the same logic in the history user data instead. This should make
the code more straightforward and less brittle in the face of changes.
2022-06-12 20:14:22 +03:00
Igor Kushnir 40dd01755e Always jump to current article before reloading
MainWindow calls ArticleView::reload() when the group list is updated.
This updating may add/remove/reorder dictionaries in the active group.

MainWindow also calls ArticleView::reload() when the display or addon
style changes.

In both of the above scenarios uncontrolled jumps and current article
change can occur (see also the parent commit message).

Move setting articleToJump from above the only ArticleView's reload()
call into ArticleView::reload() itself.
2022-06-12 20:14:22 +03:00
Igor Kushnir 0173251b22 Jump to the first article too after expanding optional parts
When the first article in the list is current, expanding or collapsing
optional parts results in:
1) uncontrolled jumps due to the content height changes if the scroll
   position is not (0, 0);
2) current article change if a non-first article is saved in history
   user data (e.g. if a mouse click had made the first article active).

Treat the first current article in the same way as non-first ones.

This change also affects the case when the current article is not
present in the article list. If the current article is simply empty,
then there is no behavior change. If the current article is not empty,
it *must* be in the list, unless something else went wrong.
2022-06-12 20:14:22 +03:00
Igor Kushnir de69036e9e ArticleView: deduplicate expand-optional-parts code 2022-06-12 20:14:22 +03:00
Igor Kushnir e8a1358bce Refactor: extract ArticleView::load()
This way it is clearer that the pages history is updated just before
each navigation to a different page.

The call to ArticleView::saveHistoryUserData() now occurs slightly later
in ArticleView::showDefinition(). I don't think the intervening code can
affect the current article or window position. So the reordering most
likely does not affect application behavior.
2022-06-12 20:13:54 +03:00
Igor Kushnir ca0209faff Save current article and window position before loading DSL picture
Without the added saveHistoryUserData() call, returning back from the
enlarged picture page ("gdpicture") restores the current article and the
window position that were last saved. At this commit the "gdpicture"
behavior is consistent with regular links: returning back from the
enlarged picture page sets the article with the picture as current and
restores the window position at the time of the click on the picture.
2022-06-12 20:13:54 +03:00
Igor Kushnir 10d0d8193b setCurrentArticle(): return false if the article doesn't exist
201f11e656 missed this possibility and may
have inadvertently changed the application behavior in a corner case.
2022-06-08 19:05:02 +03:00
Xiao YiFang 9daff6ae37 support mdex builtin link entry: 2022-06-07 08:14:53 +08:00
Xiao YiFang 5f856bf2ae refactor getqueryword 2022-06-07 08:14:53 +08:00
Xiao YiFang 80021a6328 opt: findText will clear the last findText , so this line is useless
it will override by the following findText
2022-06-03 13:09:18 +08:00
Xiao YiFang b5d005d3ed opt: clear the delayedHighlight text earlier 2022-06-03 12:32:27 +08:00
Xiao YiFang 66499007f6 clean code: remove \n in parameter of GD_DPRINTF 2022-06-02 20:11:05 +08:00
Igor Kushnir 99982a1c11 ArticleView: expose only minimal API to JavaScript
https://doc.qt.io/archives/qt-5.5/qtwebkit-bridge.html#internet-security
Qt WebKit Bridge documentation recommends:
  When exposing native objects to an open web environment, it is
  important to understand the security implications. Think whether the
  exposed object enables the web environment access things that
  shouldn't be open, and whether the web content loaded by that web page
  comes from a trusted source.

The author of Qt WebChannel has said the following in a talk that
introduced this Qt module (WebKit Bridge replacement for Qt WebEngine):
  My suggestion here is to write dedicated QObjects with a slim, minimal
  API that only have the signals and methods that you deem safe to be
  used from the outside.
- see a comment under https://redirect.invidious.io/watch?v=KnvnTi6XafA
2022-06-02 13:51:13 +03:00
Xiao YiFang f015ff555f feature: save bookmark to favorite panel
reuse fulltext match to implement this bookmark feature
2022-06-02 08:16:01 +08:00
Xiao YiFang 7d43aea9b2 opt: right context menu ,remove non-sense characters
like punctuation and space and symbols
2022-05-29 16:00:29 +08:00
Xiao YiFang c45b4cc255 fix: invalid gdlookup url should be forbidden. 2022-05-28 10:41:28 +08:00
Xiao YiFang f98ac1b588 clean code:remove useless code 2022-05-27 21:54:30 +08:00
Xiao YiFang f1bcb37e76 fix upstream merge conflict 2022-05-25 08:00:58 +08:00
Igor Kushnir 201f11e656 Set current article at most once in loadFinished()
When the current article is set and the user expands or collapses
optional parts (e.g. via the Ctrl+* shortcut),
ArticleView::setCurrentArticle() is called twice from
ArticleView::loadFinished(). Furthermore, the window scroll position is
restored before the second jump. This is wasteful. Move the
higher-priority setCurrentArticle() call up and, if it succeeds, skip
the other call and the scrolling.

I have measured the time spent running the affected code fragment on my
GNU/Linux system before and at this commit. When the loaded articles are
not very large, the performance gain of this commit is only about 1 ms.
However, when one of the displayed articles was huge (the
"United States" English Wikipedia article), the time went from 120 ms to
5 ms.
2022-05-24 21:02:20 +03:00
Xiao YiFang 1f01e545d1 disable print background 2022-05-24 21:40:53 +08:00
Xiao YiFang c6811db3a0 fix: merge conflict from upstream 2022-05-24 20:25:09 +08:00
Igor Kushnir b87b023db0 Optimize highlighting FTS matches in articles
The wall time of calls to ArticleView::highlightAllFtsOccurences() on my
GNU/Linux system before and at this commit:
allMatches.size()   uniqueMatches.size()    before(ms)  at(ms)
79                  1                       277         4
98                  1                       380         4
267                 1                       16803       65
2022-05-23 16:05:36 +03:00
Igor Kushnir bd5b36cac7 Extract ArticleView::highlightAllFtsOccurences()
Extracting this function allows to simplify the code and facilitates
optimizing it in the next commit.

Remove `#if QT_VERSION >= 0x040600` along the way as GoldenDict does not
support Qt versions older than 4.6 for several years now.
2022-05-23 16:02:01 +03:00
Xiao YiFang 55fee75acd fix: a bug with send to anki 2022-05-22 10:05:22 +08:00
Xiao YiFang 0a2661f986 add 'send to anki' function
users can configure the ankiconnect to use together with anki
2022-05-21 17:34:22 +08:00
Xiao YiFang a7ba9e4b36 opt:use acceptNavigationRequest instead of weburlinterceptor 2022-05-20 18:01:41 +08:00
Xiao YiFang 459b684e5b opt: make the inspect window's instance to exactly only one. 2022-05-20 17:31:47 +08:00
Xiao YiFang c0e3767f83 opt: format code and remove default constructor 2022-05-19 20:37:11 +08:00
Xiao YiFang 15d9104f2c fix : fulltext search will crash
close issue #69
2022-05-19 20:28:52 +08:00
Xiao YiFang a1ef0313ab opt : set webengine font family
make it take effect immediately
2022-05-17 21:24:30 +08:00
Xiao YiFang eda434f38e opt: rename emitDicts signal to dictionaryChanges 2022-05-15 22:48:22 +08:00
Xiao YiFang 20f51fc7f2 fix: double click image will clear translate input line 2022-05-08 21:02:23 +08:00
Xiao YiFang 9c402d986e opt: add dictionary fallback font family settings 2022-05-08 16:44:09 +08:00
Yifang Xiao 289b0be594 fix:archlinux variant version ,mouse back button 2022-05-05 21:37:23 +08:00
xiaoyifang 60a4853e51
Merge pull request #57 from xiaoyifang/opt/blank-page
remove blank page load
2022-04-26 20:38:56 +08:00
YiFang Xiao 75b6788937 opt: add javascript clipboard support 2022-04-26 20:21:45 +08:00
xiaoyifang ab2c1db889 remove blank page load 2022-04-22 20:24:45 +08:00
xiaoyifang e679463dc0 fix:merge compile lamda error 2022-03-31 08:54:06 +08:00
xiaoyifang 228d7001e5
Merge pull request #35 from ngn999/bugfix/Macbook_scroll_issue
disable macOS trackpad zoom; fix a deadlock
2022-03-31 00:10:37 +08:00
ngn999 13dfd39e69 fix more indent issue 2022-03-30 23:10:37 +08:00
ngn999 b187c0ef41 fix code review indent issue 2022-03-30 23:08:24 +08:00
xiaoyifang 03653925be optimize: double click send select text to tranlateline box. 2022-03-30 15:21:16 +08:00