Commit graph

124 commits

Author SHA1 Message Date
shenleban tongying 4dc040f11c Remove clipboardChanged connect in scanpopup.cc blindly 2022-11-20 00:02:12 -05:00
shenleban tongying 06a296c99f Put conditions on the ClipboardChange for X11 2022-11-19 13:48:26 -05:00
shenleban tongying b3b740854a Unify trackClipboardChanges and enableScanPopupAction
* There is no difference between those two on Windows and MacOS which only support clipboard (Ctrl+C) scanning

* Q_WS_X11 was defined on Qt4, and it causes the super weird trackClipboardChanges to occur on Windows
2022-11-19 10:30:31 -05:00
Xiao YiFang 3b05f3b4e9 fix scanpopup dialog popup condition check 2022-11-19 14:52:20 +08:00
Xiao YiFang 3561f80430 [mac specific] popup dialog stay on top 2022-10-19 20:28:41 +08:00
Xiao YiFang e8764d322c fix: access violation 2022-10-03 11:49:27 +08:00
Xiao YiFang 11b29d30a7 clean code:remove x11 scanpopup flag setting 2022-09-25 12:49:22 +08:00
Xiao YiFang cd5e5abe4d opt:scanpopup inspect element action optimization 2022-09-08 21:11:43 +08:00
Xiao YiFang 306c435ae0 fix: clipboard tracking in windows should not be functioned when not enabled. 2022-08-31 21:54:53 +08:00
Xiao YiFang 6a7e54c165 fix:add log to clipboard datachange signal
fix:add log to clipboard datachange signal
2022-08-14 23:16:51 +08:00
Xiao YiFang fa64d450ea opt: optimize the function in tracking clipboard in trayicon 2022-08-02 22:27:14 +08:00
Xiao YiFang 7a642c1917 feat: tracking clipboard 2022-06-25 20:56:26 +08:00
Xiao YiFang 7eb603a9c5 feat: expose clipboard tracking function 2022-06-24 21:20:16 +08:00
xiaoyifang 8b9544bc17 fix:currentIndexChanged slot does not match 2022-04-01 23:32:11 +08:00
ngn999 95be606a9e make ArticleView::hasSound() async 2022-03-27 22:22:42 +08:00
yifang fb2eac9b5e upgrade to 6.2,linux compile 2022-03-11 22:14:40 +08:00
xiaoyifang 23d833fbb8 6.2: currentIndexChanged signal is changed. 2022-03-11 22:00:53 +08:00
xiaoyifang 7b5511a7bd upgrade to qt6.2 2022-03-11 22:00:45 +08:00
xiaoyifang b7b347ec0e clean:remove win32 mouse over function.
this function only work on windows and text .

can be replace with ocr(with the help of Capture2Text etc.).
2022-02-25 07:55:32 +08:00
yifang 23c41789de fix: popup link clicked 2022-02-15 20:22:43 +08:00
xiaoyifang 84175279ab fix: link click in popup windows ,translation should be in popup dialog too 2022-02-14 23:48:05 +08:00
xiaoyifang 0c94406e2a fix merge conflict with feature/deprecated 2022-02-03 17:50:47 +08:00
xiaoyifang c96a83f5d2 imp. remove mouseover32 2022-02-03 16:55:10 +08:00
xiaoyifang aa12bbe167 Merge branch 'branch-qt-5.15' into dev 2022-01-24 22:27:04 +08:00
xiaoyifang 9cf5ee8443 high dpi:change icon reference in code from png to svg. 2022-01-24 22:23:38 +08:00
yifang a0014cf668
dictionary bar icon size does not display correctly 2022-01-23 19:41:50 +08:00
yifang 262e650779 fix: DPRINTF=>GD_DPRINTF ,DDPRINT does not exist now.
do not affect functionality.only existed in comments.
2022-01-15 15:29:20 +08:00
yifang 46b4151cc4 improve: replace all the deprecated method before 5.15 2022-01-08 22:08:23 +08:00
yifang 5860e81ff3 typingEvent fix,double characters when focus 2021-12-18 18:08:45 +08:00
yifang 98ca729446 remove qt_version_check macro 2021-12-13 22:45:57 +08:00
yifang.xiao 0365015ac6 clean code:
remove "#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )" check ,the check should always be true based on current situation.
2021-12-13 22:45:33 +08:00
yifang.xiao ab358fb3a5 remove old qt(<5) code. 2021-12-13 22:43:43 +08:00
Igor Kushnir 9ff28e226f Translate box: add missing wildcard symbol (un)escaping
When not-escaped wildcard symbols are placed in the translate box/line,
word completion can occupy the CPU for seconds. So it is safer to err on
the side of escaping than the other way around.

