Merge branch 'dev'

This commit is contained in:
Xiao YiFang 2022-09-23 19:52:34 +08:00
commit 158f8e405f
63 changed files with 6592 additions and 1332 deletions

View file

@ -47,6 +47,10 @@ function Main() {
Write-Host "copy license.." Write-Host "copy license.."
Copy-Item "opencc\*" $archiveName\opencc\ Copy-Item "opencc\*" $archiveName\opencc\
Write-Host "opencc config files.." Write-Host "opencc config files.."
New-Item -ItemType Directory $archiveName\help
Copy-Item "help\*" $archiveName\help\
Write-Host "help files.."
# 拷贝WinSDK dll # 拷贝WinSDK dll
$sdkDll="{0}Redist\{1}ucrt\DLLs\{2}\*.dll" -f $env:winSdkDir.Trim(),$env:winSdkVer.Trim(),$env:msvcArch $sdkDll="{0}Redist\{1}ucrt\DLLs\{2}\*.dll" -f $env:winSdkDir.Trim(),$env:winSdkVer.Trim(),$env:msvcArch
Write-Host "copy sdk dll$($sdkDll)" Write-Host "copy sdk dll$($sdkDll)"

View file

@ -22,9 +22,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View file

@ -1,4 +1,4 @@
name: macos-6.2 name: macos-6.x
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -29,9 +29,9 @@ jobs:
qt_arch: [clang_64] qt_arch: [clang_64]
env: env:
targetName: GoldenDict targetName: GoldenDict
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
steps: steps:
# macos 11.0 默认环境变了,要指定 # macos 11.0 默认环境变了,要指定
@ -110,7 +110,7 @@ jobs:
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.targetName }}.dmg file: ${{ env.targetName }}.dmg
asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }}_${{ matrix.os }}_${{steps.vars.outputs.release_date}}.dmg asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }}_${{ matrix.os }}_universal_${{steps.vars.outputs.release_date}}.dmg
tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
overwrite: true overwrite: true
release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
@ -129,6 +129,7 @@ jobs:
Qt6.X(Universal Build) Qt6.X(Universal Build)
Qt5.15.2(Intel Kind) Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-) auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]** Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES: CHANGES:

View file

@ -25,10 +25,6 @@ jobs:
os: [macos-11.0] os: [macos-11.0]
qt_ver: [5.15.2,6.2.4] qt_ver: [5.15.2,6.2.4]
qt_arch: [clang_64] qt_arch: [clang_64]
env:
version: 22.8.23
version-suffix: EndOfHeat
prerelease: false
steps: steps:
# macos 11.0 默认环境变了,要指定 # macos 11.0 默认环境变了,要指定

View file

@ -0,0 +1,81 @@
name: macos-homebrew-PR-check
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
branches:
- dev
- master
- staged
paths-ignore:
- 'docs/**'
- ".github/**"
- "howto/**"
- "*.md"
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]
qt_ver: [6.3.1]
qt_arch: [clang_64]
env:
targetName: GoldenDict
steps:
# - name: prepare env
# run: |
# cd /opt
# mkdir homebrew
# curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
# export PATH=$PATH:/opt/homebrew/bin
- name: Install Qt
uses: xiaoyifang/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cached: 'false'
modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set outputs
id: githash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: build macos
run: |
brew install pcre2 harfbuzz freetype
brew install cmake ninja python
brew install automake
brew install autoconf
brew install libtool
brew install opencc
brew install ffmpeg@5
#brew reinstall $(brew deps ffmpeg) ffmpeg
brew install libao
brew install libiconv
brew install lzo bzip2
brew install libogg
brew install zstd lzip
brew install libtiff
brew install libvorbis --force
brew install hunspell
wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2
tar xvjf eb-4.4.3.tar.bz2
cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd ..
#brew install qt # or use official offline installer
brew install xz lzo
brew install pkg-config
- name: compile
run: |
qmake CONFIG+=release CONFIG+=no_macos_universal CONFIG+=zim_support CONFIG+=no_extra_tiff_handler #CONFIG+=no_epwing_support # CONFIG+=no_ffmpeg_player #CONFIG+=no_qtmultimedia_player
make

166
.github/workflows/macos-homebrew.yml vendored Normal file
View file

@ -0,0 +1,166 @@
name: macos-homebrew
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- dev
- master
# - staged
paths-ignore:
- 'docs/**'
- ".github/**"
- "howto/**"
- "*.md"
- ".clang-format"
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11,macos-12]
qt_ver: [6.4.0]
qt_arch: [clang_64]
env:
targetName: GoldenDict
version: 22.8.24
version-suffix: alpha
prerelease: true
steps:
# macos 11.0 默认环境变了,要指定
- name: prepare env
if: ${{ matrix.os == 'macos-11' }}
run: |
softwareupdate --all --install --force
sudo xcode-select --print-path
sudo xcode-select --switch /Library/Developer/CommandLineTools
- uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Install Qt
uses: xiaoyifang/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cached: 'false'
modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia qtimageformats
setup-python: 'false'
py7zrversion: '==0.18.1'
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set outputs
id: githash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: build macos
run: |
brew install pcre2 harfbuzz freetype
brew install cmake ninja python
brew install automake
brew install autoconf
brew install libtool
brew install opencc
brew install ffmpeg
brew install libao
brew install libiconv
brew install lzo bzip2
brew install libogg
brew install zstd lzip
brew install libtiff
brew install libvorbis
brew install hunspell
wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2
tar xvjf eb-4.4.3.tar.bz2
cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd ..
#brew install qt # or use official offline installer
brew install xz lzo
brew install pkg-config
brew install create-dmg
- name: compile
run: |
qmake CONFIG+=release CONFIG+=no_macos_universal CONFIG+=zim_support CONFIG+=no_extra_tiff_handler #CONFIG+=no_epwing_support # CONFIG+=no_ffmpeg_player #CONFIG+=no_qtmultimedia_player
make -j8
# libao was specificly build https://github.com/goldendict/goldendict/pull/377
cp -fR maclibs/lib/libao* GoldenDict.app/Contents/Frameworks/
# # 打包
# - name: package
# run: |
# macdeployqt ${targetName}.app -qmldir=. -verbose=1 -dmg
# 打包
- name: package
run: |
macdeployqt ${targetName}.app -qmldir=. -verbose=1
codesign --force --deep -s - GoldenDict.app
otool -L GoldenDict.app/Contents/MacOS/GoldenDict
# otool -L GoldenDict.app/Contents/Frameworks/lib*
mkdir tmp
mv ${targetName}.app ./tmp
# --background "installer_background.png"
create-dmg --volname "${targetName} Installer" --volicon "icons/macicon.icns" --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon "${targetName}.app" 200 190 --hide-extension "${targetName}.app" --app-drop-link 600 185 --skip-jenkins "${targetName}.dmg" tmp/
- name: Generate changelog
if: ${{!env.prerelease}}
id: changelog1
uses: metcalfc/changelog-generator@v3.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Set outputs
id: vars
run: |
echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)"
echo "::set-output name=release_date::$(date +'%Y%m%d')"
echo "::set-output name=release_time::$(date +'%H%M%S')"
echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')"
echo "::set-output name=release_hm::$(date +'%y%m%d')"
- name: changelog
if: $${{env.prerelease}}
id: changelog2
run: |
previousTag=$(git tag --sort=-creatordate | sed -n 2p)
echo "previousTag : $previousTag"
CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)"
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
CHANGELOG="${CHANGELOG//'\"'/'%22'}"
CHANGELOG="${CHANGELOG//"'"/ }"
echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")"
# tag 上传Release
- name: uploadRelease
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.targetName }}.dmg
asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }}_${{ matrix.os }}_homebrew_${{steps.vars.outputs.release_date}}.dmg
tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
overwrite: true
release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
prerelease: ${{env.prerelease}}
body: |
release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}}
branch: ${{ github.ref_name }}
commit: ${{ steps.vars.outputs.sha_short }}
Qt version: Qt5.15.2, Qt6.X
Windows built with: msvc64, Visual studio 2019
## goldendict.exe can not be used alone
if you have a previous version. replace this maybe ok. if not ,download the whole bundle.
AppImage built with: Ubuntu-20.04 ,latest gcc
macos built with: macos-10.15,macos-11.0,clang_64 x86_64
Qt6.X(Universal Build)
Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES:
${{ steps.changelog1.outputs.changelog }}
${{ steps.changelog2.outputs.COMMIT_SUMMARY }}

161
.github/workflows/macos-m1.yml vendored Normal file
View file

@ -0,0 +1,161 @@
name: macos-m1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
# workflow_run:
# workflows: [AutoTag]
# types: [completed]
workflow_dispatch:
# push:
# branches:
# - dev
# - master
# # - staged
# paths-ignore:
# - 'docs/**'
# - ".github/**"
# - "howto/**"
# - "*.md"
# - ".clang-format"
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]
qt_ver: [6.3.1]
qt_arch: [clang_64]
env:
targetName: GoldenDict
version: 22.8.24
version-suffix: alpha
prerelease: true
steps:
- name: prepare env
run: |
cd /opt
mkdir homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
export PATH=$PATH:/opt/homebrew/bin
- name: Install Qt
uses: xiaoyifang/install-qt-action@v3
with:
version: ${{ matrix.qt_ver }}
arch: ${{ matrix.qt_arch }}
cached: 'false'
modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set outputs
id: githash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: build macos
run: |
brew install pcre2 harfbuzz freetype
brew install cmake ninja python
brew install automake
brew install autoconf
brew install libtool
brew install opencc
brew install ffmpeg@5
#brew reinstall $(brew deps ffmpeg) ffmpeg
brew install libao
brew install libiconv
brew install lzo bzip2
brew install libogg
brew install zstd lzip
brew install libtiff
brew install libvorbis --force
brew install hunspell
wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2
tar xvjf eb-4.4.3.tar.bz2
cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd ..
#brew install qt # or use official offline installer
brew install xz lzo
brew install pkg-config
brew install create-dmg
- name: compile
run: |
qmake CONFIG+=release CONFIG+=no_macos_universal CONFIG+=zim_support CONFIG+=no_extra_tiff_handler #CONFIG+=no_epwing_support # CONFIG+=no_ffmpeg_player #CONFIG+=no_qtmultimedia_player
make -j 8
# # 打包
# - name: package
# run: |
# macdeployqt ${targetName}.app -qmldir=. -verbose=1 -dmg
# 打包
- name: package
run: |
macdeployqt ${targetName}.app -qmldir=. -verbose=1
codesign --force --deep -s - GoldenDict.app
# otool -L GoldenDict.app/Contents/MacOS/GoldenDict
# otool -L GoldenDict.app/Contents/Frameworks/lib*
mkdir tmp
mv ${targetName}.app ./tmp
# --background "installer_background.png"
create-dmg --volname "${targetName} Installer" --volicon "icons/macicon.icns" --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon "${targetName}.app" 200 190 --hide-extension "${targetName}.app" --app-drop-link 600 185 --skip-jenkins "${targetName}.dmg" tmp/
- name: Generate changelog
if: ${{!env.prerelease}}
id: changelog1
uses: metcalfc/changelog-generator@v3.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Set outputs
id: vars
run: |
echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)"
echo "::set-output name=release_date::$(date +'%Y%m%d')"
echo "::set-output name=release_time::$(date +'%H%M%S')"
echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')"
echo "::set-output name=release_hm::$(date +'%y%m%d')"
- name: changelog
if: $${{env.prerelease}}
id: changelog2
run: |
previousTag=$(git tag --sort=-creatordate | sed -n 2p)
echo "previousTag : $previousTag"
CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)"
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
CHANGELOG="${CHANGELOG//'\"'/'%22'}"
CHANGELOG="${CHANGELOG//"'"/ }"
echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")"
# tag 上传Release
- name: uploadRelease
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.targetName }}.dmg
asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }}_${{ matrix.os }}_homebrew_${{steps.vars.outputs.release_date}}.dmg
tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
overwrite: true
release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
prerelease: ${{env.prerelease}}
body: |
release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}}
branch: ${{ github.ref_name }}
commit: ${{ steps.vars.outputs.sha_short }}
Qt version: Qt5.15.2, Qt6.X
Windows built with: msvc64, Visual studio 2019
## goldendict.exe can not be used alone
if you have a previous version. replace this maybe ok. if not ,download the whole bundle.
AppImage built with: Ubuntu-20.04 ,latest gcc
macos built with: macos-10.15,macos-11.0,clang_64 x86_64
Qt6.X(Universal Build)
Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES:
${{ steps.changelog1.outputs.changelog }}
${{ steps.changelog2.outputs.COMMIT_SUMMARY }}

