mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
DSL: Support video resources
This commit is contained in:
parent
ca3347e412
commit
0cf8ccb259
|
@ -449,6 +449,25 @@ div.xdxf
|
|||
vertical-align: text-bottom;
|
||||
}
|
||||
|
||||
.dsl_video .img
|
||||
{
|
||||
display: inline-block;
|
||||
background: url('qrcx://localhost/icons/video.png');
|
||||
background-repeat: no-repeat;
|
||||
/* Ugly hack since "vertical-align: middle;" looks _terrible_ in Qt4's webkit: */
|
||||
vertical-align: -30%;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.dsl_video .filename
|
||||
{
|
||||
display: none; /* by default, the file name is hidden */
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
/************* MDict dictionaries **************/
|
||||
.mdict
|
||||
{
|
||||
|
|
|
@ -170,7 +170,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
|
|||
return articleMaker.makeDefinitionFor( word, group, contexts, mutedDicts );
|
||||
}
|
||||
|
||||
if ( ( url.scheme() == "bres" || url.scheme() == "gdau" || url.scheme() == "gico" ) &&
|
||||
if ( ( url.scheme() == "bres" || url.scheme() == "gdau" || url.scheme() == "gdvideo" || url.scheme() == "gico" ) &&
|
||||
url.path().size() )
|
||||
{
|
||||
//DPRINTF( "Get %s\n", req.url().host().toLocal8Bit().data() );
|
||||
|
|
|
@ -688,6 +688,23 @@ void ArticleView::linkHovered ( const QString & link, const QString & , const QS
|
|||
msg = tr( "Picture" );
|
||||
}
|
||||
else
|
||||
if ( url.scheme() == "gdvideo" )
|
||||
{
|
||||
if ( url.path().isEmpty() )
|
||||
{
|
||||
msg = tr( "Video" );
|
||||
}
|
||||
else
|
||||
{
|
||||
QString path = url.path();
|
||||
if ( path.startsWith( '/' ) )
|
||||
{
|
||||
path = path.mid( 1 );
|
||||
}
|
||||
msg = tr( "Video: %1" ).arg( path );
|
||||
}
|
||||
}
|
||||
else
|
||||
if (url.scheme() == "gdlookup" || url.scheme().compare( "bword" ) == 0)
|
||||
{
|
||||
QString def = url.path();
|
||||
|
@ -784,7 +801,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
|||
}
|
||||
}
|
||||
else
|
||||
if ( url.scheme() == "bres" || url.scheme() == "gdau" ||
|
||||
if ( url.scheme() == "bres" || url.scheme() == "gdau" || url.scheme() == "gdvideo" ||
|
||||
Dictionary::WebMultimediaDownload::isAudioUrl( url ) )
|
||||
{
|
||||
// Download it
|
||||
|
|
11
dsl.cc
11
dsl.cc
|
@ -861,6 +861,17 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node )
|
|||
+ "\" alt=\"" + Html::escape( filename ) + "\"/>";
|
||||
}
|
||||
else
|
||||
if ( Filetype::isNameOfVideo( filename ) ) {
|
||||
QUrl url;
|
||||
url.setScheme( "gdvideo" );
|
||||
url.setHost( QString::fromUtf8( getId().c_str() ) );
|
||||
url.setPath( QString::fromUtf8( filename.c_str() ) );
|
||||
|
||||
result += string( "<a class=\"dsl_s dsl_video\" href=\"" ) + url.toEncoded().data() + "\">"
|
||||
+ "<span class=\"img\"></span>"
|
||||
+ "<span class=\"filename\">" + processNodeChildren( node ) + "</span>" + "</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unknown file type, downgrade to a hyperlink
|
||||
|
||||
|
|
20
filetype.cc
20
filetype.cc
|
@ -66,6 +66,26 @@ bool isNameOfSound( string const & name )
|
|||
endsWith( s, ".spx" );
|
||||
}
|
||||
|
||||
bool isNameOfVideo( string const & name )
|
||||
{
|
||||
string s = simplifyString( name );
|
||||
|
||||
return
|
||||
endsWith( s, ".mpg" ) ||
|
||||
endsWith( s, ".mpeg" )||
|
||||
endsWith( s, ".mpe" ) ||
|
||||
endsWith( s, ".ogv" ) ||
|
||||
endsWith( s, ".avi" ) ||
|
||||
endsWith( s, ".m4v" ) ||
|
||||
endsWith( s, ".mkv" ) ||
|
||||
endsWith( s, ".wmv" ) ||
|
||||
endsWith( s, ".sfw" ) ||
|
||||
endsWith( s, ".flv" ) ||
|
||||
endsWith( s, ".divx" ) ||
|
||||
endsWith( s, ".3gp" ) ||
|
||||
endsWith( s, ".mov" );
|
||||
}
|
||||
|
||||
bool isNameOfPicture( string const & name )
|
||||
{
|
||||
string s = simplifyString( name );
|
||||
|
|
|
@ -14,6 +14,9 @@ using std::string;
|
|||
/// Returns true if the name resembles the one of a sound file (i.e. ends
|
||||
/// with .wav, .ogg and such).
|
||||
bool isNameOfSound( string const & );
|
||||
/// Returns true if the name resembles the one of a video file (i.e. ends
|
||||
/// with .mpg, .ogv and such).
|
||||
bool isNameOfVideo( string const & );
|
||||
/// Returns true if the name resembles the one of a picture file (i.e. ends
|
||||
/// with .jpg, .png and such).
|
||||
bool isNameOfPicture( string const & );
|
||||
|
|
BIN
icons/video.png
Normal file
BIN
icons/video.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -71,5 +71,6 @@
|
|||
<file>icons/expand_article.png</file>
|
||||
<file>icons/collapse_article_hovered.png</file>
|
||||
<file>icons/collapse_article.png</file>
|
||||
<file>icons/video.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in a new issue