2012-09-24 12:51:51 +00:00
|
|
|
#include "dictinfo.hh"
|
|
|
|
#include "language.hh"
|
2023-07-14 00:24:59 +00:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include "config.hh"
|
2023-04-28 16:09:45 +00:00
|
|
|
|
2012-09-24 12:51:51 +00:00
|
|
|
#include <QString>
|
|
|
|
|
2012-09-27 13:00:40 +00:00
|
|
|
DictInfo::DictInfo( Config::Class & cfg_, QWidget * parent ):
|
2012-12-20 13:25:03 +00:00
|
|
|
QDialog( parent ),
|
|
|
|
cfg( cfg_ )
|
2012-09-24 12:51:51 +00:00
|
|
|
{
|
|
|
|
ui.setupUi( this );
|
2012-09-27 13:00:40 +00:00
|
|
|
if ( cfg.dictInfoGeometry.size() > 0 )
|
|
|
|
restoreGeometry( cfg.dictInfoGeometry );
|
2022-12-26 02:08:17 +00:00
|
|
|
connect( this, &QDialog::finished, this, &DictInfo::savePos );
|
2012-09-24 12:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DictInfo::showInfo( sptr< Dictionary::Class > dict )
|
|
|
|
{
|
|
|
|
setWindowTitle( QString::fromUtf8( dict->getName().data(), dict->getName().size() ) );
|
|
|
|
|
2022-10-11 13:34:24 +00:00
|
|
|
ui.dictionaryId->setText( QString::fromStdString( dict->getId() ) );
|
2023-07-26 02:03:20 +00:00
|
|
|
ui.enableFullindex->setText( dict->canFTS() ? tr( "Full-text search enabled" ) : tr( "Full-text search disabled" ) );
|
2012-09-24 12:51:51 +00:00
|
|
|
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() ) );
|
|
|
|
|
2013-06-11 15:40:45 +00:00
|
|
|
ui.openFolder->setVisible( dict->isLocalDictionary() );
|
2013-06-11 18:55:29 +00:00
|
|
|
ui.editDictionary->setVisible( dict->isLocalDictionary() && !dict->getMainFilename().isEmpty()
|
|
|
|
&& !cfg.editDictionaryCommandLine.isEmpty() );
|
2013-06-11 15:40:45 +00:00
|
|
|
ui.editDictionary->setToolTip( tr( "Edit the dictionary via command:\n%1" ).arg( cfg.editDictionaryCommandLine ) );
|
|
|
|
|
2014-02-28 12:36:28 +00:00
|
|
|
if ( dict->getWordCount() == 0 )
|
|
|
|
ui.headwordsButton->setVisible( false );
|
|
|
|
else
|
|
|
|
ui.buttonsLayout->insertSpacerItem( 0, new QSpacerItem( 40, 20, QSizePolicy::Expanding ) );
|
|
|
|
|
2012-09-24 12:51:51 +00:00
|
|
|
std::vector< std::string > const & filenames = dict->getDictionaryFilenames();
|
|
|
|
|
|
|
|
QString filenamesText;
|
|
|
|
|
2023-07-14 12:26:23 +00:00
|
|
|
for ( const auto & filename : filenames ) {
|
|
|
|
filenamesText += QString::fromStdString( filename );
|
2012-09-24 12:51:51 +00:00
|
|
|
filenamesText += '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.dictionaryFileList->setPlainText( filenamesText );
|
|
|
|
|
2023-07-14 12:26:23 +00:00
|
|
|
if ( QString info = dict->getDescription(); !info.isEmpty() && info.compare( "NONE" ) != 0 ) {
|
2023-03-19 02:46:48 +00:00
|
|
|
//qtbug QTBUG-112020
|
|
|
|
info.remove( QRegularExpression( R"(<link[^>]*>)", QRegularExpression::CaseInsensitiveOption ) );
|
|
|
|
ui.infoLabel->setHtml( info );
|
|
|
|
}
|
2012-09-24 12:51:51 +00:00
|
|
|
else
|
|
|
|
ui.infoLabel->clear();
|
2014-11-14 16:45:06 +00:00
|
|
|
|
|
|
|
setWindowIcon( dict->getIcon() );
|
2012-09-24 12:51:51 +00:00
|
|
|
}
|
2012-09-27 13:00:40 +00:00
|
|
|
|
|
|
|
void DictInfo::savePos( int )
|
|
|
|
{
|
|
|
|
cfg.dictInfoGeometry = saveGeometry();
|
|
|
|
}
|
2013-06-11 15:40:45 +00:00
|
|
|
|
|
|
|
void DictInfo::on_editDictionary_clicked()
|
|
|
|
{
|
|
|
|
done( EDIT_DICTIONARY );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DictInfo::on_openFolder_clicked()
|
|
|
|
{
|
|
|
|
done( OPEN_FOLDER );
|
|
|
|
}
|
2014-02-28 12:36:28 +00:00
|
|
|
|
|
|
|
void DictInfo::on_OKButton_clicked()
|
|
|
|
{
|
|
|
|
done( ACCEPTED );
|
|
|
|
}
|
|
|
|
|
|
|
|
void DictInfo::on_headwordsButton_clicked()
|
|
|
|
{
|
|
|
|
done( SHOW_HEADWORDS );
|
|
|
|
}
|
2023-07-14 00:24:59 +00:00
|
|
|
|
|
|
|
void DictInfo::on_openIndexFolder_clicked()
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl( QUrl::fromLocalFile( Config::getIndexDir() ) );
|
|
|
|
}
|