mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Show decription for XDXF dictionaries
This commit is contained in:
parent
52fbeac618
commit
6f56a1c374
|
@ -148,6 +148,10 @@ sptr< DataRequest > Class::getResource( string const & /*name*/ )
|
|||
return new DataRequestInstant( false );
|
||||
}
|
||||
|
||||
QString const& Class::getDescription()
|
||||
{
|
||||
return dictionaryDescription;
|
||||
}
|
||||
|
||||
string makeDictionaryId( vector< string > const & dictionaryFiles ) throw()
|
||||
{
|
||||
|
|
|
@ -254,6 +254,9 @@ class Class
|
|||
string id;
|
||||
vector< string > dictionaryFiles;
|
||||
|
||||
protected:
|
||||
QString dictionaryDescription;
|
||||
|
||||
public:
|
||||
|
||||
/// Creates a dictionary. The id should be made using
|
||||
|
@ -369,6 +372,9 @@ public:
|
|||
virtual sptr< DataRequest > getResource( string const & /*name*/ )
|
||||
throw( std::exception );
|
||||
|
||||
// Return dictionary description if presented
|
||||
virtual QString const& getDescription();
|
||||
|
||||
virtual ~Class()
|
||||
{}
|
||||
};
|
||||
|
|
|
@ -72,6 +72,10 @@ void OrderAndProps::disableDictionaryDescription()
|
|||
ui.dictionaryTranslatesFrom->clear();
|
||||
ui.dictionaryTranslatesTo->clear();
|
||||
ui.dictionaryFileList->clear();
|
||||
|
||||
ui.dictionaryDescription->clear();
|
||||
ui.dictionaryDescription->setVisible( false );
|
||||
ui.dictionaryDescriptionLabel->setVisible( false );
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -116,5 +120,18 @@ void OrderAndProps::describeDictionary( DictListWidget * lst, QModelIndex const
|
|||
}
|
||||
|
||||
ui.dictionaryFileList->setPlainText( filenamesText );
|
||||
|
||||
QString const& descText = dict->getDescription();
|
||||
if( !descText.isEmpty() && descText.compare( "NONE" ) != 0 )
|
||||
{
|
||||
ui.dictionaryDescription->setPlainText( descText );
|
||||
ui.dictionaryDescription->setVisible( true );
|
||||
ui.dictionaryDescriptionLabel->setVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dictionaryDescription->setVisible( false );
|
||||
ui.dictionaryDescriptionLabel->setVisible( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,6 +239,60 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="dictionaryDescriptionLabel">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="dictionaryDescription">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>223</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>223</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>212</red>
|
||||
<green>208</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
|
@ -247,7 +301,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>434</height>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -260,7 +314,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>256</width>
|
||||
<height>20</height>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
@ -274,6 +328,24 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="dictionaryFileList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>65</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>65</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
|
@ -314,9 +386,6 @@
|
|||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
|
|
28
xdxf.cc
28
xdxf.cc
|
@ -161,6 +161,8 @@ public:
|
|||
virtual sptr< Dictionary::DataRequest > getResource( string const & name )
|
||||
throw( std::exception );
|
||||
|
||||
virtual QString const& getDescription();
|
||||
|
||||
private:
|
||||
|
||||
void loadIcon();
|
||||
|
@ -338,6 +340,32 @@ void XdxfDictionary::loadIcon()
|
|||
dictionaryIconLoaded = true;
|
||||
}
|
||||
|
||||
QString const& XdxfDictionary::getDescription()
|
||||
{
|
||||
if( !dictionaryDescription.isEmpty() )
|
||||
return dictionaryDescription;
|
||||
|
||||
if( idxHeader.descriptionAddress == 0 )
|
||||
dictionaryDescription = "NONE";
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
vector< char > chunk;
|
||||
char * descr;
|
||||
{
|
||||
Mutex::Lock _( idxMutex );
|
||||
descr = chunks->getBlock( idxHeader.descriptionAddress, chunk );
|
||||
}
|
||||
dictionaryDescription = QString::fromUtf8( descr );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
}
|
||||
return dictionaryDescription;
|
||||
}
|
||||
|
||||
/// XdxfDictionary::getArticle()
|
||||
|
||||
class XdxfArticleRequest;
|
||||
|
|
Loading…
Reference in a new issue