The missed unescaping in ScanPopup::translateInputFinished() was
inconsistent with the main window. It made escaping in the scan popup's
translate box unusable by attempting to translate e.g. "\*" verbatim.
2021-06-30 20:01:40 +03:00
Abs62 e1c9a0d6de Fix compilation without C++11 support 2021-06-18 21:33:24 +03:00
Igor Kushnir 99ddb7686e Don't add the same phrase to history twice in a row
Each of the 3 removed history addition requests follows a call to
ArticleView::showDefinition() with the same phrase/word as an argument.
Each showDefinition() overload adds its phrase/word argument to history.

These duplicate history additions weren't noticeable because
History::addItem() searches for and removes its argument from items to
avoid duplicate history entries. But the extra function calls, signal
emissions, linear searches and QList manipulation wasted processor time.
2021-06-17 12:06:36 +03:00
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 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 353ea1793e ScanPopup: Normalize whitespaces while translate on clipboard change 2020-03-11 22:18:33 +03:00
Igor Kushnir 462218d662 Linux-specific: Qt::Dialog -> Qt::Window pinned scan popup flags
There is a regression since Qt 5.12.1 that forces the pinned scan popup
window to be always on top of the main window on Linux/X11 because of
its Qt::Dialog window flag. The same issue is present in Qt 4.
The Qt regression is reported as QTBUG-74309, but chances of it being
fixed any time soon seem slim.

The documentation for Qt::Dialog window flag states that it causes a
window to be decorated as a dialog (typically no maximize or minimize
buttons in the title bar). I suppose adding these buttons to
the scan popup's title bar is not an issue.

As a bonus, the Qt::Dialog flag prevented scan popup window tiling when
moving toward the screen edge in Xfce. It works perfectly now.
2019-05-13 14:24:14 +03:00
Igor Kushnir ec96d6ac5a Allow shrinking scan popup's toolbar height
Before this commit, when group combobox was visible, the Alt+- shortcut
reduced the heights of group combobox and translate line in the main
window, but not in scan popup. These UI elements in scan popup did not
become lower than at the time scan popup was constructed.

Applying the solution from the main window fixes this bug (#1108).
2019-01-29 15:43:18 +02:00
Igor Kushnir a9fc823c46 Avoid duplicate currentGroupChanged() connection
Before this change ScanPopup::applyWordsZoomLevel() was called before
the primary connection to ScanPopup::currentGroupChanged() in
ScanPopup's constructor. This meant that disconnect() had no effect and
connect() established the first connection during the first call to
ScanPopup::applyWordsZoomLevel(). This caused 2 issues:
  1. Since the connection happened before the filling of ui.groupList
in ScanPopup's constructor, the current group in scan popup was always
"All" on Goldendict start.
  2. Since the connection was not unique, the slot was connected twice
to the same signal, and it was actually called twice.

The bug was introduced in 92e8c85eec.
2019-01-28 14:54:32 +02:00
Abs62 92e8c85eec Fix behavior while words list font resizing (issue #1109) 2019-01-26 22:11:27 +03:00
Igor Kushnir 3bf7aad1f7 Add a shortcut to focus scan popup's article view
The article view focus is necessary to navigate a word definition via
keyboard rather than mouse. The shortcut - Ctrl+N - is the same as
the one in the main window for the corresponding action.
2018-05-16 14:54:20 +03:00
Abs62 0a8599d9b1 Fix warning in scanpopup.cc while compilation under Windows/MacOS 2018-04-17 20:52:39 +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 d530af7781 Qt5: disable an obsolete Qt4 X11 window focus workaround
I have verified in numerous desktop environments and window managers
that the workaround does not work with Qt5.
Let us disable it in Qt5 builds to prevent potential issues
and eliminate the small performance overhead.
2018-04-15 19:46:35 +03:00
Abs62 d65a1f7869 Save popup window configuration without it destroying 2018-03-27 21:23:48 +03: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
Abs62 77c9a4c3e2 Fix "Add to Favorites" icon changing 2017-11-07 17:46:59 +03:00