View file

@ -30,9 +30,9 @@ jobs:
qt_arch: [clang_64] qt_arch: [clang_64]
env: env:
targetName: GoldenDict targetName: GoldenDict
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
steps: steps:
# macos 11.0 默认环境变了,要指定 # macos 11.0 默认环境变了,要指定
@ -130,6 +130,7 @@ jobs:
Qt6.X(Universal Build) Qt6.X(Universal Build)
Qt5.15.2(Intel Kind) Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-) auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]** Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES: CHANGES:

View file

@ -30,9 +30,9 @@ jobs:
qt_ver: [6.3.1] qt_ver: [6.3.1]
qt_arch: [gcc_64] qt_arch: [gcc_64]
env: env:
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
steps: steps:
- name: Install Qt - name: Install Qt
uses: xiaoyifang/install-qt-action@v3 uses: xiaoyifang/install-qt-action@v3
@ -133,6 +133,7 @@ jobs:
Qt6.X(Universal Build) Qt6.X(Universal Build)
Qt5.15.2(Intel Kind) Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-) auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]** Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES: CHANGES:

View file

@ -25,10 +25,7 @@ jobs:
os: [ubuntu-20.04] os: [ubuntu-20.04]
qt_ver: [5.15.2,6.2.4] qt_ver: [5.15.2,6.2.4]
qt_arch: [gcc_64] qt_arch: [gcc_64]
env:
version: 22.8.23
version-suffix: EndOfHeat
prerelease: false
steps: steps:
- uses: actions/setup-python@v3 - uses: actions/setup-python@v3
with: with:

View file

@ -30,9 +30,9 @@ jobs:
qt_ver: [5.15.2] qt_ver: [5.15.2]
qt_arch: [gcc_64] qt_arch: [gcc_64]
env: env:
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
steps: steps:
- name: Install Qt - name: Install Qt
uses: xiaoyifang/install-qt-action@v3 uses: xiaoyifang/install-qt-action@v3
@ -133,6 +133,7 @@ jobs:
Qt6.X(Universal Build) Qt6.X(Universal Build)
Qt5.15.2(Intel Kind) Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-) auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]** Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES: CHANGES:

View file

@ -1,4 +1,4 @@
name: Windows-6.2 name: Windows-6.x
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -31,9 +31,9 @@ jobs:
qt_arch: [win64_msvc2019_64] qt_arch: [win64_msvc2019_64]
env: env:
targetName: GoldenDict.exe targetName: GoldenDict.exe
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
steps: steps:
- uses: actions/setup-python@v3 - uses: actions/setup-python@v3
with: with:
@ -92,7 +92,6 @@ jobs:
id: build id: build
shell: cmd shell: cmd
run: | run: |
# call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
qmake "CONFIG+=zim_support" CONFIG+=release qmake "CONFIG+=zim_support" CONFIG+=release
nmake nmake
@ -140,6 +139,7 @@ jobs:
Qt6.X(Universal Build) Qt6.X(Universal Build)
Qt5.15.2(Intel Kind) Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-) auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]** Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES: CHANGES:
@ -177,7 +177,7 @@ jobs:
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.packageName }}/GoldenDict-v22-Install.exe file: ${{ steps.package.outputs.packageName }}/GoldenDict-v22-Install.exe
asset_name: ${{ matrix.qt_ver }}-GoldenDict-v22-Install.exe asset_name: ${{ matrix.qt_ver }}-GoldenDict-v${{env.version}}-${{env.version-suffix}}-Installer.exe
tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
overwrite: true overwrite: true
release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}

View file

@ -26,12 +26,6 @@ jobs:
os: [windows-2019] os: [windows-2019]
qt_ver: [5.15.2,6.2.4] qt_ver: [5.15.2,6.2.4]
qt_arch: [win64_msvc2019_64] qt_arch: [win64_msvc2019_64]
env:
targetName: GoldenDict.exe
version: 22.8.23
version-suffix: EndOfHeat
prerelease: false
steps: steps:
- uses: actions/setup-python@v3 - uses: actions/setup-python@v3
with: with:
@ -66,12 +60,5 @@ jobs:
id: build id: build
shell: cmd shell: cmd
run: | run: |
# call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }}
qmake "CONFIG+=zim_support" CONFIG+=release qmake "CONFIG+=zim_support" CONFIG+=release
nmake nmake
echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV%
echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV%
echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV%
echo vcToolsRedistDir=%VCToolsRedistDir% >> %GITHUB_ENV%
echo QTDIR=%Qt6_DIR% >> %GITHUB_ENV%

View file

@ -32,9 +32,9 @@ jobs:
qt_arch: [win64_msvc2019_64] qt_arch: [win64_msvc2019_64]
env: env:
targetName: GoldenDict.exe targetName: GoldenDict.exe
version: 22.8.23 version: 22.8.24
version-suffix: EndOfHeat version-suffix: alpha
prerelease: false prerelease: true
# 步骤 # 步骤
steps: steps:
# 安装Qt # 安装Qt
@ -138,6 +138,7 @@ jobs:
Qt6.X(Universal Build) Qt6.X(Universal Build)
Qt5.15.2(Intel Kind) Qt5.15.2(Intel Kind)
auto built by github action. use on your on risk:-) auto built by github action. use on your on risk:-)
**recommend version**:Qt6.X (with the latest bug fixes and performance enhancements)
Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]** Filename pattern: **[Qt version]-GoldenDict-[OS]-[release-date].[ext]**
CHANGES: CHANGES:
@ -177,7 +178,7 @@ jobs:
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.packageName }}/GoldenDict-v22-Install.exe file: ${{ steps.package.outputs.packageName }}/GoldenDict-v22-Install.exe
asset_name: ${{ matrix.qt_ver }}-GoldenDict-v22-Install.exe asset_name: ${{ matrix.qt_ver }}-GoldenDict-v${{env.version}}-${{env.version-suffix}}-Installer.exe
tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} tag: v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}
overwrite: true overwrite: true
release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }} release_name: GoldenDict-v${{env.version}}-${{env.version-suffix}}.${{ steps.vars.outputs.release_hm }}.${{ steps.vars.outputs.sha_short }}

View file

@ -1,6 +1,18 @@
# Changes # Changes
## Until to now ## Until Now
- change the original default style to classic style
- add clipboard tracking menu in trayicon
- concurrent fulltext index creation
- add CJK fulltext search ability
- many minor fixes .
- add mdx source+srcset support
- qt6.x help file can not open
- many minor optimizations.
- iframe website almost full support.(except some websites)
## Until 2022-8-31
- **CLEANING OLD/USELESS CODE** - **CLEANING OLD/USELESS CODE**
- remove Runnable Class in dsl, zim , epwing etc files. - remove Runnable Class in dsl, zim , epwing etc files.

View file

@ -32,3 +32,4 @@ Nasrollah Noori <nanopqr@gmail.com>: Persian translation
Vladimir Gerovski: Macedonian Translation Vladimir Gerovski: Macedonian Translation
Nikolay Korotkiy <sikmir\gmail.com>: Finnish translation Nikolay Korotkiy <sikmir\gmail.com>: Finnish translation
Robin Townsend: Lojban translation Robin Townsend: Lojban translation
Patrik Studer: Swiss High-German translation (de-ch)

View file

@ -30,10 +30,13 @@ This code has been run and tested on Windows 10/11, Ubuntu Linux, Mac OS X.
### Fedora 35 ### Fedora 35
``` ```
sudo dnf install git pkg-config \ sudo dnf install git pkg-config libzstd-devel opencc-devel xz-devel xz-lzma-compat\
libvorbis-devel zlib-devel hunspell-devel lzo-devel bzip2-devel \ libvorbis-devel zlib-devel hunspell-devel lzo-devel bzip2-devel \
libao-devel ffmpeg-devel libtiff-devel eb-devel qt5-qtx11extras-devel libXtst-devel \ libao-devel ffmpeg-devel libtiff-devel eb-devel qt5-qtx11extras-devel libXtst-devel \
libxkbcommon-devel libxkbcommon-devel qt5-qtbase qt5-qttools qt5-qtsvg-devl qt5-qtwebengine-devel qt5-qtmultimedia-devl
qmake-qt5 CONFIG+=release CONFIG+=no_extra_tiff_handler CONFIG+=no_epwing_support
make
``` ```

View file

@ -10,7 +10,6 @@ body
margin-left: 2px; margin-left: 2px;
margin-bottom: 3px; margin-bottom: 3px;
background: white; background: white;
font-family: Tahoma, Verdana, "Lucida Sans Unicode", "Segoe UI", "Palatino Linotype", "Arial Unicode MS", sans-serif;
} }
a a

View file

