diff --git a/articleview.cc b/articleview.cc
index 6b617d95..241f0cd8 100644
--- a/articleview.cc
+++ b/articleview.cc
@@ -324,6 +324,9 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
settings->defaultSettings()->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
settings->defaultSettings()->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
settings->defaultSettings()->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
+
+ if( !cfg.preferences.webFontFamily.isEmpty() )
+ settings->defaultSettings()->setFontFamily( QWebEngineSettings::StandardFont, cfg.preferences.webFontFamily );
#else
settings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
settings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
@@ -331,18 +334,10 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
settings->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
settings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
settings->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
+
+ if( !cfg.preferences.webFontFamily.isEmpty() )
+ settings->setFontFamily( QWebEngineSettings::StandardFont, cfg.preferences.webFontFamily );
#endif
- // Load the default blank page instantly, so there would be no flicker.
-
- QString contentType;
-// QUrl blankPage( "gdlookup://localhost?blank=1" );
-
-// sptr< Dictionary::DataRequest > r = articleNetMgr.getResource( blankPage,
-// contentType );
-
-// ui.definition->setHtml( QString::fromUtf8( &( r->getFullData().front() ),
-// r->getFullData().size() ),
-// blankPage );
expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts;
diff --git a/config.cc b/config.cc
index fab25abc..2e926248 100644
--- a/config.cc
+++ b/config.cc
@@ -854,6 +854,9 @@ Class load()
c.preferences.alwaysOnTop = ( preferences.namedItem( "alwaysOnTop" ).toElement().text() == "1" );
c.preferences.searchInDock = ( preferences.namedItem( "searchInDock" ).toElement().text() == "1" );
+ if ( !preferences.namedItem( "webFontFamily" ).isNull() )
+ c.preferences.webFontFamily = preferences.namedItem( "webFontFamily" ).toElement().text();
+
if ( !preferences.namedItem( "doubleClickTranslates" ).isNull() )
c.preferences.doubleClickTranslates = ( preferences.namedItem( "doubleClickTranslates" ).toElement().text() == "1" );
@@ -1642,6 +1645,10 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( c.preferences.interfaceLanguage ) );
preferences.appendChild( opt );
+ opt = dd.createElement( "webFontFamily" );
+ opt.appendChild( dd.createTextNode( c.preferences.webFontFamily ) );
+ preferences.appendChild( opt );
+
opt = dd.createElement( "helpLanguage" );
opt.appendChild( dd.createTextNode( c.preferences.helpLanguage ) );
preferences.appendChild( opt );
diff --git a/config.hh b/config.hh
index d6675a2d..774dbdef 100644
--- a/config.hh
+++ b/config.hh
@@ -281,6 +281,7 @@ struct Preferences
QString interfaceLanguage; // Empty value corresponds to system default
QString helpLanguage; // Empty value corresponds to interface language
QString displayStyle; // Empty value corresponds to the default one
+ QString webFontFamily; // Empty value corresponds to the default one
bool newTabsOpenAfterCurrentOne;
bool newTabsOpenInBackground;
bool hideSingleTab;
diff --git a/locale/zh_CN.ts b/locale/zh_CN.ts
index 3dc35807..95efe2f9 100644
--- a/locale/zh_CN.ts
+++ b/locale/zh_CN.ts
@@ -3865,7 +3865,17 @@ however, the article from the topmost dictionary is shown.
自动定位到当前词典
-
+
+
+ 词典字体:
+
+
+
+
+ 设置词典的备用字体
+
+
+
单词被选中时显示扫描旗标
@@ -4170,6 +4180,16 @@ from Stardict, Babylon and GLS dictionaries
MB
+
+
+
+ 更改词典的备用字体
+
+
+
+
+ 重新启动程序以应用字典的备用字体。
+
ProgramTypeEditor
diff --git a/mainwindow.cc b/mainwindow.cc
index 082e4335..c4716e54 100644
--- a/mainwindow.cc
+++ b/mainwindow.cc
@@ -7,7 +7,6 @@
#include "mainwindow.hh"
#include
-#include
#include "editdictionaries.hh"
#include "loaddictionaries.hh"
#include "preferences.hh"
diff --git a/preferences.cc b/preferences.cc
index 08c8e2bf..63839dd4 100644
--- a/preferences.cc
+++ b/preferences.cc
@@ -6,7 +6,6 @@
#include "broken_xrecord.hh"
#include "mainwindow.hh"
-
Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
QDialog( parent ), prevInterfaceLanguage( 0 )
, helpWindow( 0 )
@@ -60,6 +59,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.interfaceLanguage->addItem( tr( "System default" ), QString() );
ui.interfaceLanguage->addItem( QIcon( ":/flags/us.png" ), Language::localizedNameForId( LangCoder::code2toInt( "en" ) ), QString( "en_US" ) );
+ ui.fontFamilies->addItem( tr( "System default" ), QString() );
// See which other translations do we have
@@ -95,6 +95,13 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
break;
}
+ const QStringList fontFamilies = QFontDatabase::families();
+ for( const QString & family : fontFamilies )
+ {
+ ui.fontFamilies->addItem( family );
+ }
+ prevWebFontFamily = p.webFontFamily;
+ ui.fontFamilies->setCurrentText( p.webFontFamily );
// Fill help languages combobox
ui.helpLanguage->addItem( tr( "Default" ), QString() );
@@ -362,6 +369,8 @@ Config::Preferences Preferences::getPreferences()
ui.interfaceLanguage->itemData(
ui.interfaceLanguage->currentIndex() ).toString();
+ p.webFontFamily = ui.fontFamilies->currentText();
+
p.helpLanguage =
ui.helpLanguage->itemData(
ui.helpLanguage->currentIndex() ).toString();
@@ -631,6 +640,10 @@ void Preferences::on_buttonBox_accepted()
if ( prevInterfaceLanguage != ui.interfaceLanguage->currentIndex() )
QMessageBox::information( this, tr( "Changing Language" ),
tr( "Restart the program to apply the language change." ) );
+
+ if ( prevWebFontFamily != ui.fontFamilies->currentText() )
+ QMessageBox::information( this, tr( "Changing Dictionary Font Family" ),
+ tr( "Restart the program to apply the dictionary font family change." ) );
}
void Preferences::on_useExternalPlayer_toggled( bool enabled )
diff --git a/preferences.hh b/preferences.hh
index 71142091..dcde4cc7 100644
--- a/preferences.hh
+++ b/preferences.hh
@@ -13,6 +13,8 @@ class Preferences: public QDialog
int prevInterfaceLanguage;
+ QString prevWebFontFamily;
+
Help::HelpWindow * helpWindow;
Config::Class & cfg;
QAction helpAction;
diff --git a/preferences.ui b/preferences.ui
index 9f709ffd..45da2155 100644
--- a/preferences.ui
+++ b/preferences.ui
@@ -50,86 +50,6 @@
9
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Double-click translates the word clicked
-
-
-
- -
-
-
- Tabbed browsing
-
-
-
-
-
-
- Normally, opening a new tab switches to it immediately.
-With this on however, new tabs will be opened without
-switching to them.
-
-
- Open new tabs in background
-
-
-
- -
-
-
- With this on, new tabs are opened just after the
-current, active one. Otherwise they are added to
-be the last ones.
-
-
- Open new tabs after the current one
-
-
-
- -
-
-
- Select this option if you don't want to see the main tab bar when only a single tab is opened.
-
-
- Hide single tab
-
-
-
- -
-
-
- Ctrl-Tab navigates tabs in MRU order
-
-
-
-
-
-
- -
-
-
- Turn this option on if you want to select words by single mouse click
-
-
- Select word by single click
-
-
-
-
-
@@ -206,6 +126,30 @@ be the last ones.
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Normally, pressing ESC key moves focus to the translation line.
+With this on however, it will hide the main window.
+
+
+ ESC key hides main window
+
+
+
-
@@ -253,33 +197,6 @@ the application.
- -
-
-
-
-
-
- Add-on style:
-
-
-
- -
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
@@ -315,17 +232,6 @@ however, the article from the topmost dictionary is shown.
- -
-
-
- Normally, pressing ESC key moves focus to the translation line.
-With this on however, it will hide the main window.
-
-
- ESC key hides main window
-
-
-
-
-
@@ -375,6 +281,137 @@ With this on however, it will hide the main window.
+ -
+
+
+ Turn this option on if you want to select words by single mouse click
+
+
+ Select word by single click
+
+
+
+ -
+
+
+ Double-click translates the word clicked
+
+
+
+ -
+
+
+ Tabbed browsing
+
+
+
-
+
+
+ Normally, opening a new tab switches to it immediately.
+With this on however, new tabs will be opened without
+switching to them.
+
+
+ Open new tabs in background
+
+
+
+ -
+
+
+ With this on, new tabs are opened just after the
+current, active one. Otherwise they are added to
+be the last ones.
+
+
+ Open new tabs after the current one
+
+
+
+ -
+
+
+ Select this option if you don't want to see the main tab bar when only a single tab is opened.
+
+
+ Hide single tab
+
+
+
+ -
+
+
+ Ctrl-Tab navigates tabs in MRU order
+
+
+
+
+
+
+ -
+
+
-
+
+
+ Dictionary Font:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ set the fallback font family for dictionary
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
-
+
+
+ Add-on style:
+
+
+
+ -
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+