mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
+ Implement basic 'Dictionary information' pane functionality.
- Hide arrow buttons in 'Dictionaries' for now. + Add 'ja' flag to comply to ISO (copied from 'jp')
This commit is contained in:
parent
337ceba596
commit
8535604e21
|
@ -112,6 +112,7 @@
|
|||
<file>flags/ir.png</file>
|
||||
<file>flags/is.png</file>
|
||||
<file>flags/it.png</file>
|
||||
<file>flags/ja.png</file>
|
||||
<file>flags/jm.png</file>
|
||||
<file>flags/jo.png</file>
|
||||
<file>flags/jp.png</file>
|
||||
|
|
BIN
src/flags/ja.png
Normal file
BIN
src/flags/ja.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 420 B |
|
@ -59,6 +59,19 @@ LangStruct LangCoder::langStruct(quint32 code)
|
|||
return ls;
|
||||
}
|
||||
|
||||
QString LangCoder::intToCode2( quint32 val )
|
||||
{
|
||||
if ( !val )
|
||||
return QString();
|
||||
|
||||
char code[ 2 ];
|
||||
|
||||
code[ 0 ] = val & 0xFF;
|
||||
code[ 1 ] = ( val >> 8 ) & 0xFF;
|
||||
|
||||
return QString::fromAscii( code, 2 );
|
||||
}
|
||||
|
||||
quint32 LangCoder::code3toInt(const std::string& code3)
|
||||
{
|
||||
if (code3.length() < 2)
|
||||
|
|
|
@ -224,6 +224,8 @@ public:
|
|||
static quint32 code2toInt(const char code[2])
|
||||
{ return ( ((quint32)code[1]) << 8 ) + (quint32)code[0]; }
|
||||
|
||||
static QString intToCode2( quint32 );
|
||||
|
||||
static quint32 code3toInt(const std::string& code3);
|
||||
|
||||
/// Finds the id for the given language name, written in english. The search
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "orderandprops.hh"
|
||||
#include "instances.hh"
|
||||
#include "langcoder.hh"
|
||||
|
||||
OrderAndProps::OrderAndProps( QWidget * parent,
|
||||
Config::Group const & dictionaryOrder,
|
||||
|
@ -13,6 +14,13 @@ OrderAndProps::OrderAndProps( QWidget * parent,
|
|||
{
|
||||
ui.setupUi( this );
|
||||
|
||||
// For now we don't support arrows, so remove them until we get to that
|
||||
delete ui.moveActiveUp;
|
||||
delete ui.moveActiveDown;
|
||||
|
||||
delete ui.moveToActive;
|
||||
delete ui.moveToInactive;
|
||||
|
||||
Instances::Group order( dictionaryOrder, allDictionaries );
|
||||
Instances::Group inactive( inactiveDictionaries, allDictionaries );
|
||||
|
||||
|
@ -20,6 +28,8 @@ OrderAndProps::OrderAndProps( QWidget * parent,
|
|||
|
||||
ui.dictionaryOrder->populate( order.dictionaries, allDictionaries );
|
||||
ui.inactiveDictionaries->populate( inactive.dictionaries, allDictionaries );
|
||||
|
||||
disableDictionaryDescription();
|
||||
}
|
||||
|
||||
Config::Group OrderAndProps::getCurrentDictionaryOrder() const
|
||||
|
@ -39,3 +49,70 @@ Config::Group OrderAndProps::getCurrentInactiveDictionaries() const
|
|||
|
||||
return g.makeConfigGroup();
|
||||
}
|
||||
|
||||
void OrderAndProps::on_dictionaryOrder_clicked( QModelIndex const & idx )
|
||||
{
|
||||
describeDictionary( ui.dictionaryOrder, idx );
|
||||
}
|
||||
|
||||
void OrderAndProps::on_inactiveDictionaries_clicked( QModelIndex const & idx )
|
||||
{
|
||||
describeDictionary( ui.inactiveDictionaries, idx );
|
||||
}
|
||||
|
||||
void OrderAndProps::disableDictionaryDescription()
|
||||
{
|
||||
ui.dictionaryInformation->setEnabled( false );
|
||||
|
||||
ui.dictionaryName->clear();
|
||||
ui.dictionaryTotalArticles->clear();
|
||||
ui.dictionaryTotalWords->clear();
|
||||
ui.dictionaryTranslatesFrom->clear();
|
||||
ui.dictionaryTranslatesTo->clear();
|
||||
ui.dictionaryFileList->clear();
|
||||
}
|
||||
|
||||
namespace {
|
||||
QString makeLangText( quint32 langId )
|
||||
{
|
||||
QString name = LangCoder::decode( langId );
|
||||
|
||||
if ( name.isEmpty() )
|
||||
return name;
|
||||
|
||||
QString iconId = LangCoder::intToCode2( langId );
|
||||
|
||||
return QString( "<img src=\":/flags/%1.png\"> %2" ).arg( iconId ).arg( name );
|
||||
}
|
||||
}
|
||||
|
||||
void OrderAndProps::describeDictionary( DictListWidget * lst, QModelIndex const & idx )
|
||||
{
|
||||
if ( !idx.isValid() || (unsigned) idx.row() >= lst->getCurrentDictionaries().size() )
|
||||
disableDictionaryDescription();
|
||||
else
|
||||
{
|
||||
sptr< Dictionary::Class > dict = lst->getCurrentDictionaries()[ idx.row() ];
|
||||
|
||||
ui.dictionaryInformation->setEnabled( true );
|
||||
|
||||
ui.dictionaryName->setText( QString::fromUtf8( dict->getName().c_str() ) );
|
||||
|
||||
ui.dictionaryTotalArticles->setText( QString::number( dict->getArticleCount() ) );
|
||||
ui.dictionaryTotalWords->setText( QString::number( dict->getWordCount() ) );
|
||||
ui.dictionaryTranslatesFrom->setText( makeLangText( dict->getLangFrom() ) );
|
||||
ui.dictionaryTranslatesTo->setText( makeLangText( dict->getLangTo() ) );
|
||||
|
||||
std::vector< std::string > const & filenames = dict->getDictionaryFilenames();
|
||||
|
||||
QString filenamesText;
|
||||
|
||||
for( unsigned x = 0; x < filenames.size(); x++ )
|
||||
{
|
||||
filenamesText += QString::fromLocal8Bit( filenames[ x ].c_str() );
|
||||
filenamesText += '\n';
|
||||
}
|
||||
|
||||
ui.dictionaryFileList->setPlainText( filenamesText );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,17 @@ public:
|
|||
Config::Group getCurrentDictionaryOrder() const;
|
||||
Config::Group getCurrentInactiveDictionaries() const;
|
||||
|
||||
private slots:
|
||||
|
||||
void on_dictionaryOrder_clicked( QModelIndex const & );
|
||||
void on_inactiveDictionaries_clicked( QModelIndex const & );
|
||||
|
||||
private:
|
||||
|
||||
Ui::OrderAndProps ui;
|
||||
|
||||
void disableDictionaryDescription();
|
||||
void describeDictionary( DictListWidget *, QModelIndex const & );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<widget class="QGroupBox" name="dictionaryInformation">
|
||||
<property name="title">
|
||||
<string>Dictionary information</string>
|
||||
</property>
|
||||
|
@ -162,7 +162,78 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="dictionaryName">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="dictionaryTotalArticles">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Total articles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Total words:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="dictionaryTotalWords">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Translates from:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Translates to:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="dictionaryTranslatesFrom">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="dictionaryTranslatesTo">
|
||||
<property name="text">
|
||||
<string notr="true">TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -194,6 +265,63 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Files comprising this dictionary:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="dictionaryFileList">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>222</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>222</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>222</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue