Skip to content

Commit

Permalink
Merge branch 'staged' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Oct 29, 2023
2 parents 8905de6 + 10595ab commit a238161
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/article_netmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest co

if ( req.url().scheme() == "gdlookup" ) {
QString path = url.path();
if ( !path.isEmpty() ) {
if ( path.size() > 1 ) {
url.setPath( "" );

Utils::Url::addQueryItem( url, "word", path.mid( 1 ) );
Expand Down
2 changes: 1 addition & 1 deletion src/dict/epwing_book.cc
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ EB_Error_Code EpwingBook::forwardText( EB_Position & startPos )
ret = eb_forward_text( &book, &appendix );
while ( ret != EB_SUCCESS ) {

if ( startPos.page >= book.subbook_current->text.end_page )
if ( ret == EB_ERR_END_OF_CONTENT || startPos.page >= book.subbook_current->text.end_page )
return EB_ERR_END_OF_CONTENT;

const auto offset = startPos.offset + 2;
Expand Down
5 changes: 4 additions & 1 deletion src/dict/mediawiki.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str,

Utils::Url::addQueryItem( reqUrl, "apprefix", QString::fromStdU32String( str ).replace( '+', "%2B" ) );

netReply = std::shared_ptr< QNetworkReply >( mgr.get( QNetworkRequest( reqUrl ) ) );
QNetworkRequest req( reqUrl );
//millseconds.
req.setTransferTimeout( 2000 );
netReply = std::shared_ptr< QNetworkReply >( mgr.get( req ) );

connect( netReply.get(), SIGNAL( finished() ), this, SLOT( downloadFinished() ) );

Expand Down
2 changes: 1 addition & 1 deletion src/fulltextsearch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void Indexing::run()
QFuture< void > const f = QtConcurrent::run( [ this, &sem, &dictionary ]() {
QSemaphoreReleaser const _( sem );
const QString & dictionaryName = QString::fromUtf8( dictionary->getName().c_str() );
qDebug() << "[FULLTEXT] make fts for the dictionary:" << dictionaryName;
qDebug() << "[FULLTEXT] checking fts for the dictionary:" << dictionaryName;
emit sendNowIndexingName( dictionaryName );
dictionary->makeFTSIndex( isCancelled, false );
} );
Expand Down
18 changes: 3 additions & 15 deletions src/ui/articleview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -733,18 +733,8 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev )
}

if ( obj == webview ) {
if ( ev->type() == QEvent::MouseButtonPress ) {
auto event = static_cast< QMouseEvent * >( ev );
if ( event->button() == Qt::XButton1 ) {
back();
return true;
}
if ( event->button() == Qt::XButton2 ) {
forward();
return true;
}
}
else if ( ev->type() == QEvent::KeyPress ) {

if ( ev->type() == QEvent::KeyPress ) {
auto keyEvent = static_cast< QKeyEvent * >( ev );

if ( keyEvent->modifiers() & ( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) )
Expand Down Expand Up @@ -1348,9 +1338,7 @@ void ArticleView::updateMutedContents()

bool ArticleView::canGoBack()
{
// First entry in a history is always an empty page,
// so we skip it.
return webview->history()->currentItemIndex() > 1;
return webview->history()->canGoBack();
}

bool ArticleView::canGoForward()
Expand Down
24 changes: 2 additions & 22 deletions src/ui/articlewebview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ bool ArticleWebView::eventFilter( QObject * obj, QEvent * ev )
singleClickAction( pe );
} );
}
mousePressEvent( pe );
if ( pe->buttons() & Qt::MiddleButton )
midButtonPressed = true;
}
if ( ev->type() == QEvent::MouseButtonRelease ) {
auto pe = dynamic_cast< QMouseEvent * >( ev );
Expand All @@ -102,19 +103,6 @@ bool ArticleWebView::eventFilter( QObject * obj, QEvent * ev )
return QWebEngineView::eventFilter( obj, ev );
}

void ArticleWebView::mousePressEvent( QMouseEvent * event )
{
if ( event->buttons() & Qt::MiddleButton )
midButtonPressed = true;

if ( event->buttons() & Qt::XButton1 ) {
back();
}
if ( event->buttons() & Qt::XButton2 ) {
forward();
}
}

void ArticleWebView::singleClickAction( QMouseEvent * event )
{
if ( !singleClickToDbClick )
Expand Down Expand Up @@ -146,14 +134,6 @@ void ArticleWebView::sendCustomMouseEvent( QEvent::Type type )
}
}

void ArticleWebView::mouseReleaseEvent( QMouseEvent * event )
{
bool noMidButton = !( event->buttons() & Qt::MiddleButton );

// if ( midButtonPressed & noMidButton )
// midButtonPressed = false;
}

void ArticleWebView::doubleClickAction( QMouseEvent * event )
{
if ( Qt::MouseEventSynthesizedByApplication != event->source() ) {
Expand Down
2 changes: 0 additions & 2 deletions src/ui/articlewebview.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ protected:
bool event( QEvent * event ) override;
void singleClickAction( QMouseEvent * event );
void sendCustomMouseEvent( QEvent::Type type );
void mousePressEvent( QMouseEvent * event ) override;
void mouseReleaseEvent( QMouseEvent * event ) override;
void doubleClickAction( QMouseEvent * event );
void wheelEvent( QWheelEvent * event ) override;

Expand Down

0 comments on commit a238161

Please sign in to comment.