@ -6,8 +6,7 @@ html {
body body
{ {
font-family: Tahoma, Verdana, "Lucida Sans Unicode", sans-serif; font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;
height: 100%;
} }
/* This stylesheet is used to highligh current selection when doing a search. /* This stylesheet is used to highligh current selection when doing a search.

View file

@ -28,22 +28,11 @@ void ArticleInspector::setInspectPage( QWebEnginePage * page )
} }
qDebug() << page->lifecycleState(); qDebug() << page->lifecycleState();
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) #if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) || QT_VERSION > QT_VERSION_CHECK(6,3,0) )
page->triggerAction( QWebEnginePage::InspectElement ); page->triggerAction( QWebEnginePage::InspectElement );
#else #else
// without this line, application will crash on qt6.2 ,see https://bugreports.qt.io/browse/QTBUG-101724 // without this line, application will crash on qt6.2 ,see https://bugreports.qt.io/browse/QTBUG-101724
// and seems to hangup forever on qt6.3.0 ,so the best solution for now is to comment out the following lines. // and seems to hangup forever on qt6.3.0 ,so the best solution for now is to comment out the following lines.
static bool first{ true };
if( first )
{
qDebug()<<"inspector,phase first time";
first = false;
}
else
{
qDebug()<<"inspector,phase not first time";
page->triggerAction( QWebEnginePage::InspectElement );
}
#endif #endif
raise(); raise();

View file

@ -54,12 +54,15 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
// add jquery // add jquery
{ {
result += "<script type=\"text/javascript\" " result += "<script type=\"text/javascript\" "
"src=\"qrc:///resources/jquery-3.6.0.slim.min.js\"></script>"; "src=\"qrc:///scripts/jquery-3.6.0.slim.min.js\"></script>";
result += "<script> var $_$=$.noConflict(); </script>"; result += "<script> var $_$=$.noConflict(); </script>";
//custom javascript //custom javascript
result += "<script type=\"text/javascript\" src=\"qrc:///resources/gd-custom.js\"></script>"; result += "<script type=\"text/javascript\" src=\"qrc:///scripts/gd-custom.js\"></script>";
//iframe resizer javascript
result += "<script type=\"text/javascript\" src=\"qrc:///scripts/iframeResizer.min.js\"></script>";
} }
// add qwebchannel // add qwebchannel
@ -144,7 +147,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
"return tr_map[key] || '';" "return tr_map[key] || '';"
"}" "}"
"</script>"; "</script>";
result+= "<script type=\"text/javascript\" src=\"qrc:///resources/gd-builtin.js\"></script>"; result+= "<script type=\"text/javascript\" src=\"qrc:///scripts/gd-builtin.js\"></script>";
result += "</head><body>"; result += "</head><body>";
return result; return result;

View file

@ -1950,6 +1950,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
} }
menu.addSeparator(); menu.addSeparator();
if(!popupView||cfg.pinPopupWindow)
menu.addAction( &inspectAction ); menu.addAction( &inspectAction );
if ( !menu.isEmpty() ) if ( !menu.isEmpty() )

View file

@ -47,10 +47,10 @@ QRegularExpression Mdx::stylesRe2( "([\\s\"']href\\s*=)\\s*(?![\\s\"']|\\b(?:(?:
QRegularExpression Mdx::inlineScriptRe( "<\\s*script(?:(?=\\s)(?:(?![\\s\"']src\\s*=)[^>])+|\\s*)>", QRegularExpression Mdx::inlineScriptRe( "<\\s*script(?:(?=\\s)(?:(?![\\s\"']src\\s*=)[^>])+|\\s*)>",
QRegularExpression::CaseInsensitiveOption ); QRegularExpression::CaseInsensitiveOption );
QRegularExpression Mdx::closeScriptTagRe( "<\\s*/script\\s*>", QRegularExpression::CaseInsensitiveOption ); QRegularExpression Mdx::closeScriptTagRe( "<\\s*/script\\s*>", QRegularExpression::CaseInsensitiveOption );
QRegularExpression Mdx::srcRe( "([\\s\"']src\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://" QRegularExpression Mdx::srcRe( "([\\s\"'](?:src|srcset)\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://"
"|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\">]+)\\2", "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\">]+)\\2",
QRegularExpression::CaseInsensitiveOption ); QRegularExpression::CaseInsensitiveOption );
QRegularExpression Mdx::srcRe2( "([\\s\"']src\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://" QRegularExpression Mdx::srcRe2( "([\\s\"'](?:src|srcset)\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://"
"|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)",
QRegularExpression::CaseInsensitiveOption ); QRegularExpression::CaseInsensitiveOption );

View file

@ -2264,11 +2264,6 @@ QString getProgramDataDir() noexcept
#endif #endif
} }
QString getEmbedLocDir() noexcept
{
return ":/locale";
}
QString getLocDir() noexcept QString getLocDir() noexcept
{ {
if ( QDir( getProgramDataDir() ).cd( "locale" ) ) if ( QDir( getProgramDataDir() ).cd( "locale" ) )

View file

@ -811,7 +811,6 @@ QString getUserQtCssFileName() ;
QString getProgramDataDir() noexcept; QString getProgramDataDir() noexcept;
/// Returns the directory storing program localizized files (.qm). /// Returns the directory storing program localizized files (.qm).
QString getEmbedLocDir() noexcept;
QString getLocDir() noexcept; QString getLocDir() noexcept;
/// Returns the directory storing program help files (.qch). /// Returns the directory storing program help files (.qch).

View file

@ -273,11 +273,11 @@ bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
return false; return false;
} }
bool Class::loadIconFromText( QString const & text ) bool Class::loadIconFromText( QString iconUrl, QString const & text )
{ {
if( text.isEmpty() ) if( text.isEmpty() )
return false; return false;
QImage img( ":/icons/mdict-bg.png" ); QImage img( iconUrl );
if ( !img.isNull() ) if ( !img.isNull() )
{ {
@ -293,7 +293,7 @@ bool Class::loadIconFromText( QString const & text )
painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2, painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2,
img.height() == max ? 0 : ( max - img.height() ) / 2 ), img.height() == max ? 0 : ( max - img.height() ) / 2 ),
img ); img );
painter.setCompositionMode(QPainter::CompositionMode_DestinationOut); painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
QFont font = painter.font(); QFont font = painter.font();
//the text should be a little smaller than the icon //the text should be a little smaller than the icon

View file

@ -56,7 +56,9 @@ class Request: public QObject
Q_OBJECT Q_OBJECT
public: public:
Request( QObject * parent = nullptr ) : QObject( parent )
{
}
/// Returns whether the request has been processed in full and finished. /// Returns whether the request has been processed in full and finished.
/// This means that the data accumulated is final and won't change anymore. /// This means that the data accumulated is final and won't change anymore.
bool isFinished(); bool isFinished();
@ -177,7 +179,6 @@ class DataRequest: public Request
Q_OBJECT Q_OBJECT
public: public:
/// Returns the number of bytes read, with a -1 meaning that so far it's /// Returns the number of bytes read, with a -1 meaning that so far it's
/// uncertain whether resource even exists or not, and any non-negative value /// uncertain whether resource even exists or not, and any non-negative value
/// meaning that that amount of bytes is not available. /// meaning that that amount of bytes is not available.
@ -194,7 +195,9 @@ public:
/// done, this can only be called after the request has finished. /// done, this can only be called after the request has finished.
vector< char > & getFullData() ; vector< char > & getFullData() ;
DataRequest(): hasAnyData( false ) {} DataRequest( QObject * parent = 0 ) : Request( parent ), hasAnyData( false )
{
}
protected: protected:
@ -276,7 +279,7 @@ protected:
// Load icon from filename directly if isFullName == true // Load icon from filename directly if isFullName == true
// else treat filename as name without extension // else treat filename as name without extension
bool loadIconFromFile( QString const & filename, bool isFullName = false ); bool loadIconFromFile( QString const & filename, bool isFullName = false );
bool loadIconFromText( QString const & text ); bool loadIconFromText( QString iconUrl, QString const & text );
QString getAbbrName( QString const & text ); QString getAbbrName( QString const & text );

4
dsl.cc
View file

