From 56000cf3b1105a98f630e8f5ffe495140cebd0ee Mon Sep 17 00:00:00 2001 From: yifang Date: Fri, 18 Feb 2022 01:13:01 +0800 Subject: [PATCH 01/10] optimize: F12 inspect element optimize:inspect element dialog --- articleview.cc | 32 +++++++++++++++++++++++--------- articleview.hh | 3 ++- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/articleview.cc b/articleview.cc index 4b1ac8917..759b39b81 100644 --- a/articleview.cc +++ b/articleview.cc @@ -321,15 +321,8 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au inspectAction.setText( tr( "Inspect" ) ); ui.definition->addAction( &inspectAction ); - QWebEnginePage *page = ui.definition->page(); - connect(&inspectAction, &QAction::triggered, this, [page, this]() { - if (inspectView == nullptr || !inspectView->isVisible()) { - inspectView = new QWebEngineView(); - page->setDevToolsPage(inspectView->page()); - page->triggerAction(QWebEnginePage::InspectElement); - inspectView->show(); - } - }); + + connect(&inspectAction, &QAction::triggered, this, &ArticleView::inspectElement); ui.definition->installEventFilter( this ); ui.searchFrame->installEventFilter( this ); @@ -512,6 +505,27 @@ void ArticleView::showAnticipation() ui.definition->setCursor( Qt::WaitCursor ); } +void ArticleView::inspectElement(){ + QWebEnginePage *page = ui.definition->page(); + if (inspectView == nullptr) { + inspectView = new QWebEngineView(); + page->setDevToolsPage( inspectView->page() ); + devDialog = new QDialog( this ); + devDialog->setWindowTitle( tr( "Inspect" ) ); + devDialog->setWindowFlags( Qt::Window ); + devDialog->setContentsMargins( 0, 0, 0, 0 ); + devDialog->setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false ); + QVBoxLayout * v=new QVBoxLayout( devDialog ); +// devDialog->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); +// inspectView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); +// inspectView->setContentsMargins(0,0,0,0); + v->addWidget( inspectView ); + } + page->triggerAction( QWebEnginePage::InspectElement ); + devDialog->raise(); + devDialog->show(); +} + void ArticleView::loadFinished( bool result ) { setZoomFactor(cfg.preferences.zoomFactor); diff --git a/articleview.hh b/articleview.hh index 521756b81..1fb0c86c8 100644 --- a/articleview.hh +++ b/articleview.hh @@ -46,6 +46,7 @@ class ArticleView: public QFrame //used to hold the F12 inspect source view. QWebEngineView *inspectView = nullptr; + QDialog * devDialog = nullptr; /// Any resource we've decided to download off the dictionary gets stored here. /// Full vector capacity is used for search requests, where we have to make @@ -303,7 +304,7 @@ public slots: //aim to receive signal from html. the fragment url click to navigation through page wil not be intecepted by weburlinteceptor Q_INVOKABLE void linkClickedInHtml( QUrl const & ); private slots: - + void inspectElement(); void loadFinished( bool ok ); void loadProgress(int); void handleTitleChanged( QString const & title ); From 7993d87b6a5c7e0633d18429d42a2272d9ec12d4 Mon Sep 17 00:00:00 2001 From: yifang Date: Fri, 18 Feb 2022 20:45:22 +0800 Subject: [PATCH 02/10] github: remove not work release drafter --- .github/release-drafter.yml | 4 --- .../workflows/release_drafter_workflow.yml | 33 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 .github/release-drafter.yml delete mode 100644 .github/workflows/release_drafter_workflow.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 0a5d792cb..000000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,4 +0,0 @@ -template: | - ## What’s Changed - - $CHANGES \ No newline at end of file diff --git a/.github/workflows/release_drafter_workflow.yml b/.github/workflows/release_drafter_workflow.yml deleted file mode 100644 index ea06ddf2f..000000000 --- a/.github/workflows/release_drafter_workflow.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Release Drafter - -on: - workflow_dispatch: - push: - # branches to consider in the event; optional, defaults to all - branches: - - staged - # pull_request event is required only for autolabeler - pull_request: - # Only following types are handled by the action, but one can default to all as well - # types: [opened, reopened, synchronize] - # pull_request_target event is required for autolabeler to support PRs from forks - # pull_request_target: - # types: [opened, reopened, synchronize] - -jobs: - update_release_draft: - runs-on: ubuntu-latest - steps: - # (Optional) GitHub Enterprise requires GHE_HOST variable set - #- name: Set GHE_HOST - # run: | - # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV - - # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@master - # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml - # with: - # config-name: my-config.yml - # disable-autolabeler: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d835c0ba9c2200212c4fb8f83c17795ffc873041 Mon Sep 17 00:00:00 2001 From: yifang Date: Fri, 18 Feb 2022 20:50:15 +0800 Subject: [PATCH 03/10] optimize:folder structure rearrange --- goldendict.pro | 2 +- .../qtsingleapplication}/INSTALL.TXT | 0 .../qtsingleapplication}/README.TXT | 0 .../qtsingleapplication}/source.txt | 0 .../qtsingleapplication}/src/QtLockedFile | 0 .../qtsingleapplication}/src/QtSingleApplication | 0 .../qtsingleapplication}/src/qtlocalpeer.cpp | 0 .../qtsingleapplication}/src/qtlocalpeer.h | 0 .../qtsingleapplication}/src/qtlockedfile.cpp | 0 .../qtsingleapplication}/src/qtlockedfile.h | 0 .../qtsingleapplication}/src/qtlockedfile_unix.cpp | 0 .../qtsingleapplication}/src/qtlockedfile_win.cpp | 0 .../qtsingleapplication}/src/qtsingleapplication.cpp | 0 .../qtsingleapplication}/src/qtsingleapplication.h | 0 .../qtsingleapplication}/src/qtsingleapplication.pri | 0 .../qtsingleapplication}/src/qtsinglecoreapplication.cpp | 0 .../qtsingleapplication}/src/qtsinglecoreapplication.h | 0 .../qtsingleapplication}/src/qtsinglecoreapplication.pri | 0 18 files changed, 1 insertion(+), 1 deletion(-) rename {qtsingleapplication => thirdparty/qtsingleapplication}/INSTALL.TXT (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/README.TXT (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/source.txt (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/QtLockedFile (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/QtSingleApplication (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtlocalpeer.cpp (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtlocalpeer.h (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtlockedfile.cpp (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtlockedfile.h (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtlockedfile_unix.cpp (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtlockedfile_win.cpp (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtsingleapplication.cpp (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtsingleapplication.h (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtsingleapplication.pri (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtsinglecoreapplication.cpp (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtsinglecoreapplication.h (100%) rename {qtsingleapplication => thirdparty/qtsingleapplication}/src/qtsinglecoreapplication.pri (100%) diff --git a/goldendict.pro b/goldendict.pro index 113eb5209..8ddd8ba4c 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -649,5 +649,5 @@ TS_OUT = $$TRANSLATIONS TS_OUT ~= s/.ts/.qm/g PRE_TARGETDEPS += $$TS_OUT -include( qtsingleapplication/src/qtsingleapplication.pri ) +include( thirdparty/qtsingleapplication/src/qtsingleapplication.pri ) diff --git a/qtsingleapplication/INSTALL.TXT b/thirdparty/qtsingleapplication/INSTALL.TXT similarity index 100% rename from qtsingleapplication/INSTALL.TXT rename to thirdparty/qtsingleapplication/INSTALL.TXT diff --git a/qtsingleapplication/README.TXT b/thirdparty/qtsingleapplication/README.TXT similarity index 100% rename from qtsingleapplication/README.TXT rename to thirdparty/qtsingleapplication/README.TXT diff --git a/qtsingleapplication/source.txt b/thirdparty/qtsingleapplication/source.txt similarity index 100% rename from qtsingleapplication/source.txt rename to thirdparty/qtsingleapplication/source.txt diff --git a/qtsingleapplication/src/QtLockedFile b/thirdparty/qtsingleapplication/src/QtLockedFile similarity index 100% rename from qtsingleapplication/src/QtLockedFile rename to thirdparty/qtsingleapplication/src/QtLockedFile diff --git a/qtsingleapplication/src/QtSingleApplication b/thirdparty/qtsingleapplication/src/QtSingleApplication similarity index 100% rename from qtsingleapplication/src/QtSingleApplication rename to thirdparty/qtsingleapplication/src/QtSingleApplication diff --git a/qtsingleapplication/src/qtlocalpeer.cpp b/thirdparty/qtsingleapplication/src/qtlocalpeer.cpp similarity index 100% rename from qtsingleapplication/src/qtlocalpeer.cpp rename to thirdparty/qtsingleapplication/src/qtlocalpeer.cpp diff --git a/qtsingleapplication/src/qtlocalpeer.h b/thirdparty/qtsingleapplication/src/qtlocalpeer.h similarity index 100% rename from qtsingleapplication/src/qtlocalpeer.h rename to thirdparty/qtsingleapplication/src/qtlocalpeer.h diff --git a/qtsingleapplication/src/qtlockedfile.cpp b/thirdparty/qtsingleapplication/src/qtlockedfile.cpp similarity index 100% rename from qtsingleapplication/src/qtlockedfile.cpp rename to thirdparty/qtsingleapplication/src/qtlockedfile.cpp diff --git a/qtsingleapplication/src/qtlockedfile.h b/thirdparty/qtsingleapplication/src/qtlockedfile.h similarity index 100% rename from qtsingleapplication/src/qtlockedfile.h rename to thirdparty/qtsingleapplication/src/qtlockedfile.h diff --git a/qtsingleapplication/src/qtlockedfile_unix.cpp b/thirdparty/qtsingleapplication/src/qtlockedfile_unix.cpp similarity index 100% rename from qtsingleapplication/src/qtlockedfile_unix.cpp rename to thirdparty/qtsingleapplication/src/qtlockedfile_unix.cpp diff --git a/qtsingleapplication/src/qtlockedfile_win.cpp b/thirdparty/qtsingleapplication/src/qtlockedfile_win.cpp similarity index 100% rename from qtsingleapplication/src/qtlockedfile_win.cpp rename to thirdparty/qtsingleapplication/src/qtlockedfile_win.cpp diff --git a/qtsingleapplication/src/qtsingleapplication.cpp b/thirdparty/qtsingleapplication/src/qtsingleapplication.cpp similarity index 100% rename from qtsingleapplication/src/qtsingleapplication.cpp rename to thirdparty/qtsingleapplication/src/qtsingleapplication.cpp diff --git a/qtsingleapplication/src/qtsingleapplication.h b/thirdparty/qtsingleapplication/src/qtsingleapplication.h similarity index 100% rename from qtsingleapplication/src/qtsingleapplication.h rename to thirdparty/qtsingleapplication/src/qtsingleapplication.h diff --git a/qtsingleapplication/src/qtsingleapplication.pri b/thirdparty/qtsingleapplication/src/qtsingleapplication.pri similarity index 100% rename from qtsingleapplication/src/qtsingleapplication.pri rename to thirdparty/qtsingleapplication/src/qtsingleapplication.pri diff --git a/qtsingleapplication/src/qtsinglecoreapplication.cpp b/thirdparty/qtsingleapplication/src/qtsinglecoreapplication.cpp similarity index 100% rename from qtsingleapplication/src/qtsinglecoreapplication.cpp rename to thirdparty/qtsingleapplication/src/qtsinglecoreapplication.cpp diff --git a/qtsingleapplication/src/qtsinglecoreapplication.h b/thirdparty/qtsingleapplication/src/qtsinglecoreapplication.h similarity index 100% rename from qtsingleapplication/src/qtsinglecoreapplication.h rename to thirdparty/qtsingleapplication/src/qtsinglecoreapplication.h diff --git a/qtsingleapplication/src/qtsinglecoreapplication.pri b/thirdparty/qtsingleapplication/src/qtsinglecoreapplication.pri similarity index 100% rename from qtsingleapplication/src/qtsinglecoreapplication.pri rename to thirdparty/qtsingleapplication/src/qtsinglecoreapplication.pri From f06fc48b40207cae1cd3ccb095e961c885905103 Mon Sep 17 00:00:00 2001 From: yifang Date: Fri, 18 Feb 2022 22:12:58 +0800 Subject: [PATCH 04/10] format:refactor code --- gls.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/gls.cc b/gls.cc index 9702d4e1c..a0a26cac0 100644 --- a/gls.cc +++ b/gls.cc @@ -284,13 +284,8 @@ bool GlsScanner::readNextLine( wstring & out, size_t & offset ) readBufferPtr += pos; linesRead++; -#ifdef __WIN32 - out = line.toStdU32String(); -#else - out = line.toStdU32String(); -#endif - return true; - + out = line.toStdU32String(); + return true; } } From 7e2231805f712231d0e75641e08cc0fb3a56d416 Mon Sep 17 00:00:00 2001 From: yifang Date: Sat, 19 Feb 2022 00:16:11 +0800 Subject: [PATCH 05/10] optimize: float number compare precision optimize: float number compare precision --- helpwindow.cc | 2 +- mainwindow.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/helpwindow.cc b/helpwindow.cc index 8630afcbb..fb81d04d9 100644 --- a/helpwindow.cc +++ b/helpwindow.cc @@ -254,7 +254,7 @@ void HelpWindow::applyZoomFactor() zoomInAction->setEnabled( cfg.preferences.helpZoomFactor < 5 ); zoomOutAction->setEnabled( cfg.preferences.helpZoomFactor > 0.2 ); - zoomBaseAction->setEnabled( cfg.preferences.helpZoomFactor != 1.0 ); + zoomBaseAction->setEnabled( !qFuzzyCompare(cfg.preferences.helpZoomFactor, 1.0) ); if( fontSize > 0 ) { diff --git a/mainwindow.cc b/mainwindow.cc index 70fbb37f7..ee475d1b7 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -3720,7 +3720,7 @@ void MainWindow::adjustCurrentZoomFactor() zoomIn->setEnabled( cfg.preferences.zoomFactor < 5 ); zoomOut->setEnabled( cfg.preferences.zoomFactor > 0.1 ); - zoomBase->setEnabled( cfg.preferences.zoomFactor != 1.0 ); + zoomBase->setEnabled( !qFuzzyCompare( cfg.preferences.zoomFactor, 1.0 ) ); } void MainWindow::scaleArticlesByCurrentZoomFactor() From 95db9de880af0a6cabb6df4509d17706a6fdc668 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:02:39 +0800 Subject: [PATCH 06/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4b8fc16b..aa526ca17 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This code has been run and tested on Windows XP/Vista/7, Ubuntu Linux, Mac OS X. libvorbis-dev zlib1g-dev libhunspell-dev x11proto-record-dev \ qtdeclarative5-dev libxtst-dev liblzo2-dev libbz2-dev \ libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev \ - libqt5webkit5-dev libqt5svg5-dev libqt5x11extras5-dev qttools5-dev \ + libqt5svg5-dev libqt5x11extras5-dev qttools5-dev \ qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins ## How to build From d376f996917afc48685f5643deca6567664afda7 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sat, 19 Feb 2022 12:03:35 +0800 Subject: [PATCH 07/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa526ca17..6f9896415 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Requirements -This code has been run and tested on Windows XP/Vista/7, Ubuntu Linux, Mac OS X. +This code has been run and tested on Windows 10/11, Ubuntu Linux, Mac OS X. ### External Deps From 3e88a5615d76431b6052843df5c9d177781a7762 Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sat, 19 Feb 2022 18:59:19 +0800 Subject: [PATCH 08/10] optimize:F12 inspect element --- articleview.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/articleview.cc b/articleview.cc index 759b39b81..8cdb4230a 100644 --- a/articleview.cc +++ b/articleview.cc @@ -513,12 +513,10 @@ void ArticleView::inspectElement(){ devDialog = new QDialog( this ); devDialog->setWindowTitle( tr( "Inspect" ) ); devDialog->setWindowFlags( Qt::Window ); - devDialog->setContentsMargins( 0, 0, 0, 0 ); devDialog->setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false ); QVBoxLayout * v=new QVBoxLayout( devDialog ); -// devDialog->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); -// inspectView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding); -// inspectView->setContentsMargins(0,0,0,0); + v->setSpacing( 0 ); + v->setContentsMargins( 0, 0, 0, 0 ); v->addWidget( inspectView ); } page->triggerAction( QWebEnginePage::InspectElement ); From 0e19c34bbe363002fa3b8a5f2e5ee842b171e8be Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sat, 19 Feb 2022 19:01:02 +0800 Subject: [PATCH 09/10] Revert "clean:remove win specific vs files" This reverts commit c3f3f942588f26ef2188f01ddee3625bcd6c49a2. --- GoldenDict.exe.manifest | 14 ++++++++++++++ goldendict.pro | 2 +- goldendict.rc | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 GoldenDict.exe.manifest create mode 100644 goldendict.rc diff --git a/GoldenDict.exe.manifest b/GoldenDict.exe.manifest new file mode 100644 index 000000000..c1375d4ee --- /dev/null +++ b/GoldenDict.exe.manifest @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/goldendict.pro b/goldendict.pro index 8ddd8ba4c..507546d41 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -97,7 +97,7 @@ win32 { } - #RC_FILE = goldendict.rc + RC_FILE = goldendict.rc INCLUDEPATH += winlibs/include # Enable console in Debug mode on Windows, with useful logging messages diff --git a/goldendict.rc b/goldendict.rc new file mode 100644 index 000000000..f6fbce0cb --- /dev/null +++ b/goldendict.rc @@ -0,0 +1,39 @@ +#include "windows.h" + +IDI_ICON1 ICON DISCARDABLE "icons/programicon.ico" +IDI_ICON2 ICON DISCARDABLE "icons/programicon_old.ico" +#define GOLDENDICT_VER 1,5,0,0 +#define GOLDENDICT_VER_STR "1.5.0" + +#if !defined( _MSC_VER ) && !defined( GD_NO_MANIFEST ) // Visual Studio embeds the manifest automatically +1 RT_MANIFEST GoldenDict.exe.manifest +#endif + +1 VERSIONINFO + FILEVERSION GOLDENDICT_VER + PRODUCTVERSION GOLDENDICT_VER + FILEFLAGS 0x0L + FILEFLAGSMASK 0x3fL + FILEOS 0x00040004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "CompanyName", "GoldenDict" + VALUE "FileDescription", "GoldenDict dictionary lookup program" + VALUE "FileVersion", GOLDENDICT_VER_STR + VALUE "LegalCopyright", "www.goldendict.org" + VALUE "InternalName", "goldendict" + VALUE "OriginalFilename", "goldendict.exe" + VALUE "ProductName", "GoldenDict" + VALUE "ProductVersion", GOLDENDICT_VER_STR + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END From 49fa66c29d3c205ea8d23ca87180308ffdae140e Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Sat, 19 Feb 2022 19:05:01 +0800 Subject: [PATCH 10/10] format: format one line --- articleview.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/articleview.cc b/articleview.cc index 8cdb4230a..f1506402d 100644 --- a/articleview.cc +++ b/articleview.cc @@ -514,7 +514,7 @@ void ArticleView::inspectElement(){ devDialog->setWindowTitle( tr( "Inspect" ) ); devDialog->setWindowFlags( Qt::Window ); devDialog->setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false ); - QVBoxLayout * v=new QVBoxLayout( devDialog ); + QVBoxLayout * v = new QVBoxLayout( devDialog ); v->setSpacing( 0 ); v->setContentsMargins( 0, 0, 0, 0 ); v->addWidget( inspectView );