diff --git a/articleview.cc b/articleview.cc index f366129d..06fba01b 100644 --- a/articleview.cc +++ b/articleview.cc @@ -318,25 +318,19 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au QWebEngineSettings * settings = ui.definition->settings(); settings->setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy::DisallowUnknownUrlSchemes); #if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) - settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true ); - settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true ); - settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false ); + settings->defaultSettings()->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true ); + settings->defaultSettings()->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true ); + settings->defaultSettings()->setAttribute( QWebEngineSettings::ErrorPageEnabled, false ); 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 ); - settings->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false ); + settings->setAttribute( QWebEngineSettings::LocalContentCanAccessRemoteUrls, true ); + settings->setAttribute( QWebEngineSettings::LocalContentCanAccessFileUrls, true ); + settings->setAttribute( QWebEngineSettings::ErrorPageEnabled, false ); 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 expandOptionalParts = cfg.preferences.alwaysExpandOptionalParts; diff --git a/preferences.cc b/preferences.cc index 0ef9dd52..46705bf2 100644 --- a/preferences.cc +++ b/preferences.cc @@ -5,6 +5,8 @@ #include #include "broken_xrecord.hh" #include "mainwindow.hh" +#include +#include Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): QDialog( parent ), prevInterfaceLanguage( 0 ) @@ -105,7 +107,9 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): ui.fontFamilies->addItem( family ); } prevWebFontFamily = p.webFontFamily; - ui.fontFamilies->setCurrentText( p.webFontFamily ); + + if(!p.webFontFamily.isEmpty()) + ui.fontFamilies->setCurrentText( p.webFontFamily ); // Fill help languages combobox ui.helpLanguage->addItem( tr( "Default" ), QString() ); @@ -373,7 +377,9 @@ Config::Preferences Preferences::getPreferences() ui.interfaceLanguage->itemData( ui.interfaceLanguage->currentIndex() ).toString(); - p.webFontFamily = ui.fontFamilies->currentText(); + //bypass the first default + if(ui.fontFamilies->currentIndex()>0) + p.webFontFamily = ui.fontFamilies->currentText(); p.helpLanguage = ui.helpLanguage->itemData( @@ -645,9 +651,20 @@ void Preferences::on_buttonBox_accepted() 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." ) ); + auto currentFontFamily = ui.fontFamilies->currentText(); + if( prevWebFontFamily != currentFontFamily ) + { + //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 )