mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
opt : set webengine font family
make it take effect immediately
This commit is contained in:
parent
949f46313d
commit
a1ef0313ab
|
@ -318,25 +318,19 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
|
||||||
QWebEngineSettings * settings = ui.definition->settings();
|
QWebEngineSettings * settings = ui.definition->settings();
|
||||||
settings->setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy::DisallowUnknownUrlSchemes);
|
settings->setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy::DisallowUnknownUrlSchemes);
|
||||||
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
|
settings->defaultSettings()->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true );
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
|
settings->defaultSettings()->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true );
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false );
|
settings->defaultSettings()->setAttribute( QWebEngineSettings::ErrorPageEnabled, false );
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
|
settings->defaultSettings()->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
settings->defaultSettings()->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
||||||
settings->defaultSettings()->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
settings->defaultSettings()->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
||||||
|
|
||||||
if( !cfg.preferences.webFontFamily.isEmpty() )
|
|
||||||
settings->defaultSettings()->setFontFamily( QWebEngineSettings::StandardFont, cfg.preferences.webFontFamily );
|
|
||||||
#else
|
#else
|
||||||
settings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
|
settings->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true );
|
||||||
settings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
|
settings->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true );
|
||||||
settings->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false );
|
settings->setAttribute( QWebEngineSettings::ErrorPageEnabled, false );
|
||||||
settings->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
|
settings->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
|
||||||
settings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
settings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
|
||||||
settings->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
settings->setAttribute( QWebEngineSettings::JavascriptCanAccessClipboard, true );
|
||||||
|
|
||||||
if( !cfg.preferences.webFontFamily.isEmpty() )
|
|
||||||
settings->setFontFamily( QWebEngineSettings::StandardFont, cfg.preferences.webFontFamily );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts;
|
expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include "broken_xrecord.hh"
|
#include "broken_xrecord.hh"
|
||||||
#include "mainwindow.hh"
|
#include "mainwindow.hh"
|
||||||
|
#include <QWebEngineSettings>
|
||||||
|
#include <QWebEngineProfile>
|
||||||
|
|
||||||
Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
||||||
QDialog( parent ), prevInterfaceLanguage( 0 )
|
QDialog( parent ), prevInterfaceLanguage( 0 )
|
||||||
|
@ -105,6 +107,8 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
||||||
ui.fontFamilies->addItem( family );
|
ui.fontFamilies->addItem( family );
|
||||||
}
|
}
|
||||||
prevWebFontFamily = p.webFontFamily;
|
prevWebFontFamily = p.webFontFamily;
|
||||||
|
|
||||||
|
if(!p.webFontFamily.isEmpty())
|
||||||
ui.fontFamilies->setCurrentText( p.webFontFamily );
|
ui.fontFamilies->setCurrentText( p.webFontFamily );
|
||||||
// Fill help languages combobox
|
// Fill help languages combobox
|
||||||
|
|
||||||
|
@ -373,6 +377,8 @@ Config::Preferences Preferences::getPreferences()
|
||||||
ui.interfaceLanguage->itemData(
|
ui.interfaceLanguage->itemData(
|
||||||
ui.interfaceLanguage->currentIndex() ).toString();
|
ui.interfaceLanguage->currentIndex() ).toString();
|
||||||
|
|
||||||
|
//bypass the first default
|
||||||
|
if(ui.fontFamilies->currentIndex()>0)
|
||||||
p.webFontFamily = ui.fontFamilies->currentText();
|
p.webFontFamily = ui.fontFamilies->currentText();
|
||||||
|
|
||||||
p.helpLanguage =
|
p.helpLanguage =
|
||||||
|
@ -645,9 +651,20 @@ void Preferences::on_buttonBox_accepted()
|
||||||
QMessageBox::information( this, tr( "Changing Language" ),
|
QMessageBox::information( this, tr( "Changing Language" ),
|
||||||
tr( "Restart the program to apply the language change." ) );
|
tr( "Restart the program to apply the language change." ) );
|
||||||
|
|
||||||
if ( prevWebFontFamily != ui.fontFamilies->currentText() )
|
auto currentFontFamily = ui.fontFamilies->currentText();
|
||||||
QMessageBox::information( this, tr( "Changing Dictionary Font Family" ),
|
if( prevWebFontFamily != currentFontFamily )
|
||||||
tr( "Restart the program to apply the dictionary font family change." ) );
|
{
|
||||||
|
//reset to default font .
|
||||||
|
if( currentFontFamily.isEmpty() )
|
||||||
|
{
|
||||||
|
QWebEngineProfile::defaultProfile()->settings()->resetFontFamily( QWebEngineSettings::StandardFont );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QWebEngineProfile::defaultProfile()->settings()->setFontFamily( QWebEngineSettings::StandardFont,
|
||||||
|
currentFontFamily );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::on_useExternalPlayer_toggled( bool enabled )
|
void Preferences::on_useExternalPlayer_toggled( bool enabled )
|
||||||
|
|
Loading…
Reference in a new issue