@ -1100,7 +1100,9 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
url.setScheme( "gdlookup" ); url.setScheme( "gdlookup" );
url.setHost( "localhost" ); url.setHost( "localhost" );
url.setPath( Utils::Url::ensureLeadingSlash( gd::toQString( node.renderAsText() ) ) ); wstring nodeStr = node.renderAsText();
normalizeHeadword( nodeStr );
url.setPath( Utils::Url::ensureLeadingSlash( gd::toQString( nodeStr ) ) );
if( !node.tagAttrs.empty() ) if( !node.tagAttrs.empty() )
{ {
QString attr = gd::toQString( node.tagAttrs ).remove( '\"' ); QString attr = gd::toQString( node.tagAttrs ).remove( '\"' );

119
epwing.cc
View file

@ -429,28 +429,6 @@ void EpwingDictionary::getArticleText( uint32_t articleAddress, QString & headwo
/// EpwingDictionary::getArticle() /// EpwingDictionary::getArticle()
class EpwingArticleRequest;
class EpwingArticleRequestRunnable: public QRunnable
{
EpwingArticleRequest & r;
QSemaphore & hasExited;
public:
EpwingArticleRequestRunnable( EpwingArticleRequest & r_,
QSemaphore & hasExited_ ): r( r_ ),
hasExited( hasExited_ )
{}
~EpwingArticleRequestRunnable()
{
hasExited.release();
}
virtual void run();
};
class EpwingArticleRequest: public Dictionary::DataRequest class EpwingArticleRequest: public Dictionary::DataRequest
{ {
friend class EpwingArticleRequestRunnable; friend class EpwingArticleRequestRunnable;
@ -476,7 +454,11 @@ public:
// new EpwingArticleRequestRunnable( *this, hasExited ) ); // new EpwingArticleRequestRunnable( *this, hasExited ) );
} }
void run(); // Run from another thread by EpwingArticleRequestRunnable void run();
void getBuiltInArticle(wstring const & word_, QVector< int > & pages,
QVector< int > & offsets,
multimap< wstring, pair< string, string > > & mainArticles );
virtual void cancel() virtual void cancel()
{ {
@ -491,11 +473,6 @@ public:
} }
}; };
void EpwingArticleRequestRunnable::run()
{
r.run();
}
void EpwingArticleRequest::run() void EpwingArticleRequest::run()
{ {
if ( Utils::AtomicInt::loadAcquire( isCancelled ) ) if ( Utils::AtomicInt::loadAcquire( isCancelled ) )
@ -509,7 +486,6 @@ void EpwingArticleRequest::run()
for( unsigned x = 0; x < alts.size(); ++x ) for( unsigned x = 0; x < alts.size(); ++x )
{ {
/// Make an additional query for each alt /// Make an additional query for each alt
vector< WordArticleLink > altChain = dict.findArticles( alts[ x ], ignoreDiacritics ); vector< WordArticleLink > altChain = dict.findArticles( alts[ x ], ignoreDiacritics );
chain.insert( chain.end(), altChain.begin(), altChain.end() ); chain.insert( chain.end(), altChain.begin(), altChain.end() );
@ -577,44 +553,10 @@ void EpwingArticleRequest::run()
} }
// Also try to find word in the built-in dictionary index // Also try to find word in the built-in dictionary index
try getBuiltInArticle(word, pages, offsets, mainArticles );
{ for( unsigned x = 0; x < alts.size(); ++x )
string headword, articleText;
QVector< int > pg, off;
{
Mutex::Lock _( dict.eBook.getLibMutex() );
dict.eBook.getArticlePos( gd::toQString( word ), pg, off );
}
for( int i = 0; i < pg.size(); i++ )
{
bool already = false;
for( int n = 0; n < pages.size(); n++ )
{
if( pages.at( n ) == pg.at( i )
&& abs( offsets.at( n ) - off.at( i ) ) <= 4 )
{
already = true;
break;
}
}
if( !already )
{
dict.loadArticle( pg.at( i ), off.at( i ), headword, articleText );
mainArticles.insert( pair< wstring, pair< string, string > >(
Folding::applySimpleCaseOnly( Utf8::decode( headword ) ),
pair< string, string >( headword, articleText ) ) );
pages.append( pg.at( i ) );
offsets.append( off.at( i ) );
}
}
}
catch(...)
{ {
getBuiltInArticle( alts[ x ], pages, offsets, alternateArticles );
} }
if ( mainArticles.empty() && alternateArticles.empty() ) if ( mainArticles.empty() && alternateArticles.empty() )
@ -657,6 +599,51 @@ void EpwingArticleRequest::run()
finish(); finish();
} }
void EpwingArticleRequest::getBuiltInArticle( wstring const & word_,
QVector< int > & pages,
QVector< int > & offsets,
multimap< wstring, pair< string, string > > & mainArticles )
{
try
{
string headword, articleText;
QVector< int > pg, off;
{
Mutex::Lock _( dict.eBook.getLibMutex() );
dict.eBook.getArticlePos( gd::toQString( word_ ), pg, off );
}
for( int i = 0; i < pg.size(); i++ )
{
bool already = false;
for( int n = 0; n < pages.size(); n++ )
{
if( pages.at( n ) == pg.at( i ) && abs( offsets.at( n ) - off.at( i ) ) <= 4 )
{
already = true;
break;
}
}
if( !already )
{
dict.loadArticle( pg.at( i ), off.at( i ), headword, articleText );
mainArticles.insert(
pair< wstring, pair< string, string > >( Folding::applySimpleCaseOnly( Utf8::decode( headword ) ),
pair< string, string >( headword, articleText ) ) );
pages.append( pg.at( i ) );
offsets.append( off.at( i ) );
}
}
}
catch( ... )
{
}
}
sptr< Dictionary::DataRequest > EpwingDictionary::getArticle( wstring const & word, sptr< Dictionary::DataRequest > EpwingDictionary::getArticle( wstring const & word,
vector< wstring > const & alts, vector< wstring > const & alts,
wstring const &, wstring const &,

View file

@ -126,6 +126,72 @@ QString FtsIndexing::nowIndexingName()
return nowIndexing; return nowIndexing;
} }
void addSortedHeadwords( QList< FtsHeadword > & base_list, QList< FtsHeadword > const & add_list)
{
QList< FtsHeadword > list;
if( add_list.isEmpty() )
return;
if( base_list.isEmpty() )
{
base_list = add_list;
return;
}
list.reserve( base_list.size() + add_list.size() );
QList< FtsHeadword >::iterator base_it = base_list.begin();
QList< FtsHeadword >::const_iterator add_it = add_list.constBegin();
while( base_it != base_list.end() || add_it != add_list.end() )
{
if( base_it == base_list.end() )
{
while( add_it != add_list.end() )
{
list.append( *add_it );
++add_it;
}
break;
}
if( add_it == add_list.end() )
{
while( base_it != base_list.end() )
{
list.append( *base_it );
++base_it;
}
break;
}
if( *add_it < *base_it )
{
list.append( *add_it );
++add_it;
}
else if( *add_it == *base_it )
{
base_it->dictIDs.append( add_it->dictIDs );
for( QStringList::const_iterator itr = add_it->foundHiliteRegExps.constBegin();
itr != add_it->foundHiliteRegExps.constEnd(); ++itr )
{
if( !base_it->foundHiliteRegExps.contains( *itr ) )
base_it->foundHiliteRegExps.append( *itr );
}
++add_it;
}
else
{
list.append( *base_it );
++base_it;
}
}
base_list.swap( list );
}
FullTextSearchDialog::FullTextSearchDialog( QWidget * parent, FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
Config::Class & cfg_, Config::Class & cfg_,
std::vector< sptr< Dictionary::Class > > const & dictionaries_, std::vector< sptr< Dictionary::Class > > const & dictionaries_,
@ -405,6 +471,7 @@ void FullTextSearchDialog::accept()
void FullTextSearchDialog::searchReqFinished() void FullTextSearchDialog::searchReqFinished()
{ {
QList< FtsHeadword > allHeadwords;
while ( searchReqs.size() ) while ( searchReqs.size() )
{ {
std::list< sptr< Dictionary::DataRequest > >::iterator it; std::list< sptr< Dictionary::DataRequest > >::iterator it;
@ -421,13 +488,14 @@ void FullTextSearchDialog::searchReqFinished()
QList< FtsHeadword > * headwords; QList< FtsHeadword > * headwords;
if( (unsigned)(*it)->dataSize() >= sizeof( headwords ) ) if( (unsigned)(*it)->dataSize() >= sizeof( headwords ) )
{ {
QList< FtsHeadword > hws;
try try
{ {
(*it)->getDataSlice( 0, sizeof( headwords ), &headwords ); (*it)->getDataSlice( 0, sizeof( headwords ), &headwords );
model->addResults( QModelIndex(), *headwords ); hws.swap( *headwords );
std::sort( hws.begin(), hws.end() );
delete headwords; delete headwords;
ui.articlesFoundLabel->setText( tr( "Articles found: " ) addSortedHeadwords( allHeadwords, hws );
+ QString::number( results.size() ) );
} }
catch( std::exception & e ) catch( std::exception & e )
{ {
@ -449,6 +517,14 @@ void FullTextSearchDialog::searchReqFinished()
else else
break; break;
} }
if( !allHeadwords.isEmpty() )
{
model->addResults( QModelIndex(), allHeadwords );
ui.articlesFoundLabel->setText( tr( "Articles found: " )
+ QString::number( results.size() ) );
}
if ( searchReqs.empty() ) if ( searchReqs.empty() )
{ {
ui.searchProgressBar->hide(); ui.searchProgressBar->hide();
@ -608,27 +684,7 @@ void HeadwordsListModel::addResults(const QModelIndex & parent, QList< FtsHeadwo
Q_UNUSED( parent ); Q_UNUSED( parent );
beginResetModel(); beginResetModel();
QList< FtsHeadword > temp; addSortedHeadwords( headwords, hws );
for( int x = 0; x < hws.length(); x++ )
{
QList< FtsHeadword >::iterator it = std::lower_bound( headwords.begin(), headwords.end(), hws.at( x ) );
if( it != headwords.end() && *it == hws.at( x ) )
{
it->dictIDs.push_back( hws.at( x ).dictIDs.front() );
for( QStringList::const_iterator itr = it->foundHiliteRegExps.constBegin();
itr != it->foundHiliteRegExps.constEnd(); ++itr )
{
if( !it->foundHiliteRegExps.contains( *itr ) )
it->foundHiliteRegExps.append( *itr );
}
}
else
temp.append( hws.at( x ) );
}
headwords.append( temp );
std::sort( headwords.begin(), headwords.end() );
endResetModel(); endResetModel();
emit contentChanged(); emit contentChanged();

View file

@ -1,6 +1,6 @@
TEMPLATE = app TEMPLATE = app
TARGET = goldendict TARGET = goldendict
VERSION = 22.8.23-EndOfHeat VERSION = 22.8.24-alpha
# Generate version file. We do this here and in a build rule described later. # Generate version file. We do this here and in a build rule described later.
# The build rule is required since qmake isn't run each time the project is # The build rule is required since qmake isn't run each time the project is
@ -69,19 +69,18 @@ CONFIG += exceptions \
stl \ stl \
c++17 \ c++17 \
lrelease \ lrelease \
embed_translations \
utf8_source \ utf8_source \
force_debug_info force_debug_info
mac { mac {
DEBUG:CONFIG += app_bundle CONFIG += app_bundle
} }
QM_FILES_RESOURCE_PREFIX = /locale/ QM_FILES_INSTALL_PATH = /locale/
OBJECTS_DIR = build OBJECTS_DIR = build
UI_DIR = build UI_DIR = build
MOC_DIR = build MOC_DIR = build
#RCC_DIR = build RCC_DIR = build
LIBS += -lz \ LIBS += -lz \
-lbz2 \ -lbz2 \
-llzo2 -llzo2
@ -90,7 +89,8 @@ win32 {
TARGET = GoldenDict TARGET = GoldenDict
win32-msvc* { win32-msvc* {
VERSION = 22.8.23 # VS does not recognize 22.number.alpha,cause errors during compilation under MSVC++ # VS does not recognize 22.number.alpha,cause errors during compilation under MSVC++
VERSION = 22.8.24
DEFINES += __WIN32 _CRT_SECURE_NO_WARNINGS DEFINES += __WIN32 _CRT_SECURE_NO_WARNINGS
contains(QMAKE_TARGET.arch, x86_64) { contains(QMAKE_TARGET.arch, x86_64) {
DEFINES += NOMINMAX __WIN64 DEFINES += NOMINMAX __WIN64
@ -138,7 +138,9 @@ win32 {
CONFIG += chinese_conversion_support CONFIG += chinese_conversion_support
} }
} }
!CONFIG( no_macos_universal ) {
DEFINES += INCLUDE_LIBRARY_PATH
}
unix:!mac { unix:!mac {
DEFINES += HAVE_X11 DEFINES += HAVE_X11
@ -202,8 +204,8 @@ mac {
-lvorbisfile \ -lvorbisfile \
-lvorbis \ -lvorbis \
-logg \ -logg \
-lhunspell \
-llzo2 -llzo2
!CONFIG( no_ffmpeg_player ) { !CONFIG( no_ffmpeg_player ) {
LIBS += -lao \ LIBS += -lao \
-lswresample \ -lswresample \
@ -213,19 +215,38 @@ mac {
} }
QT_CONFIG -= no-pkg-config QT_CONFIG -= no-pkg-config
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
!CONFIG( no_macos_universal ) {
LIBS+= -lhunspell
INCLUDEPATH = $${PWD}/maclibs/include INCLUDEPATH = $${PWD}/maclibs/include
LIBS += -L$${PWD}/maclibs/lib -framework AppKit -framework Carbon LIBS += -L$${PWD}/maclibs/lib -framework AppKit -framework Carbon
}
else{
PKGCONFIG += hunspell
INCLUDEPATH = /opt/homebrew/include /usr/local/include
LIBS += -L/opt/homebrew/lib -L/usr/local/lib -framework AppKit -framework Carbon
}
OBJECTIVE_SOURCES += lionsupport.mm \ OBJECTIVE_SOURCES += lionsupport.mm \
machotkeywrapper.mm \ machotkeywrapper.mm \
macmouseover.mm \ macmouseover.mm \
speechclient_mac.mm speechclient_mac.mm
ICON = icons/macicon.icns ICON = icons/macicon.icns
QMAKE_INFO_PLIST = myInfo.plist QMAKE_INFO_PLIST = myInfo.plist
!CONFIG( no_macos_universal ) {
QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks && \ QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks && \
cp -nR $${PWD}/maclibs/lib/ GoldenDict.app/Contents/Frameworks/ && \ cp -nR $${PWD}/maclibs/lib/ GoldenDict.app/Contents/Frameworks/ && \
mkdir -p GoldenDict.app/Contents/MacOS/help && \ mkdir -p GoldenDict.app/Contents/MacOS/help && \
cp -R $${PWD}/help/*.qch GoldenDict.app/Contents/MacOS/help/ cp -R $${PWD}/help/*.qch GoldenDict.app/Contents/MacOS/help/
}
else{
QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks && \
cp -nR $${PWD}/maclibs/lib/libeb.dylib GoldenDict.app/Contents/Frameworks/ && \
mkdir -p GoldenDict.app/Contents/MacOS/help && \
cp -R $${PWD}/help/*.qch GoldenDict.app/Contents/MacOS/help/
}
!CONFIG( no_chinese_conversion_support ) { !CONFIG( no_chinese_conversion_support ) {
CONFIG += chinese_conversion_support CONFIG += chinese_conversion_support
QMAKE_POST_LINK += && mkdir -p GoldenDict.app/Contents/MacOS/opencc && \ QMAKE_POST_LINK += && mkdir -p GoldenDict.app/Contents/MacOS/opencc && \
@ -563,12 +584,14 @@ CONFIG( chinese_conversion_support ) {
} }
RESOURCES += resources.qrc \ RESOURCES += resources.qrc \
scripts.qrc \
flags.qrc flags.qrc
#EXTRA_TRANSLATIONS += thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts #EXTRA_TRANSLATIONS += thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts
TRANSLATIONS += locale/ru_RU.ts \ TRANSLATIONS += locale/ru_RU.ts \
locale/zh_CN.ts \ locale/zh_CN.ts \
locale/cs_CZ.ts \ locale/cs_CZ.ts \
locale/de_DE.ts \ locale/de_DE.ts \
locale/de_CH.ts \
locale/el_GR.ts \ locale/el_GR.ts \
locale/bg_BG.ts \ locale/bg_BG.ts \
locale/ar_SA.ts \ locale/ar_SA.ts \
@ -604,13 +627,38 @@ TRANSLATIONS += locale/ru_RU.ts \
locale/jb_JB.ts \ locale/jb_JB.ts \
locale/hi_IN.ts \ locale/hi_IN.ts \
locale/ie_001.ts locale/ie_001.ts
# Build version file # Build version file
!isEmpty( hasGit ) { !isEmpty( hasGit ) {
PRE_TARGETDEPS += $$PWD/version.txt PRE_TARGETDEPS += $$PWD/version.txt
} }
# This makes qmake generate translations
isEmpty(QMAKE_LRELEASE):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
# The *.qm files might not exist when qmake is run for the first time,
# causing the standard install rule to be ignored, and no translations
# will be installed. With this, we create the qm files during qmake run.
!win32 {
system($${QMAKE_LRELEASE} -silent $${_PRO_FILE_} 2> /dev/null)
}
else{
system($${QMAKE_LRELEASE} -silent $${_PRO_FILE_})
}
updateqm.input = TRANSLATIONS
updateqm.output = locale/${QMAKE_FILE_BASE}.qm
updateqm.commands = $$QMAKE_LRELEASE \
${QMAKE_FILE_IN} \
-qm \
${QMAKE_FILE_OUT}
updateqm.CONFIG += no_link
QMAKE_EXTRA_COMPILERS += updateqm
TS_OUT = $$TRANSLATIONS
TS_OUT ~= s/.ts/.qm/g
PRE_TARGETDEPS += $$TS_OUT
include( thirdparty/qtsingleapplication/src/qtsingleapplication.pri ) include( thirdparty/qtsingleapplication/src/qtsingleapplication.pri )

Binary file not shown.

Binary file not shown.

View file

@ -113,6 +113,10 @@ HelpWindow::HelpWindow( QWidget * parent, Config::Class & cfg_ ) :
helpEngine = new QHelpEngine( helpCollectionFile ); helpEngine = new QHelpEngine( helpCollectionFile );
#if (QT_VERSION > QT_VERSION_CHECK(6,0,0))
helpEngine->setReadOnly( false );
#endif
if( !helpEngine->setupData() ) if( !helpEngine->setupData() )
{ {
gdWarning( "Help engine initialization error: %s", helpEngine->error().toUtf8().data() ); gdWarning( "Help engine initialization error: %s", helpEngine->error().toUtf8().data() );

View file

@ -23,7 +23,11 @@
#include <QFileInfo> #include <QFileInfo>
#include <set> #include <set>
#ifndef INCLUDE_LIBRARY_PATH
#include <hunspell.hxx>
#else
#include <hunspell/hunspell.hxx> #include <hunspell/hunspell.hxx>
#endif
#include "gddebug.hh" #include "gddebug.hh"
#include "fsencoding.hh" #include "fsencoding.hh"
#include "utils.hh" #include "utils.hh"

View file

@ -19,22 +19,29 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
auto finishAction = [ = ]() -> void auto finishAction = [ = ]() -> void
{ {
QByteArray contentType = "text/html;charset=UTF-8"; QByteArray contentType = "text/html";
QBuffer * buffer = new QBuffer( requestJob ); QBuffer * buffer = new QBuffer( requestJob );
// Handle reply data
if( reply->error() != QNetworkReply::NoError )
{
QString emptyHtml = QString( "<html><body>%1</body></html>" ).arg( reply->errorString() );
buffer->setData( emptyHtml.toUtf8() );
requestJob->reply( contentType, buffer );
return;
}
QByteArray replyData = reply->readAll(); QByteArray replyData = reply->readAll();
QString articleString; QString articleString;
QTextCodec * codec = QTextCodec::codecForHtml( replyData, QTextCodec::codecForName( "UTF-8" ) ); QTextCodec * codec = QTextCodec::codecForHtml( replyData, QTextCodec::codecForName( "UTF-8" ) );
articleString = codec->toUnicode( replyData ); articleString = codec->toUnicode( replyData );
// Handle reply data
// 404 response may have response body.
if( reply->error() != QNetworkReply::NoError && articleString.isEmpty())
{
if(reply->error()==QNetworkReply::ContentNotFoundError){
//work around to fix QTBUG-106573
requestJob->redirect(url);
return;
}
QString emptyHtml = QString( "<html><body>%1</body></html>" ).arg( reply->errorString() );
buffer->setData( emptyHtml.toUtf8() );
requestJob->reply( contentType, buffer );
return;
}
// Change links from relative to absolute // Change links from relative to absolute
@ -46,6 +53,10 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
QString baseTagHtml = "<base href=\"" + base + "\">"; QString baseTagHtml = "<base href=\"" + base + "\">";
QString depressionFocus ="<script type=\"application/javascript\"> HTMLElement.prototype.focus=function(){console.log(\"focus() has been disabled.\");}</script>"
"<script type=\"text/javascript\" src=\"qrc:///scripts/iframeResizer.contentWindow.min.js\"></script>"
"<script type=\"text/javascript\" src=\"qrc:///scripts/iframe-defer.js\"></script>";
// remove existed base tag // remove existed base tag
articleString.remove( baseTag ) ; articleString.remove( baseTag ) ;
@ -56,12 +67,14 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
if( match.hasMatch() ) if( match.hasMatch() )
{ {
articleString.insert( match.capturedEnd(), baseTagHtml ); articleString.insert( match.capturedEnd(), baseTagHtml );
articleString.insert( match.capturedEnd(), depressionFocus );
} }
else else
{ {
// the html contain no head element // the html contain no head element
// just insert at the beginning of the html ,and leave it at the mercy of browser(chrome webengine) // just insert at the beginning of the html ,and leave it at the mercy of browser(chrome webengine)
articleString.insert( 0, baseTagHtml ); articleString.insert( 0, baseTagHtml );
articleString.insert( 0, depressionFocus );
} }
buffer->setData(codec->fromUnicode(articleString)); buffer->setData(codec->fromUnicode(articleString));

5164
locale/de_CH.ts Normal file

File diff suppressed because it is too large Load diff

View file

@ -399,7 +399,7 @@ int main( int argc, char ** argv )
app.installTranslator( &qtTranslator ); app.installTranslator( &qtTranslator );
} }
translator.load( Config::getEmbedLocDir() + "/" + localeName ); translator.load( Config::getLocDir() + "/" + localeName );
app.installTranslator( &translator ); app.installTranslator( &translator );
QTranslator webengineTs; QTranslator webengineTs;

View file

@ -181,7 +181,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor( wuri ); QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor( wuri );
if(!cfg.preferences.hideGoldenDictHeader){ if(!cfg.preferences.hideGoldenDictHeader){
QWebEngineProfile::defaultProfile()->setHttpUserAgent(QWebEngineProfile::defaultProfile()->httpUserAgent()+" GoldenDict/webengine"); QWebEngineProfile::defaultProfile()->setHttpUserAgent(QWebEngineProfile::defaultProfile()->httpUserAgent()+" GoldenDict/WebEngine");
} }
qRegisterMetaType< Config::InputPhrase >(); qRegisterMetaType< Config::InputPhrase >();
@ -238,7 +238,11 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
enableScanPopup->setVisible( cfg.preferences.enableScanPopup ); enableScanPopup->setVisible( cfg.preferences.enableScanPopup );
navToolbar->widgetForAction( enableScanPopup )->setObjectName( "scanPopupButton" ); navToolbar->widgetForAction( enableScanPopup )->setObjectName( "scanPopupButton" );
if( cfg.preferences.enableScanPopup && cfg.preferences.startWithScanPopupOn ) if( cfg.preferences.enableScanPopup && cfg.preferences.startWithScanPopupOn )
{
enableScanPopup->setIcon( QIcon( ":/icons/wizard-selected.svg" ) );
enableScanPopup->setChecked( true ); enableScanPopup->setChecked( true );
}
connect( enableScanPopup, SIGNAL( toggled( bool ) ), connect( enableScanPopup, SIGNAL( toggled( bool ) ),
this, SLOT( scanEnableToggled( bool ) ) ); this, SLOT( scanEnableToggled( bool ) ) );
@ -1514,6 +1518,8 @@ void MainWindow::makeScanPopup()
connect( scanPopup.get(), SIGNAL( setExpandMode( bool ) ), connect( scanPopup.get(), SIGNAL( setExpandMode( bool ) ),
this, SLOT( setExpandMode( bool ) ) ); this, SLOT( setExpandMode( bool ) ) );
connect( scanPopup.get(), &ScanPopup::inspectSignal,this,&MainWindow::inspectElement );
connect( scanPopup.get(), SIGNAL( forceAddWordToHistory( const QString & ) ), connect( scanPopup.get(), SIGNAL( forceAddWordToHistory( const QString & ) ),
this, SLOT( forceAddWordToHistory( const QString & ) ) ); this, SLOT( forceAddWordToHistory( const QString & ) ) );
@ -3453,7 +3459,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri
{ {
QUrl url( rx.cap( 1 ) ); QUrl url( rx.cap( 1 ) );
QString host = url.host(); QString host = url.host();
QString resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( Utils::Url::path( url ), "/" ) ); QString resourcePath = Utils::Url::path( url );
if ( !host.startsWith( '/' ) ) if ( !host.startsWith( '/' ) )
host.insert( 0, '/' ); host.insert( 0, '/' );
@ -3470,6 +3476,7 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri
} }
// Modify original url, set to the native one // Modify original url, set to the native one
resourcePath = QString::fromLatin1( QUrl::toPercentEncoding( resourcePath, "/" ) );
QString newUrl = sep + QDir( folder ).dirName() + host + resourcePath + sep; QString newUrl = sep + QDir( folder ).dirName() + host + resourcePath + sep;
html.replace( pos, rx.cap().length(), newUrl ); html.replace( pos, rx.cap().length(), newUrl );
pos += newUrl.length(); pos += newUrl.length();
@ -3512,7 +3519,8 @@ void MainWindow::on_saveArticle_triggered()
&selectedFilter, &selectedFilter,
options ); options );
bool complete = ( selectedFilter == filters[ 0 ] ); // The " (*.html)" part of filters[i] is absent from selectedFilter in Qt 5.
bool const complete = filters.at( 0 ).startsWith( selectedFilter );
if( fileName.isEmpty() ) if( fileName.isEmpty() )
return; return;

View file

@ -198,88 +198,13 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>254</red>
<green>253</green>
<blue>235</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>254</red>
<green>253</green>
<blue>235</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="frame"> <property name="frame">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="WordList" name="wordList"> <widget class="WordList" name="wordList"/>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>254</red>
<green>253</green>
<blue>235</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>254</red>
<green>253</green>
<blue>235</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

11
mdx.cc
View file

@ -200,7 +200,7 @@ public:
}; };
class MdxDictionary: public BtreeIndexing::BtreeDictionary class MdxDictionary: public QObject, public BtreeIndexing::BtreeDictionary
{ {
Mutex idxMutex; Mutex idxMutex;
File::Class idx; File::Class idx;
@ -695,10 +695,8 @@ class MddResourceRequest: public Dictionary::DataRequest
public: public:
MddResourceRequest( MdxDictionary & dict_, MddResourceRequest( MdxDictionary & dict_, string const & resourceName_ ) :
string const & resourceName_ ): Dictionary::DataRequest( &dict_ ), dict( dict_ ), resourceName( Utf8::decode( resourceName_ ) )
dict( dict_ ),
resourceName( Utf8::decode( resourceName_ ) )
{ {
f = QtConcurrent::run( [ this ]() { this->run(); } ); f = QtConcurrent::run( [ this ]() { this->run(); } );
// QThreadPool::globalInstance()->start( [ this ]() { this->run(); } ); // QThreadPool::globalInstance()->start( [ this ]() { this->run(); } );
@ -854,7 +852,6 @@ void MddResourceRequest::run()
if( Filetype::isNameOfTiff( u8ResourceName ) ) if( Filetype::isNameOfTiff( u8ResourceName ) )
{ {
// Convert it // Convert it
Mutex::Lock _( dataMutex );
GdTiff::tiff2img( data ); GdTiff::tiff2img( data );
} }
} }
@ -902,7 +899,7 @@ void MdxDictionary::loadIcon() noexcept
fileName.chop( 3 ); fileName.chop( 3 );
QString text = QString::fromStdString( dictionaryName ); QString text = QString::fromStdString( dictionaryName );
if( !loadIconFromFile( fileName ) && !loadIconFromText( text ) ) if( !loadIconFromFile( fileName ) && !loadIconFromText(":/icons/mdict-bg.png", text ) )
{ {
// Use default icons // Use default icons
dictionaryIcon = dictionaryNativeIcon = QIcon( ":/icons/mdict.png" ); dictionaryIcon = dictionaryNativeIcon = QIcon( ":/icons/mdict.png" );

View file

@ -19,32 +19,9 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
connect( ui.enableScanPopup, SIGNAL( toggled( bool ) ), connect( ui.enableScanPopup, SIGNAL( toggled( bool ) ),
this, SLOT( enableScanPopupToggled( bool ) ) ); this, SLOT( enableScanPopupToggled( bool ) ) );
connect( ui.enableScanPopupModifiers, SIGNAL( toggled( bool ) ),
this, SLOT( enableScanPopupModifiersToggled( bool ) ) );
connect( ui.showScanFlag, SIGNAL( toggled( bool ) ), connect( ui.showScanFlag, SIGNAL( toggled( bool ) ),
this, SLOT( showScanFlagToggled( bool ) ) ); this, SLOT( showScanFlagToggled( bool ) ) );
connect( ui.altKey, SIGNAL( clicked( bool ) ),
this, SLOT( wholeAltClicked( bool ) ) );
connect( ui.ctrlKey, SIGNAL( clicked( bool ) ),
this, SLOT( wholeCtrlClicked( bool ) ) );
connect( ui.shiftKey, SIGNAL( clicked( bool ) ),
this, SLOT( wholeShiftClicked( bool ) ) );
connect( ui.leftAlt, SIGNAL( clicked( bool ) ),
this, SLOT( sideAltClicked( bool ) ) );
connect( ui.rightAlt, SIGNAL( clicked( bool ) ),
this, SLOT( sideAltClicked( bool ) ) );
connect( ui.leftCtrl, SIGNAL( clicked( bool ) ),
this, SLOT( sideCtrlClicked( bool ) ) );
connect( ui.rightCtrl, SIGNAL( clicked( bool ) ),
this, SLOT( sideCtrlClicked( bool ) ) );
connect( ui.leftShift, SIGNAL( clicked( bool ) ),
this, SLOT( sideShiftClicked( bool ) ) );
connect( ui.rightShift, SIGNAL( clicked( bool ) ),
this, SLOT( sideShiftClicked( bool ) ) );
connect( ui.buttonBox, SIGNAL( helpRequested() ), connect( ui.buttonBox, SIGNAL( helpRequested() ),
this, SLOT( helpRequested() ) ); this, SLOT( helpRequested() ) );
@ -64,7 +41,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
// See which other translations do we have // See which other translations do we have
QStringList availLocs = QDir( Config::getEmbedLocDir() ).entryList( QStringList( "*.qm" ), QStringList availLocs = QDir( Config::getLocDir() ).entryList( QStringList( "*.qm" ),
QDir::Files ); QDir::Files );
// We need to sort by language name -- otherwise list looks really weird // We need to sort by language name -- otherwise list looks really weird
@ -192,21 +169,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.enableScanPopup->setChecked( p.enableScanPopup ); ui.enableScanPopup->setChecked( p.enableScanPopup );
ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn ); ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn );
ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers );
ui.altKey->setChecked( p.scanPopupModifiers & KeyboardState::Alt );
ui.ctrlKey->setChecked( p.scanPopupModifiers & KeyboardState::Ctrl );
ui.shiftKey->setChecked( p.scanPopupModifiers & KeyboardState::Shift );
ui.winKey->setChecked( p.scanPopupModifiers & KeyboardState::Win );
ui.leftAlt->setChecked( p.scanPopupModifiers & KeyboardState::LeftAlt );
ui.rightAlt->setChecked( p.scanPopupModifiers & KeyboardState::RightAlt );
ui.leftCtrl->setChecked( p.scanPopupModifiers & KeyboardState::LeftCtrl );
ui.rightCtrl->setChecked( p.scanPopupModifiers & KeyboardState::RightCtrl );
ui.leftShift->setChecked( p.scanPopupModifiers & KeyboardState::LeftShift );
ui.rightShift->setChecked( p.scanPopupModifiers & KeyboardState::RightShift );
ui.scanPopupAltMode->setChecked( p.scanPopupAltMode );
ui.scanPopupAltModeSecs->setValue( p.scanPopupAltModeSecs );
ui.ignoreOwnClipboardChanges->setChecked( p.ignoreOwnClipboardChanges ); ui.ignoreOwnClipboardChanges->setChecked( p.ignoreOwnClipboardChanges );
ui.scanToMainWindow->setChecked( p.scanToMainWindow ); ui.scanToMainWindow->setChecked( p.scanToMainWindow );
ui.scanPopupUnpinnedWindowFlags->setCurrentIndex( p.scanPopupUnpinnedWindowFlags ); ui.scanPopupUnpinnedWindowFlags->setCurrentIndex( p.scanPopupUnpinnedWindowFlags );
@ -238,22 +201,6 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
// Different platforms have different keys available // Different platforms have different keys available
#ifdef Q_OS_WIN32
ui.winKey->hide();
#else
ui.leftAlt->hide();
ui.rightAlt->hide();
ui.leftCtrl->hide();
ui.rightCtrl->hide();
ui.leftShift->hide();
ui.rightShift->hide();
#ifdef Q_OS_MAC
ui.altKey->setText( "Opt" );
ui.winKey->setText( "Ctrl" );
ui.ctrlKey->setText( "Cmd" );
#endif
#endif
//Platform-specific options //Platform-specific options
#ifndef ENABLE_SPWF_CUSTOMIZATION #ifndef ENABLE_SPWF_CUSTOMIZATION
@ -415,21 +362,7 @@ Config::Preferences Preferences::getPreferences()
p.enableScanPopup = ui.enableScanPopup->isChecked(); p.enableScanPopup = ui.enableScanPopup->isChecked();
p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked(); p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked();
p.enableScanPopupModifiers = ui.enableScanPopupModifiers->isChecked();
p.scanPopupModifiers += ui.altKey->isChecked() ? KeyboardState::Alt : 0;
p.scanPopupModifiers += ui.ctrlKey->isChecked() ? KeyboardState::Ctrl: 0;
p.scanPopupModifiers += ui.shiftKey->isChecked() ? KeyboardState::Shift: 0;
p.scanPopupModifiers += ui.winKey->isChecked() ? KeyboardState::Win: 0;
p.scanPopupModifiers += ui.leftAlt->isChecked() ? KeyboardState::LeftAlt: 0;
p.scanPopupModifiers += ui.rightAlt->isChecked() ? KeyboardState::RightAlt: 0;
p.scanPopupModifiers += ui.leftCtrl->isChecked() ? KeyboardState::LeftCtrl: 0;
p.scanPopupModifiers += ui.rightCtrl->isChecked() ? KeyboardState::RightCtrl: 0;
p.scanPopupModifiers += ui.leftShift->isChecked() ? KeyboardState::LeftShift: 0;
p.scanPopupModifiers += ui.rightShift->isChecked() ? KeyboardState::RightShift: 0;
p.scanPopupAltMode = ui.scanPopupAltMode->isChecked();
p.scanPopupAltModeSecs = ui.scanPopupAltModeSecs->value();
p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked(); p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked();
p.scanToMainWindow = ui.scanToMainWindow->isChecked(); p.scanToMainWindow = ui.scanToMainWindow->isChecked();
#ifdef HAVE_X11 #ifdef HAVE_X11
@ -582,7 +515,7 @@ Config::Preferences Preferences::getPreferences()
void Preferences::enableScanPopupToggled( bool b ) void Preferences::enableScanPopupToggled( bool b )
{ {
ui.scanPopupModifiers->setEnabled( b && ui.enableScanPopupModifiers->isChecked() ); ui.scanPopupModifiers->setEnabled( b );
} }
void Preferences::enableScanPopupModifiersToggled( bool b ) void Preferences::enableScanPopupModifiersToggled( bool b )
@ -592,62 +525,11 @@ void Preferences::enableScanPopupModifiersToggled( bool b )
ui.showScanFlag->setChecked( false ); ui.showScanFlag->setChecked( false );
} }
void Preferences::showScanFlagToggled( bool b )
{
if( b )
ui.enableScanPopupModifiers->setChecked( false );
}
void Preferences::on_scanPopupUnpinnedWindowFlags_currentIndexChanged( int index ) void Preferences::on_scanPopupUnpinnedWindowFlags_currentIndexChanged( int index )
{ {
ui.scanPopupUnpinnedBypassWMHint->setEnabled( Config::spwfFromInt( index ) != Config::SPWF_default ); ui.scanPopupUnpinnedBypassWMHint->setEnabled( Config::spwfFromInt( index ) != Config::SPWF_default );
} }
void Preferences::wholeAltClicked( bool b )
{
if ( b )
{
ui.leftAlt->setChecked( false );
ui.rightAlt->setChecked( false );
}
}
void Preferences::wholeCtrlClicked( bool b )
{
if ( b )
{
ui.leftCtrl->setChecked( false );
ui.rightCtrl->setChecked( false );
}
}
void Preferences::wholeShiftClicked( bool b )
{
if ( b )
{
ui.leftShift->setChecked( false );
ui.rightShift->setChecked( false );
}
}
void Preferences::sideAltClicked( bool )
{
if ( ui.leftAlt->isChecked() || ui.rightAlt->isChecked() )
ui.altKey->setChecked( false );
}
void Preferences::sideCtrlClicked( bool )
{
if ( ui.leftCtrl->isChecked() || ui.rightCtrl->isChecked() )
ui.ctrlKey->setChecked( false );
}
void Preferences::sideShiftClicked( bool )
{
if ( ui.leftShift->isChecked() || ui.rightShift->isChecked() )
ui.shiftKey->setChecked( false );
}
void Preferences::on_enableMainWindowHotkey_toggled( bool checked ) void Preferences::on_enableMainWindowHotkey_toggled( bool checked )
{ {
ui.mainWindowHotkey->setEnabled( checked ); ui.mainWindowHotkey->setEnabled( checked );

View file

@ -35,17 +35,8 @@ private slots:
void enableScanPopupToggled( bool ); void enableScanPopupToggled( bool );
void enableScanPopupModifiersToggled( bool ); void enableScanPopupModifiersToggled( bool );
void showScanFlagToggled( bool b );
void on_scanPopupUnpinnedWindowFlags_currentIndexChanged( int index ); void on_scanPopupUnpinnedWindowFlags_currentIndexChanged( int index );
void wholeAltClicked( bool );
void wholeCtrlClicked( bool );
void wholeShiftClicked( bool );
void sideAltClicked( bool );
void sideCtrlClicked( bool );
void sideShiftClicked( bool );
void on_enableMainWindowHotkey_toggled( bool checked ); void on_enableMainWindowHotkey_toggled( bool checked );
void on_enableClipboardHotkey_toggled( bool checked ); void on_enableClipboardHotkey_toggled( bool checked );

View file

@ -452,17 +452,6 @@ the program would always start with the scan popup active.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="enableScanPopupModifiers">
<property name="toolTip">
<string>With this enabled, the popup would only show up if all chosen keys are
in the pressed state when the word selection changes.</string>
</property>
<property name="text">
<string>Only show popup when all selected keys are kept pressed:</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QFrame" name="scanPopupModifiers"> <widget class="QFrame" name="scanPopupModifiers">
<property name="frameShape"> <property name="frameShape">
@ -487,218 +476,9 @@ in the pressed state when the word selection changes.</string>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QCheckBox" name="leftCtrl">
<property name="toolTip">
<string>Left Ctrl only</string>
</property>
<property name="text">
<string>Left Ctrl</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="rightShift">
<property name="toolTip">
<string>Right Shift only</string>
</property>
<property name="text">
<string>Right Shift</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="altKey">
<property name="toolTip">
<string>Alt key</string>
</property>
<property name="text">
<string>Alt</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="ctrlKey">
<property name="toolTip">
<string>Ctrl key</string>
</property>
<property name="text">
<string>Ctrl</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="leftAlt">
<property name="toolTip">
<string>Left Alt only</string>
</property>
<property name="text">
<string>Left Alt</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="shiftKey">
<property name="toolTip">
<string>Shift key</string>
</property>
<property name="text">
<string>Shift</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="rightAlt">
<property name="toolTip">
<string>Right Alt only</string>
</property>
<property name="text">
<string>Right Alt</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="rightCtrl">
<property name="toolTip">
<string>Right Ctrl only</string>
</property>
<property name="text">
<string>Right Ctrl</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="leftShift">
<property name="toolTip">
<string>Left Shift only</string>
</property>
<property name="text">
<string>Left Shift</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="winKey">
<property name="toolTip">
<string>Windows key or Meta key</string>
</property>
<property name="text">
<string>Win/Meta</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="scanPopupAltMode">
<property name="toolTip">
<string>Normally, in order to activate a popup you have to
maintain the chosen keys pressed while you select
a word. With this enabled, the chosen keys may also
be pressed shortly after the selection is done.</string>
</property>
<property name="text">
<string>Keys may also be pressed afterwards, within</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="scanPopupAltModeSecs">
<property name="toolTip">
<string>To avoid false positives, the keys are only monitored
after the selection's done for a limited amount of
seconds, which is specified here.</string>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>secs</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="showScanFlag"> <widget class="QCheckBox" name="showScanFlag">
<property name="toolTip"> <property name="toolTip">
@ -1911,19 +1691,6 @@ from Stardict, Babylon and GLS dictionaries</string>
<tabstop>cbAutostart</tabstop> <tabstop>cbAutostart</tabstop>
<tabstop>interfaceLanguage</tabstop> <tabstop>interfaceLanguage</tabstop>
<tabstop>startWithScanPopupOn</tabstop> <tabstop>startWithScanPopupOn</tabstop>
<tabstop>enableScanPopupModifiers</tabstop>
<tabstop>leftCtrl</tabstop>
<tabstop>rightShift</tabstop>
<tabstop>altKey</tabstop>
<tabstop>ctrlKey</tabstop>
<tabstop>leftAlt</tabstop>
<tabstop>shiftKey</tabstop>
<tabstop>rightAlt</tabstop>
<tabstop>rightCtrl</tabstop>
<tabstop>leftShift</tabstop>
<tabstop>winKey</tabstop>
<tabstop>scanPopupAltMode</tabstop>
<tabstop>scanPopupAltModeSecs</tabstop>
<tabstop>useProxyServer</tabstop> <tabstop>useProxyServer</tabstop>
<tabstop>proxyType</tabstop> <tabstop>proxyType</tabstop>
<tabstop>proxyHost</tabstop> <tabstop>proxyHost</tabstop>

View file

@ -1,7 +1,7 @@
MainWindow #translateLine, ScanPopup #translateLine, MainWindow #searchPane #wordList, MainWindow #dictsPane #dictsList, MainWindow #translateLine, ScanPopup #translateLine, MainWindow #searchPane #wordList, MainWindow #dictsPane #dictsList,
MainWindow #historyPane #historyList, MainWindow #favoritesPane #favoritesTree MainWindow #historyPane #historyList, MainWindow #favoritesPane #favoritesTree
{ {
background: white;
} }
MainWindow #searchPane #translateLine MainWindow #searchPane #translateLine

View file

@ -1,7 +1,7 @@
MainWindow #translateLine, ScanPopup #translateLine, MainWindow #wordList, MainWindow #dictsPane #dictsList, MainWindow #translateLine, ScanPopup #translateLine, MainWindow #wordList, MainWindow #dictsPane #dictsList,
MainWindow #historyPane #historyList, MainWindow #favoritesPane #favoritesTree MainWindow #historyPane #historyList, MainWindow #favoritesPane #favoritesTree
{ {
background: white;
} }
/* WARNING: hides all separators! */ /* WARNING: hides all separators! */

View file

@ -3,8 +3,7 @@ MainWindow #translateLine, ScanPopup #translateLine, MainWindow #wordList, MainW
} }
MainWindow #translateLine[noResults="true"], MainWindow #translateLine[noResults="true"],
ScanPopup #translateLine[noResults="true"] ScanPopup #translateLine[noResults="true"] {
{
background: #febb7d; background: #febb7d;
} }

View file

@ -57,9 +57,6 @@
<file>icons/icon32_gls.png</file> <file>icons/icon32_gls.png</file>
<file>icons/folder.png</file> <file>icons/folder.png</file>
<file>icons/ontop.svg</file> <file>icons/ontop.svg</file>
<file>resources/jquery-3.6.0.slim.min.js</file>
<file>resources/gd-custom.js</file>
<file>resources/gd-builtin.js</file>
<file>icons/addtab.svg</file> <file>icons/addtab.svg</file>
<file>icons/book.svg</file> <file>icons/book.svg</file>
<file>icons/bookcase.svg</file> <file>icons/bookcase.svg</file>

View file

@ -114,6 +114,8 @@ ScanPopup::ScanPopup( QWidget * parent,
definition, SLOT( receiveExpandOptionalParts( bool ) ) ); definition, SLOT( receiveExpandOptionalParts( bool ) ) );
connect( definition, SIGNAL( setExpandMode( bool ) ), connect( definition, SIGNAL( setExpandMode( bool ) ),
this, SIGNAL( setExpandMode( bool ) ) ); this, SIGNAL( setExpandMode( bool ) ) );
connect( definition, SIGNAL( inspectSignal( QWebEnginePage* ) ),
this, SLOT( inspectElementWhenPinned( QWebEnginePage* ) ) );
connect( definition, SIGNAL( forceAddWordToHistory( QString ) ), connect( definition, SIGNAL( forceAddWordToHistory( QString ) ),
this, SIGNAL( forceAddWordToHistory( QString ) ) ); this, SIGNAL( forceAddWordToHistory( QString ) ) );
connect( this, SIGNAL( closeMenu() ), connect( this, SIGNAL( closeMenu() ),
@ -369,6 +371,11 @@ void ScanPopup::disableScanning()
} }
} }
void ScanPopup::inspectElementWhenPinned( QWebEnginePage * page ){
if(cfg.pinPopupWindow)
emit inspectSignal(page);
}
void ScanPopup::applyZoomFactor() void ScanPopup::applyZoomFactor()
{ {
definition->setZoomFactor( cfg.preferences.zoomFactor ); definition->setZoomFactor( cfg.preferences.zoomFactor );
@ -514,6 +521,8 @@ void ScanPopup::delayShow()
void ScanPopup::clipboardChanged( QClipboard::Mode m ) void ScanPopup::clipboardChanged( QClipboard::Mode m )
{ {
if( !cfg.preferences.trackClipboardChanges )
return;
if( !isScanningEnabled ) if( !isScanningEnabled )
return; return;
@ -1085,6 +1094,7 @@ void ScanPopup::pinButtonClicked( bool checked )
mouseEnteredOnce = true; mouseEnteredOnce = true;
} }
cfg.pinPopupWindow = checked;
show(); show();
} }

View file

@ -63,6 +63,7 @@ signals:
void closeMenu(); void closeMenu();
/// Signals to set expand optional parts mode (retranslation from/to MainWindow and dictionary bar) /// Signals to set expand optional parts mode (retranslation from/to MainWindow and dictionary bar)
void setExpandMode( bool expand ); void setExpandMode( bool expand );
void inspectSignal(QWebEnginePage * page);
void setViewExpandMode( bool expand ); void setViewExpandMode( bool expand );
/// Signal to switch expand optional parts mode /// Signal to switch expand optional parts mode
void switchExpandMode(); void switchExpandMode();
@ -92,6 +93,7 @@ signals:
public slots: public slots:
void requestWindowFocus(); void requestWindowFocus();
void inspectElementWhenPinned( QWebEnginePage * page );
/// Translates the word from the clipboard, showing the window etc. /// Translates the word from the clipboard, showing the window etc.
void translateWordFromClipboard(); void translateWordFromClipboard();
/// Translates the word from the clipboard selection /// Translates the word from the clipboard selection

10
scripts.qrc Normal file
View file

@ -0,0 +1,10 @@
<RCC>
<qresource prefix="/">
<file>scripts/iframeResizer.contentWindow.min.js</file>
<file>scripts/iframeResizer.min.js</file>
<file>scripts/gd-builtin.js</file>
<file>scripts/gd-custom.js</file>
<file>scripts/jquery-3.6.0.slim.min.js</file>
<file>scripts/iframe-defer.js</file>
</qresource>
</RCC>

View file

@ -49,23 +49,7 @@
}); });
//monitor iframe height. //monitor iframe height.
$('iframe').iFrameResize({ checkOrigin:false,maxHeight :800,scrolling:true,warningTimeout:0,minHeight :250,log:true,autoResize:false});
$("iframe").on("load", function () {
var iframe = $(this);
resizeIframe(iframe[0]);
});
function resizeIframe(obj) {
setInterval(function () {
//in some cases ,the website in iframe will load result after document has been loaded. the height will continue to change.
var height = $(obj).contents().height();
$(obj).height(Math.min(2000, height));
if (height >= 2000) {
obj.scrolling = "yes";
}
}, 500);
}
}); });
})($_$); })($_$);

