From 9700969a0429aba9b209a9f70d7a2a1d8c98e096 Mon Sep 17 00:00:00 2001 From: yifang Date: Thu, 20 Jan 2022 21:59:47 +0800 Subject: [PATCH 1/7] imp. : "select current article" ,if not in the view.scroll into view. --- articleview.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/articleview.cc b/articleview.cc index 5208e034..8cca33c8 100644 --- a/articleview.cc +++ b/articleview.cc @@ -663,12 +663,8 @@ void ArticleView::setActiveArticleId(QString const & dictId){ QString ArticleView::getCurrentArticle() { - QVariant v=ui.definition->property("currentArticle"); - - if ( v.type() == QVariant::String ) - return v.toString(); - else - return QString(); + QString dictId=getActiveArticleId(); + return scrollToFromDictionaryId( dictId ); } void ArticleView::jumpToDictionary( QString const & id, bool force ) @@ -702,7 +698,7 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt ) void ArticleView::selectCurrentArticle() { ui.definition->page()->runJavaScript( - QString( "gdSelectArticle( '%1' );" ).arg( getActiveArticleId() ) ); + QString( "gdSelectArticle( '%1' );var elem=document.getElementById('%2'); if(elem!=undefined){elem.scrollIntoView(true);}" ).arg( getActiveArticleId() ,getCurrentArticle()) ); } bool ArticleView::isFramedArticle( QString const & ca ) From be24e04c176702307808207f8283628fb766967e Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Fri, 21 Jan 2022 09:30:49 +0800 Subject: [PATCH 2/7] fix: body and banner overlap --- article-style.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/article-style.css b/article-style.css index 4f9dff06..a2c51c65 100644 --- a/article-style.css +++ b/article-style.css @@ -75,6 +75,12 @@ pre clear: both; } +.gddictnamebodyseparator +{ + display: inline-block; + clear: both; +} + /* Dictionary query error description string */ .gderrordesc { From b127144b184614103562d7d0a750257d9dac19df Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Fri, 21 Jan 2022 09:35:45 +0800 Subject: [PATCH 3/7] fix: remove width 100% style revert to previous version,seems in some cases will affect visual display. --- article-style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/article-style.css b/article-style.css index a2c51c65..4fb8ff5f 100644 --- a/article-style.css +++ b/article-style.css @@ -70,7 +70,6 @@ pre /* Appears between the articles */ .gdarticleseparator { - width: 100%; display: inline-block; clear: both; } From f0d0a56ecc0cb9f88f16e9ef6c83d23e56baec8b Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 21 Jan 2022 16:16:22 +0800 Subject: [PATCH 4/7] clean code:remove qmake CONFIG 'old_hunspell' that means libhunspell > 1.5 from now on. --- README.md | 2 +- goldendict.pro | 4 --- hunspell.cc | 67 -------------------------------------------------- 3 files changed, 1 insertion(+), 72 deletions(-) diff --git a/README.md b/README.md index e2c92dbd..214b4081 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ make sure that `qmake` is from Qt 5 installation. If not, you can try finding it at a path like `/usr/lib/x86_64-linux-gnu/qt5/bin/qmake`. Alternatively, you might want to load `goldendict.pro` file from within Qt Creator, especially on Windows. -Note: To compile with `libhunspell` older than 1.5 pass `"CONFIG+=old_hunspell"` to `qmake`. +Note: `libhunspell` version > 1.5. ### Building with Chinese conversion support diff --git a/goldendict.pro b/goldendict.pro index 756cde39..ce65de81 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -578,10 +578,6 @@ CONFIG( chinese_conversion_support ) { } } -CONFIG( old_hunspell ) { - DEFINES += OLD_HUNSPELL_INTERFACE -} - RESOURCES += resources.qrc \ flags.qrc TRANSLATIONS += locale/ru_RU.ts \ diff --git a/hunspell.cc b/hunspell.cc index ef5c9d3c..51542610 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -245,13 +245,7 @@ void HunspellArticleRequest::run() return; } -#ifdef OLD_HUNSPELL_INTERFACE - // We'd need to free this if it gets allocated and an exception shows up - char ** suggestions = 0; - int suggestionsCount = 0; -#else vector< string > suggestions; -#endif try { @@ -268,24 +262,15 @@ void HunspellArticleRequest::run() string encodedWord = encodeToHunspell( hunspell, trimmedWord ); -#ifdef OLD_HUNSPELL_INTERFACE - if ( hunspell.spell( encodedWord.c_str() ) ) -#else if ( hunspell.spell( encodedWord ) ) -#endif { // Good word -- no spelling suggestions then. finish(); return; } -#ifdef OLD_HUNSPELL_INTERFACE - suggestionsCount = hunspell.suggest( &suggestions, encodedWord.c_str() ); - if ( suggestionsCount ) -#else suggestions = hunspell.suggest( encodedWord ); if ( !suggestions.empty() ) -#endif { // There were some suggestions made for us. Make an appropriate output. @@ -294,15 +279,9 @@ void HunspellArticleRequest::run() wstring lowercasedWord = Folding::applySimpleCaseOnly( word ); -#ifdef OLD_HUNSPELL_INTERFACE - for( int x = 0; x < suggestionsCount; ++x ) - { - wstring suggestion = decodeFromHunspell( hunspell, suggestions[ x ] ); -#else for( vector< string >::size_type x = 0; x < suggestions.size(); ++x ) { wstring suggestion = decodeFromHunspell( hunspell, suggestions[ x ].c_str() ); -#endif if ( Folding::applySimpleCaseOnly( suggestion ) == lowercasedWord ) { @@ -312,9 +291,6 @@ void HunspellArticleRequest::run() finish(); -#ifdef OLD_HUNSPELL_INTERFACE - hunspell.free_list( &suggestions, suggestionsCount ); -#endif return; } string suggestionUtf8 = Utf8::encode( suggestion ); @@ -323,11 +299,7 @@ void HunspellArticleRequest::run() result += Html::escape( suggestionUtf8 ) + "\">"; result += Html::escape( suggestionUtf8 ) + ""; -#ifdef OLD_HUNSPELL_INTERFACE - if ( x != suggestionsCount - 1 ) -#else if ( x != suggestions.size() - 1 ) -#endif result += ", "; } @@ -351,15 +323,6 @@ void HunspellArticleRequest::run() gdWarning( "Hunspell: error: %s\n", e.what() ); } -#ifdef OLD_HUNSPELL_INTERFACE - if ( suggestions ) - { - Mutex::Lock _( hunspellMutex ); - - hunspell.free_list( &suggestions, suggestionsCount ); - } -#endif - finish(); } @@ -487,13 +450,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu { QVector< wstring > result; -#ifdef OLD_HUNSPELL_INTERFACE - // We'd need to free this if it gets allocated and an exception shows up - char ** suggestions = 0; - int suggestionsCount = 0; -#else vector< string > suggestions; -#endif try { @@ -501,13 +458,8 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu string encodedWord = encodeToHunspell( hunspell, word ); -#ifdef OLD_HUNSPELL_INTERFACE - suggestionsCount = hunspell.analyze( &suggestions, encodedWord.c_str() ); - if ( suggestionsCount ) -#else suggestions = hunspell.analyze( encodedWord ); if ( !suggestions.empty() ) -#endif { // There were some suggestions made for us. Make an appropriate output. @@ -515,15 +467,9 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu static QRegExp cutStem( "^\\s*st:(((\\s+(?!\\w{2}:)(?!-)(?!\\+))|\\S+)+)" ); -#ifdef OLD_HUNSPELL_INTERFACE - for( int x = 0; x < suggestionsCount; ++x ) - { - QString suggestion = gd::toQString( decodeFromHunspell( hunspell, suggestions[ x ] ) ); -#else for( vector< string >::size_type x = 0; x < suggestions.size(); ++x ) { QString suggestion = gd::toQString( decodeFromHunspell( hunspell, suggestions[ x ].c_str() ) ); -#endif // Strip comments int n = suggestion.indexOf( '#' ); @@ -552,15 +498,6 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu gdWarning( "Hunspell: charset conversion error, no processing's done: %s\n", e.what() ); } -#ifdef OLD_HUNSPELL_INTERFACE - if ( suggestions ) - { - Mutex::Lock _( hunspellMutex ); - - hunspell.free_list( &suggestions, suggestionsCount ); - } -#endif - return result; } @@ -662,11 +599,7 @@ void HunspellPrefixMatchRequest::run() string encodedWord = encodeToHunspell( hunspell, trimmedWord ); -#ifdef OLD_HUNSPELL_INTERFACE - if ( hunspell.spell( encodedWord.c_str() ) ) -#else if ( hunspell.spell( encodedWord ) ) -#endif { // Known word -- add it to the result From e779292e2bf68eafe5ed1ed896638d51f596940e Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 21 Jan 2022 16:25:55 +0800 Subject: [PATCH 5/7] modify README.md to update the qt version. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 214b4081..1fc06bd9 100644 --- a/README.md +++ b/README.md @@ -104,9 +104,8 @@ To build GoldenDict with Visual Studio take one of next library packs and unpack [GoldenDict_libs_VS2015_x86_v4.7z](http://www.mediafire.com/file/0a7ygy9rn99oevm/GoldenDict_libs_VS2015_x86_v4.7z) - for MS Visual Studio 2015, 32 bit [GoldenDict_libs_VS2015_x64_v4.7z](http://www.mediafire.com/file/yoy2q8af0s1467m/GoldenDict_libs_VS2015_x64_v4.7z) - for MS Visual Studio 2015, 64 bit -To create project files for Visual Studio you can pass `"-tp vc"` option to `qmake`. - -Note: In Qt 5.6.0 and later the `Webkit` module was removed from official release builds. You should to build it from sources to compile GoldenDict. +To build with Visual Studio. +check this [how to build with visual studio](howto/how to build and debug with VS2019.md) ## Installation From 2e5faeb136e731513208990b43cd1bf004138138 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Fri, 21 Jan 2022 16:57:09 +0800 Subject: [PATCH 6/7] update readme.md link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1fc06bd9..e564df9f 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ To build GoldenDict with Visual Studio take one of next library packs and unpack [GoldenDict_libs_VS2015_x64_v4.7z](http://www.mediafire.com/file/yoy2q8af0s1467m/GoldenDict_libs_VS2015_x64_v4.7z) - for MS Visual Studio 2015, 64 bit To build with Visual Studio. -check this [how to build with visual studio](howto/how to build and debug with VS2019.md) +check this [how to build with visual studio](howto/how%20to%20build%20and%20debug%20with%20VS2019.md) ## Installation From c7de72a98271108b77b92381b8b8d20b587c91f0 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 21 Jan 2022 22:32:47 +0800 Subject: [PATCH 7/7] imp. : remove unnecessary qtsingleapplication files ,make it simpler. --- qtsingleapplication/buildlib/buildlib.pro | 13 --- qtsingleapplication/common.pri | 6 -- qtsingleapplication/config.pri | 1 - qtsingleapplication/configure | 25 ------ qtsingleapplication/configure.bat | 79 ------------------- .../src/qtsingleapplication.pri | 18 +---- 6 files changed, 4 insertions(+), 138 deletions(-) delete mode 100644 qtsingleapplication/buildlib/buildlib.pro delete mode 100644 qtsingleapplication/common.pri delete mode 100644 qtsingleapplication/config.pri delete mode 100755 qtsingleapplication/configure delete mode 100644 qtsingleapplication/configure.bat diff --git a/qtsingleapplication/buildlib/buildlib.pro b/qtsingleapplication/buildlib/buildlib.pro deleted file mode 100644 index 37dddcda..00000000 --- a/qtsingleapplication/buildlib/buildlib.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE=lib -CONFIG += qt dll qtsingleapplication-buildlib -mac:CONFIG += absolute_library_soname -win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all -include(../src/qtsingleapplication.pri) -TARGET = $$QTSINGLEAPPLICATION_LIBNAME -DESTDIR = $$QTSINGLEAPPLICATION_LIBDIR -win32 { - DLLDESTDIR = $$[QT_INSTALL_BINS] - QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${QTSINGLEAPPLICATION_LIBNAME}.dll -} -target.path = $$DESTDIR -INSTALLS += target diff --git a/qtsingleapplication/common.pri b/qtsingleapplication/common.pri deleted file mode 100644 index bae27173..00000000 --- a/qtsingleapplication/common.pri +++ /dev/null @@ -1,6 +0,0 @@ -exists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib -TEMPLATE += fakelib -QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head) -TEMPLATE -= fakelib -QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib -unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR diff --git a/qtsingleapplication/config.pri b/qtsingleapplication/config.pri deleted file mode 100644 index b62531c5..00000000 --- a/qtsingleapplication/config.pri +++ /dev/null @@ -1 +0,0 @@ -SOLUTIONS_LIBRARY = yes diff --git a/qtsingleapplication/configure b/qtsingleapplication/configure deleted file mode 100755 index 3c4edfff..00000000 --- a/qtsingleapplication/configure +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -if [ "x$1" != "x" -a "x$1" != "x-library" ]; then - echo "Usage: $0 [-library]" - echo - echo "-library: Build the component as a dynamic library (DLL). Default is to" - echo " include the component source code directly in the application." - echo - exit 0 -fi - -rm -f config.pri -if [ "x$1" = "x-library" ]; then - echo "Configuring to build this component as a dynamic library." - echo "SOLUTIONS_LIBRARY = yes" > config.pri -fi - -echo -echo "This component is now configured." -echo -echo "To build the component library (if requested) and example(s)," -echo "run qmake and your make command." -echo -echo "To remove or reconfigure, run make distclean." -echo diff --git a/qtsingleapplication/configure.bat b/qtsingleapplication/configure.bat deleted file mode 100644 index 339d3cf0..00000000 --- a/qtsingleapplication/configure.bat +++ /dev/null @@ -1,79 +0,0 @@ -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: -:: Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -:: Contact: http://www.qt-project.org/legal -:: -:: This file is part of the Qt Solutions component. -:: -:: $QT_BEGIN_LICENSE:BSD$ -:: You may use this file under the terms of the BSD license as follows: -:: -:: "Redistribution and use in source and binary forms, with or without -:: modification, are permitted provided that the following conditions are -:: met: -:: * Redistributions of source code must retain the above copyright -:: notice, this list of conditions and the following disclaimer. -:: * Redistributions in binary form must reproduce the above copyright -:: notice, this list of conditions and the following disclaimer in -:: the documentation and/or other materials provided with the -:: distribution. -:: * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names -:: of its contributors may be used to endorse or promote products derived -:: from this software without specific prior written permission. -:: -:: -:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -:: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -:: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -:: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -:: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -:: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -:: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -:: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -:: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -:: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -:: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -:: -:: $QT_END_LICENSE$ -:: -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -@echo off - -rem -rem "Main" -rem - -if not "%1"=="" ( - if not "%1"=="-library" ( - call :PrintUsage - goto EOF - ) -) - -if exist config.pri. del config.pri -if "%1"=="-library" ( - echo Configuring to build this component as a dynamic library. - echo SOLUTIONS_LIBRARY = yes > config.pri -) - -echo . -echo This component is now configured. -echo . -echo To build the component library (if requested) and example(s), -echo run qmake and your make or nmake command. -echo . -echo To remove or reconfigure, run make (nmake) distclean. -echo . - -:PrintUsage -echo Usage: configure.bat [-library] -echo . -echo -library: Build the component as a dynamic library (DLL). Default is to -echo include the component source directly in the application. -echo A DLL may be preferable for technical or licensing (LGPL) reasons. -echo . -goto EOF - - -:EOF diff --git a/qtsingleapplication/src/qtsingleapplication.pri b/qtsingleapplication/src/qtsingleapplication.pri index 6f2bced9..d08a6521 100644 --- a/qtsingleapplication/src/qtsingleapplication.pri +++ b/qtsingleapplication/src/qtsingleapplication.pri @@ -1,17 +1,7 @@ -include(../common.pri) +QT += core network widgets +CONFIG += c++11 INCLUDEPATH += $$PWD DEPENDPATH += $$PWD -QT *= network -greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets -qtsingleapplication-uselib:!qtsingleapplication-buildlib { - LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME -} else { - SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp - HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h -} - -win32 { - contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT - else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT -} +SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp +HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h