Commit graph

157 commits

Author SHA1 Message Date
Igor Kushnir 60bc05218f Add input phrase's punctuation suffix to alts
Preferences::sanitizeInputPhrase() transforms an input phrase by
removing its whitespace/punctuation prefix and suffix. Translating a
phrase from X11 primary selection or from clipboard, via mouse-over or
from the command line results in such sanitization. This is useful when
a punctuation mark or a space is selected accidentally alongside a word.
This sanitization can be undesirable, however, when an abbreviated word
is selected. For example: "etc.", "e.g.", "i.e.".

This commit implements searching for the input word with the punctuation
suffix preserved as an alternative form of the sanitized word to show
articles for both. For example, when the word "etc." is translated from
the clipboard, both "ETC" and "etc." articles are displayed.

The punctuation suffix is preserved when the word is passed from the
scan popup to the main window and when the translate line text is
refreshed (e.g. when the current group is changed). The suffix is not
stored in history and favorites (doing so would require file format
changes and possibly substantial code changes, this can be implemented
later if need be).

Trim the input phrase once in ArticleNetworkAccessManager::getResource()
instead of verbose trimming in multiple places in
ArticleMaker::makeDefinitionFor().

Closes #1350.
2021-06-17 12:06:36 +03:00
Igor Kushnir 57c4c33780 Add support for *.oga audio files
For example, the first audio link in "The United States" English
Wikipedia article - "The Star-Spangled Banner" - ends with ".oga".
Without this commit the audio link is not recognized by GoldenDict:
* it is not pronounced when a Preferences=>Audio=>"Auto-pronounce..."
  option is enabled;
* clicking on the link opens it in the default browser instead of
  playing inside GoldenDict.
2021-06-12 07:53:19 +03: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
Abs62 58b6c60374 DSL: Fix sound saving from preferred dictionary 2019-06-27 18:09:00 +03:00
Abs62 76127eb04f
Merge pull request #955 from vedgy/fix-mediawiki-tooltips
Show #link as a tooltip instead of empty "Definition: "
2019-02-07 18:48:11 +03:00
Abs62 2bd422ad73 Full-text search: QRegularExpression instead of QRegExp to highlight found words in Qt5-based builds 2018-09-25 17:58:51 +03:00
Boyuan Yang 5d5432dbad
Fix typos found by codespell 2018-07-07 17:33:15 +08:00
Abs62 d7bc012411 Add option to ignore diacritics while articles search 2018-06-13 19:00:42 +03:00
Abs62 5fa5cc123f Full-text search: Allow ignore diacritics while search 2018-04-10 17:49:52 +03:00
Igor Kushnir 278e05cbf3 Run a single external audio player process at a time
External and internal audio players work similarly now. Fixes #950.

* inherit a new ExternalAudioPlayer class from AudioPlayerInterface;
* use an existing ExternalViewer class to implement ExternalAudioPlayer;
* take (const char *, int) instead of std::vector<char> in
  ExternalViewer constructor to fit into AudioPlayerInterface;
* extend ExternalViewer API to let ExternalAudioPlayer stop superseded
  audio player processes;
* make AudioPlayerInterface::play() return an error message string to
  allow reporting immediate failures from derived classes;
* Document AudioPlayerInterface API;
* Document AudioPlayerFactory::player();
* use the common audio interface exclusively in ArticleView.
2018-03-24 21:34:06 +02:00
Igor Kushnir e5045860ef Make adding new audio player implementations easy
* add a new interface class AudioPlayerInterface;
* inherit a new proxy class Ffmpeg::AudioPlayer from it;
* partially switch ArlticleView to using the interface;
* expose MainWindow's AudioPlayerInterface instance to all ArticleView
  instances;
* add a new AudioPlayerFactory class responsible for creating instances
  of concrete classes derived from AudioPlayerInterface depending on
  relevant Config::Preferences values;
* increase minimum supported Qt version from 4.5 to 4.6 in README
  in order to use QScopedPointer introduced in Qt 4.6.
2018-03-24 21:31:48 +02:00
Igor Kushnir 50fe9be623 Show #link as a tooltip instead of empty "Definition: "
Internal links in MediaWiki articles don't lead to word definitions,
so the "Definition: " prefix is not correct for them. It also does not
provide any information and is largely useless.

