Skip to content

Commit

Permalink
Merge branch 'staged' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed May 23, 2022
2 parents 7c9c4c1 + 2ffd494 commit f497c5e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 15 deletions.
3 changes: 2 additions & 1 deletion epwing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries(

for( ; ; )
{
if( !head.headword.isEmpty() )
//skip too long headword
if( !head.headword.isEmpty() && head.headword.size() < 30 )
{
uint32_t offset = chunks.startNewBlock();
chunks.addToBlock( &head.page, sizeof( head.page ) );
Expand Down
42 changes: 33 additions & 9 deletions epwing_book.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void EpwingBook::getFirstHeadword( EpwingHeadword & head )
fixHeadword( head.headword );

EWPos epos( pos.page, pos.offset );
allHeadwordPositions[ head.headword ] = epos;
allHeadwordPositions[ head.headword ] << epos;
}

bool EpwingBook::getNextHeadword( EpwingHeadword & head )
Expand Down Expand Up @@ -881,13 +881,25 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )

if( allHeadwordPositions.contains( head.headword ) )
{
EWPos epos = allHeadwordPositions[ head.headword ];
if( pos.page != epos.first || abs( pos.offset - epos.second ) > 4 )
// existed position
bool existed = false;
foreach( EWPos epos, allHeadwordPositions[ head.headword ] )
{
if( pos.page == epos.first && abs( pos.offset - epos.second ) <= 4 )
{
existed = true;
break;
}
}
if( !existed )
{
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
return true;
}
}
else
{
allHeadwordPositions[ head.headword ] = EWPos( pos.page, pos.offset );
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
return true;
}
}
Expand Down Expand Up @@ -943,14 +955,26 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head )

if( allHeadwordPositions.contains( head.headword ) )
{
EWPos epos = allHeadwordPositions[ head.headword ];
if( pos.page != epos.first || abs( pos.offset - epos.second ) > 4 )
break;
// existed position
bool existed = false;
foreach( EWPos epos, allHeadwordPositions[ head.headword ] )
{
if( pos.page == epos.first && abs( pos.offset - epos.second ) <= 4 )
{
existed = true;
break;
}
}
if( !existed )
{
allHeadwordPositions[ head.headword ] << EWPos( pos.page, pos.offset );
return true;
}
}
else
{
allHeadwordPositions[ head.headword ] = EWPos( pos.page, pos.offset );
break;
allHeadwordPositions[ head.headword ]<<EWPos( pos.page, pos.offset );
return true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion epwing_book.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class EpwingBook
QStringList imageCacheList, soundsCacheList, moviesCacheList, fontsCacheList;
QMap< QString, QString > baseFontsMap, customFontsMap;
QVector< int > refPages, refOffsets;
QMap< QString, EWPos > allHeadwordPositions;
QMap< QString, QList<EWPos> > allHeadwordPositions;
QVector< EWPos > LinksQueue;
int refOpenCount, refCloseCount;
static Mutex libMutex;
Expand Down
6 changes: 2 additions & 4 deletions goldendict.pro
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
DEFINES += MAKE_FFMPEG_PLAYER
}

#QT += sql
CONFIG += exceptions \
rtti \
stl \
c++14 \
c++17 \
lrelease \
embed_translations

Expand Down Expand Up @@ -76,13 +75,12 @@ win32 {
DEFINES += NOMINMAX __WIN64
}
LIBS += -L$${PWD}/winlibs/lib/msvc
QMAKE_CXXFLAGS += /wd4290 # silence the warning C4290: C++ exception specification ignored
QMAKE_CXXFLAGS += /wd4290 /Zc:__cplusplus /std:c++17 # silence the warning C4290: C++ exception specification ignored
# QMAKE_LFLAGS_RELEASE += /OPT:REF /OPT:ICF
# QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO /DEBUG
CONFIG+=force_debug_info
QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO
DEFINES += GD_NO_MANIFEST
# QMAKE_CXXFLAGS_RELEASE += /GL # slows down the linking significantly
LIBS += -lshell32 -luser32 -lsapi -lole32
Debug: LIBS+= -lhunspelld
Expand Down
19 changes: 19 additions & 0 deletions mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
#include "wstring_qt.hh"
#endif

#include <QWebEngineSettings>
#include <QWebEngineProfile>

#ifdef HAVE_X11
#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
#include <QtGui/private/qtx11extras_p.h>
Expand Down Expand Up @@ -90,6 +93,19 @@ class InitSSLRunnable : public QRunnable

#endif

void MainWindow::changeWebEngineViewFont()
{
if( cfg.preferences.webFontFamily.isEmpty() )
{
QWebEngineProfile::defaultProfile()->settings()->resetFontFamily( QWebEngineSettings::StandardFont );
}
else
{
QWebEngineProfile::defaultProfile()->settings()->setFontFamily( QWebEngineSettings::StandardFont,
cfg.preferences.webFontFamily );
}
}

MainWindow::MainWindow( Config::Class & cfg_ ):
trayIcon( 0 ),
groupLabel( &searchPaneTitleBar ),
Expand Down Expand Up @@ -761,6 +777,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):

applyProxySettings();

//set webengineview font
changeWebEngineViewFont();

connect( &dictNetMgr, SIGNAL( proxyAuthenticationRequired( QNetworkProxy, QAuthenticator * ) ),
this, SLOT( proxyAuthentication( QNetworkProxy, QAuthenticator * ) ) );

Expand Down
2 changes: 2 additions & 0 deletions mainwindow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ private:
TranslateBoxPopup popupAction );
void setTranslateBoxTextAndClearSuffix( QString const & text, WildcardPolicy wildcardPolicy,
TranslateBoxPopup popupAction );
void changeWebEngineViewFont();

private slots:

void hotKeyActivated( int );
Expand Down

0 comments on commit f497c5e

Please sign in to comment.