goldendict-ng/src/ui/dictinfo.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.7 KiB
C++
Raw Normal View History

#include "dictinfo.hh"
#include "language.hh"
#include <QDesktopServices>
#include "config.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, &QDialog::finished, this, &DictInfo::savePos );
}
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() ) );
feat: customize dictionary's fullindex option with metadata.toml (#1000) * feat: customize dictionary's fullindex option with metadata.toml * [autofix.ci] apply automated fixes * feat: display fulltext status in the dictionary info dialog * [autofix.ci] apply automated fixes * doc: add document about how to enable dictionary's fullindex feature * Update src/metadata.cc Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update src/ui/dictinfo.ui Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/mkdocs.yml Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/docs/custom_dictionary.md Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/docs/custom_dictionary.md Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/docs/custom_dictionary.md Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/docs/custom_dictionary.md Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/docs/custom_dictionary.md Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * Update website/docs/custom_dictionary.md Co-authored-by: shenleban tongying <shenlebantongying@gmail.com> * add images * feat: show fulltext search status in dictionary info dialog * Update dictinfo.cc * [autofix.ci] apply automated fixes * ui: change layout --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: YiFang Xiao <yifang.xiao@noreply.com> Co-authored-by: shenleban tongying <shenlebantongying@gmail.com>
2023-07-26 02:03:20 +00:00
ui.enableFullindex->setText( dict->canFTS() ? tr( "Full-text search enabled" ) : tr( "Full-text search disabled" ) );
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;
2023-07-14 12:26:23 +00:00
for ( const auto & filename : filenames ) {
filenamesText += QString::fromStdString( filename );
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 ) {
//qtbug QTBUG-112020
info.remove( QRegularExpression( R"(<link[^>]*>)", QRegularExpression::CaseInsensitiveOption ) );
ui.infoLabel->setHtml( 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 );
}
void DictInfo::on_openIndexFolder_clicked()
{
QDesktopServices::openUrl( QUrl::fromLocalFile( Config::getIndexDir() ) );
}