fix : add default groupid to the globalinstance

This commit is contained in:
Xiao YiFang 2022-11-24 20:34:21 +08:00
parent 1284846d27
commit df2bb387e2
3 changed files with 8 additions and 7 deletions

View file

@ -170,14 +170,9 @@ QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest co
if( !path.isEmpty() )
{
url.setPath( "" );
QByteArray referer = req.rawHeader( "Referer" );
QUrl refererUrl = QUrl::fromEncoded( referer );
Utils::Url::addQueryItem( url, "word", path.mid( 1 ) );
if( Utils::Url::hasQueryItem( refererUrl, "group" ) )
{
Utils::Url::addQueryItem( url, "group", Utils::Url::queryItemValue( refererUrl, "group" ) );
}
Utils::Url::addQueryItem( url, "group", QString::number(GlobalBroadcaster::instance()->currentGroupId ) );
}
}
@ -318,7 +313,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
bool ignoreDiacritics = Utils::Url::queryItemValue( url, "ignore_diacritics" ) == "1";
if ( phrase.isValid() ) // Require group and phrase to be passed
if ( groupIsValid && phrase.isValid() ) // Require group and phrase to be passed
return articleMaker.makeDefinitionFor( phrase, group, contexts, mutedDicts, QStringList(), ignoreDiacritics );
}

View file

@ -25,6 +25,7 @@ public:
void addWhitelist(QString host);
bool existedInWhitelist(QString host);
static GlobalBroadcaster * instance();
unsigned currentGroupId;
signals:
void dictionaryChanges( ActiveDictIds ad );

View file

@ -572,6 +572,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
igrp->checkMutedDictionaries( &grp->mutedDictionaries );
dictionaryBar.setMutedDictionaries( grp ? &grp->mutedDictionaries : 0 );
}
GlobalBroadcaster::instance()->currentGroupId = cfg.lastMainGroupId;
showDictBarNamesTriggered(); // Make update its state according to initial
// setting
@ -2323,6 +2324,10 @@ void MainWindow::currentGroupChanged( int )
dictionaryBar.setMutedDictionaries( 0 );
}
if(igrp){
GlobalBroadcaster::instance()->currentGroupId = cfg.lastMainGroupId;
}
updateDictionaryBar();
// Update word search results