mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
opt: add dictionary fallback font family settings
This commit is contained in:
parent
e6159f2e26
commit
9c402d986e
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3865,7 +3865,17 @@ however, the article from the topmost dictionary is shown.</source>
|
|||
<translation>自动定位到当前词典</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../preferences.ui" line="668"/>
|
||||
<location filename="../preferences.ui" line="356"/>
|
||||
<source>Dictionary Font: </source>
|
||||
<translation>词典字体: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../preferences.ui" line="369"/>
|
||||
<source>set the fallback font family for dictionary</source>
|
||||
<translation>设置词典的备用字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../preferences.ui" line="708"/>
|
||||
<source>Show scan flag when word is selected</source>
|
||||
<translation>单词被选中时显示扫描旗标</translation>
|
||||
</message>
|
||||
|
@ -4170,6 +4180,16 @@ from Stardict, Babylon and GLS dictionaries</source>
|
|||
<source> MB</source>
|
||||
<translation> MB</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../preferences.cc" line="645"/>
|
||||
<source>Changing Dictionary Font Family</source>
|
||||
<translation>更改词典的备用字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../preferences.cc" line="646"/>
|
||||
<source>Restart the program to apply the dictionary font family change.</source>
|
||||
<translation>重新启动程序以应用字典的备用字体。</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ProgramTypeEditor</name>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "mainwindow.hh"
|
||||
#include <QWebEngineProfile>
|
||||
#include <QWebEngineSettings>
|
||||
#include "editdictionaries.hh"
|
||||
#include "loaddictionaries.hh"
|
||||
#include "preferences.hh"
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -13,6 +13,8 @@ class Preferences: public QDialog
|
|||
|
||||
int prevInterfaceLanguage;
|
||||
|
||||
QString prevWebFontFamily;
|
||||
|
||||
Help::HelpWindow * helpWindow;
|
||||
Config::Class & cfg;
|
||||
QAction helpAction;
|
||||
|
|
273
preferences.ui
273
preferences.ui
|
@ -50,86 +50,6 @@
|
|||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="doubleClickTranslates">
|
||||
<property name="text">
|
||||
<string>Double-click translates the word clicked</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Tabbed browsing</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="newTabsOpenInBackground">
|
||||
<property name="toolTip">
|
||||
<string>Normally, opening a new tab switches to it immediately.
|
||||
With this on however, new tabs will be opened without
|
||||
switching to them.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open new tabs in background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="newTabsOpenAfterCurrentOne">
|
||||
<property name="toolTip">
|
||||
<string>With this on, new tabs are opened just after the
|
||||
current, active one. Otherwise they are added to
|
||||
be the last ones.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open new tabs after the current one</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="hideSingleTab">
|
||||
<property name="toolTip">
|
||||
<string>Select this option if you don't want to see the main tab bar when only a single tab is opened.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide single tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="mruTabOrder">
|
||||
<property name="text">
|
||||
<string>Ctrl-Tab navigates tabs in MRU order</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="selectBySingleClick">
|
||||
<property name="toolTip">
|
||||
<string>Turn this option on if you want to select words by single mouse click</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select word by single click</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
|
@ -206,6 +126,30 @@ be the last ones.</string>
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="14" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="escKeyHidesMainWindow">
|
||||
<property name="toolTip">
|
||||
<string>Normally, pressing ESC key moves focus to the translation line.
|
||||
With this on however, it will hide the main window.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ESC key hides main window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="enableTrayIcon">
|
||||
<property name="toolTip">
|
||||
|
@ -253,33 +197,6 @@ the application.</string>
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="addonStylesLabel">
|
||||
<property name="text">
|
||||
<string>Add-on style:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StylesComboBox" name="addonStyles"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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 row="3" column="1">
|
||||
<widget class="QCheckBox" name="autoScrollToTargetArticle">
|
||||
<property name="toolTip">
|
||||
|
@ -315,17 +232,6 @@ however, the article from the topmost dictionary is shown.</string>
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="escKeyHidesMainWindow">
|
||||
<property name="toolTip">
|
||||
<string>Normally, pressing ESC key moves focus to the translation line.
|
||||
With this on however, it will hide the main window.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ESC key hides main window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||
<item>
|
||||
|
@ -375,6 +281,137 @@ With this on however, it will hide the main window.</string>
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="selectBySingleClick">
|
||||
<property name="toolTip">
|
||||
<string>Turn this option on if you want to select words by single mouse click</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select word by single click</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="doubleClickTranslates">
|
||||
<property name="text">
|
||||
<string>Double-click translates the word clicked</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Tabbed browsing</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="newTabsOpenInBackground">
|
||||
<property name="toolTip">
|
||||
<string>Normally, opening a new tab switches to it immediately.
|
||||
With this on however, new tabs will be opened without
|
||||
switching to them.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open new tabs in background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="newTabsOpenAfterCurrentOne">
|
||||
<property name="toolTip">
|
||||
<string>With this on, new tabs are opened just after the
|
||||
current, active one. Otherwise they are added to
|
||||
be the last ones.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open new tabs after the current one</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="hideSingleTab">
|
||||
<property name="toolTip">
|
||||
<string>Select this option if you don't want to see the main tab bar when only a single tab is opened.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide single tab</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="mruTabOrder">
|
||||
<property name="text">
|
||||
<string>Ctrl-Tab navigates tabs in MRU order</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="text">
|
||||
<string>Dictionary Font: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="fontFamilies">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>set the fallback font family for dictionary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_13">
|
||||
<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 row="7" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="addonStylesLabel">
|
||||
<property name="text">
|
||||
<string>Add-on style:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="StylesComboBox" name="addonStyles"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
|
|
Loading…
Reference in a new issue