Commit graph

64 commits

Author SHA1 Message Date
Igor Kushnir d7ec541383 Add "Automatically scroll to target article" option
When a user clicks on a link in a dictionary or requests translation of
a word by double-clicking or translates selection via the context menu,
at first the article from the highest-priority dictionary is at the top.
Then, after approximately one second, the article from the dictionary,
out of which the translation was requested, becomes current and the view
scrolls down to this article placing it on top, hiding articles from the
dictionaries above it.

Such application behavior is inconvenient in some workflows so that the
user manually navigates to the top dictionary translation when this
automatic scrolling happens.

For example: a user has English->Russian dictionaries and
English->English dictionaries. The English->Russian dictionaries are
higher up in the dictionary order because they provide easier/faster to
understand translations. Some rare words and phrases are missing from
the English->Russian dictionaries however. Thus the user occasionally
reads the English explanation of a word/phrase. When the user
double-clicks on a word or follows a link in the English->English
dictionary article, she would rather see translations from the
preferable English->Russian dictionaries.

The new option allows to disable automatic scrolling and ensure that
articles from higher-priority dictionaries are visible. The option
doesn't affect backward/forward navigation via arrow buttons or
Alt+Arrow shortcuts: these still scroll to the stored vertical position
among articles. This remaining automatic scrolling happens much faster,
is not a problem for the described use case and hopefully for other use
cases.
2022-02-12 12:48:48 +08:00
xiaoyifang 0c94406e2a fix merge conflict with feature/deprecated 2022-02-03 17:50:47 +08:00
xiaoyifang ddd390cc2f remove mouse32 ,fix linux compile error 2022-02-03 17:47:03 +08:00
xiaoyifang 82cff25856 imp. remove mouseover32 preferences.ui configuration . 2022-02-03 13:34:52 +08:00
yifang 46b4151cc4 improve: replace all the deprecated method before 5.15 2022-01-08 22:08:23 +08:00
Igor Kushnir f919685797 Extract duplicated "gdfrom-" string manipulation into functions
Such helper functions facilitate understanding of the code and simplify
implementing new features.
2021-06-29 13:31:09 +03:00
Igor Kushnir ecb8f54293 Preferences: disable spinboxes when their checkboxes are unchecked
Neither of the two int options has any effect if the corresponding bool
option is turned off.
2020-11-19 18:00:44 +02:00
Igor Kushnir 27ca24f83d Fix indentation of recently added code: 4 => 2 spaces 2020-11-19 12:49:23 +02:00
Igor Kushnir 193aa4e31d Set up network disk cache for articleNetMgr
When a Wikipedia article is already cached, this change reduces the
amount of sent and received network data almost tenfold.

Setting up a network disk cache in the same way for dictNetMgr does not
noticeably impact the amount of network traffic. Either this network
access manager sends and receives very little data or the data is never
the same. So dictNetMgr does not need a disk cache.

Use QNetworkDiskCache's default maximum size of 50 MiB as the default
network cache size. This size is large enough to accommodate tens of
huge MediaWiki articles. It is also small enough that the user is
unlikely to run out of disk space because of the cache.

Clear network cache on exit by default because most users probably
don't load the same online articles after restarting GoldenDict. Plus
storing the network cache on disk indefinitely by default would be a new
and unexpected to the users privacy risk.

Nikita Moor came up with the idea and wrote an initial network disk
cache implementation in #1310.
2020-11-18 19:04:28 +02:00
Igor Kushnir 61eb4e08fe Add options to limit input phrase length
When a long text is accidentally selected or copied while the scan popup
is on, Goldendict spends a lot of CPU time to gradually create a
"No translation..." article. When translation of huge (e.g. 15 MB) text
from the clipboard is (accidentally) requested, Goldendict freezes for a
while. Turning the added input phrase limit option on eliminates this
waste of the CPU time.

I have implemented these options primarily for selection and clipboard,
but they also affect mouse-over translation on Windows and command line
translation requests. This is mostly because I did not bother to limit
the options' scope. I guess hovering over an extremely long text without
spaces (e.g. Base64-encoded) could cause the same performance issue on
Windows. The command-line translation could be requested from a script
that integrates Goldendict with some other application, from which long
text could be sent for translation by accident.