Perhaps the actual footnote text should be displayed in the tooltip,
but this requires distinguishing them from citations/references and
backlinks.
2018-02-21 13:01:02 +02:00
Abs62 d763c6ec81 Dsl: Add support for "#SOUND_DICTIONARY" directive 2017-07-09 20:15:35 +03:00
Abs62 ab7df09bee A little optimization for resources search 2017-04-28 15:25:45 +03:00
Abs62 747dc0aaaf Refactor resource downloading 2017-04-28 00:13:25 +03:00
Abs62 67b6b6b91c Add "gdvideo://" scheme to saved resources 2017-04-27 18:05:28 +03:00
Abs62 2085314eb9 1. Don't show "failed to download" error message while saving resources like "gdau://search/..."
2. Stop search if resource is found
2017-04-27 18:04:26 +03:00
Abs62 d9e6c812fc For full-text search in article disable "Next" button if only one match found 2017-04-26 18:40:13 +03:00
Abs62 bef8e2f8ac Don't show some context menu items for selection with spaces only 2017-04-24 17:41:07 +03:00
Abs62 cc7d7e196a Qt 5: Partially workaround of same-origin policy 2017-03-21 17:35:34 +03:00
Abs62 9714ad54f0 Lock jump on links while Alt key is pressed 2017-03-14 17:47:38 +03:00
Abs62 9511494c2b Send image to external viewer by double click 2017-03-13 17:38:27 +03:00
Abs62 4290734589 MDict: Fix handling of anchors like "<a id="xxx"> 2016-05-11 17:41:13 +03:00
Abs62 eee04266db Merge branch 'Original' into Qt4x5 2016-04-02 01:51:38 +03:00
Abs62 1f97957621 Fix anchor handling in Qt 5 builds 2016-04-01 16:38:07 +03:00
Abs62 2ab4eeaf60 Merge branch 'Original' into Qt4x5 2015-10-30 22:24:44 +03:00
Abs62 d8eba31d2d Slob: Handle inter-article anchors 2015-10-30 21:01:38 +03:00
Abs62 af69639b9d Adjust code for Qt5 2015-10-30 16:35:00 +03:00
Abs62 b2b60fc2e1 Merge branch 'Original' into Qt4x5 2015-10-30 16:34:08 +03:00
Abs62 c2eb4a0ef2 MDict: Handle inter-article anchors 2015-10-28 23:24:10 +03:00
Abs62 e24de4d881 Merge branch 'Original' into Qt4x5
Conflicts:
	xdxf2html.cc
2015-10-14 18:23:46 +03:00
Abs62 8ac7eddf2f Limit headword length in article context menu 2015-10-14 18:18:11 +03:00
Abs62 b9666f7f9f Merge branch 'Original' into Qt4x5
Conflicts:
	bgl_babylon.cc
2014-05-12 18:10:26 +04:00
Abs62 e2b0a7f39c Mac-specific: Adjust code for Qt5 build 2014-05-12 17:53:13 +04:00
Igor Kushnir e79338b3a1 Fixed activating link with <Enter>; fixed FullTextSearchDialog tab order; fixed switching between UI elements via shortcuts. 2014-05-11 14:52:25 +03:00
Abs62 273b1b5757 Merge branch 'Original' into Qt4x5
Conflicts:
	articleview.cc
	btreeidx.cc
2014-05-05 21:31:16 +04:00
Abs62 f8dd01e0a2 Full-text search: Highlight words with accent mark added by DSL tag 2014-04-24 18:12:00 +04:00
Abs62 90130d0fff Adjust code for Qt5 2014-04-23 18:19:46 +04:00
Abs62 10532279b1 Merge branch 'Original' into Qt4x5
Conflicts:
	article_netmgr.cc
	mainwindow.cc
2014-04-23 18:16:06 +04:00
Abs62 88c40141d0 A little refactoring of keys handling (old solution don't work correctly in Qt5) 2014-04-23 17:46:48 +04:00
Abs62 503650d617 Full-text search: Set group for ArticleView::showDefinition() when view article 2014-04-23 00:08:21 +04:00
Abs62 c2cdf9b177 Full-text search: Highlight of the search results 2014-04-22 22:29:58 +04:00
Abs62 e7477cfd24 Full-text search: Fix handling of some DSL headwords 2014-04-21 20:20:24 +04:00
Abs62 9ad0d5f985 Implement full-text search 2014-04-16 20:18:28 +04:00
Abs62 0fa4087b38 Merge branch 'Original' into Qt4x5
Conflicts:
	goldendict.pro
	mainwindow.cc
	zim.cc
	zipsounds.cc
2014-02-11 23:39:31 +04:00
Abs62 dabceff223 Don't jump to dictionary when new page opens in background 2014-02-09 19:15:41 +04:00
Abs62 97c4697a80 Handle some touch screen gestures in article view window 2014-02-04 22:38:50 +04:00
Abs62 34271ecc1d Merge branch 'Temp' into Qt4x5
Conflicts:
	article_maker.cc
	article_netmgr.cc
	articleview.cc
	forvo.cc
	goldendict.pro
	hotkeywrapper.cc
	hunspell.cc
	mainwindow.cc
2013-12-18 19:09:48 +04:00
Abs62 444938a330 Fix logging to file UTF-8 encoded messages 2013-11-16 22:34:09 +04:00
Abs62 cc5cd4bc26 Fix exception handling at article save 2013-10-18 18:32:58 +04:00