20
scripts/iframe-defer.js Normal file
View file

@ -0,0 +1,20 @@
var start_time=new Date().getTime();
var interval = setInterval(function () {
var end_time=new Date().getTime();
//for 10 seconds.
if(end_time-start_time>=10000){
clearInterval(interval);
}
const body = document.body;
const html = document.documentElement;
const height = Math.max(body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight);
if ('parentIFrame' in window) {
console.log("iframe set height to " + height);
parentIFrame.size(height);
}
}, 500);

File diff suppressed because one or more lines are too long

9
scripts/iframeResizer.min.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -94,9 +94,23 @@ inline bool isExternalLink(QUrl const &url) {
inline bool isHtmlResources(QUrl const &url) { inline bool isHtmlResources(QUrl const &url) {
auto fileName = url.fileName(); auto fileName = url.fileName();
auto ext=fileName.mid(fileName.lastIndexOf(".")); qsizetype index = fileName.lastIndexOf( "." );
QStringList extensions{".css",".woff",".woff2","ttf",".bmp" ,".jpg", ".png",".gif", ".tif",".wav", ".ogg", ".oga", ".mp3", ".mp4", ".aac", ".flac",".mid", ".wv",".ape"} ; QStringList extensions{ ".css", ".woff", ".woff2", ".ttf", ".otf", ".bmp", ".jpg", ".png", ".gif", ".tif",
return extensions.contains( ext, Qt::CaseInsensitive ); ".wav", ".ogg", ".oga", ".mp3", ".mp4", ".aac", ".flac", ".mid", ".wv", ".ape" };
if( index > -1 )
{
auto ext = fileName.mid( index );
if( extensions.contains( ext, Qt::CaseInsensitive ) )
return true;
}
// some url has the form like https://xxxx/audio?file=***.mp3&a=1 etc links.
for( QString extension : extensions )
{
if( url.url().contains( extension, Qt::CaseInsensitive ) )
return true;
}
return false;
} }
inline QString escape( QString const & plain ) inline QString escape( QString const & plain )

View file

@ -399,9 +399,8 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
"\" src=\""+encodeUrl.toStdString() + "\" src=\""+encodeUrl.toStdString() +
"\" onmouseover=\"processIframeMouseOver('gdexpandframe-" + getId() + "');\" " "\" onmouseover=\"processIframeMouseOver('gdexpandframe-" + getId() + "');\" "
"onmouseout=\"processIframeMouseOut();\" " "onmouseout=\"processIframeMouseOut();\" "
"scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" " "scrolling=\"no\" "
"frameborder=\"0\" vspace=\"0\" hspace=\"0\"" "style=\"overflow:visible; width:100%; display:block; border:none;\" sandbox=\"allow-same-origin allow-scripts allow-popups\">"
"style=\"overflow:visible; width:100%; display:block;\" sandbox=\"allow-same-origin allow-scripts allow-popups\">"
"</iframe>"; "</iframe>";
dr->getData().resize( result.size() ); dr->getData().resize( result.size() );
@ -538,7 +537,7 @@ void WebSiteDictionary::loadIcon() noexcept
if( fInfo.isFile() ) if( fInfo.isFile() )
loadIconFromFile( fInfo.absoluteFilePath(), true ); loadIconFromFile( fInfo.absoluteFilePath(), true );
} }
if( dictionaryIcon.isNull() ) if( dictionaryIcon.isNull() && !loadIconFromText(":/icons/webdict.svg", QString::fromStdString(name ) ) )
dictionaryIcon = dictionaryNativeIcon = QIcon(":/icons/webdict.svg"); dictionaryIcon = dictionaryNativeIcon = QIcon(":/icons/webdict.svg");
dictionaryIconLoaded = true; dictionaryIconLoaded = true;
} }

