Compare commits

..

No commits in common. "6c63ba45b69a52efccf7857a9860114457683d4c" and "c0697ecdda788e1de260610e1f507df9baabae39" have entirely different histories.

5 changed files with 30 additions and 39 deletions

View file

@ -524,11 +524,7 @@ void ArticleRequest::altSearchFinished()
QString requestUrl = Utils::WebSite::urlReplaceWord( QString::fromStdString( url ), word );
emit GlobalBroadcaster::instance()
-> websiteDictionarySignal( QString::fromStdString( activeDict->getName() ), requestUrl );
QStringList dictIds;
dictIds << QString::fromStdString( activeDict->getId() );
ActiveDictIds hittedWord{ group.id, word, dictIds };
emit GlobalBroadcaster::instance() -> dictionaryChanges( hittedWord );
-> websiteDictionary( QString::fromStdString( activeDict->getName() ), requestUrl );
continue;
}
}

View file

@ -47,7 +47,7 @@ signals:
void indexingDictionary( QString );
void websiteDictionarySignal( QString, QString );
void websiteDictionary( QString, QString );
};
#endif // GLOBAL_GLOBALBROADCASTER_H

View file

@ -85,6 +85,18 @@ QString ArticleView::scrollToFromDictionaryId( QString const & dictionaryId )
Q_ASSERT( !isScrollTo( dictionaryId ) );
return scrollToPrefix + dictionaryId;
}
ArticleView::ArticleView( QWidget * parent,
ArticleNetworkAccessManager & nm,
AudioPlayerPtr const & audioPlayer_,
Config::Class const & cfg_ ):
QWidget( parent ),
articleNetMgr( nm ),
audioPlayer( audioPlayer_ ),
cfg( cfg_ )
{
// setup GUI
setupWebview();
}
void ArticleView::setupWebview()
{ // setup GUI
this->webview = new ArticleWebView( this );
@ -96,10 +108,9 @@ void ArticleView::setupWebview()
auto * baseLayout = new QVBoxLayout( this );
this->tabWidget = new QTabWidget( this );
baseLayout->setContentsMargins( 0, 0, 0, 0 );
baseLayout->addWidget( this->tabWidget );
auto * tab1 = new QWidget( tabWidget );
QWidget * tab1 = new QWidget( tabWidget );
// Layout
auto * mainLayout = new QVBoxLayout( tab1 );
mainLayout->addWidget( this->webview );
@ -222,26 +233,6 @@ void ArticleView::setupWebview()
this->webview->grabGesture( Gestures::GDSwipeGestureType );
#endif
}
void ArticleView::addWebsiteTab( QString name, QString url )
{
auto * view = new QWebEngineView( this );
view->load( url );
view->setZoomFactor( this->cfg.preferences.zoomFactor );
int index = tabWidget->count();
QString escaped = Utils::escapeAmps( name );
tabWidget->insertTab( index, view, escaped );
}
void ArticleView::clearWebsiteTabs()
{
int index = tabWidget->count();
// keep the first tab
while ( index-- > 1 ) {
tabWidget->removeTab( index );
}
}
ArticleView::ArticleView( QWidget * parent,
ArticleNetworkAccessManager & nm,
AudioPlayerPtr const & audioPlayer_,
@ -338,7 +329,6 @@ void ArticleView::showDefinition( QString const & word,
Contexts const & contexts_ )
{
GlobalBroadcaster::instance()->pronounce_engine.reset();
clearWebsiteTabs();
currentWord = word.trimmed();
if ( currentWord.isEmpty() ) {
return;
@ -386,7 +376,7 @@ void ArticleView::showDefinition( QString const & word,
QString mutedDicts = getMutedForGroup( group );
if ( !mutedDicts.isEmpty() ) {
if ( mutedDicts.size() ) {
Utils::Url::addQueryItem( req, "muted", mutedDicts );
}

View file

@ -96,8 +96,11 @@ public:
QLineEdit const * translateLine,
QAction * dictionaryBarToggled = nullptr,
unsigned currentGroupId = 0 );
explicit ArticleView( QWidget * parent,
ArticleNetworkAccessManager & nm,
AudioPlayerPtr const & audioPlayer_,
Config::Class const & cfg_ );
void openWebsiteInNewTab( QString name, QString url );
void setCurrentGroupId( unsigned currengGrgId );
unsigned getCurrentGroupId();
@ -168,9 +171,7 @@ public:
/// \brief Set background as black if darkreader mode is enabled.
void syncBackgroundColorWithCfgDarkReader() const;
void addWebsiteTab( QString name, QString url );
void clearWebsiteTabs();
void openWebsiteInNewTab( QString name, QString url );
private:
// widgets

View file

@ -63,7 +63,6 @@
#include <QWebEngineSettings>
#include <QProxyStyle>
#include <utility>
#ifdef HAVE_X11
#if ( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) )
@ -715,7 +714,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
this,
&MainWindow::showFTSIndexingName );
connect( GlobalBroadcaster::instance(),
&GlobalBroadcaster::websiteDictionarySignal,
&GlobalBroadcaster::websiteDictionary,
this,
&MainWindow::openWebsiteInNewTab );
@ -2149,7 +2148,7 @@ void MainWindow::updateFoundInDictsList()
if ( dictionaries[ x ]->getId() == i->toUtf8().data() ) {
QString dictName = QString::fromUtf8( dictionaries[ x ]->getName().c_str() );
QString dictId = QString::fromUtf8( dictionaries[ x ]->getId().c_str() );
auto * item =
QListWidgetItem * item =
new QListWidgetItem( dictionaries[ x ]->getIcon(), dictName, ui.dictsList, QListWidgetItem::Type );
item->setData( Qt::UserRole, QVariant( dictId ) );
item->setToolTip( dictName );
@ -2163,7 +2162,7 @@ void MainWindow::updateFoundInDictsList()
}
}
//if no item in dict List panel has been choosen ,select first one.
//if no item in dict List panel has been choose ,select first one.
if ( ui.dictsList->count() > 0 && ui.dictsList->selectedItems().empty() ) {
ui.dictsList->setCurrentRow( 0 );
}
@ -3716,6 +3715,11 @@ ArticleView * MainWindow::getCurrentArticleView()
{
if ( QWidget * cw = ui.tabWidget->currentWidget() ) {
auto * pView = dynamic_cast< ArticleView * >( cw );
if ( pView != nullptr ) {
if ( pView->getParentView() != nullptr ) {
return pView->getParentView();
}
}
return pView;
}
return nullptr;
@ -4382,7 +4386,7 @@ void MainWindow::openWebsiteInNewTab( QString name, QString url )
// ui.tabWidget->insertTab( index, view, escaped );
// mruList.append( dynamic_cast< QWidget * >( view ) );
getCurrentArticleView()->addWebsiteTab( std::move( name ), url );
getCurrentArticleView()->addWebsiteTab( name, url );
}
QString MainWindow::unescapeTabHeader( QString const & header )