-
求助!如题, 有办法不创建MainWindow类实例的情况下获得完整可用功能的ArticleNetworkAccessManager类吗? 想要给gd添加web接口,最好能实现无头化放到server上跑。 我目前使用从mainwindow偷来的实例化好的ArticleNetworkAccessManager,实现了基本的web功能。 所以,有可能不做大修改的前提下,改出无头版的ArticleNetworkAccessManager及其依赖吗? |
Beta Was this translation helpful? Give feedback.
Answered by
94Bo
Oct 29, 2024
Replies: 2 comments 1 reply
-
没有就 auto* articleNetMgr = new ArticleNetworkAccessManager(nullptr,
dictionaries,
articleMaker,
cfg.preferences.disallowContentFromOtherSites,
cfg.preferences.hideGoldenDictHeader );
dictionaries 和 articleMaker 也要 goldendict-ng/src/ui/mainwindow.cc Lines 159 to 164 in 85d5612 |
Beta Was this translation helpful? Give feedback.
1 reply
-
整理清楚了 // disable none local dictionaries
cfg.webSites.clear();
cfg.mediawikis.clear();
cfg.dictServers.clear();
// instanciate articleNetMgr
GlobalBroadcaster::instance()->setPreference( &cfg.preferences );
vector< sptr< Dictionary::Class > > dictionaries;
Instances::Groups groupInstances;
QNetworkAccessManager dictNetMgr;
ArticleMaker articleMaker( dictionaries, groupInstances, cfg.preferences );
ArticleNetworkAccessManager articleNetMgr( &app,
dictionaries,
articleMaker,
cfg.preferences.disallowContentFromOtherSites,
cfg.preferences.hideGoldenDictHeader );
// load dictionaries
vector< sptr< Dictionary::Class > > dictionaries_loaded;
loadDictionaries( nullptr, false, cfg, dictionaries_loaded, dictNetMgr, true );
for ( auto pdict : dictionaries_loaded ) {
auto it = std::find_if( cfg.inactiveDictionaries.dictionaries.begin(),
cfg.inactiveDictionaries.dictionaries.end(),
[ pdict ]( Config::DictionaryRef dref ) {
return dref.id.toStdString() == pdict->getId();
} );
if ( it == cfg.inactiveDictionaries.dictionaries.end() ) {
dictionaries.push_back( pdict );
}
} 如此实例化一个可用的articleNetMgr |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
94Bo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
整理清楚了