View file

@ -21,7 +21,12 @@ void WebUrlRequestInterceptor::interceptRequest( QWebEngineUrlRequestInfo &info)
//whitelist url does not block //whitelist url does not block
return; return;
} }
if(Utils::isHtmlResources(info.requestUrl())){ if( info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeImage
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeFontResource
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeStylesheet
|| info.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMedia
|| Utils::isHtmlResources( info.requestUrl() ) )
{
//let throuth the resources file. //let throuth the resources file.
return; return;
} }

View file

@ -51,14 +51,12 @@ void WordList::updateMatchResults( bool finished )
WordFinder::SearchResults const & results = wordFinder->getResults(); WordFinder::SearchResults const & results = wordFinder->getResults();
setUpdatesEnabled( false ); setUpdatesEnabled( false );
//clear all existed items
clear();
for( unsigned x = 0; x < results.size(); ++x ) for( unsigned x = 0; x < results.size(); ++x )
{ {
QListWidgetItem * i = item( x ); QListWidgetItem * i = new QListWidgetItem( results[ x ].first, this );
if ( !i )
{
i = new QListWidgetItem( results[ x ].first, this );
i->setToolTip( results[ x ].first ); i->setToolTip( results[ x ].first );
if( results[ x ].second ) if( results[ x ].second )
@ -67,38 +65,10 @@ void WordList::updateMatchResults( bool finished )
f.setItalic( true ); f.setItalic( true );
i->setFont( f ); i->setFont( f );
} }
addItem( i );
}
else
{
if ( i->text() != results[ x ].first )
{
i->setText( results[ x ].first );
i->setToolTip( results[ x ].first );
}
QFont f = i->font();
if ( f.italic() != results[ x ].second )
{
f.setItalic( results[ x ].second );
i->setFont( f );
}
}
i->setTextAlignment( Qt::AlignLeft ); i->setTextAlignment( Qt::AlignLeft );
} }
while ( count() > (int) results.size() )
{
// Chop off any extra items that were there
QListWidgetItem * i = takeItem( count() - 1 );
if ( i )
delete i;
else
break;
}
if ( count() ) if ( count() )
{ {
scrollToItem( item( 0 ), QAbstractItemView::PositionAtTop ); scrollToItem( item( 0 ), QAbstractItemView::PositionAtTop );
@ -141,20 +111,3 @@ void WordList::refreshTranslateLine()
} }
} }
void WordList::resizeEvent( QResizeEvent * ev )
{
// In some rare cases Qt start send QResizeEvent recursively
// up to full stack depletion (tested on Qt 4.8.5, 4.8.6).
// We use this trick to break such suicidal process.
for( int x = 0; x < resizedSizes.size(); x++ )
if( resizedSizes.at( x ) == ev->size() )
return;
resizedSizes.push_back( ev->size() );
QListWidget::resizeEvent( ev );
resizedSizes.pop_back();
}

View file

@ -20,7 +20,6 @@ public:
{ translateLine = line; } { translateLine = line; }
protected: protected:
virtual void resizeEvent( QResizeEvent * ev );
signals: signals:
void statusBarMessage(QString const & message, int timeout = 0, QPixmap const & pixmap = QPixmap()); void statusBarMessage(QString const & message, int timeout = 0, QPixmap const & pixmap = QPixmap());