I hope that the default value of 200 characters will be sufficient for
just about any real-world user input in any language. The option is on
by default, because the default length limit is generous and any longer
text is unlikely to be sent for translation intentionally. My personal
preference for the input phrase length limit is 100 symbols.

ArticleView::pasteTriggered() didn't call QString::simplified() on the
text retrieved from the clipboard. I assumed this was an oversight, so
now it *is* called - indirectly, via Preferences::sanitizeInputPhrase().
2020-11-13 17:44:38 +02:00
Igor Kushnir 0b7c65023c articleSizeLimit option: minor code cleanup
When an integral value is converted to a signed integer type, if the
result is not representable, the resulting value is implementation
defined (until C++20). Convert the string value from configuration file
to the target type (int) to avoid the redundant type conversion.

Use the more direct and efficient QSpinBox::value() instead of
QAbstractSpinBox::text().toInt().
2020-11-06 22:04:59 +02:00
Abs62 d7bc012411 Add option to ignore diacritics while articles search 2018-06-13 19:00:42 +03:00
Igor Kushnir 5c74494935 Linux-specific: Add an option to disable scan popup inside Goldendict
When scan popup is configured to appear without any key modifiers
pressed and is active on X11, it interferes with selecting text inside
the scan popup window (or inside the main window if "Send translated
word to main window" option is enabled). It also makes searching text
inside article definition impossible - in the main window and
even more so in the scan popup window.

However, when scan popup is configured to appear only when some keys are
pressed, or when the scan flag feature is enabled, it may work fine
inside Goldendict windows.

It is possible to automatically decide whether to show scan popup when
selection or clipboard inside Goldendict changes. But such logic might
be unsuitable for some use cases. For example, invoking scan popup by
selecting article definition text in the main window works fine.
Therefore this commit makes ignoring selection and clipboard changes
inside Goldendict itself optional. This commit implements one of two
feature requests in issue #606.

This new option could have effect on non-X11 platforms if the hidden
trackClipboardChanges option is enabled. But it is much less useful on
these platforms because scan popup without key modifiers is unusable
there (at least under Windows). Let us show and use the option only on
X11 to avoid cluttering Preferences UI on other platforms.
2018-04-17 20:13:25 +03:00
Igor Kushnir 15dfdee49f Allow customizing unpinned scan popup window flags on X11 with Qt5
My tests in many desktop environments and window managers indicate that
no single configuration works perfectly in all environments. There are
also behavior differences between Qt::Popup and Qt::Tool flags, which
are not exactly bugs, so I suppose users might subjectively prefer
different options.

Customizing the flags allows the user to prevent unpinned scan popup
window flickering with Qt5 on Linux. In a way adding these options fixes
issue #645, which is: the scan popup window blinks rapidly, barely
noticeably in some applications, such as Calibre ebook-viewer
and Chromium. In this case the scan popup window usually ends up hidden
when selection ends, unless it was finished with a jerk.

I have tested the new options in 9 desktop environments and window
managers: at least one configuration for each eliminates #645 and makes
the scan popup window work the same as with Qt4 in this regard:
the popup window remains visible, text in the popup's translation line
keeps up with the text selection in the external application,
and the selected text is being translated on the fly.

Moreover, for each tested DE/WM, at least one configuration makes
the scan popup window work perfectly as far as I am concerned.

This issue was partially worked around with a 200ms scan popup delay
timer in the recent commit 58e41fe3ce
for the duplicate issue #854. However the timer solution is incomplete
because it requires the user to select text quickly and without delays.
If global mouse selection does not change for 200ms while the left mouse
button is held down, the user will likely not see the scan popup when
(s)he finishes selection, and will have to try selecting again -
hopefully faster this time.

The 200ms delay is no longer critically important after this commit,
but it is still beneficial: the lookup query changes less often,
which in turn reduces article definition update frequency.
So the delay improves the UI (perhaps subjectively) and performance.
2018-04-15 19:46:35 +03:00
Igor Kushnir 9aa3c44d4e Add QMediaPlayer internal player back end (Qt5 only)
* add config and GUI support for internal player back end switching;
* make FFmpeg player disabling option consistent with other similar
  qmake options by using CONFIG;
* add a new qmake option that disables Qt Multimedia player. This is
  useful for GNU/Linux distributions where Qt WebKit and Qt Multimedia
  packages depend on different GStreamer versions and don't work
  correctly when combined in one application.

The existing FFmpeg+libao internal player back end has a relatively
low-level implementation, which is difficult to understand and improve.
There are at least 3 open internal player issues:
  1) many GNU/Linux users have to edit their libao configuration file to
     make Goldendict's internal player work (issue #412);
  2) libao's pulseaudio plugin does not support 32-bit audio, which
     means that many MediaWiki pronunciations don't work with the most
     popular GNU/Linux audio driver (issue #949);
  3) Ffmpeg::DecoderContext uses deprecated FFmpeg APIs, which causes
     compiler warnings and means that this internal player back end
     may not compile with a future FFmpeg library version (issue #978).

The Qt Multimedia back end implementation uses the highest-level
Qt audio API and is very simple.
This new back end works flawlessly on my GNU/Linux machine.
I'm not making it the default back end because I don't know how well
it will work on other platforms with different configurations.
2018-03-30 17:10:33 +03:00
Igor Kushnir d5998cabb7 Remove redundant option useExternalPlayer from Preferences
This change substantially reduces audio player configuration code
complexity. The single remaining bool option - useInternalPlayer -
is enough for the binary audio player implementation choice.

Removing the useExternalPlayer option doesn't change the application GUI
behavior except for minor differences in one or two corner cases, which
could be classified as bugs fixed by this commit. For example, before
this commit, if the configuration file contained the following lines
  <useExternalPlayer>0</useExternalPlayer>
  <useInternalPlayer>0</useInternalPlayer>
an external player would be actually used for audio playback, but
neither of the two audio radio buttons would be checked in
Preferences GUI, and audioPlaybackProgram line edit would be disabled.
Whereas, after this commit, an external player is still used for
audio playback, but useExternalPlayer radio button is checked
in Preferences GUI, and the audioPlaybackProgram line edit is enabled.
2018-03-30 17:03:45 +03:00
sunwxg ad8008c37b Add scan popup flag
After select a word, show a flag window, click the flag to show
popup window.
2017-06-05 21:15:38 +08:00
Abs62 caf39bfdb5 Add option for turn on/off confirmation for favorites items deletion 2017-05-17 18:26:32 +03:00
Abs62 72523dcfb4 Add option to periodical save of Favorites 2017-05-13 13:18:25 +03:00
Abs62 fa9d1aecd9 Add option to enable/disable search via synonyms 2017-03-09 19:11:17 +03:00
Abs62 eba7f5578f Add support for GLS (Babylon source) format 2017-03-07 16:45:09 +03:00
Abs62 0912df7cb5 Add SLOB dictionaries support 2015-01-22 18:17:05 +03:00
Abs62 d3a13bd154 Allow to choose help language 2014-06-25 18:01:11 +04:00
Abs62 3531a74c6e Add help buttons to dialogs 2014-06-24 17:55:06 +04:00
Abs62 d9169bd45b Add support for Epwing dictionaries 2014-05-20 17:59:56 +04:00
Abs62 e2b0a7f39c Mac-specific: Adjust code for Qt5 build 2014-05-12 17:53:13 +04:00
Abs62 361a9ceb97 Full-text search: Hide option for Zim format in preferences if GoldenDict compiled without it support 2014-04-20 12:42:45 +04:00
Abs62 fd1d035c01 Add full-text search tuning tab to preferences dialog 2014-04-17 18:31:51 +04:00
Abs62 fe9998f2bf Add system proxy choose in preferences 2014-04-02 17:54:50 +04:00
Abs62 0195151399 Show native identifiers for key modifiers 2014-02-17 17:48:05 +04:00
Tvangeste 039caf07f1 Fixed #183: Provide a higher resolution main GoldenDict icon
Finally! :)
2013-07-19 19:07:32 +02:00
Timon Wong cf71499242 Add "DISABLE_INTERNAL_PLAYER" to .pro as an option to disable internal audio player (issue #356) 2013-06-18 09:12:31 +08:00
Tvangeste de2bf73e66 New interface preference: Context menu dictionaries limit
Controls both context menus, in the dictionary bar and in the article view.
Can be adjusted in Preferences -> Interface -> Context menu dictionaries limit.
By default, it is set to 20.
2013-06-11 20:31:01 +02:00
Abs62 d721e627b1 Allow to collapse/expand articles; auto collapse for big articles (issue #331) 2013-06-02 15:20:33 +04:00
Tvangeste 82e6648efc Added an option to hide GoldenDict identification in the HTTP User-Agent headers (Issue #259).
A new preference in the "Network" tab is added:
* Do not identify GoldenDict in HTTP headers.
2013-05-15 17:59:30 +02:00
Timon Wong c4752eb14c Add internal audio player(ffmpeg/libav + libao).
* phonon, bass, playsound are removed.
2013-05-05 18:22:12 +08:00
Tvangeste 994eb998e9 Another lingoes style. The previous one is renamed to Lingoes-Blue 2013-03-24 21:19:03 +01:00
Tvangeste eef66a8f0f Lingoes theme/style (by anion23)
Use Preferences -> Interface -> Display Style -> Lingoes.
2013-03-23 19:20:55 +01:00
Tvangeste d1787dd98b Added a new built-in style 'Modern' (Prefs->Interface->Display Style->Modern) 2013-03-23 17:48:31 +01:00
Abs62 2553ddf2b8 Periodical save of history (issue #209) 2013-02-05 16:51:23 +04:00
Tvangeste 9faf843ab7 Part of work for #212: Make GD source to be ready for Qt5.
Replaced deprecated to/fromAscii with to/fromLatin1
2013-02-03 21:19:55 +01:00
Tvangeste 3ed7772996 History Pane rewrite.
The new History Pane features proper mouse and keyboard navigation,
multiple selection and ability to remove the selected entries,
plus a dynamic context menu. Additionaly, the History's size is now
configurable in Preferences.

Use Ctrl+H to show/hide the History Pane.

History Pane's titlebar can be styled via #historyPaneTitleBar, e.g.:

/* Colored header for the History Pane */
  background: lightsteelblue;
  margin: 2px;
}

Closes #162: Make History sidebar independent from the Search Pane
Closes #159: "Send to main window" button from Pop-Up window does nothing when History is shown
Closes #158: Preserve History mode after restart
Closes #157: History with new UI: New words are not added when History is shown
Closes #156: History with new UI: Extra Groups widget in History is shown
Closes #155: History with new UI: Arrow keys navigation in History doesn't work
Closes #154: History with new UI: DEL key does not delete the current history entry
2013-01-17 10:08:53 +01:00
Abs62 8901dccbef Switch user styles on-the-fly 2012-12-10 18:14:13 +04:00
Abs62 03af1da9af Win-specific: Play sounds via Bass library 2012-11-23 16:43:36 +04:00
Abs62 ad8ddc8daf Add option for word selection by single mouse click 2012-09-26 17:59:48 +04:00
Abs62 305c9ed1b8 Show/hide optional parts of articles (DSL dictionaries only) 2012-09-16 14:19:47 +04:00
Abs62 e5943ec7ed Allow to turn on/off history in preferences 2012-09-11 17:03:10 +04:00
Julian Depetris Chauvin ba2ce47ae3 Merge branch 'themighty1-mru-tab' 2012-04-02 15:41:58 -03:00
wwwwww 753b0185df MRU tab switching implemented 2012-02-17 00:00:00 +02:00
vtliem 96bc934578 fix for blg dict
1/fix some babylon dict's language name not displayed (ex: Traditional Chinese )
2/add babylon style (dict name & icon)
3/fix for issue @https://github.com/goldendict/goldendict/issues/19
2012-01-28 12:07:23 +09:00