diff --git a/src/article_maker.cc b/src/article_maker.cc index d7ffd713..ed360b7e 100644 --- a/src/article_maker.cc +++ b/src/article_maker.cc @@ -444,9 +444,8 @@ string ArticleMaker::makeEmptyPageHtml() const sptr< Dictionary::DataRequest > ArticleMaker::makePicturePage( string const & url ) const { - string const result = makeHtmlHeader( tr( "(picture)" ), QString(), true ) - + R"lit()lit" + R"()" - + ""; + string const result = + makeHtmlHeader( tr( "(picture)" ), QString(), true ) + R"()" + ""; sptr< Dictionary::DataRequestInstant > r = std::make_shared< Dictionary::DataRequestInstant >( true ); diff --git a/src/dict/dsl.cc b/src/dict/dsl.cc index 6a214d73..dba31523 100644 --- a/src/dict/dsl.cc +++ b/src/dict/dsl.cc @@ -840,61 +840,12 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) url.setHost( QString::fromUtf8( getId().c_str() ) ); url.setPath( Utils::Url::ensureLeadingSlash( QString::fromUtf8( filename.c_str() ) ) ); - vector< char > imgdata; - bool resize = false; + string maxWidthStyle = " style=\"max-width:100%;\" "; - try { - File::loadFromFile( n, imgdata ); - } - catch ( File::exCantOpen & ) { - try { - n = resourceDir2 + filename; - File::loadFromFile( n, imgdata ); - } - catch ( File::exCantOpen & ) { - try { - n = getContainingFolder().toStdString() + Utils::Fs::separator() + filename; - File::loadFromFile( n, imgdata ); - } - catch ( File::exCantOpen & ) { - // Try reading from zip file - if ( resourceZip.isOpen() ) { - QMutexLocker _( &resourceZipMutex ); - resourceZip.loadFile( Utf8::decode( filename ), imgdata ); - } - } - } - } - catch ( ... ) { - } - - if ( !imgdata.empty() ) { - if ( Filetype::isNameOfSvg( filename ) ) { - // We don't need to render svg file now - - QSvgRenderer svg; - svg.load( QByteArray::fromRawData( imgdata.data(), imgdata.size() ) ); - if ( svg.isValid() ) { - QSize imgsize = svg.defaultSize(); - resize = maxPictureWidth > 0 && imgsize.width() > maxPictureWidth; - } - } - else { - QImage img = QImage::fromData( (unsigned char *)&imgdata.front(), imgdata.size() ); - - resize = maxPictureWidth > 0 && img.width() > maxPictureWidth; - } - } - - if ( resize ) { - string link( url.toEncoded().data() ); - link.replace( 0, 4, "gdpicture" ); - result += string( "" + "\""" - + ""; - } - else - result += string( "\"""; + string link( url.toEncoded().data() ); + link.replace( 0, 4, "gdpicture" ); + result += string( "" + "\""" + ""; } else if ( Filetype::isNameOfVideo( filename ) ) { QUrl url; diff --git a/src/ui/mainwindow.cc b/src/ui/mainwindow.cc index d950927a..8c5c7337 100644 --- a/src/ui/mainwindow.cc +++ b/src/ui/mainwindow.cc @@ -182,14 +182,15 @@ MainWindow::MainWindow( Config::Class & cfg_ ): GlobalBroadcaster::instance()->setPreference( &cfg.preferences ); localSchemeHandler = new LocalSchemeHandler( articleNetMgr, this ); - QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( "gdlookup", localSchemeHandler ); - QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( "bword", localSchemeHandler ); - QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( "entry", localSchemeHandler ); + QStringList htmlScheme = { "gdlookup", "bword", "entry", "gdpicture" }; + for ( const auto & localScheme : htmlScheme ) { + QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( localScheme.toLatin1(), localSchemeHandler ); + } iframeSchemeHandler = new IframeSchemeHandler( this ); QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( "ifr", iframeSchemeHandler ); - QStringList localSchemes = { "gdau", "gico", "qrcx", "bres", "gdprg", "gdvideo", "gdpicture", "gdtts" }; + QStringList localSchemes = { "gdau", "gico", "qrcx", "bres", "gdprg", "gdvideo", "gdtts" }; resourceSchemeHandler = new ResourceSchemeHandler( articleNetMgr, this ); for ( const auto & localScheme : localSchemes ) { QWebEngineProfile::defaultProfile()->installUrlSchemeHandler( localScheme.toLatin1(), resourceSchemeHandler );