Commit graph

134 commits

Author SHA1 Message Date
Xiao YiFang 4a30302864 fix: move Contexts to header file 2023-01-02 22:00:42 +08:00
shenleban tongying 7fa87b6b42 fix: remove unused isScanningEnabled, the logic is handled in mainwindow::clipboardChanged() 2022-12-28 21:58:27 -05:00
shenleban tongying b933d52245 fix: remove unused clipboard change method in scanpopup 2022-12-28 21:37:09 -05:00
shenleban tongying bdc43650bb fix: add a mini delay for selection clipboard 2022-12-28 21:36:02 -05:00
shenleban tongying 07e92e8ac1 refactor: upgrade most of macro based Signal/Slot to new syntax 2022-12-25 21:08:17 -05:00
shenleban tongying 664a1e87e4 Remove ScanPopup Alt mode ("Keys may also be pressed afterwards").
The functionality of "select then press a key to get popup " has equivalent of using Ctrl+C+C on Hotkeys.
2022-11-20 04:12:58 -05:00
shenlebantongying 451fdb5c21 Fix win build with HAVE_X11 2022-11-20 01:51:23 -05:00
shenleban tongying 6e0a6cfa42 refactor & simplify ScanFlag:
All slots of ScanFlag are used just as functions calls.
2022-11-20 01:19:27 -05:00
shenleban tongying 79f8b05d40 Add showScanFlag condition to mainWindow's clipboardChange 2022-11-20 00:39:41 -05:00
shenleban tongying c2cc848cc7 remove forcePopup from showScanFlag signal
That flag isn't use in any of the slots
2022-11-20 00:14:36 -05:00
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