forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictinfo.cc
81 lines (64 loc) · 2.24 KB
/
dictinfo.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "dictinfo.hh"
#include "langcoder.hh"
#include "language.hh"
#include "fsencoding.hh"
#include <QString>
DictInfo::DictInfo( Config::Class &cfg_, QWidget *parent ) :
QDialog( parent),
cfg( cfg_)
{
ui.setupUi( this );
if( cfg.dictInfoGeometry.size() > 0 )
restoreGeometry( cfg.dictInfoGeometry );
connect( this, SIGNAL( finished( int ) ), this, SLOT( savePos( int ) ) );
}
void DictInfo::showInfo( sptr<Dictionary::Class> dict )
{
setWindowTitle( QString::fromUtf8( dict->getName().data(), dict->getName().size() ) );
ui.dictionaryTotalArticles->setText( QString::number( dict->getArticleCount() ) );
ui.dictionaryTotalWords->setText( QString::number( dict->getWordCount() ) );
ui.dictionaryTranslatesFrom->setText( Language::localizedStringForId( dict->getLangFrom() ) );
ui.dictionaryTranslatesTo->setText( Language::localizedStringForId( dict->getLangTo() ) );
ui.openFolder->setVisible( dict->isLocalDictionary() );
ui.editDictionary->setVisible( dict->isLocalDictionary() && !dict->getMainFilename().isEmpty() && !cfg.editDictionaryCommandLine.isEmpty());
ui.editDictionary->setToolTip(
tr( "Edit the dictionary via command:\n%1" ).arg( cfg.editDictionaryCommandLine ) );
if( dict->getWordCount() == 0 )
ui.headwordsButton->setVisible( false );
else
ui.buttonsLayout->insertSpacerItem( 0, new QSpacerItem( 40, 20, QSizePolicy::Expanding ) );
std::vector< std::string > const & filenames = dict->getDictionaryFilenames();
QString filenamesText;
for( unsigned x = 0; x < filenames.size(); x++ )
{
filenamesText += FsEncoding::decode( filenames[ x ].c_str() );
filenamesText += '\n';
}
ui.dictionaryFileList->setPlainText( filenamesText );
QString info = dict->getDescription();
if( !info.isEmpty() && info.compare( "NONE" ) != 0 )
ui.infoLabel->setPlainText( info );
else
ui.infoLabel->clear();
setWindowIcon( dict->getIcon() );
}
void DictInfo::savePos( int )
{
cfg.dictInfoGeometry = saveGeometry();
}
void DictInfo::on_editDictionary_clicked()
{
done( EDIT_DICTIONARY );
}
void DictInfo::on_openFolder_clicked()
{
done( OPEN_FOLDER );
}
void DictInfo::on_OKButton_clicked()
{
done( ACCEPTED );
}
void DictInfo::on_headwordsButton_clicked()
{
done( SHOW_HEADWORDS );
}